{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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' {$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 :: Lens' GetXssMatchSet Text
getXssMatchSet_xssMatchSetId = 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 :: (Service -> Service) -> GetXssMatchSet -> Request GetXssMatchSet
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetXssMatchSet
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetXssMatchSet)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe XssMatchSet -> Int -> GetXssMatchSetResponse
GetXssMatchSetResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"XssMatchSet")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetXssMatchSet where
  hashWithSalt :: Int -> GetXssMatchSet -> Int
hashWithSalt Int
_salt GetXssMatchSet' {Text
xssMatchSetId :: Text
$sel:xssMatchSetId:GetXssMatchSet' :: GetXssMatchSet -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
xssMatchSetId

instance Prelude.NFData GetXssMatchSet where
  rnf :: GetXssMatchSet -> ()
rnf GetXssMatchSet' {Text
xssMatchSetId :: Text
$sel:xssMatchSetId:GetXssMatchSet' :: GetXssMatchSet -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
xssMatchSetId

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

instance Data.ToJSON GetXssMatchSet where
  toJSON :: GetXssMatchSet -> Value
toJSON GetXssMatchSet' {Text
xssMatchSetId :: Text
$sel:xssMatchSetId:GetXssMatchSet' :: GetXssMatchSet -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"XssMatchSetId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
xssMatchSetId)
          ]
      )

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

instance Data.ToQuery GetXssMatchSet where
  toQuery :: GetXssMatchSet -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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. 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'
    { $sel:xssMatchSet:GetXssMatchSetResponse' :: Maybe XssMatchSet
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 :: Lens' GetXssMatchSetResponse (Maybe XssMatchSet)
getXssMatchSetResponse_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 :: Lens' GetXssMatchSetResponse Int
getXssMatchSetResponse_httpStatus = 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 where
  rnf :: GetXssMatchSetResponse -> ()
rnf GetXssMatchSetResponse' {Int
Maybe XssMatchSet
httpStatus :: Int
xssMatchSet :: Maybe XssMatchSet
$sel:httpStatus:GetXssMatchSetResponse' :: GetXssMatchSetResponse -> Int
$sel:xssMatchSet:GetXssMatchSetResponse' :: GetXssMatchSetResponse -> Maybe XssMatchSet
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe XssMatchSet
xssMatchSet
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus