{-# 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.WAF.GetSizeConstraintSet
-- 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 SizeConstraintSet specified by @SizeConstraintSetId@.
module Amazonka.WAF.GetSizeConstraintSet
  ( -- * Creating a Request
    GetSizeConstraintSet (..),
    newGetSizeConstraintSet,

    -- * Request Lenses
    getSizeConstraintSet_sizeConstraintSetId,

    -- * Destructuring the Response
    GetSizeConstraintSetResponse (..),
    newGetSizeConstraintSetResponse,

    -- * Response Lenses
    getSizeConstraintSetResponse_sizeConstraintSet,
    getSizeConstraintSetResponse_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.WAF.Types

-- | /See:/ 'newGetSizeConstraintSet' smart constructor.
data GetSizeConstraintSet = GetSizeConstraintSet'
  { -- | The @SizeConstraintSetId@ of the SizeConstraintSet that you want to get.
    -- @SizeConstraintSetId@ is returned by CreateSizeConstraintSet and by
    -- ListSizeConstraintSets.
    GetSizeConstraintSet -> Text
sizeConstraintSetId :: Prelude.Text
  }
  deriving (GetSizeConstraintSet -> GetSizeConstraintSet -> Bool
(GetSizeConstraintSet -> GetSizeConstraintSet -> Bool)
-> (GetSizeConstraintSet -> GetSizeConstraintSet -> Bool)
-> Eq GetSizeConstraintSet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSizeConstraintSet -> GetSizeConstraintSet -> Bool
$c/= :: GetSizeConstraintSet -> GetSizeConstraintSet -> Bool
== :: GetSizeConstraintSet -> GetSizeConstraintSet -> Bool
$c== :: GetSizeConstraintSet -> GetSizeConstraintSet -> Bool
Prelude.Eq, ReadPrec [GetSizeConstraintSet]
ReadPrec GetSizeConstraintSet
Int -> ReadS GetSizeConstraintSet
ReadS [GetSizeConstraintSet]
(Int -> ReadS GetSizeConstraintSet)
-> ReadS [GetSizeConstraintSet]
-> ReadPrec GetSizeConstraintSet
-> ReadPrec [GetSizeConstraintSet]
-> Read GetSizeConstraintSet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSizeConstraintSet]
$creadListPrec :: ReadPrec [GetSizeConstraintSet]
readPrec :: ReadPrec GetSizeConstraintSet
$creadPrec :: ReadPrec GetSizeConstraintSet
readList :: ReadS [GetSizeConstraintSet]
$creadList :: ReadS [GetSizeConstraintSet]
readsPrec :: Int -> ReadS GetSizeConstraintSet
$creadsPrec :: Int -> ReadS GetSizeConstraintSet
Prelude.Read, Int -> GetSizeConstraintSet -> ShowS
[GetSizeConstraintSet] -> ShowS
GetSizeConstraintSet -> String
(Int -> GetSizeConstraintSet -> ShowS)
-> (GetSizeConstraintSet -> String)
-> ([GetSizeConstraintSet] -> ShowS)
-> Show GetSizeConstraintSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSizeConstraintSet] -> ShowS
$cshowList :: [GetSizeConstraintSet] -> ShowS
show :: GetSizeConstraintSet -> String
$cshow :: GetSizeConstraintSet -> String
showsPrec :: Int -> GetSizeConstraintSet -> ShowS
$cshowsPrec :: Int -> GetSizeConstraintSet -> ShowS
Prelude.Show, (forall x. GetSizeConstraintSet -> Rep GetSizeConstraintSet x)
-> (forall x. Rep GetSizeConstraintSet x -> GetSizeConstraintSet)
-> Generic GetSizeConstraintSet
forall x. Rep GetSizeConstraintSet x -> GetSizeConstraintSet
forall x. GetSizeConstraintSet -> Rep GetSizeConstraintSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetSizeConstraintSet x -> GetSizeConstraintSet
$cfrom :: forall x. GetSizeConstraintSet -> Rep GetSizeConstraintSet x
Prelude.Generic)

-- |
-- Create a value of 'GetSizeConstraintSet' 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:
--
-- 'sizeConstraintSetId', 'getSizeConstraintSet_sizeConstraintSetId' - The @SizeConstraintSetId@ of the SizeConstraintSet that you want to get.
-- @SizeConstraintSetId@ is returned by CreateSizeConstraintSet and by
-- ListSizeConstraintSets.
newGetSizeConstraintSet ::
  -- | 'sizeConstraintSetId'
  Prelude.Text ->
  GetSizeConstraintSet
newGetSizeConstraintSet :: Text -> GetSizeConstraintSet
newGetSizeConstraintSet Text
pSizeConstraintSetId_ =
  GetSizeConstraintSet' :: Text -> GetSizeConstraintSet
GetSizeConstraintSet'
    { $sel:sizeConstraintSetId:GetSizeConstraintSet' :: Text
sizeConstraintSetId =
        Text
pSizeConstraintSetId_
    }

-- | The @SizeConstraintSetId@ of the SizeConstraintSet that you want to get.
-- @SizeConstraintSetId@ is returned by CreateSizeConstraintSet and by
-- ListSizeConstraintSets.
getSizeConstraintSet_sizeConstraintSetId :: Lens.Lens' GetSizeConstraintSet Prelude.Text
getSizeConstraintSet_sizeConstraintSetId :: (Text -> f Text) -> GetSizeConstraintSet -> f GetSizeConstraintSet
getSizeConstraintSet_sizeConstraintSetId = (GetSizeConstraintSet -> Text)
-> (GetSizeConstraintSet -> Text -> GetSizeConstraintSet)
-> Lens GetSizeConstraintSet GetSizeConstraintSet Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSizeConstraintSet' {Text
sizeConstraintSetId :: Text
$sel:sizeConstraintSetId:GetSizeConstraintSet' :: GetSizeConstraintSet -> Text
sizeConstraintSetId} -> Text
sizeConstraintSetId) (\s :: GetSizeConstraintSet
s@GetSizeConstraintSet' {} Text
a -> GetSizeConstraintSet
s {$sel:sizeConstraintSetId:GetSizeConstraintSet' :: Text
sizeConstraintSetId = Text
a} :: GetSizeConstraintSet)

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

instance Prelude.NFData GetSizeConstraintSet

instance Core.ToHeaders GetSizeConstraintSet where
  toHeaders :: GetSizeConstraintSet -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetSizeConstraintSet -> 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_20150824.GetSizeConstraintSet" ::
                          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 GetSizeConstraintSet where
  toJSON :: GetSizeConstraintSet -> Value
toJSON GetSizeConstraintSet' {Text
sizeConstraintSetId :: Text
$sel:sizeConstraintSetId:GetSizeConstraintSet' :: GetSizeConstraintSet -> 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
"SizeConstraintSetId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
sizeConstraintSetId)
          ]
      )

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

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

-- | /See:/ 'newGetSizeConstraintSetResponse' smart constructor.
data GetSizeConstraintSetResponse = GetSizeConstraintSetResponse'
  { -- | Information about the SizeConstraintSet that you specified in the
    -- @GetSizeConstraintSet@ request. For more information, see the following
    -- topics:
    --
    -- -   SizeConstraintSet: Contains @SizeConstraintSetId@,
    --     @SizeConstraints@, and @Name@
    --
    -- -   @SizeConstraints@: Contains an array of SizeConstraint objects. Each
    --     @SizeConstraint@ object contains FieldToMatch, @TextTransformation@,
    --     @ComparisonOperator@, and @Size@
    --
    -- -   FieldToMatch: Contains @Data@ and @Type@
    GetSizeConstraintSetResponse -> Maybe SizeConstraintSet
sizeConstraintSet :: Prelude.Maybe SizeConstraintSet,
    -- | The response's http status code.
    GetSizeConstraintSetResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetSizeConstraintSetResponse
-> GetSizeConstraintSetResponse -> Bool
(GetSizeConstraintSetResponse
 -> GetSizeConstraintSetResponse -> Bool)
-> (GetSizeConstraintSetResponse
    -> GetSizeConstraintSetResponse -> Bool)
-> Eq GetSizeConstraintSetResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSizeConstraintSetResponse
-> GetSizeConstraintSetResponse -> Bool
$c/= :: GetSizeConstraintSetResponse
-> GetSizeConstraintSetResponse -> Bool
== :: GetSizeConstraintSetResponse
-> GetSizeConstraintSetResponse -> Bool
$c== :: GetSizeConstraintSetResponse
-> GetSizeConstraintSetResponse -> Bool
Prelude.Eq, ReadPrec [GetSizeConstraintSetResponse]
ReadPrec GetSizeConstraintSetResponse
Int -> ReadS GetSizeConstraintSetResponse
ReadS [GetSizeConstraintSetResponse]
(Int -> ReadS GetSizeConstraintSetResponse)
-> ReadS [GetSizeConstraintSetResponse]
-> ReadPrec GetSizeConstraintSetResponse
-> ReadPrec [GetSizeConstraintSetResponse]
-> Read GetSizeConstraintSetResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSizeConstraintSetResponse]
$creadListPrec :: ReadPrec [GetSizeConstraintSetResponse]
readPrec :: ReadPrec GetSizeConstraintSetResponse
$creadPrec :: ReadPrec GetSizeConstraintSetResponse
readList :: ReadS [GetSizeConstraintSetResponse]
$creadList :: ReadS [GetSizeConstraintSetResponse]
readsPrec :: Int -> ReadS GetSizeConstraintSetResponse
$creadsPrec :: Int -> ReadS GetSizeConstraintSetResponse
Prelude.Read, Int -> GetSizeConstraintSetResponse -> ShowS
[GetSizeConstraintSetResponse] -> ShowS
GetSizeConstraintSetResponse -> String
(Int -> GetSizeConstraintSetResponse -> ShowS)
-> (GetSizeConstraintSetResponse -> String)
-> ([GetSizeConstraintSetResponse] -> ShowS)
-> Show GetSizeConstraintSetResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSizeConstraintSetResponse] -> ShowS
$cshowList :: [GetSizeConstraintSetResponse] -> ShowS
show :: GetSizeConstraintSetResponse -> String
$cshow :: GetSizeConstraintSetResponse -> String
showsPrec :: Int -> GetSizeConstraintSetResponse -> ShowS
$cshowsPrec :: Int -> GetSizeConstraintSetResponse -> ShowS
Prelude.Show, (forall x.
 GetSizeConstraintSetResponse -> Rep GetSizeConstraintSetResponse x)
