{-# 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-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 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.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

-- | /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
(GetGeoMatchSet -> GetGeoMatchSet -> Bool)
-> (GetGeoMatchSet -> GetGeoMatchSet -> Bool) -> Eq GetGeoMatchSet
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]
(Int -> ReadS GetGeoMatchSet)
-> ReadS [GetGeoMatchSet]
-> ReadPrec GetGeoMatchSet
-> ReadPrec [GetGeoMatchSet]
-> Read 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
(Int -> GetGeoMatchSet -> ShowS)
-> (GetGeoMatchSet -> String)
-> ([GetGeoMatchSet] -> ShowS)
-> Show GetGeoMatchSet
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. GetGeoMatchSet -> Rep GetGeoMatchSet x)
-> (forall x. Rep GetGeoMatchSet x -> GetGeoMatchSet)
-> Generic GetGeoMatchSet
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' :: Text -> GetGeoMatchSet
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 :: (Text -> f Text) -> GetGeoMatchSet -> f GetGeoMatchSet
getGeoMatchSet_geoMatchSetId = (GetGeoMatchSet -> Text)
-> (GetGeoMatchSet -> Text -> GetGeoMatchSet)
-> Lens GetGeoMatchSet GetGeoMatchSet Text Text
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 :: GetGeoMatchSet -> Request GetGeoMatchSet
request = Service -> GetGeoMatchSet -> Request GetGeoMatchSet
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetGeoMatchSet
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetGeoMatchSet)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetGeoMatchSet))
-> Logger
-> Service
-> Proxy GetGeoMatchSet
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetGeoMatchSet)))
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 GeoMatchSet -> Int -> GetGeoMatchSetResponse
GetGeoMatchSetResponse'
            (Maybe GeoMatchSet -> Int -> GetGeoMatchSetResponse)
-> Either String (Maybe GeoMatchSet)
-> Either String (Int -> GetGeoMatchSetResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe GeoMatchSet)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"GeoMatchSet")
            Either String (Int -> GetGeoMatchSetResponse)
-> Either String Int -> Either String GetGeoMatchSetResponse
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 GetGeoMatchSet

instance Prelude.NFData GetGeoMatchSet

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

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

instance Core.ToQuery GetGeoMatchSet where
  toQuery :: GetGeoMatchSet -> QueryString
toQuery = QueryString -> GetGeoMatchSet -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(GetGeoMatchSetResponse -> GetGeoMatchSetResponse -> Bool)
-> (GetGeoMatchSetResponse -> GetGeoMatchSetResponse -> Bool)
-> Eq GetGeoMatchSetResponse
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]
(Int -> ReadS GetGeoMatchSetResponse)
-> ReadS [GetGeoMatchSetResponse]
-> ReadPrec GetGeoMatchSetResponse
-> ReadPrec [GetGeoMatchSetResponse]
-> Read 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
(Int -> GetGeoMatchSetResponse -> ShowS)
-> (GetGeoMatchSetResponse -> String)
-> ([GetGeoMatchSetResponse] -> ShowS)
-> Show GetGeoMatchSetResponse
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. GetGeoMatchSetResponse -> Rep GetGeoMatchSetResponse x)
-> (forall x.
    Rep GetGeoMatchSetResponse x -> GetGeoMatchSetResponse)
-> Generic GetGeoMatchSetResponse
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' :: Maybe GeoMatchSet -> Int -> GetGeoMatchSetResponse
GetGeoMatchSetResponse'
    { $sel:geoMatchSet:GetGeoMatchSetResponse' :: Maybe GeoMatchSet
geoMatchSet =
        Maybe 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 :: (Maybe GeoMatchSet -> f (Maybe GeoMatchSet))
-> GetGeoMatchSetResponse -> f GetGeoMatchSetResponse
getGeoMatchSetResponse_geoMatchSet = (GetGeoMatchSetResponse -> Maybe GeoMatchSet)
-> (GetGeoMatchSetResponse
    -> Maybe GeoMatchSet -> GetGeoMatchSetResponse)
-> Lens
     GetGeoMatchSetResponse
     GetGeoMatchSetResponse
     (Maybe GeoMatchSet)
     (Maybe 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 :: (Int -> f Int)
-> GetGeoMatchSetResponse -> f GetGeoMatchSetResponse
getGeoMatchSetResponse_httpStatus = (GetGeoMatchSetResponse -> Int)
-> (GetGeoMatchSetResponse -> Int -> GetGeoMatchSetResponse)
-> Lens GetGeoMatchSetResponse GetGeoMatchSetResponse Int Int
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