{-# 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.Route53.GetChange
-- 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 current status of a change batch request. The status is one
-- of the following values:
--
-- -   @PENDING@ indicates that the changes in this request have not
--     propagated to all Amazon Route 53 DNS servers. This is the initial
--     status of all change batch requests.
--
-- -   @INSYNC@ indicates that the changes have propagated to all Route 53
--     DNS servers.
module Amazonka.Route53.GetChange
  ( -- * Creating a Request
    GetChange (..),
    newGetChange,

    -- * Request Lenses
    getChange_id,

    -- * Destructuring the Response
    GetChangeResponse (..),
    newGetChangeResponse,

    -- * Response Lenses
    getChangeResponse_httpStatus,
    getChangeResponse_changeInfo,
  )
where

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

-- | The input for a GetChange request.
--
-- /See:/ 'newGetChange' smart constructor.
data GetChange = GetChange'
  { -- | The ID of the change batch request. The value that you specify here is
    -- the value that @ChangeResourceRecordSets@ returned in the @Id@ element
    -- when you submitted the request.
    GetChange -> Text
id :: Prelude.Text
  }
  deriving (GetChange -> GetChange -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetChange -> GetChange -> Bool
$c/= :: GetChange -> GetChange -> Bool
== :: GetChange -> GetChange -> Bool
$c== :: GetChange -> GetChange -> Bool
Prelude.Eq, ReadPrec [GetChange]
ReadPrec GetChange
Int -> ReadS GetChange
ReadS [GetChange]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetChange]
$creadListPrec :: ReadPrec [GetChange]
readPrec :: ReadPrec GetChange
$creadPrec :: ReadPrec GetChange
readList :: ReadS [GetChange]
$creadList :: ReadS [GetChange]
readsPrec :: Int -> ReadS GetChange
$creadsPrec :: Int -> ReadS GetChange
Prelude.Read, Int -> GetChange -> ShowS
[GetChange] -> ShowS
GetChange -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetChange] -> ShowS
$cshowList :: [GetChange] -> ShowS
show :: GetChange -> String
$cshow :: GetChange -> String
showsPrec :: Int -> GetChange -> ShowS
$cshowsPrec :: Int -> GetChange -> ShowS
Prelude.Show, forall x. Rep GetChange x -> GetChange
forall x. GetChange -> Rep GetChange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetChange x -> GetChange
$cfrom :: forall x. GetChange -> Rep GetChange x
Prelude.Generic)

-- |
-- Create a value of 'GetChange' 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:
--
-- 'id', 'getChange_id' - The ID of the change batch request. The value that you specify here is
-- the value that @ChangeResourceRecordSets@ returned in the @Id@ element
-- when you submitted the request.
newGetChange ::
  -- | 'id'
  Prelude.Text ->
  GetChange
newGetChange :: Text -> GetChange
newGetChange Text
pId_ = GetChange' {$sel:id:GetChange' :: Text
id = Text
pId_}

-- | The ID of the change batch request. The value that you specify here is
-- the value that @ChangeResourceRecordSets@ returned in the @Id@ element
-- when you submitted the request.
getChange_id :: Lens.Lens' GetChange Prelude.Text
getChange_id :: Lens' GetChange Text
getChange_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetChange' {Text
id :: Text
$sel:id:GetChange' :: GetChange -> Text
id} -> Text
id) (\s :: GetChange
s@GetChange' {} Text
a -> GetChange
s {$sel:id:GetChange' :: Text
id = Text
a} :: GetChange)

instance Core.AWSRequest GetChange where
  type AWSResponse GetChange = GetChangeResponse
  request :: (Service -> Service) -> GetChange -> Request GetChange
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 GetChange
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetChange)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> ChangeInfo -> GetChangeResponse
GetChangeResponse'
            forall (f :: * -> *) a b. Functor 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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"ChangeInfo")
      )

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

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

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

instance Data.ToPath GetChange where
  toPath :: GetChange -> ByteString
toPath GetChange' {Text
id :: Text
$sel:id:GetChange' :: GetChange -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/2013-04-01/change/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
id]

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

-- | A complex type that contains the @ChangeInfo@ element.
--
-- /See:/ 'newGetChangeResponse' smart constructor.
data GetChangeResponse = GetChangeResponse'
  { -- | The response's http status code.
    GetChangeResponse -> Int
httpStatus :: Prelude.Int,
    -- | A complex type that contains information about the specified change
    -- batch.
    GetChangeResponse -> ChangeInfo
changeInfo :: ChangeInfo
  }
  deriving (GetChangeResponse -> GetChangeResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetChangeResponse -> GetChangeResponse -> Bool
$c/= :: GetChangeResponse -> GetChangeResponse -> Bool
== :: GetChangeResponse -> GetChangeResponse -> Bool
$c== :: GetChangeResponse -> GetChangeResponse -> Bool
Prelude.Eq, ReadPrec [GetChangeResponse]
ReadPrec GetChangeResponse
Int -> ReadS GetChangeResponse
ReadS [GetChangeResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetChangeResponse]
$creadListPrec :: ReadPrec [GetChangeResponse]
readPrec :: ReadPrec GetChangeResponse
$creadPrec :: ReadPrec GetChangeResponse
readList :: ReadS [GetChangeResponse]
$creadList :: ReadS [GetChangeResponse]
readsPrec :: Int -> ReadS GetChangeResponse
$creadsPrec :: Int -> ReadS GetChangeResponse
Prelude.Read, Int -> GetChangeResponse -> ShowS
[GetChangeResponse] -> ShowS
GetChangeResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetChangeResponse] -> ShowS
$cshowList :: [GetChangeResponse] -> ShowS
show :: GetChangeResponse -> String
$cshow :: GetChangeResponse -> String
showsPrec :: Int -> GetChangeResponse -> ShowS
$cshowsPrec :: Int -> GetChangeResponse -> ShowS
Prelude.Show, forall x. Rep GetChangeResponse x -> GetChangeResponse
forall x. GetChangeResponse -> Rep GetChangeResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetChangeResponse x -> GetChangeResponse
$cfrom :: forall x. GetChangeResponse -> Rep GetChangeResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetChangeResponse' 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:
--
-- 'httpStatus', 'getChangeResponse_httpStatus' - The response's http status code.
--
-- 'changeInfo', 'getChangeResponse_changeInfo' - A complex type that contains information about the specified change
-- batch.
newGetChangeResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'changeInfo'
  ChangeInfo ->
  GetChangeResponse
newGetChangeResponse :: Int -> ChangeInfo -> GetChangeResponse
newGetChangeResponse Int
pHttpStatus_ ChangeInfo
pChangeInfo_ =
  GetChangeResponse'
    { $sel:httpStatus:GetChangeResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:changeInfo:GetChangeResponse' :: ChangeInfo
changeInfo = ChangeInfo
pChangeInfo_
    }

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

-- | A complex type that contains information about the specified change
-- batch.
getChangeResponse_changeInfo :: Lens.Lens' GetChangeResponse ChangeInfo
getChangeResponse_changeInfo :: Lens' GetChangeResponse ChangeInfo
getChangeResponse_changeInfo = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetChangeResponse' {ChangeInfo
changeInfo :: ChangeInfo
$sel:changeInfo:GetChangeResponse' :: GetChangeResponse -> ChangeInfo
changeInfo} -> ChangeInfo
changeInfo) (\s :: GetChangeResponse
s@GetChangeResponse' {} ChangeInfo
a -> GetChangeResponse
s {$sel:changeInfo:GetChangeResponse' :: ChangeInfo
changeInfo = ChangeInfo
a} :: GetChangeResponse)

instance Prelude.NFData GetChangeResponse where
  rnf :: GetChangeResponse -> ()
rnf GetChangeResponse' {Int
ChangeInfo
changeInfo :: ChangeInfo
httpStatus :: Int
$sel:changeInfo:GetChangeResponse' :: GetChangeResponse -> ChangeInfo
$sel:httpStatus:GetChangeResponse' :: GetChangeResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ChangeInfo
changeInfo