-> (forall x.
    Rep GetSizeConstraintSetResponse x -> GetSizeConstraintSetResponse)
-> Generic GetSizeConstraintSetResponse
forall x.
Rep GetSizeConstraintSetResponse x -> GetSizeConstraintSetResponse
forall x.
GetSizeConstraintSetResponse -> Rep GetSizeConstraintSetResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetSizeConstraintSetResponse x -> GetSizeConstraintSetResponse
$cfrom :: forall x.
GetSizeConstraintSetResponse -> Rep GetSizeConstraintSetResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetSizeConstraintSetResponse' 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:
--
-- 'sizeConstraintSet', 'getSizeConstraintSetResponse_sizeConstraintSet' - Information about the SizeConstraintSet that you specified in the
-- @GetSizeConstraintSet@ request. For more information, see the following
-- topics:
--
-- -   SizeConstraintSet: Contains @SizeConstraintSetId@,
--     @SizeConstraints@, and @Name@
--
-- -   @SizeConstraints@: Contains an array of SizeConstraint objects. Each
--     @SizeConstraint@ object contains FieldToMatch, @TextTransformation@,
--     @ComparisonOperator@, and @Size@
--
-- -   FieldToMatch: Contains @Data@ and @Type@
--
-- 'httpStatus', 'getSizeConstraintSetResponse_httpStatus' - The response's http status code.
newGetSizeConstraintSetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetSizeConstraintSetResponse
newGetSizeConstraintSetResponse :: Int -> GetSizeConstraintSetResponse
newGetSizeConstraintSetResponse Int
pHttpStatus_ =
  GetSizeConstraintSetResponse' :: Maybe SizeConstraintSet -> Int -> GetSizeConstraintSetResponse
GetSizeConstraintSetResponse'
    { $sel:sizeConstraintSet:GetSizeConstraintSetResponse' :: Maybe SizeConstraintSet
sizeConstraintSet =
        Maybe SizeConstraintSet
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetSizeConstraintSetResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the SizeConstraintSet that you specified in the
-- @GetSizeConstraintSet@ request. For more information, see the following
-- topics:
--
-- -   SizeConstraintSet: Contains @SizeConstraintSetId@,
--     @SizeConstraints@, and @Name@
--
-- -   @SizeConstraints@: Contains an array of SizeConstraint objects. Each
--     @SizeConstraint@ object contains FieldToMatch, @TextTransformation@,
--     @ComparisonOperator@, and @Size@
--
-- -   FieldToMatch: Contains @Data@ and @Type@
getSizeConstraintSetResponse_sizeConstraintSet :: Lens.Lens' GetSizeConstraintSetResponse (Prelude.Maybe SizeConstraintSet)
getSizeConstraintSetResponse_sizeConstraintSet :: (Maybe SizeConstraintSet -> f (Maybe SizeConstraintSet))
-> GetSizeConstraintSetResponse -> f GetSizeConstraintSetResponse
getSizeConstraintSetResponse_sizeConstraintSet = (GetSizeConstraintSetResponse -> Maybe SizeConstraintSet)
-> (GetSizeConstraintSetResponse
    -> Maybe SizeConstraintSet -> GetSizeConstraintSetResponse)
-> Lens
     GetSizeConstraintSetResponse
     GetSizeConstraintSetResponse
     (Maybe SizeConstraintSet)
     (Maybe SizeConstraintSet)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSizeConstraintSetResponse' {Maybe SizeConstraintSet
sizeConstraintSet :: Maybe SizeConstraintSet
$sel:sizeConstraintSet:GetSizeConstraintSetResponse' :: GetSizeConstraintSetResponse -> Maybe SizeConstraintSet
sizeConstraintSet} -> Maybe SizeConstraintSet
sizeConstraintSet) (\s :: GetSizeConstraintSetResponse
s@GetSizeConstraintSetResponse' {} Maybe SizeConstraintSet
a -> GetSizeConstraintSetResponse
s {$sel:sizeConstraintSet:GetSizeConstraintSetResponse' :: Maybe SizeConstraintSet
sizeConstraintSet = Maybe SizeConstraintSet
a} :: GetSizeConstraintSetResponse)

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

instance Prelude.NFData GetSizeConstraintSetResponse