{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.OpenSearch.GetUpgradeStatus
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns the most recent status of the last upgrade or upgrade
-- eligibility check performed on an Amazon OpenSearch Service domain.
module Amazonka.OpenSearch.GetUpgradeStatus
  ( -- * Creating a Request
    GetUpgradeStatus (..),
    newGetUpgradeStatus,

    -- * Request Lenses
    getUpgradeStatus_domainName,

    -- * Destructuring the Response
    GetUpgradeStatusResponse (..),
    newGetUpgradeStatusResponse,

    -- * Response Lenses
    getUpgradeStatusResponse_stepStatus,
    getUpgradeStatusResponse_upgradeName,
    getUpgradeStatusResponse_upgradeStep,
    getUpgradeStatusResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.OpenSearch.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Container for the request parameters to the @GetUpgradeStatus@
-- operation.
--
-- /See:/ 'newGetUpgradeStatus' smart constructor.
data GetUpgradeStatus = GetUpgradeStatus'
  { -- | The domain of the domain to get upgrade status information for.
    GetUpgradeStatus -> Text
domainName :: Prelude.Text
  }
  deriving (GetUpgradeStatus -> GetUpgradeStatus -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetUpgradeStatus -> GetUpgradeStatus -> Bool
$c/= :: GetUpgradeStatus -> GetUpgradeStatus -> Bool
== :: GetUpgradeStatus -> GetUpgradeStatus -> Bool
$c== :: GetUpgradeStatus -> GetUpgradeStatus -> Bool
Prelude.Eq, ReadPrec [GetUpgradeStatus]
ReadPrec GetUpgradeStatus
Int -> ReadS GetUpgradeStatus
ReadS [GetUpgradeStatus]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetUpgradeStatus]
$creadListPrec :: ReadPrec [GetUpgradeStatus]
readPrec :: ReadPrec GetUpgradeStatus
$creadPrec :: ReadPrec GetUpgradeStatus
readList :: ReadS [GetUpgradeStatus]
$creadList :: ReadS [GetUpgradeStatus]
readsPrec :: Int -> ReadS GetUpgradeStatus
$creadsPrec :: Int -> ReadS GetUpgradeStatus
Prelude.Read, Int -> GetUpgradeStatus -> ShowS
[GetUpgradeStatus] -> ShowS
GetUpgradeStatus -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetUpgradeStatus] -> ShowS
$cshowList :: [GetUpgradeStatus] -> ShowS
show :: GetUpgradeStatus -> String
$cshow :: GetUpgradeStatus -> String
showsPrec :: Int -> GetUpgradeStatus -> ShowS
$cshowsPrec :: Int -> GetUpgradeStatus -> ShowS
Prelude.Show, forall x. Rep GetUpgradeStatus x -> GetUpgradeStatus
forall x. GetUpgradeStatus -> Rep GetUpgradeStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetUpgradeStatus x -> GetUpgradeStatus
$cfrom :: forall x. GetUpgradeStatus -> Rep GetUpgradeStatus x
Prelude.Generic)

-- |
-- Create a value of 'GetUpgradeStatus' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'domainName', 'getUpgradeStatus_domainName' - The domain of the domain to get upgrade status information for.
newGetUpgradeStatus ::
  -- | 'domainName'
  Prelude.Text ->
  GetUpgradeStatus
newGetUpgradeStatus :: Text -> GetUpgradeStatus
newGetUpgradeStatus Text
pDomainName_ =
  GetUpgradeStatus' {$sel:domainName:GetUpgradeStatus' :: Text
domainName = Text
pDomainName_}

-- | The domain of the domain to get upgrade status information for.
getUpgradeStatus_domainName :: Lens.Lens' GetUpgradeStatus Prelude.Text
getUpgradeStatus_domainName :: Lens' GetUpgradeStatus Text
getUpgradeStatus_domainName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUpgradeStatus' {Text
domainName :: Text
$sel:domainName:GetUpgradeStatus' :: GetUpgradeStatus -> Text
domainName} -> Text
domainName) (\s :: GetUpgradeStatus
s@GetUpgradeStatus' {} Text
a -> GetUpgradeStatus
s {$sel:domainName:GetUpgradeStatus' :: Text
domainName = Text
a} :: GetUpgradeStatus)

instance Core.AWSRequest GetUpgradeStatus where
  type
    AWSResponse GetUpgradeStatus =
      GetUpgradeStatusResponse
  request :: (Service -> Service)
-> GetUpgradeStatus -> Request GetUpgradeStatus
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetUpgradeStatus
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetUpgradeStatus)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe UpgradeStatus
-> Maybe Text
-> Maybe UpgradeStep
-> Int
-> GetUpgradeStatusResponse
GetUpgradeStatusResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"StepStatus")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"UpgradeName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"UpgradeStep")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetUpgradeStatus where
  hashWithSalt :: Int -> GetUpgradeStatus -> Int
hashWithSalt Int
_salt GetUpgradeStatus' {Text
domainName :: Text
$sel:domainName:GetUpgradeStatus' :: GetUpgradeStatus -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
domainName

instance Prelude.NFData GetUpgradeStatus where
  rnf :: GetUpgradeStatus -> ()
rnf GetUpgradeStatus' {Text
domainName :: Text
$sel:domainName:GetUpgradeStatus' :: GetUpgradeStatus -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
domainName

instance Data.ToHeaders GetUpgradeStatus where
  toHeaders :: GetUpgradeStatus -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath GetUpgradeStatus where
  toPath :: GetUpgradeStatus -> ByteString
toPath GetUpgradeStatus' {Text
domainName :: Text
$sel:domainName:GetUpgradeStatus' :: GetUpgradeStatus -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/2021-01-01/opensearch/upgradeDomain/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
domainName,
        ByteString
"/status"
      ]

instance Data.ToQuery GetUpgradeStatus where
  toQuery :: GetUpgradeStatus -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | Container for the response returned by the @GetUpgradeStatus@ operation.
--
-- /See:/ 'newGetUpgradeStatusResponse' smart constructor.
data GetUpgradeStatusResponse = GetUpgradeStatusResponse'
  { -- | The status of the current step that an upgrade is on.
    GetUpgradeStatusResponse -> Maybe UpgradeStatus
stepStatus :: Prelude.Maybe UpgradeStatus,
    -- | A string that describes the update.
    GetUpgradeStatusResponse -> Maybe Text
upgradeName :: Prelude.Maybe Prelude.Text,
    -- | One of three steps that an upgrade or upgrade eligibility check goes
    -- through.
    GetUpgradeStatusResponse -> Maybe UpgradeStep
upgradeStep :: Prelude.Maybe UpgradeStep,
    -- | The response's http status code.
    GetUpgradeStatusResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetUpgradeStatusResponse -> GetUpgradeStatusResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetUpgradeStatusResponse -> GetUpgradeStatusResponse -> Bool
$c/= :: GetUpgradeStatusResponse -> GetUpgradeStatusResponse -> Bool
== :: GetUpgradeStatusResponse -> GetUpgradeStatusResponse -> Bool
$c== :: GetUpgradeStatusResponse -> GetUpgradeStatusResponse -> Bool
Prelude.Eq, ReadPrec [GetUpgradeStatusResponse]
ReadPrec GetUpgradeStatusResponse
Int -> ReadS GetUpgradeStatusResponse
ReadS [GetUpgradeStatusResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetUpgradeStatusResponse]
$creadListPrec :: ReadPrec [GetUpgradeStatusResponse]
readPrec :: ReadPrec GetUpgradeStatusResponse
$creadPrec :: ReadPrec GetUpgradeStatusResponse
readList :: ReadS [GetUpgradeStatusResponse]
$creadList :: ReadS [GetUpgradeStatusResponse]
readsPrec :: Int -> ReadS GetUpgradeStatusResponse
$creadsPrec :: Int -> ReadS GetUpgradeStatusResponse
Prelude.Read, Int -> GetUpgradeStatusResponse -> ShowS
[GetUpgradeStatusResponse] -> ShowS
GetUpgradeStatusResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetUpgradeStatusResponse] -> ShowS
$cshowList :: [GetUpgradeStatusResponse] -> ShowS
show :: GetUpgradeStatusResponse -> String
$cshow :: GetUpgradeStatusResponse -> String
showsPrec :: Int -> GetUpgradeStatusResponse -> ShowS
$cshowsPrec :: Int -> GetUpgradeStatusResponse -> ShowS
Prelude.Show, forall x.
Rep GetUpgradeStatusResponse x -> GetUpgradeStatusResponse
forall x.
GetUpgradeStatusResponse -> Rep GetUpgradeStatusResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetUpgradeStatusResponse x -> GetUpgradeStatusResponse
$cfrom :: forall x.
GetUpgradeStatusResponse -> Rep GetUpgradeStatusResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetUpgradeStatusResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'stepStatus', 'getUpgradeStatusResponse_stepStatus' - The status of the current step that an upgrade is on.
--
-- 'upgradeName', 'getUpgradeStatusResponse_upgradeName' - A string that describes the update.
--
-- 'upgradeStep', 'getUpgradeStatusResponse_upgradeStep' - One of three steps that an upgrade or upgrade eligibility check goes
-- through.
--
-- 'httpStatus', 'getUpgradeStatusResponse_httpStatus' - The response's http status code.
newGetUpgradeStatusResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetUpgradeStatusResponse
newGetUpgradeStatusResponse :: Int -> GetUpgradeStatusResponse
newGetUpgradeStatusResponse Int
pHttpStatus_ =
  GetUpgradeStatusResponse'
    { $sel:stepStatus:GetUpgradeStatusResponse' :: Maybe UpgradeStatus
stepStatus =
        forall a. Maybe a
Prelude.Nothing,
      $sel:upgradeName:GetUpgradeStatusResponse' :: Maybe Text
upgradeName = forall a. Maybe a
Prelude.Nothing,
      $sel:upgradeStep:GetUpgradeStatusResponse' :: Maybe UpgradeStep
upgradeStep = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetUpgradeStatusResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The status of the current step that an upgrade is on.
getUpgradeStatusResponse_stepStatus :: Lens.Lens' GetUpgradeStatusResponse (Prelude.Maybe UpgradeStatus)
getUpgradeStatusResponse_stepStatus :: Lens' GetUpgradeStatusResponse (Maybe UpgradeStatus)
getUpgradeStatusResponse_stepStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUpgradeStatusResponse' {Maybe UpgradeStatus
stepStatus :: Maybe UpgradeStatus
$sel:stepStatus:GetUpgradeStatusResponse' :: GetUpgradeStatusResponse -> Maybe UpgradeStatus
stepStatus} -> Maybe UpgradeStatus
stepStatus) (\s :: GetUpgradeStatusResponse
s@GetUpgradeStatusResponse' {} Maybe UpgradeStatus
a -> GetUpgradeStatusResponse
s {$sel:stepStatus:GetUpgradeStatusResponse' :: Maybe UpgradeStatus
stepStatus = Maybe UpgradeStatus
a} :: GetUpgradeStatusResponse)

-- | A string that describes the update.
getUpgradeStatusResponse_upgradeName :: Lens.Lens' GetUpgradeStatusResponse (Prelude.Maybe Prelude.Text)
getUpgradeStatusResponse_upgradeName :: Lens' GetUpgradeStatusResponse (Maybe Text)
getUpgradeStatusResponse_upgradeName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUpgradeStatusResponse' {Maybe Text
upgradeName :: Maybe Text
$sel:upgradeName:GetUpgradeStatusResponse' :: GetUpgradeStatusResponse -> Maybe Text
upgradeName} -> Maybe Text
upgradeName) (\s :: GetUpgradeStatusResponse
s@GetUpgradeStatusResponse' {} Maybe Text
a -> GetUpgradeStatusResponse
s {$sel:upgradeName:GetUpgradeStatusResponse' :: Maybe Text
upgradeName = Maybe Text
a} :: GetUpgradeStatusResponse)

-- | One of three steps that an upgrade or upgrade eligibility check goes
-- through.
getUpgradeStatusResponse_upgradeStep :: Lens.Lens' GetUpgradeStatusResponse (Prelude.Maybe UpgradeStep)
getUpgradeStatusResponse_upgradeStep :: Lens' GetUpgradeStatusResponse (Maybe UpgradeStep)
getUpgradeStatusResponse_upgradeStep = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUpgradeStatusResponse' {Maybe UpgradeStep
upgradeStep :: Maybe UpgradeStep
$sel:upgradeStep:GetUpgradeStatusResponse' :: GetUpgradeStatusResponse -> Maybe UpgradeStep
upgradeStep} -> Maybe UpgradeStep
upgradeStep) (\s :: GetUpgradeStatusResponse
s@GetUpgradeStatusResponse' {} Maybe UpgradeStep
a -> GetUpgradeStatusResponse
s {$sel:upgradeStep:GetUpgradeStatusResponse' :: Maybe UpgradeStep
upgradeStep = Maybe UpgradeStep
a} :: GetUpgradeStatusResponse)

-- | The response's http status code.
getUpgradeStatusResponse_httpStatus :: Lens.Lens' GetUpgradeStatusResponse Prelude.Int
getUpgradeStatusResponse_httpStatus :: Lens' GetUpgradeStatusResponse Int
getUpgradeStatusResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUpgradeStatusResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetUpgradeStatusResponse' :: GetUpgradeStatusResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetUpgradeStatusResponse
s@GetUpgradeStatusResponse' {} Int
a -> GetUpgradeStatusResponse
s {$sel:httpStatus:GetUpgradeStatusResponse' :: Int
httpStatus = Int
a} :: GetUpgradeStatusResponse)

instance Prelude.NFData GetUpgradeStatusResponse where
  rnf :: GetUpgradeStatusResponse -> ()
rnf GetUpgradeStatusResponse' {Int
Maybe Text
Maybe UpgradeStatus
Maybe UpgradeStep
httpStatus :: Int
upgradeStep :: Maybe UpgradeStep
upgradeName :: Maybe Text
stepStatus :: Maybe UpgradeStatus
$sel:httpStatus:GetUpgradeStatusResponse' :: GetUpgradeStatusResponse -> Int
$sel:upgradeStep:GetUpgradeStatusResponse' :: GetUpgradeStatusResponse -> Maybe UpgradeStep
$sel:upgradeName:GetUpgradeStatusResponse' :: GetUpgradeStatusResponse -> Maybe Text
$sel:stepStatus:GetUpgradeStatusResponse' :: GetUpgradeStatusResponse -> Maybe UpgradeStatus
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe UpgradeStatus
stepStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
upgradeName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe UpgradeStep
upgradeStep
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus