{-# 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.GetXssMatchSet
-- 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 XssMatchSet that is specified by @XssMatchSetId@.
module Amazonka.WAFRegional.GetXssMatchSet
  ( -- * Creating a Request
    GetXssMatchSet (..),
    newGetXssMatchSet,

    -- * Request Lenses
    getXssMatchSet_xssMatchSetId,

    -- * Destructuring the Response
    GetXssMatchSetResponse (..),
    newGetXssMatchSetResponse,

    -- * Response Lenses
    getXssMatchSetResponse_xssMatchSet,
    getXssMatchSetResponse_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

-- | A request to get an XssMatchSet.
--
-- /See:/ 'newGetXssMatchSet' smart constructor.
data GetXssMatchSet = GetXssMatchSet'
  { -- | The @XssMatchSetId@ of the XssMatchSet that you want to get.
    -- @XssMatchSetId@ is returned by CreateXssMatchSet and by
    -- ListXssMatchSets.
    GetXssMatchSet -> Text
xssMatchSetId :: Prelude.Text
  }
  deriving (GetXssMatchSet -> GetXssMatchSet -> Bool
(GetXssMatchSet -> GetXssMatchSet -> Bool)
-> (GetXssMatchSet -> GetXssMatchSet -> Bool) -> Eq GetXssMatchSet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetXssMatchSet -> GetXssMatchSet -> Bool
$c/= :: GetXssMatchSet -> GetXssMatchSet -> Bool
== :: GetXssMatchSet -> GetXssMatchSet -> Bool
$c== :: GetXssMatchSet -> GetXssMatchSet -> Bool
Prelude.Eq, ReadPrec [GetXssMatchSet]
ReadPrec GetXssMatchSet
Int -> ReadS GetXssMatchSet
ReadS [GetXssMatchSet]
(Int -> ReadS GetXssMatchSet)
-> ReadS [GetXssMatchSet]
-> ReadPrec GetXssMatchSet
-> ReadPrec [GetXssMatchSet]
-> Read GetXssMatchSet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetXssMatchSet]
$creadListPrec :: ReadPrec [GetXssMatchSet]
readPrec :: ReadPrec GetXssMatchSet
$creadPrec :: ReadPrec GetXssMatchSet
readList :: ReadS [GetXssMatchSet]
$creadList :: ReadS [GetXssMatchSet]
readsPrec :: Int -> ReadS GetXssMatchSet
$creadsPrec :: Int -> ReadS GetXssMatchSet
Prelude.Read, Int -> GetXssMatchSet -> ShowS
[GetXssMatchSet] -> ShowS
GetXssMatchSet -> String
(Int -> GetXssMatchSet -> ShowS)
-> (GetXssMatchSet -> String)
-> ([GetXssMatchSet] -> ShowS)
-> Show GetXssMatchSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetXssMatchSet] -> ShowS
$cshowList :: [GetXssMatchSet] -> ShowS
show :: GetXssMatchSet -> String
$cshow :: GetXssMatchSet -> String
showsPrec :: Int -> GetXssMatchSet -> ShowS
$cshowsPrec :: Int -> GetXssMatchSet -> ShowS
Prelude.Show, (forall x. GetXssMatchSet -> Rep GetXssMatchSet x)
-> (forall x. Rep GetXssMatchSet x -> GetXssMatchSet)
-> Generic GetXssMatchSet
forall x. Rep GetXssMatchSet x -> GetXssMatchSet
forall x. GetXssMatchSet -> Rep GetXssMatchSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetXssMatchSet x -> GetXssMatchSet
$cfrom :: forall x. GetXssMatchSet -> Rep GetXssMatchSet x
Prelude.Generic)

-- |
-- Create a value of 'GetXssMatchSet' 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:
--
-- 'xssMatchSetId', 'getXssMatchSet_xssMatchSetId' - The @XssMatchSetId@ of the XssMatchSet that you want to get.
-- @XssMatchSetId@ is returned by CreateXssMatchSet and by
-- ListXssMatchSets.
newGetXssMatchSet ::
  -- | 'xssMatchSetId'
  Prelude.Text ->
  GetXssMatchSet
newGetXssMatchSet :: Text -> GetXssMatchSet
newGetXssMatchSet Text
pXssMatchSetId_ =
  GetXssMatchSet' :: Text -> GetXssMatchSet
GetXssMatchSet' {$sel:xssMatchSetId:GetXssMatchSet' :: Text
xssMatchSetId = Text
pXssMatchSetId_}

