{-# 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.GetByteMatchSet
-- 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 ByteMatchSet specified by @ByteMatchSetId@.
module Amazonka.WAF.GetByteMatchSet
  ( -- * Creating a Request
    GetByteMatchSet (..),
    newGetByteMatchSet,

    -- * Request Lenses
    getByteMatchSet_byteMatchSetId,

    -- * Destructuring the Response
    GetByteMatchSetResponse (..),
    newGetByteMatchSetResponse,

    -- * Response Lenses
    getByteMatchSetResponse_byteMatchSet,
    getByteMatchSetResponse_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:/ 'newGetByteMatchSet' smart constructor.
data GetByteMatchSet = GetByteMatchSet'
  { -- | The @ByteMatchSetId@ of the ByteMatchSet that you want to get.
    -- @ByteMatchSetId@ is returned by CreateByteMatchSet and by
    -- ListByteMatchSets.
    GetByteMatchSet -> Text
byteMatchSetId :: Prelude.Text
  }
  deriving (GetByteMatchSet -> GetByteMatchSet -> Bool
(GetByteMatchSet -> GetByteMatchSet -> Bool)
-> (GetByteMatchSet -> GetByteMatchSet -> Bool)
-> Eq GetByteMatchSet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetByteMatchSet -> GetByteMatchSet -> Bool
$c/= :: GetByteMatchSet -> GetByteMatchSet -> Bool
== :: GetByteMatchSet -> GetByteMatchSet -> Bool
$c== :: GetByteMatchSet -> GetByteMatchSet -> Bool
Prelude.Eq, ReadPrec [GetByteMatchSet]
ReadPrec GetByteMatchSet
Int -> ReadS GetByteMatchSet
ReadS [GetByteMatchSet]
(Int -> ReadS GetByteMatchSet)
-> ReadS [GetByteMatchSet]
-> ReadPrec GetByteMatchSet
-> ReadPrec [GetByteMatchSet]
-> Read GetByteMatchSet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetByteMatchSet]
$creadListPrec :: ReadPrec [GetByteMatchSet]
readPrec :: ReadPrec GetByteMatchSet
$creadPrec :: ReadPrec GetByteMatchSet
readList :: ReadS [GetByteMatchSet]
$creadList :: ReadS [GetByteMatchSet]
readsPrec :: Int -> ReadS GetByteMatchSet
$creadsPrec :: Int -> ReadS GetByteMatchSet
Prelude.Read, Int -> GetByteMatchSet -> ShowS
[GetByteMatchSet] -> ShowS
GetByteMatchSet -> String
(Int -> GetByteMatchSet -> ShowS)
-> (GetByteMatchSet -> String)
-> ([GetByteMatchSet] -> ShowS)
-> Show GetByteMatchSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetByteMatchSet] -> ShowS
$cshowList :: [GetByteMatchSet] -> ShowS
show :: GetByteMatchSet -> String
$cshow :: GetByteMatchSet -> String
showsPrec :: Int -> GetByteMatchSet -> ShowS
$cshowsPrec :: Int -> GetByteMatchSet -> ShowS
Prelude.Show, (forall x. GetByteMatchSet -> Rep GetByteMatchSet x)
-> (forall x. Rep GetByteMatchSet x -> GetByteMatchSet)
-> Generic GetByteMatchSet
forall x. Rep GetByteMatchSet x -> GetByteMatchSet
forall x. GetByteMatchSet -> Rep GetByteMatchSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetByteMatchSet x -> GetByteMatchSet
$cfrom :: forall x. GetByteMatchSet -> Rep GetByteMatchSet x
Prelude.Generic)

-- |
-- Create a value of 'GetByteMatchSet' 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:
--
-- 'byteMatchSetId', 'getByteMatchSet_byteMatchSetId' - The @ByteMatchSetId@ of the ByteMatchSet that you want to get.
-- @ByteMatchSetId@ is returned by CreateByteMatchSet and by
-- ListByteMatchSets.
newGetByteMatchSet ::
  -- | 'byteMatchSetId'
  Prelude.Text ->
  GetByteMatchSet
newGetByteMatchSet :: Text -> GetByteMatchSet
newGetByteMatchSet Text
pByteMatchSetId_ =
  GetByteMatchSet' :: Text -> GetByteMatchSet
GetByteMatchSet' {$sel:byteMatchSetId:GetByteMatchSet' :: Text
byteMatchSetId = Text
pByteMatchSetId_}

-- | The @ByteMatchSetId@ of the ByteMatchSet that you want to get.
-- @ByteMatchSetId@ is returned by CreateByteMatchSet and by
-- ListByteMatchSets.
getByteMatchSet_byteMatchSetId :: Lens.Lens' GetByteMatchSet Prelude.Text
getByteMatchSet_byteMatchSetId :: (Text -> f Text) -> GetByteMatchSet -> f GetByteMatchSet
getByteMatchSet_byteMatchSetId = (GetByteMatchSet -> Text)
-> (GetByteMatchSet -> Text -> GetByteMatchSet)
-> Lens GetByteMatchSet GetByteMatchSet Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetByteMatchSet' {Text
byteMatchSetId :: Text
$sel:byteMatchSetId:GetByteMatchSet' :: GetByteMatchSet -> Text
byteMatchSetId} -> Text
byteMatchSetId) (\s :: GetByteMatchSet
s@GetByteMatchSet' {} Text
a -> GetByteMatchSet
s {$sel:byteMatchSetId:GetByteMatchSet' :: Text
byteMatchSetId = Text
a} :: GetByteMatchSet)

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

instance Prelude.NFData GetByteMatchSet

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

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

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

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

-- |
-- Create a value of 'GetByteMatchSetResponse' 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:
--
-- 'byteMatchSet', 'getByteMatchSetResponse_byteMatchSet' - Information about the ByteMatchSet that you specified in the
-- @GetByteMatchSet@ request. For more information, see the following
-- topics:
--
-- -   ByteMatchSet: Contains @ByteMatchSetId@, @ByteMatchTuples@, and
--     @Name@
--
-- -   @ByteMatchTuples@: Contains an array of ByteMatchTuple objects. Each
--     @ByteMatchTuple@ object contains FieldToMatch,
--     @PositionalConstraint@, @TargetString@, and @TextTransformation@
--
-- -   FieldToMatch: Contains @Data@ and @Type@
--
-- 'httpStatus', 'getByteMatchSetResponse_httpStatus' - The response's http status code.
newGetByteMatchSetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetByteMatchSetResponse
newGetByteMatchSetResponse :: Int -> GetByteMatchSetResponse
newGetByteMatchSetResponse Int
pHttpStatus_ =
  GetByteMatchSetResponse' :: Maybe ByteMatchSet -> Int -> GetByteMatchSetResponse
GetByteMatchSetResponse'
    { $sel:byteMatchSet:GetByteMatchSetResponse' :: Maybe ByteMatchSet
byteMatchSet =
        Maybe ByteMatchSet
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetByteMatchSetResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the ByteMatchSet that you specified in the
-- @GetByteMatchSet@ request. For more information, see the following
-- topics:
--
-- -   ByteMatchSet: Contains @ByteMatchSetId@, @ByteMatchTuples@, and
--     @Name@
--
-- -   @ByteMatchTuples@: Contains an array of ByteMatchTuple objects. Each
--     @ByteMatchTuple@ object contains FieldToMatch,
--     @PositionalConstraint@, @TargetString@, and @TextTransformation@
--
-- -   FieldToMatch: Contains @Data@ and @Type@
getByteMatchSetResponse_byteMatchSet :: Lens.Lens' GetByteMatchSetResponse (Prelude.Maybe ByteMatchSet)
getByteMatchSetResponse_byteMatchSet :: (Maybe ByteMatchSet -> f (Maybe ByteMatchSet))
-> GetByteMatchSetResponse -> f GetByteMatchSetResponse
getByteMatchSetResponse_byteMatchSet = (GetByteMatchSetResponse -> Maybe ByteMatchSet)
-> (GetByteMatchSetResponse
    -> Maybe ByteMatchSet -> GetByteMatchSetResponse)
-> Lens
     GetByteMatchSetResponse
     GetByteMatchSetResponse
     (Maybe ByteMatchSet)
     (Maybe ByteMatchSet)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetByteMatchSetResponse' {Maybe ByteMatchSet
byteMatchSet :: Maybe ByteMatchSet
$sel:byteMatchSet:GetByteMatchSetResponse' :: GetByteMatchSetResponse -> Maybe ByteMatchSet
byteMatchSet} -> Maybe ByteMatchSet
byteMatchSet) (\s :: GetByteMatchSetResponse
s@GetByteMatchSetResponse' {} Maybe ByteMatchSet
a -> GetByteMatchSetResponse
s {$sel:byteMatchSet:GetByteMatchSetResponse' :: Maybe ByteMatchSet
byteMatchSet = Maybe ByteMatchSet
a} :: GetByteMatchSetResponse)

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

instance Prelude.NFData GetByteMatchSetResponse