{-# 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.GetGeoMatchSet
-- 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 GeoMatchSet that is specified by @GeoMatchSetId@.
module Amazonka.WAFRegional.GetGeoMatchSet
  ( -- * Creating a Request
    GetGeoMatchSet (..),
    newGetGeoMatchSet,

    -- * Request Lenses
    getGeoMatchSet_geoMatchSetId,

    -- * Destructuring the Response
    GetGeoMatchSetResponse (..),
    newGetGeoMatchSetResponse,

    -- * Response Lenses
    getGeoMatchSetResponse_geoMatchSet,
    getGeoMatchSetResponse_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

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

-- |
-- Create a value of 'GetGeoMatchSet' 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:
--
-- 'geoMatchSetId', 'getGeoMatchSet_geoMatchSetId' - The @GeoMatchSetId@ of the GeoMatchSet that you want to get.
-- @GeoMatchSetId@ is returned by CreateGeoMatchSet and by
-- ListGeoMatchSets.
newGetGeoMatchSet ::
  -- | 'geoMatchSetId'
  Prelude.Text ->
  GetGeoMatchSet
newGetGeoMatchSet :: Text -> GetGeoMatchSet
newGetGeoMatchSet Text
pGeoMatchSetId_ =
  GetGeoMatchSet' {$sel:geoMatchSetId:GetGeoMatchSet' :: Text
geoMatchSetId = Text
pGeoMatchSetId_}

-- | The @GeoMatchSetId@ of the GeoMatchSet that you want to get.
-- @GeoMatchSetId@ is returned by CreateGeoMatchSet and by
-- ListGeoMatchSets.
getGeoMatchSet_geoMatchSetId :: Lens.Lens' GetGeoMatchSet Prelude.Text
getGeoMatchSet_geoMatchSetId :: Lens' GetGeoMatchSet Text
getGeoMatchSet_geoMatchSetId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetGeoMatchSet' {Text
geoMatchSetId :: Text
$sel:geoMatchSetId:GetGeoMatchSet' :: GetGeoMatchSet -> Text
geoMatchSetId} -> Text
geoMatchSetId) (\s :: GetGeoMatchSet
s@GetGeoMatchSet' {} Text
a -> GetGeoMatchSet
s {$sel:geoMatchSetId:GetGeoMatchSet' :: Text
geoMatchSetId = Text
a} :: GetGeoMatchSet)

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

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

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

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

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

-- | /See:/ 'newGetGeoMatchSetResponse' smart constructor.
data GetGeoMatchSetResponse = GetGeoMatchSetResponse'
  { -- | Information about the GeoMatchSet that you specified in the
    -- @GetGeoMatchSet@ request. This includes the @Type@, which for a
    -- @GeoMatchContraint@ is always @Country@, as well as the @Value@, which
    -- is the identifier for a specific country.
    GetGeoMatchSetResponse -> Maybe GeoMatchSet
geoMatchSet :: Prelude.Maybe GeoMatchSet,
    -- | The response's http status code.
    GetGeoMatchSetResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetGeoMatchSetResponse -> GetGeoMatchSetResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetGeoMatchSetResponse -> GetGeoMatchSetResponse -> Bool
$c/= :: GetGeoMatchSetResponse -> GetGeoMatchSetResponse -> Bool
== :: GetGeoMatchSetResponse -> GetGeoMatchSetResponse -> Bool
$c== :: GetGeoMatchSetResponse -> GetGeoMatchSetResponse -> Bool
Prelude.Eq, ReadPrec [GetGeoMatchSetResponse]
ReadPrec GetGeoMatchSetResponse
Int -> ReadS GetGeoMatchSetResponse
ReadS [GetGeoMatchSetResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetGeoMatchSetResponse]
$creadListPrec :: ReadPrec [GetGeoMatchSetResponse]
readPrec :: ReadPrec GetGeoMatchSetResponse
$creadPrec :: ReadPrec GetGeoMatchSetResponse
readList :: ReadS [GetGeoMatchSetResponse]
$creadList :: ReadS [GetGeoMatchSetResponse]
readsPrec :: Int -> ReadS GetGeoMatchSetResponse
$creadsPrec :: Int -> ReadS GetGeoMatchSetResponse
Prelude.Read, Int -> GetGeoMatchSetResponse -> ShowS
[GetGeoMatchSetResponse] -> ShowS
GetGeoMatchSetResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetGeoMatchSetResponse] -> ShowS
$cshowList :: [GetGeoMatchSetResponse] -> ShowS
show :: GetGeoMatchSetResponse -> String
$cshow :: GetGeoMatchSetResponse -> String
showsPrec :: Int -> GetGeoMatchSetResponse -> ShowS
$cshowsPrec :: Int -> GetGeoMatchSetResponse -> ShowS
Prelude.Show, forall x. Rep GetGeoMatchSetResponse x -> GetGeoMatchSetResponse
forall x. GetGeoMatchSetResponse -> Rep GetGeoMatchSetResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetGeoMatchSetResponse x -> GetGeoMatchSetResponse
$cfrom :: forall x. GetGeoMatchSetResponse -> Rep GetGeoMatchSetResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetGeoMatchSetResponse' 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:
--
-- 'geoMatchSet', 'getGeoMatchSetResponse_geoMatchSet' - Information about the GeoMatchSet that you specified in the
-- @GetGeoMatchSet@ request. This includes the @Type@, which for a
-- @GeoMatchContraint@ is always @Country@, as well as the @Value@, which
-- is the identifier for a specific country.
--
-- 'httpStatus', 'getGeoMatchSetResponse_httpStatus' - The response's http status code.
newGetGeoMatchSetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetGeoMatchSetResponse
newGetGeoMatchSetResponse :: Int -> GetGeoMatchSetResponse
newGetGeoMatchSetResponse Int
pHttpStatus_ =
  GetGeoMatchSetResponse'
    { $sel:geoMatchSet:GetGeoMatchSetResponse' :: Maybe GeoMatchSet
geoMatchSet =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetGeoMatchSetResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the GeoMatchSet that you specified in the
-- @GetGeoMatchSet@ request. This includes the @Type@, which for a
-- @GeoMatchContraint@ is always @Country@, as well as the @Value@, which
-- is the identifier for a specific country.
getGeoMatchSetResponse_geoMatchSet :: Lens.Lens' GetGeoMatchSetResponse (Prelude.Maybe GeoMatchSet)
getGeoMatchSetResponse_geoMatchSet :: Lens' GetGeoMatchSetResponse (Maybe GeoMatchSet)
getGeoMatchSetResponse_geoMatchSet = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetGeoMatchSetResponse' {Maybe GeoMatchSet
geoMatchSet :: Maybe GeoMatchSet
$sel:geoMatchSet:GetGeoMatchSetResponse' :: GetGeoMatchSetResponse -> Maybe GeoMatchSet
geoMatchSet} -> Maybe GeoMatchSet
geoMatchSet) (\s :: GetGeoMatchSetResponse
s@GetGeoMatchSetResponse' {} Maybe GeoMatchSet
a -> GetGeoMatchSetResponse
s {$sel:geoMatchSet:GetGeoMatchSetResponse' :: Maybe GeoMatchSet
geoMatchSet = Maybe GeoMatchSet
a} :: GetGeoMatchSetResponse)

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

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