{-# 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.WAFRegional.GetChangeTokenStatus
-- 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)
--
-- This is __AWS WAF Classic__ documentation. For more information, see
-- <https://docs.aws.amazon.com/waf/latest/developerguide/classic-waf-chapter.html AWS WAF Classic>
-- in the developer guide.
--
-- __For the latest version of AWS WAF__, use the AWS WAFV2 API and see the
-- <https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html AWS WAF Developer Guide>.
-- With the latest version, AWS WAF has a single set of endpoints for
-- regional and global use.
--
-- Returns the status of a @ChangeToken@ that you got by calling
-- GetChangeToken. @ChangeTokenStatus@ is one of the following values:
--
-- -   @PROVISIONED@: You requested the change token by calling
--     @GetChangeToken@, but you haven\'t used it yet in a call to create,
--     update, or delete an AWS WAF object.
--
-- -   @PENDING@: AWS WAF is propagating the create, update, or delete
--     request to all AWS WAF servers.
--
-- -   @INSYNC@: Propagation is complete.
module Amazonka.WAFRegional.GetChangeTokenStatus
  ( -- * Creating a Request
    GetChangeTokenStatus (..),
    newGetChangeTokenStatus,

    -- * Request Lenses
    getChangeTokenStatus_changeToken,

    -- * Destructuring the Response
    GetChangeTokenStatusResponse (..),
    newGetChangeTokenStatusResponse,

    -- * Response Lenses
    getChangeTokenStatusResponse_changeTokenStatus,
    getChangeTokenStatusResponse_httpStatus,
  )
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.WAFRegional.Types

-- | /See:/ 'newGetChangeTokenStatus' smart constructor.
data GetChangeTokenStatus = GetChangeTokenStatus'
  { -- | The change token for which you want to get the status. This change token
    -- was previously returned in the @GetChangeToken@ response.
    GetChangeTokenStatus -> Text
changeToken :: Prelude.Text
  }
  deriving (GetChangeTokenStatus -> GetChangeTokenStatus -> Bool
(GetChangeTokenStatus -> GetChangeTokenStatus -> Bool)
-> (GetChangeTokenStatus -> GetChangeTokenStatus -> Bool)
-> Eq GetChangeTokenStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetChangeTokenStatus -> GetChangeTokenStatus -> Bool
$c/= :: GetChangeTokenStatus -> GetChangeTokenStatus -> Bool
== :: GetChangeTokenStatus -> GetChangeTokenStatus -> Bool
$c== :: GetChangeTokenStatus -> GetChangeTokenStatus -> Bool
Prelude.Eq, ReadPrec [GetChangeTokenStatus]
ReadPrec GetChangeTokenStatus
Int -> ReadS GetChangeTokenStatus
ReadS [GetChangeTokenStatus]
(Int -> ReadS GetChangeTokenStatus)
-> ReadS [GetChangeTokenStatus]
-> ReadPrec GetChangeTokenStatus
-> ReadPrec [GetChangeTokenStatus]
-> Read GetChangeTokenStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetChangeTokenStatus]
$creadListPrec :: ReadPrec [GetChangeTokenStatus]
readPrec :: ReadPrec GetChangeTokenStatus
$creadPrec :: ReadPrec GetChangeTokenStatus
readList :: ReadS [GetChangeTokenStatus]
$creadList :: ReadS [GetChangeTokenStatus]
readsPrec :: Int -> ReadS GetChangeTokenStatus
$creadsPrec :: Int -> ReadS GetChangeTokenStatus
Prelude.Read, Int -> GetChangeTokenStatus -> ShowS
[GetChangeTokenStatus] -> ShowS
GetChangeTokenStatus -> String
(Int -> GetChangeTokenStatus -> ShowS)
-> (GetChangeTokenStatus -> String)
-> ([GetChangeTokenStatus] -> ShowS)
-> Show GetChangeTokenStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetChangeTokenStatus] -> ShowS
$cshowList :: [GetChangeTokenStatus] -> ShowS
show :: GetChangeTokenStatus -> String
$cshow :: GetChangeTokenStatus -> String
showsPrec :: Int -> GetChangeTokenStatus -> ShowS
$cshowsPrec :: Int -> GetChangeTokenStatus -> ShowS
Prelude.Show, (forall x. GetChangeTokenStatus -> Rep GetChangeTokenStatus x)
-> (forall x. Rep GetChangeTokenStatus x -> GetChangeTokenStatus)
-> Generic GetChangeTokenStatus
forall x. Rep GetChangeTokenStatus x -> GetChangeTokenStatus
forall x. GetChangeTokenStatus -> Rep GetChangeTokenStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetChangeTokenStatus x -> GetChangeTokenStatus
$cfrom :: forall x. GetChangeTokenStatus -> Rep GetChangeTokenStatus x
Prelude.Generic)

-- |
-- Create a value of 'GetChangeTokenStatus' 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:
--
-- 'changeToken', 'getChangeTokenStatus_changeToken' - The change token for which you want to get the status. This change token
-- was previously returned in the @GetChangeToken@ response.
newGetChangeTokenStatus ::
  -- | 'changeToken'
  Prelude.Text ->
  GetChangeTokenStatus
newGetChangeTokenStatus :: Text -> GetChangeTokenStatus
newGetChangeTokenStatus Text
pChangeToken_ =
  GetChangeTokenStatus' :: Text -> GetChangeTokenStatus
GetChangeTokenStatus' {$sel:changeToken:GetChangeTokenStatus' :: Text
changeToken = Text
pChangeToken_}

-- | The change token for which you want to get the status. This change token
-- was previously returned in the @GetChangeToken@ response.
getChangeTokenStatus_changeToken :: Lens.Lens' GetChangeTokenStatus Prelude.Text
getChangeTokenStatus_changeToken :: (Text -> f Text) -> GetChangeTokenStatus -> f GetChangeTokenStatus
getChangeTokenStatus_changeToken = (GetChangeTokenStatus -> Text)
-> (GetChangeTokenStatus -> Text -> GetChangeTokenStatus)
-> Lens GetChangeTokenStatus GetChangeTokenStatus Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetChangeTokenStatus' {Text
changeToken :: Text
$sel:changeToken:GetChangeTokenStatus' :: GetChangeTokenStatus -> Text
changeToken} -> Text
changeToken) (\s :: GetChangeTokenStatus
s@GetChangeTokenStatus' {} Text
a -> GetChangeTokenStatus
s {$sel:changeToken:GetChangeTokenStatus' :: Text
changeToken = Text
a} :: GetChangeTokenStatus)

instance Core.AWSRequest GetChangeTokenStatus where
  type
    AWSResponse GetChangeTokenStatus =
      GetChangeTokenStatusResponse
  request :: GetChangeTokenStatus -> Request GetChangeTokenStatus
request = Service -> GetChangeTokenStatus -> Request GetChangeTokenStatus
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetChangeTokenStatus
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetChangeTokenStatus)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetChangeTokenStatus))
-> Logger
-> Service
-> Proxy GetChangeTokenStatus
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetChangeTokenStatus)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe ChangeTokenStatus -> Int -> GetChangeTokenStatusResponse
GetChangeTokenStatusResponse'
            (Maybe ChangeTokenStatus -> Int -> GetChangeTokenStatusResponse)
-> Either String (Maybe ChangeTokenStatus)
-> Either String (Int -> GetChangeTokenStatusResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ChangeTokenStatus)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ChangeTokenStatus")
            Either String (Int -> GetChangeTokenStatusResponse)
-> Either String Int -> Either String GetChangeTokenStatusResponse
forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable GetChangeTokenStatus

instance Prelude.NFData GetChangeTokenStatus

instance Core.ToHeaders GetChangeTokenStatus where
  toHeaders :: GetChangeTokenStatus -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetChangeTokenStatus -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSWAF_Regional_20161128.GetChangeTokenStatus" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON GetChangeTokenStatus where
  toJSON :: GetChangeTokenStatus -> Value
toJSON GetChangeTokenStatus' {Text
changeToken :: Text
$sel:changeToken:GetChangeTokenStatus' :: GetChangeTokenStatus -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ChangeToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
changeToken)]
      )

instance Core.ToPath GetChangeTokenStatus where
  toPath :: GetChangeTokenStatus -> ByteString
toPath = ByteString -> GetChangeTokenStatus -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newGetChangeTokenStatusResponse' smart constructor.
data GetChangeTokenStatusResponse = GetChangeTokenStatusResponse'
  { -- | The status of the change token.
    GetChangeTokenStatusResponse -> Maybe ChangeTokenStatus
changeTokenStatus :: Prelude.Maybe ChangeTokenStatus,
    -- | The response's http status code.
    GetChangeTokenStatusResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetChangeTokenStatusResponse
-> GetChangeTokenStatusResponse -> Bool
(GetChangeTokenStatusResponse
 -> GetChangeTokenStatusResponse -> Bool)
-> (GetChangeTokenStatusResponse
    -> GetChangeTokenStatusResponse -> Bool)
-> Eq GetChangeTokenStatusResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetChangeTokenStatusResponse
-> GetChangeTokenStatusResponse -> Bool
$c/= :: GetChangeTokenStatusResponse
-> GetChangeTokenStatusResponse -> Bool
== :: GetChangeTokenStatusResponse
-> GetChangeTokenStatusResponse -> Bool
$c== :: GetChangeTokenStatusResponse
-> GetChangeTokenStatusResponse -> Bool
Prelude.Eq, ReadPrec [GetChangeTokenStatusResponse]
ReadPrec GetChangeTokenStatusResponse
Int -> ReadS GetChangeTokenStatusResponse
ReadS [GetChangeTokenStatusResponse]
(Int -> ReadS GetChangeTokenStatusResponse)
-> ReadS [GetChangeTokenStatusResponse]
-> ReadPrec GetChangeTokenStatusResponse
-> ReadPrec [GetChangeTokenStatusResponse]
-> Read GetChangeTokenStatusResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetChangeTokenStatusResponse]
$creadListPrec :: ReadPrec [GetChangeTokenStatusResponse]
readPrec :: ReadPrec GetChangeTokenStatusResponse
$creadPrec :: ReadPrec GetChangeTokenStatusResponse
readList :: ReadS [GetChangeTokenStatusResponse]
$creadList :: ReadS [GetChangeTokenStatusResponse]
readsPrec :: Int -> ReadS GetChangeTokenStatusResponse
$creadsPrec :: Int -> ReadS GetChangeTokenStatusResponse
Prelude.Read, Int -> GetChangeTokenStatusResponse -> ShowS
[GetChangeTokenStatusResponse] -> ShowS
GetChangeTokenStatusResponse -> String
(Int -> GetChangeTokenStatusResponse -> ShowS)
-> (GetChangeTokenStatusResponse -> String)
-> ([GetChangeTokenStatusResponse] -> ShowS)
-> Show GetChangeTokenStatusResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetChangeTokenStatusResponse] -> ShowS
$cshowList :: [GetChangeTokenStatusResponse] -> ShowS
show :: GetChangeTokenStatusResponse -> String
$cshow :: GetChangeTokenStatusResponse -> String
showsPrec :: Int -> GetChangeTokenStatusResponse -> ShowS
$cshowsPrec :: Int -> GetChangeTokenStatusResponse -> ShowS
Prelude.Show, (forall x.
 GetChangeTokenStatusResponse -> Rep GetChangeTokenStatusResponse x)
-> (forall x.
    Rep GetChangeTokenStatusResponse x -> GetChangeTokenStatusResponse)
-> Generic GetChangeTokenStatusResponse
forall x.
Rep GetChangeTokenStatusResponse x -> GetChangeTokenStatusResponse
forall x.
GetChangeTokenStatusResponse -> Rep GetChangeTokenStatusResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetChangeTokenStatusResponse x -> GetChangeTokenStatusResponse
$cfrom :: forall x.
GetChangeTokenStatusResponse -> Rep GetChangeTokenStatusResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetChangeTokenStatusResponse' 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:
--
-- 'changeTokenStatus', 'getChangeTokenStatusResponse_changeTokenStatus' - The status of the change token.
--
-- 'httpStatus', 'getChangeTokenStatusResponse_httpStatus' - The response's http status code.
newGetChangeTokenStatusResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetChangeTokenStatusResponse
newGetChangeTokenStatusResponse :: Int -> GetChangeTokenStatusResponse
newGetChangeTokenStatusResponse Int
pHttpStatus_ =
  GetChangeTokenStatusResponse' :: Maybe ChangeTokenStatus -> Int -> GetChangeTokenStatusResponse
GetChangeTokenStatusResponse'
    { $sel:changeTokenStatus:GetChangeTokenStatusResponse' :: Maybe ChangeTokenStatus
changeTokenStatus =
        Maybe ChangeTokenStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetChangeTokenStatusResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The status of the change token.
getChangeTokenStatusResponse_changeTokenStatus :: Lens.Lens' GetChangeTokenStatusResponse (Prelude.Maybe ChangeTokenStatus)
getChangeTokenStatusResponse_changeTokenStatus :: (Maybe ChangeTokenStatus -> f (Maybe ChangeTokenStatus))
-> GetChangeTokenStatusResponse -> f GetChangeTokenStatusResponse
getChangeTokenStatusResponse_changeTokenStatus = (GetChangeTokenStatusResponse -> Maybe ChangeTokenStatus)
-> (GetChangeTokenStatusResponse
    -> Maybe ChangeTokenStatus -> GetChangeTokenStatusResponse)
-> Lens
     GetChangeTokenStatusResponse
     GetChangeTokenStatusResponse
     (Maybe ChangeTokenStatus)
     (Maybe ChangeTokenStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetChangeTokenStatusResponse' {Maybe ChangeTokenStatus
changeTokenStatus :: Maybe ChangeTokenStatus
$sel:changeTokenStatus:GetChangeTokenStatusResponse' :: GetChangeTokenStatusResponse -> Maybe ChangeTokenStatus
changeTokenStatus} -> Maybe ChangeTokenStatus
changeTokenStatus) (\s :: GetChangeTokenStatusResponse
s@GetChangeTokenStatusResponse' {} Maybe ChangeTokenStatus
a -> GetChangeTokenStatusResponse
s {$sel:changeTokenStatus:GetChangeTokenStatusResponse' :: Maybe ChangeTokenStatus
changeTokenStatus = Maybe ChangeTokenStatus
a} :: GetChangeTokenStatusResponse)

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

instance Prelude.NFData GetChangeTokenStatusResponse