{-# 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.ElasticSearch.DescribeDomainChangeProgress
-- 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 information about the current blue\/green deployment happening
-- on a domain, including a change ID, status, and progress stages.
module Amazonka.ElasticSearch.DescribeDomainChangeProgress
  ( -- * Creating a Request
    DescribeDomainChangeProgress (..),
    newDescribeDomainChangeProgress,

    -- * Request Lenses
    describeDomainChangeProgress_changeId,
    describeDomainChangeProgress_domainName,

    -- * Destructuring the Response
    DescribeDomainChangeProgressResponse (..),
    newDescribeDomainChangeProgressResponse,

    -- * Response Lenses
    describeDomainChangeProgressResponse_changeProgressStatus,
    describeDomainChangeProgressResponse_httpStatus,
  )
where

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

-- | Container for the parameters to the @DescribeDomainChangeProgress@
-- operation. Specifies the domain name and optional change specific
-- identity for which you want progress information.
--
-- /See:/ 'newDescribeDomainChangeProgress' smart constructor.
data DescribeDomainChangeProgress = DescribeDomainChangeProgress'
  { -- | The specific change ID for which you want to get progress information.
    -- This is an optional parameter. If omitted, the service returns
    -- information about the most recent configuration change.
    DescribeDomainChangeProgress -> Maybe Text
changeId :: Prelude.Maybe Prelude.Text,
    -- | The domain you want to get the progress information about.
    DescribeDomainChangeProgress -> Text
domainName :: Prelude.Text
  }
  deriving (DescribeDomainChangeProgress
-> DescribeDomainChangeProgress -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeDomainChangeProgress
-> DescribeDomainChangeProgress -> Bool
$c/= :: DescribeDomainChangeProgress
-> DescribeDomainChangeProgress -> Bool
== :: DescribeDomainChangeProgress
-> DescribeDomainChangeProgress -> Bool
$c== :: DescribeDomainChangeProgress
-> DescribeDomainChangeProgress -> Bool
Prelude.Eq, ReadPrec [DescribeDomainChangeProgress]
ReadPrec DescribeDomainChangeProgress
Int -> ReadS DescribeDomainChangeProgress
ReadS [DescribeDomainChangeProgress]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeDomainChangeProgress]
$creadListPrec :: ReadPrec [DescribeDomainChangeProgress]
readPrec :: ReadPrec DescribeDomainChangeProgress
$creadPrec :: ReadPrec DescribeDomainChangeProgress
readList :: ReadS [DescribeDomainChangeProgress]
$creadList :: ReadS [DescribeDomainChangeProgress]
readsPrec :: Int -> ReadS DescribeDomainChangeProgress
$creadsPrec :: Int -> ReadS DescribeDomainChangeProgress
Prelude.Read, Int -> DescribeDomainChangeProgress -> ShowS
[DescribeDomainChangeProgress] -> ShowS
DescribeDomainChangeProgress -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeDomainChangeProgress] -> ShowS
$cshowList :: [DescribeDomainChangeProgress] -> ShowS
show :: DescribeDomainChangeProgress -> String
$cshow :: DescribeDomainChangeProgress -> String
showsPrec :: Int -> DescribeDomainChangeProgress -> ShowS
$cshowsPrec :: Int -> DescribeDomainChangeProgress -> ShowS
Prelude.Show, forall x.
Rep DescribeDomainChangeProgress x -> DescribeDomainChangeProgress
forall x.
DescribeDomainChangeProgress -> Rep DescribeDomainChangeProgress x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeDomainChangeProgress x -> DescribeDomainChangeProgress
$cfrom :: forall x.
DescribeDomainChangeProgress -> Rep DescribeDomainChangeProgress x
Prelude.Generic)

-- |
-- Create a value of 'DescribeDomainChangeProgress' 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:
--
-- 'changeId', 'describeDomainChangeProgress_changeId' - The specific change ID for which you want to get progress information.
-- This is an optional parameter. If omitted, the service returns
-- information about the most recent configuration change.
--
-- 'domainName', 'describeDomainChangeProgress_domainName' - The domain you want to get the progress information about.
newDescribeDomainChangeProgress ::
  -- | 'domainName'
  Prelude.Text ->
  DescribeDomainChangeProgress
newDescribeDomainChangeProgress :: Text -> DescribeDomainChangeProgress
newDescribeDomainChangeProgress Text
pDomainName_ =
  DescribeDomainChangeProgress'
    { $sel:changeId:DescribeDomainChangeProgress' :: Maybe Text
changeId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:domainName:DescribeDomainChangeProgress' :: Text
domainName = Text
pDomainName_
    }

-- | The specific change ID for which you want to get progress information.
-- This is an optional parameter. If omitted, the service returns
-- information about the most recent configuration change.
describeDomainChangeProgress_changeId :: Lens.Lens' DescribeDomainChangeProgress (Prelude.Maybe Prelude.Text)
describeDomainChangeProgress_changeId :: Lens' DescribeDomainChangeProgress (Maybe Text)
describeDomainChangeProgress_changeId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDomainChangeProgress' {Maybe Text
changeId :: Maybe Text
$sel:changeId:DescribeDomainChangeProgress' :: DescribeDomainChangeProgress -> Maybe Text
changeId} -> Maybe Text
changeId) (\s :: DescribeDomainChangeProgress
s@DescribeDomainChangeProgress' {} Maybe Text
a -> DescribeDomainChangeProgress
s {$sel:changeId:DescribeDomainChangeProgress' :: Maybe Text
changeId = Maybe Text
a} :: DescribeDomainChangeProgress)

-- | The domain you want to get the progress information about.
describeDomainChangeProgress_domainName :: Lens.Lens' DescribeDomainChangeProgress Prelude.Text
describeDomainChangeProgress_domainName :: Lens' DescribeDomainChangeProgress Text
describeDomainChangeProgress_domainName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDomainChangeProgress' {Text
domainName :: Text
$sel:domainName:DescribeDomainChangeProgress' :: DescribeDomainChangeProgress -> Text
domainName} -> Text
domainName) (\s :: DescribeDomainChangeProgress
s@DescribeDomainChangeProgress' {} Text
a -> DescribeDomainChangeProgress
s {$sel:domainName:DescribeDomainChangeProgress' :: Text
domainName = Text
a} :: DescribeDomainChangeProgress)

instance Core.AWSRequest DescribeDomainChangeProgress where
  type
    AWSResponse DescribeDomainChangeProgress =
      DescribeDomainChangeProgressResponse
  request :: (Service -> Service)
-> DescribeDomainChangeProgress
-> Request DescribeDomainChangeProgress
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 DescribeDomainChangeProgress
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeDomainChangeProgress)))
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 ChangeProgressStatusDetails
-> Int -> DescribeDomainChangeProgressResponse
DescribeDomainChangeProgressResponse'
            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
"ChangeProgressStatus")
            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
    DescribeDomainChangeProgress
  where
  hashWithSalt :: Int -> DescribeDomainChangeProgress -> Int
hashWithSalt Int
_salt DescribeDomainChangeProgress' {Maybe Text
Text
domainName :: Text
changeId :: Maybe Text
$sel:domainName:DescribeDomainChangeProgress' :: DescribeDomainChangeProgress -> Text
$sel:changeId:DescribeDomainChangeProgress' :: DescribeDomainChangeProgress -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
changeId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
domainName

instance Prelude.NFData DescribeDomainChangeProgress where
  rnf :: DescribeDomainChangeProgress -> ()
rnf DescribeDomainChangeProgress' {Maybe Text
Text
domainName :: Text
changeId :: Maybe Text
$sel:domainName:DescribeDomainChangeProgress' :: DescribeDomainChangeProgress -> Text
$sel:changeId:DescribeDomainChangeProgress' :: DescribeDomainChangeProgress -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
changeId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
domainName

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

instance Data.ToPath DescribeDomainChangeProgress where
  toPath :: DescribeDomainChangeProgress -> ByteString
toPath DescribeDomainChangeProgress' {Maybe Text
Text
domainName :: Text
changeId :: Maybe Text
$sel:domainName:DescribeDomainChangeProgress' :: DescribeDomainChangeProgress -> Text
$sel:changeId:DescribeDomainChangeProgress' :: DescribeDomainChangeProgress -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/2015-01-01/es/domain/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
domainName,
        ByteString
"/progress"
      ]

instance Data.ToQuery DescribeDomainChangeProgress where
  toQuery :: DescribeDomainChangeProgress -> QueryString
toQuery DescribeDomainChangeProgress' {Maybe Text
Text
domainName :: Text
changeId :: Maybe Text
$sel:domainName:DescribeDomainChangeProgress' :: DescribeDomainChangeProgress -> Text
$sel:changeId:DescribeDomainChangeProgress' :: DescribeDomainChangeProgress -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"changeid" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
changeId]

-- | The result of a @DescribeDomainChangeProgress@ request. Contains the
-- progress information of the requested domain change.
--
-- /See:/ 'newDescribeDomainChangeProgressResponse' smart constructor.
data DescribeDomainChangeProgressResponse = DescribeDomainChangeProgressResponse'
  { -- | Progress information for the configuration change that is requested in
    -- the @DescribeDomainChangeProgress@ request.
    DescribeDomainChangeProgressResponse
-> Maybe ChangeProgressStatusDetails
changeProgressStatus :: Prelude.Maybe ChangeProgressStatusDetails,
    -- | The response's http status code.
    DescribeDomainChangeProgressResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeDomainChangeProgressResponse
-> DescribeDomainChangeProgressResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeDomainChangeProgressResponse
-> DescribeDomainChangeProgressResponse -> Bool
$c/= :: DescribeDomainChangeProgressResponse
-> DescribeDomainChangeProgressResponse -> Bool
== :: DescribeDomainChangeProgressResponse
-> DescribeDomainChangeProgressResponse -> Bool
$c== :: DescribeDomainChangeProgressResponse
-> DescribeDomainChangeProgressResponse -> Bool
Prelude.Eq, ReadPrec [DescribeDomainChangeProgressResponse]
ReadPrec DescribeDomainChangeProgressResponse
Int -> ReadS DescribeDomainChangeProgressResponse
ReadS [DescribeDomainChangeProgressResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeDomainChangeProgressResponse]
$creadListPrec :: ReadPrec [DescribeDomainChangeProgressResponse]
readPrec :: ReadPrec DescribeDomainChangeProgressResponse
$creadPrec :: ReadPrec DescribeDomainChangeProgressResponse
readList :: ReadS [DescribeDomainChangeProgressResponse]
$creadList :: ReadS [DescribeDomainChangeProgressResponse]
readsPrec :: Int -> ReadS DescribeDomainChangeProgressResponse
$creadsPrec :: Int -> ReadS DescribeDomainChangeProgressResponse
Prelude.Read, Int -> DescribeDomainChangeProgressResponse -> ShowS
[DescribeDomainChangeProgressResponse] -> ShowS
DescribeDomainChangeProgressResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeDomainChangeProgressResponse] -> ShowS
$cshowList :: [DescribeDomainChangeProgressResponse] -> ShowS
show :: DescribeDomainChangeProgressResponse -> String
$cshow :: DescribeDomainChangeProgressResponse -> String
showsPrec :: Int -> DescribeDomainChangeProgressResponse -> ShowS
$cshowsPrec :: Int -> DescribeDomainChangeProgressResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeDomainChangeProgressResponse x
-> DescribeDomainChangeProgressResponse
forall x.
DescribeDomainChangeProgressResponse
-> Rep DescribeDomainChangeProgressResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeDomainChangeProgressResponse x
-> DescribeDomainChangeProgressResponse
$cfrom :: forall x.
DescribeDomainChangeProgressResponse
-> Rep DescribeDomainChangeProgressResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeDomainChangeProgressResponse' 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:
--
-- 'changeProgressStatus', 'describeDomainChangeProgressResponse_changeProgressStatus' - Progress information for the configuration change that is requested in
-- the @DescribeDomainChangeProgress@ request.
--
-- 'httpStatus', 'describeDomainChangeProgressResponse_httpStatus' - The response's http status code.
newDescribeDomainChangeProgressResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeDomainChangeProgressResponse
newDescribeDomainChangeProgressResponse :: Int -> DescribeDomainChangeProgressResponse
newDescribeDomainChangeProgressResponse Int
pHttpStatus_ =
  DescribeDomainChangeProgressResponse'
    { $sel:changeProgressStatus:DescribeDomainChangeProgressResponse' :: Maybe ChangeProgressStatusDetails
changeProgressStatus =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeDomainChangeProgressResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Progress information for the configuration change that is requested in
-- the @DescribeDomainChangeProgress@ request.
describeDomainChangeProgressResponse_changeProgressStatus :: Lens.Lens' DescribeDomainChangeProgressResponse (Prelude.Maybe ChangeProgressStatusDetails)
describeDomainChangeProgressResponse_changeProgressStatus :: Lens'
  DescribeDomainChangeProgressResponse
  (Maybe ChangeProgressStatusDetails)
describeDomainChangeProgressResponse_changeProgressStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDomainChangeProgressResponse' {Maybe ChangeProgressStatusDetails
changeProgressStatus :: Maybe ChangeProgressStatusDetails
$sel:changeProgressStatus:DescribeDomainChangeProgressResponse' :: DescribeDomainChangeProgressResponse
-> Maybe ChangeProgressStatusDetails
changeProgressStatus} -> Maybe ChangeProgressStatusDetails
changeProgressStatus) (\s :: DescribeDomainChangeProgressResponse
s@DescribeDomainChangeProgressResponse' {} Maybe ChangeProgressStatusDetails
a -> DescribeDomainChangeProgressResponse
s {$sel:changeProgressStatus:DescribeDomainChangeProgressResponse' :: Maybe ChangeProgressStatusDetails
changeProgressStatus = Maybe ChangeProgressStatusDetails
a} :: DescribeDomainChangeProgressResponse)

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

instance
  Prelude.NFData
    DescribeDomainChangeProgressResponse
  where
  rnf :: DescribeDomainChangeProgressResponse -> ()
rnf DescribeDomainChangeProgressResponse' {Int
Maybe ChangeProgressStatusDetails
httpStatus :: Int
changeProgressStatus :: Maybe ChangeProgressStatusDetails
$sel:httpStatus:DescribeDomainChangeProgressResponse' :: DescribeDomainChangeProgressResponse -> Int
$sel:changeProgressStatus:DescribeDomainChangeProgressResponse' :: DescribeDomainChangeProgressResponse
-> Maybe ChangeProgressStatusDetails
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ChangeProgressStatusDetails
changeProgressStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus