{-# 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.GetIPSet
-- 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 IPSet that is specified by @IPSetId@.
module Amazonka.WAFRegional.GetIPSet
  ( -- * Creating a Request
    GetIPSet (..),
    newGetIPSet,

    -- * Request Lenses
    getIPSet_iPSetId,

    -- * Destructuring the Response
    GetIPSetResponse (..),
    newGetIPSetResponse,

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

-- |
-- Create a value of 'GetIPSet' 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:
--
-- 'iPSetId', 'getIPSet_iPSetId' - The @IPSetId@ of the IPSet that you want to get. @IPSetId@ is returned
-- by CreateIPSet and by ListIPSets.
newGetIPSet ::
  -- | 'iPSetId'
  Prelude.Text ->
  GetIPSet
newGetIPSet :: Text -> GetIPSet
newGetIPSet Text
pIPSetId_ =
  GetIPSet' :: Text -> GetIPSet
GetIPSet' {$sel:iPSetId:GetIPSet' :: Text
iPSetId = Text
pIPSetId_}

-- | The @IPSetId@ of the IPSet that you want to get. @IPSetId@ is returned
-- by CreateIPSet and by ListIPSets.
getIPSet_iPSetId :: Lens.Lens' GetIPSet Prelude.Text
getIPSet_iPSetId :: (Text -> f Text) -> GetIPSet -> f GetIPSet
getIPSet_iPSetId = (GetIPSet -> Text)
-> (GetIPSet -> Text -> GetIPSet)
-> Lens GetIPSet GetIPSet Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetIPSet' {Text
iPSetId :: Text
$sel:iPSetId:GetIPSet' :: GetIPSet -> Text
iPSetId} -> Text
iPSetId) (\s :: GetIPSet
s@GetIPSet' {} Text
a -> GetIPSet
s {$sel:iPSetId:GetIPSet' :: Text
iPSetId = Text
a} :: GetIPSet)

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

instance Prelude.NFData GetIPSet

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

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

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

-- | /See:/ 'newGetIPSetResponse' smart constructor.
data GetIPSetResponse = GetIPSetResponse'
  { -- | Information about the IPSet that you specified in the @GetIPSet@
    -- request. For more information, see the following topics:
    --
    -- -   IPSet: Contains @IPSetDescriptors@, @IPSetId@, and @Name@
    --
    -- -   @IPSetDescriptors@: Contains an array of IPSetDescriptor objects.
    --     Each @IPSetDescriptor@ object contains @Type@ and @Value@
    GetIPSetResponse -> Maybe IPSet
iPSet :: Prelude.Maybe IPSet,
    -- | The response's http status code.
    GetIPSetResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetIPSetResponse -> GetIPSetResponse -> Bool
(GetIPSetResponse -> GetIPSetResponse -> Bool)
-> (GetIPSetResponse -> GetIPSetResponse -> Bool)
-> Eq GetIPSetResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetIPSetResponse -> GetIPSetResponse -> Bool
$c/= :: GetIPSetResponse -> GetIPSetResponse -> Bool
== :: GetIPSetResponse -> GetIPSetResponse -> Bool
$c== :: GetIPSetResponse -> GetIPSetResponse -> Bool
Prelude.Eq, ReadPrec [GetIPSetResponse]
ReadPrec GetIPSetResponse
Int -> ReadS GetIPSetResponse
ReadS [GetIPSetResponse]
(Int -> ReadS GetIPSetResponse)
-> ReadS [GetIPSetResponse]
-> ReadPrec GetIPSetResponse
-> ReadPrec [GetIPSetResponse]
-> Read GetIPSetResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetIPSetResponse]
$creadListPrec :: ReadPrec [GetIPSetResponse]
readPrec :: ReadPrec GetIPSetResponse
$creadPrec :: ReadPrec GetIPSetResponse
readList :: ReadS [GetIPSetResponse]
$creadList :: ReadS [GetIPSetResponse]
readsPrec :: Int -> ReadS GetIPSetResponse
$creadsPrec :: Int -> ReadS GetIPSetResponse
Prelude.Read, Int -> GetIPSetResponse -> ShowS
[GetIPSetResponse] -> ShowS
GetIPSetResponse -> String
(Int -> GetIPSetResponse -> ShowS)
-> (GetIPSetResponse -> String)
-> ([GetIPSetResponse] -> ShowS)
-> Show GetIPSetResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetIPSetResponse] -> ShowS
$cshowList :: [GetIPSetResponse] -> ShowS
show :: GetIPSetResponse -> String
$cshow :: GetIPSetResponse -> String
showsPrec :: Int -> GetIPSetResponse -> ShowS
$cshowsPrec :: Int -> GetIPSetResponse -> ShowS
Prelude.Show, (forall x. GetIPSetResponse -> Rep GetIPSetResponse x)
-> (forall x. Rep GetIPSetResponse x -> GetIPSetResponse)
-> Generic GetIPSetResponse
forall x. Rep GetIPSetResponse x -> GetIPSetResponse
forall x. GetIPSetResponse -> Rep GetIPSetResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetIPSetResponse x -> GetIPSetResponse
$cfrom :: forall x. GetIPSetResponse -> Rep GetIPSetResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetIPSetResponse' 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:
--
-- 'iPSet', 'getIPSetResponse_iPSet' - Information about the IPSet that you specified in the @GetIPSet@
-- request. For more information, see the following topics:
--
-- -   IPSet: Contains @IPSetDescriptors@, @IPSetId@, and @Name@
--
-- -   @IPSetDescriptors@: Contains an array of IPSetDescriptor objects.
--     Each @IPSetDescriptor@ object contains @Type@ and @Value@
--
-- 'httpStatus', 'getIPSetResponse_httpStatus' - The response's http status code.
newGetIPSetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetIPSetResponse
newGetIPSetResponse :: Int -> GetIPSetResponse
newGetIPSetResponse Int
pHttpStatus_ =
  GetIPSetResponse' :: Maybe IPSet -> Int -> GetIPSetResponse
GetIPSetResponse'
    { $sel:iPSet:GetIPSetResponse' :: Maybe IPSet
iPSet = Maybe IPSet
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetIPSetResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the IPSet that you specified in the @GetIPSet@
-- request. For more information, see the following topics:
--
-- -   IPSet: Contains @IPSetDescriptors@, @IPSetId@, and @Name@
--
-- -   @IPSetDescriptors@: Contains an array of IPSetDescriptor objects.
--     Each @IPSetDescriptor@ object contains @Type@ and @Value@
getIPSetResponse_iPSet :: Lens.Lens' GetIPSetResponse (Prelude.Maybe IPSet)
getIPSetResponse_iPSet :: (Maybe IPSet -> f (Maybe IPSet))
-> GetIPSetResponse -> f GetIPSetResponse
getIPSetResponse_iPSet = (GetIPSetResponse -> Maybe IPSet)
-> (GetIPSetResponse -> Maybe IPSet -> GetIPSetResponse)
-> Lens
     GetIPSetResponse GetIPSetResponse (Maybe IPSet) (Maybe IPSet)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetIPSetResponse' {Maybe IPSet
iPSet :: Maybe IPSet
$sel:iPSet:GetIPSetResponse' :: GetIPSetResponse -> Maybe IPSet
iPSet} -> Maybe IPSet
iPSet) (\s :: GetIPSetResponse
s@GetIPSetResponse' {} Maybe IPSet
a -> GetIPSetResponse
s {$sel:iPSet:GetIPSetResponse' :: Maybe IPSet
iPSet = Maybe IPSet
a} :: GetIPSetResponse)

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

instance Prelude.NFData GetIPSetResponse