{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- 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.Lens as Lens
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 -> ResourceId
id :: ResourceId
  }
  deriving (GetChange -> GetChange -> Bool
(GetChange -> GetChange -> Bool)
-> (GetChange -> GetChange -> Bool) -> Eq GetChange
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]
(Int -> ReadS GetChange)
-> ReadS [GetChange]
-> ReadPrec GetChange
-> ReadPrec [GetChange]
-> Read 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
(Int -> GetChange -> ShowS)
-> (GetChange -> String)
-> ([GetChange] -> ShowS)
-> Show GetChange
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. GetChange -> Rep GetChange x)
-> (forall x. Rep GetChange x -> GetChange) -> Generic GetChange
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'
  ResourceId ->
  GetChange
newGetChange :: ResourceId -> GetChange
newGetChange ResourceId
pId_ = GetChange' :: ResourceId -> GetChange
GetChange' {$sel:id:GetChange' :: ResourceId
id = ResourceId
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 ResourceId
getChange_id :: (ResourceId -> f ResourceId) -> GetChange -> f GetChange
getChange_id = (GetChange -> ResourceId)
-> (GetChange -> ResourceId -> GetChange)
-> Lens GetChange GetChange ResourceId ResourceId
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetChange' {ResourceId
id :: ResourceId
$sel:id:GetChange' :: GetChange -> ResourceId
id} -> ResourceId
id) (\s :: GetChange
s@GetChange' {} ResourceId
a -> GetChange
s {$sel:id:GetChange' :: ResourceId
id = ResourceId
a} :: GetChange)

instance Core.AWSRequest GetChange where
  type AWSResponse GetChange = GetChangeResponse
  request :: GetChange -> Request GetChange
request = Service -> GetChange -> Request GetChange
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetChange
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetChange)))
response =
    (Int
 -> ResponseHeaders
 -> [Node]
 -> Either String (AWSResponse GetChange))
-> Logger
-> Service
-> Proxy GetChange
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetChange)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> ChangeInfo -> GetChangeResponse
GetChangeResponse'
            (Int -> ChangeInfo -> GetChangeResponse)
-> Either String Int
-> Either String (ChangeInfo -> GetChangeResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            Either String (ChangeInfo -> GetChangeResponse)
-> Either String ChangeInfo -> Either String GetChangeResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String ChangeInfo
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"ChangeInfo")
      )

instance Prelude.Hashable GetChange

instance Prelude.NFData GetChange

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

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

instance Core.ToQuery GetChange where
  toQuery :: GetChange -> QueryString
toQuery = QueryString -> GetChange -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(GetChangeResponse -> GetChangeResponse -> Bool)
-> (GetChangeResponse -> GetChangeResponse -> Bool)
-> Eq GetChangeResponse
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]
(Int -> ReadS GetChangeResponse)
-> ReadS [GetChangeResponse]
-> ReadPrec GetChangeResponse
-> ReadPrec [GetChangeResponse]
-> Read 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
(Int -> GetChangeResponse -> ShowS)
-> (GetChangeResponse -> String)
-> ([GetChangeResponse] -> ShowS)
-> Show GetChangeResponse
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. GetChangeResponse -> Rep GetChangeResponse x)
-> (forall x. Rep GetChangeResponse x -> GetChangeResponse)
-> Generic GetChangeResponse
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' :: Int -> ChangeInfo -> GetChangeResponse
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 :: (Int -> f Int) -> GetChangeResponse -> f GetChangeResponse
getChangeResponse_httpStatus = (GetChangeResponse -> Int)
-> (GetChangeResponse -> Int -> GetChangeResponse)
-> Lens GetChangeResponse GetChangeResponse Int Int
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 :: (ChangeInfo -> f ChangeInfo)
-> GetChangeResponse -> f GetChangeResponse
getChangeResponse_changeInfo = (GetChangeResponse -> ChangeInfo)
-> (GetChangeResponse -> ChangeInfo -> GetChangeResponse)
-> Lens GetChangeResponse GetChangeResponse ChangeInfo 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