{-# 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-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 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.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:/ '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
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]
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
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. 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' {$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 :: Lens' GetIPSet Text
getIPSet_iPSetId = 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 :: (Service -> Service) -> GetIPSet -> Request GetIPSet
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 GetIPSet
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetIPSet)))
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 IPSet -> Int -> GetIPSetResponse
GetIPSetResponse'
            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
"IPSet")
            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 GetIPSet where
  hashWithSalt :: Int -> GetIPSet -> Int
hashWithSalt Int
_salt GetIPSet' {Text
iPSetId :: Text
$sel:iPSetId:GetIPSet' :: GetIPSet -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
iPSetId

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

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

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

instance Data.ToQuery GetIPSet where
  toQuery :: GetIPSet -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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. 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'
    { $sel:iPSet:GetIPSetResponse' :: Maybe IPSet
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 :: Lens' GetIPSetResponse (Maybe IPSet)
getIPSetResponse_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 :: Lens' GetIPSetResponse Int
getIPSetResponse_httpStatus = 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 where
  rnf :: GetIPSetResponse -> ()
rnf GetIPSetResponse' {Int
Maybe IPSet
httpStatus :: Int
iPSet :: Maybe IPSet
$sel:httpStatus:GetIPSetResponse' :: GetIPSetResponse -> Int
$sel:iPSet:GetIPSetResponse' :: GetIPSetResponse -> Maybe IPSet
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe IPSet
iPSet
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus