{-# 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.GetRegexPatternSet
-- 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 RegexPatternSet specified by @RegexPatternSetId@.
module Amazonka.WAF.GetRegexPatternSet
  ( -- * Creating a Request
    GetRegexPatternSet (..),
    newGetRegexPatternSet,

    -- * Request Lenses
    getRegexPatternSet_regexPatternSetId,

    -- * Destructuring the Response
    GetRegexPatternSetResponse (..),
    newGetRegexPatternSetResponse,

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

-- |
-- Create a value of 'GetRegexPatternSet' 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:
--
-- 'regexPatternSetId', 'getRegexPatternSet_regexPatternSetId' - The @RegexPatternSetId@ of the RegexPatternSet that you want to get.
-- @RegexPatternSetId@ is returned by CreateRegexPatternSet and by
-- ListRegexPatternSets.
newGetRegexPatternSet ::
  -- | 'regexPatternSetId'
  Prelude.Text ->
  GetRegexPatternSet
newGetRegexPatternSet :: Text -> GetRegexPatternSet
newGetRegexPatternSet Text
pRegexPatternSetId_ =
  GetRegexPatternSet' :: Text -> GetRegexPatternSet
GetRegexPatternSet'
    { $sel:regexPatternSetId:GetRegexPatternSet' :: Text
regexPatternSetId =
        Text
pRegexPatternSetId_
    }

-- | The @RegexPatternSetId@ of the RegexPatternSet that you want to get.
-- @RegexPatternSetId@ is returned by CreateRegexPatternSet and by
-- ListRegexPatternSets.
getRegexPatternSet_regexPatternSetId :: Lens.Lens' GetRegexPatternSet Prelude.Text
getRegexPatternSet_regexPatternSetId :: (Text -> f Text) -> GetRegexPatternSet -> f GetRegexPatternSet
getRegexPatternSet_regexPatternSetId = (GetRegexPatternSet -> Text)
-> (GetRegexPatternSet -> Text -> GetRegexPatternSet)
-> Lens GetRegexPatternSet GetRegexPatternSet Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRegexPatternSet' {Text
regexPatternSetId :: Text
$sel:regexPatternSetId:GetRegexPatternSet' :: GetRegexPatternSet -> Text
regexPatternSetId} -> Text
regexPatternSetId) (\s :: GetRegexPatternSet
s@GetRegexPatternSet' {} Text
a -> GetRegexPatternSet
s {$sel:regexPatternSetId:GetRegexPatternSet' :: Text
regexPatternSetId = Text
a} :: GetRegexPatternSet)

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

instance Prelude.NFData GetRegexPatternSet

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

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

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

-- | /See:/ 'newGetRegexPatternSetResponse' smart constructor.
data GetRegexPatternSetResponse = GetRegexPatternSetResponse'
  { -- | Information about the RegexPatternSet that you specified in the
    -- @GetRegexPatternSet@ request, including the identifier of the pattern
    -- set and the regular expression patterns you want AWS WAF to search for.
    GetRegexPatternSetResponse -> Maybe RegexPatternSet
regexPatternSet :: Prelude.Maybe RegexPatternSet,
    -- | The response's http status code.
    GetRegexPatternSetResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetRegexPatternSetResponse -> GetRegexPatternSetResponse -> Bool
(GetRegexPatternSetResponse -> GetRegexPatternSetResponse -> Bool)
-> (GetRegexPatternSetResponse
    -> GetRegexPatternSetResponse -> Bool)
-> Eq GetRegexPatternSetResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRegexPatternSetResponse -> GetRegexPatternSetResponse -> Bool
$c/= :: GetRegexPatternSetResponse -> GetRegexPatternSetResponse -> Bool
== :: GetRegexPatternSetResponse -> GetRegexPatternSetResponse -> Bool
$c== :: GetRegexPatternSetResponse -> GetRegexPatternSetResponse -> Bool
Prelude.Eq, ReadPrec [GetRegexPatternSetResponse]
ReadPrec GetRegexPatternSetResponse
Int -> ReadS GetRegexPatternSetResponse
ReadS [GetRegexPatternSetResponse]
(Int -> ReadS GetRegexPatternSetResponse)
-> ReadS [GetRegexPatternSetResponse]
-> ReadPrec GetRegexPatternSetResponse
-> ReadPrec [GetRegexPatternSetResponse]
-> Read GetRegexPatternSetResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRegexPatternSetResponse]
$creadListPrec :: ReadPrec [GetRegexPatternSetResponse]
readPrec :: ReadPrec GetRegexPatternSetResponse
$creadPrec :: ReadPrec GetRegexPatternSetResponse
readList :: ReadS [GetRegexPatternSetResponse]
$creadList :: ReadS [GetRegexPatternSetResponse]
readsPrec :: Int -> ReadS GetRegexPatternSetResponse
$creadsPrec :: Int -> ReadS GetRegexPatternSetResponse
Prelude.Read, Int -> GetRegexPatternSetResponse -> ShowS
[GetRegexPatternSetResponse] -> ShowS
GetRegexPatternSetResponse -> String
(Int -> GetRegexPatternSetResponse -> ShowS)
-> (GetRegexPatternSetResponse -> String)
-> ([GetRegexPatternSetResponse] -> ShowS)
-> Show GetRegexPatternSetResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRegexPatternSetResponse] -> ShowS
$cshowList :: [GetRegexPatternSetResponse] -> ShowS
show :: GetRegexPatternSetResponse -> String
$cshow :: GetRegexPatternSetResponse -> String
showsPrec :: Int -> GetRegexPatternSetResponse -> ShowS
$cshowsPrec :: Int -> GetRegexPatternSetResponse -> ShowS
Prelude.Show, (forall x.
 GetRegexPatternSetResponse -> Rep GetRegexPatternSetResponse x)
-> (forall x.
    Rep GetRegexPatternSetResponse x -> GetRegexPatternSetResponse)
-> Generic GetRegexPatternSetResponse
forall x.
Rep GetRegexPatternSetResponse x -> GetRegexPatternSetResponse
forall x.
GetRegexPatternSetResponse -> Rep GetRegexPatternSetResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetRegexPatternSetResponse x -> GetRegexPatternSetResponse
$cfrom :: forall x.
GetRegexPatternSetResponse -> Rep GetRegexPatternSetResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetRegexPatternSetResponse' 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:
--
-- 'regexPatternSet', 'getRegexPatternSetResponse_regexPatternSet' - Information about the RegexPatternSet that you specified in the
-- @GetRegexPatternSet@ request, including the identifier of the pattern
-- set and the regular expression patterns you want AWS WAF to search for.
--
-- 'httpStatus', 'getRegexPatternSetResponse_httpStatus' - The response's http status code.
newGetRegexPatternSetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetRegexPatternSetResponse
newGetRegexPatternSetResponse :: Int -> GetRegexPatternSetResponse
newGetRegexPatternSetResponse Int
pHttpStatus_ =
  GetRegexPatternSetResponse' :: Maybe RegexPatternSet -> Int -> GetRegexPatternSetResponse
GetRegexPatternSetResponse'
    { $sel:regexPatternSet:GetRegexPatternSetResponse' :: Maybe RegexPatternSet
regexPatternSet =
        Maybe RegexPatternSet
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetRegexPatternSetResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the RegexPatternSet that you specified in the
-- @GetRegexPatternSet@ request, including the identifier of the pattern
-- set and the regular expression patterns you want AWS WAF to search for.
getRegexPatternSetResponse_regexPatternSet :: Lens.Lens' GetRegexPatternSetResponse (Prelude.Maybe RegexPatternSet)
getRegexPatternSetResponse_regexPatternSet :: (Maybe RegexPatternSet -> f (Maybe RegexPatternSet))
-> GetRegexPatternSetResponse -> f GetRegexPatternSetResponse
getRegexPatternSetResponse_regexPatternSet = (GetRegexPatternSetResponse -> Maybe RegexPatternSet)
-> (GetRegexPatternSetResponse
    -> Maybe RegexPatternSet -> GetRegexPatternSetResponse)
-> Lens
     GetRegexPatternSetResponse
     GetRegexPatternSetResponse
     (Maybe RegexPatternSet)
     (Maybe RegexPatternSet)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRegexPatternSetResponse' {Maybe RegexPatternSet
regexPatternSet :: Maybe RegexPatternSet
$sel:regexPatternSet:GetRegexPatternSetResponse' :: GetRegexPatternSetResponse -> Maybe RegexPatternSet
regexPatternSet} -> Maybe RegexPatternSet
regexPatternSet) (\s :: GetRegexPatternSetResponse
s@GetRegexPatternSetResponse' {} Maybe RegexPatternSet
a -> GetRegexPatternSetResponse
s {$sel:regexPatternSet:GetRegexPatternSetResponse' :: Maybe RegexPatternSet
regexPatternSet = Maybe RegexPatternSet
a} :: GetRegexPatternSetResponse)

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

instance Prelude.NFData GetRegexPatternSetResponse