{-# 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.GetRegexMatchSet
-- 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 RegexMatchSet specified by @RegexMatchSetId@.
module Amazonka.WAF.GetRegexMatchSet
  ( -- * Creating a Request
    GetRegexMatchSet (..),
    newGetRegexMatchSet,

    -- * Request Lenses
    getRegexMatchSet_regexMatchSetId,

    -- * Destructuring the Response
    GetRegexMatchSetResponse (..),
    newGetRegexMatchSetResponse,

    -- * Response Lenses
    getRegexMatchSetResponse_regexMatchSet,
    getRegexMatchSetResponse_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.WAF.Types

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

-- |
-- Create a value of 'GetRegexMatchSet' 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:
--
-- 'regexMatchSetId', 'getRegexMatchSet_regexMatchSetId' - The @RegexMatchSetId@ of the RegexMatchSet that you want to get.
-- @RegexMatchSetId@ is returned by CreateRegexMatchSet and by
-- ListRegexMatchSets.
newGetRegexMatchSet ::
  -- | 'regexMatchSetId'
  Prelude.Text ->
  GetRegexMatchSet
newGetRegexMatchSet :: Text -> GetRegexMatchSet
newGetRegexMatchSet Text
pRegexMatchSetId_ =
  GetRegexMatchSet'
    { $sel:regexMatchSetId:GetRegexMatchSet' :: Text
regexMatchSetId =
        Text
pRegexMatchSetId_
    }

-- | The @RegexMatchSetId@ of the RegexMatchSet that you want to get.
-- @RegexMatchSetId@ is returned by CreateRegexMatchSet and by
-- ListRegexMatchSets.
getRegexMatchSet_regexMatchSetId :: Lens.Lens' GetRegexMatchSet Prelude.Text
getRegexMatchSet_regexMatchSetId :: Lens' GetRegexMatchSet Text
getRegexMatchSet_regexMatchSetId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRegexMatchSet' {Text
regexMatchSetId :: Text
$sel:regexMatchSetId:GetRegexMatchSet' :: GetRegexMatchSet -> Text
regexMatchSetId} -> Text
regexMatchSetId) (\s :: GetRegexMatchSet
s@GetRegexMatchSet' {} Text
a -> GetRegexMatchSet
s {$sel:regexMatchSetId:GetRegexMatchSet' :: Text
regexMatchSetId = Text
a} :: GetRegexMatchSet)

instance Core.AWSRequest GetRegexMatchSet where
  type
    AWSResponse GetRegexMatchSet =
      GetRegexMatchSetResponse
  request :: (Service -> Service)
-> GetRegexMatchSet -> Request GetRegexMatchSet
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 GetRegexMatchSet
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetRegexMatchSet)))
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 RegexMatchSet -> Int -> GetRegexMatchSetResponse
GetRegexMatchSetResponse'
            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
"RegexMatchSet")
            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 GetRegexMatchSet where
  hashWithSalt :: Int -> GetRegexMatchSet -> Int
hashWithSalt Int
_salt GetRegexMatchSet' {Text
regexMatchSetId :: Text
$sel:regexMatchSetId:GetRegexMatchSet' :: GetRegexMatchSet -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
regexMatchSetId

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

instance Data.ToHeaders GetRegexMatchSet where
  toHeaders :: GetRegexMatchSet -> 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_20150824.GetRegexMatchSet" ::
                          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 GetRegexMatchSet where
  toJSON :: GetRegexMatchSet -> Value
toJSON GetRegexMatchSet' {Text
regexMatchSetId :: Text
$sel:regexMatchSetId:GetRegexMatchSet' :: GetRegexMatchSet -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"RegexMatchSetId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
regexMatchSetId)
          ]
      )

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

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

-- | /See:/ 'newGetRegexMatchSetResponse' smart constructor.
data GetRegexMatchSetResponse = GetRegexMatchSetResponse'
  { -- | Information about the RegexMatchSet that you specified in the
    -- @GetRegexMatchSet@ request. For more information, see RegexMatchTuple.
    GetRegexMatchSetResponse -> Maybe RegexMatchSet
regexMatchSet :: Prelude.Maybe RegexMatchSet,
    -- | The response's http status code.
    GetRegexMatchSetResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetRegexMatchSetResponse -> GetRegexMatchSetResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRegexMatchSetResponse -> GetRegexMatchSetResponse -> Bool
$c/= :: GetRegexMatchSetResponse -> GetRegexMatchSetResponse -> Bool
== :: GetRegexMatchSetResponse -> GetRegexMatchSetResponse -> Bool
$c== :: GetRegexMatchSetResponse -> GetRegexMatchSetResponse -> Bool
Prelude.Eq, ReadPrec [GetRegexMatchSetResponse]
ReadPrec GetRegexMatchSetResponse
Int -> ReadS GetRegexMatchSetResponse
ReadS [GetRegexMatchSetResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRegexMatchSetResponse]
$creadListPrec :: ReadPrec [GetRegexMatchSetResponse]
readPrec :: ReadPrec GetRegexMatchSetResponse
$creadPrec :: ReadPrec GetRegexMatchSetResponse
readList :: ReadS [GetRegexMatchSetResponse]
$creadList :: ReadS [GetRegexMatchSetResponse]
readsPrec :: Int -> ReadS GetRegexMatchSetResponse
$creadsPrec :: Int -> ReadS GetRegexMatchSetResponse
Prelude.Read, Int -> GetRegexMatchSetResponse -> ShowS
[GetRegexMatchSetResponse] -> ShowS
GetRegexMatchSetResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRegexMatchSetResponse] -> ShowS
$cshowList :: [GetRegexMatchSetResponse] -> ShowS
show :: GetRegexMatchSetResponse -> String
$cshow :: GetRegexMatchSetResponse -> String
showsPrec :: Int -> GetRegexMatchSetResponse -> ShowS
$cshowsPrec :: Int -> GetRegexMatchSetResponse -> ShowS
Prelude.Show, forall x.
Rep GetRegexMatchSetResponse x -> GetRegexMatchSetResponse
forall x.
GetRegexMatchSetResponse -> Rep GetRegexMatchSetResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetRegexMatchSetResponse x -> GetRegexMatchSetResponse
$cfrom :: forall x.
GetRegexMatchSetResponse -> Rep GetRegexMatchSetResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetRegexMatchSetResponse' 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:
--
-- 'regexMatchSet', 'getRegexMatchSetResponse_regexMatchSet' - Information about the RegexMatchSet that you specified in the
-- @GetRegexMatchSet@ request. For more information, see RegexMatchTuple.
--
-- 'httpStatus', 'getRegexMatchSetResponse_httpStatus' - The response's http status code.
newGetRegexMatchSetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetRegexMatchSetResponse
newGetRegexMatchSetResponse :: Int -> GetRegexMatchSetResponse
newGetRegexMatchSetResponse Int
pHttpStatus_ =
  GetRegexMatchSetResponse'
    { $sel:regexMatchSet:GetRegexMatchSetResponse' :: Maybe RegexMatchSet
regexMatchSet =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetRegexMatchSetResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the RegexMatchSet that you specified in the
-- @GetRegexMatchSet@ request. For more information, see RegexMatchTuple.
getRegexMatchSetResponse_regexMatchSet :: Lens.Lens' GetRegexMatchSetResponse (Prelude.Maybe RegexMatchSet)
getRegexMatchSetResponse_regexMatchSet :: Lens' GetRegexMatchSetResponse (Maybe RegexMatchSet)
getRegexMatchSetResponse_regexMatchSet = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRegexMatchSetResponse' {Maybe RegexMatchSet
regexMatchSet :: Maybe RegexMatchSet
$sel:regexMatchSet:GetRegexMatchSetResponse' :: GetRegexMatchSetResponse -> Maybe RegexMatchSet
regexMatchSet} -> Maybe RegexMatchSet
regexMatchSet) (\s :: GetRegexMatchSetResponse
s@GetRegexMatchSetResponse' {} Maybe RegexMatchSet
a -> GetRegexMatchSetResponse
s {$sel:regexMatchSet:GetRegexMatchSetResponse' :: Maybe RegexMatchSet
regexMatchSet = Maybe RegexMatchSet
a} :: GetRegexMatchSetResponse)

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

instance Prelude.NFData GetRegexMatchSetResponse where
  rnf :: GetRegexMatchSetResponse -> ()
rnf GetRegexMatchSetResponse' {Int
Maybe RegexMatchSet
httpStatus :: Int
regexMatchSet :: Maybe RegexMatchSet
$sel:httpStatus:GetRegexMatchSetResponse' :: GetRegexMatchSetResponse -> Int
$sel:regexMatchSet:GetRegexMatchSetResponse' :: GetRegexMatchSetResponse -> Maybe RegexMatchSet
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe RegexMatchSet
regexMatchSet
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus