{-# 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 #-}
module Amazonka.WAFRegional.GetIPSet
(
GetIPSet (..),
newGetIPSet,
getIPSet_iPSetId,
GetIPSetResponse (..),
newGetIPSetResponse,
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
data GetIPSet = GetIPSet'
{
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)
newGetIPSet ::
Prelude.Text ->
GetIPSet
newGetIPSet :: Text -> GetIPSet
newGetIPSet Text
pIPSetId_ =
GetIPSet' :: Text -> GetIPSet
GetIPSet' {$sel:iPSetId:GetIPSet' :: Text
iPSetId = Text
pIPSetId_}
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
data GetIPSetResponse = GetIPSetResponse'
{
GetIPSetResponse -> Maybe IPSet
iPSet :: Prelude.Maybe IPSet,
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)
newGetIPSetResponse ::
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_
}
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)
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