-- | The @XssMatchSetId@ of the XssMatchSet that you want to get.
-- @XssMatchSetId@ is returned by CreateXssMatchSet and by
-- ListXssMatchSets.
getXssMatchSet_xssMatchSetId :: Lens.Lens' GetXssMatchSet Prelude.Text
getXssMatchSet_xssMatchSetId :: (Text -> f Text) -> GetXssMatchSet -> f GetXssMatchSet
getXssMatchSet_xssMatchSetId = (GetXssMatchSet -> Text)
-> (GetXssMatchSet -> Text -> GetXssMatchSet)
-> Lens GetXssMatchSet GetXssMatchSet Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetXssMatchSet' {Text
xssMatchSetId :: Text
$sel:xssMatchSetId:GetXssMatchSet' :: GetXssMatchSet -> Text
xssMatchSetId} -> Text
xssMatchSetId) (\s :: GetXssMatchSet
s@GetXssMatchSet' {} Text
a -> GetXssMatchSet
s {$sel:xssMatchSetId:GetXssMatchSet' :: Text
xssMatchSetId = Text
a} :: GetXssMatchSet)

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

instance Prelude.NFData GetXssMatchSet

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

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

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

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

-- |
-- Create a value of 'GetXssMatchSetResponse' 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:
--
-- 'xssMatchSet', 'getXssMatchSetResponse_xssMatchSet' - Information about the XssMatchSet that you specified in the
-- @GetXssMatchSet@ request. For more information, see the following
-- topics:
--
-- -   XssMatchSet: Contains @Name@, @XssMatchSetId@, and an array of
--     @XssMatchTuple@ objects
--
-- -   XssMatchTuple: Each @XssMatchTuple@ object contains @FieldToMatch@
--     and @TextTransformation@
--
-- -   FieldToMatch: Contains @Data@ and @Type@
--
-- 'httpStatus', 'getXssMatchSetResponse_httpStatus' - The response's http status code.
newGetXssMatchSetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetXssMatchSetResponse
newGetXssMatchSetResponse :: Int -> GetXssMatchSetResponse
newGetXssMatchSetResponse Int
pHttpStatus_ =
  GetXssMatchSetResponse' :: Maybe XssMatchSet -> Int -> GetXssMatchSetResponse
GetXssMatchSetResponse'
    { $sel:xssMatchSet:GetXssMatchSetResponse' :: Maybe XssMatchSet
xssMatchSet =
        Maybe XssMatchSet
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetXssMatchSetResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the XssMatchSet that you specified in the
-- @GetXssMatchSet@ request. For more information, see the following
-- topics:
--
-- -   XssMatchSet: Contains @Name@, @XssMatchSetId@, and an array of
--     @XssMatchTuple@ objects
--
-- -   XssMatchTuple: Each @XssMatchTuple@ object contains @FieldToMatch@
--     and @TextTransformation@
--
-- -   FieldToMatch: Contains @Data@ and @Type@
getXssMatchSetResponse_xssMatchSet :: Lens.Lens' GetXssMatchSetResponse (Prelude.Maybe XssMatchSet)
getXssMatchSetResponse_xssMatchSet :: (Maybe XssMatchSet -> f (Maybe XssMatchSet))
-> GetXssMatchSetResponse -> f GetXssMatchSetResponse
getXssMatchSetResponse_xssMatchSet = (GetXssMatchSetResponse -> Maybe XssMatchSet)
-> (GetXssMatchSetResponse
    -> Maybe XssMatchSet -> GetXssMatchSetResponse)
-> Lens
     GetXssMatchSetResponse
     GetXssMatchSetResponse
     (Maybe XssMatchSet)
     (Maybe XssMatchSet)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetXssMatchSetResponse' {Maybe XssMatchSet
xssMatchSet :: Maybe XssMatchSet
$sel:xssMatchSet:GetXssMatchSetResponse' :: GetXssMatchSetResponse -> Maybe XssMatchSet
xssMatchSet} -> Maybe XssMatchSet
xssMatchSet) (\s :: GetXssMatchSetResponse
s@GetXssMatchSetResponse' {} Maybe XssMatchSet
a -> GetXssMatchSetResponse
s {$sel:xssMatchSet:GetXssMatchSetResponse' :: Maybe XssMatchSet
xssMatchSet = Maybe XssMatchSet
a} :: GetXssMatchSetResponse)

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

instance Prelude.NFData GetXssMatchSetResponse