{-# 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.WAF.CreateIPSet
(
CreateIPSet (..),
newCreateIPSet,
createIPSet_name,
createIPSet_changeToken,
CreateIPSetResponse (..),
newCreateIPSetResponse,
createIPSetResponse_changeToken,
createIPSetResponse_iPSet,
createIPSetResponse_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.WAF.Types
data CreateIPSet = CreateIPSet'
{
CreateIPSet -> Text
name :: Prelude.Text,
CreateIPSet -> Text
changeToken :: Prelude.Text
}
deriving (CreateIPSet -> CreateIPSet -> Bool
(CreateIPSet -> CreateIPSet -> Bool)
-> (CreateIPSet -> CreateIPSet -> Bool) -> Eq CreateIPSet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateIPSet -> CreateIPSet -> Bool
$c/= :: CreateIPSet -> CreateIPSet -> Bool
== :: CreateIPSet -> CreateIPSet -> Bool
$c== :: CreateIPSet -> CreateIPSet -> Bool
Prelude.Eq, ReadPrec [CreateIPSet]
ReadPrec CreateIPSet
Int -> ReadS CreateIPSet
ReadS [CreateIPSet]
(Int -> ReadS CreateIPSet)
-> ReadS [CreateIPSet]
-> ReadPrec CreateIPSet
-> ReadPrec [CreateIPSet]
-> Read CreateIPSet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateIPSet]
$creadListPrec :: ReadPrec [CreateIPSet]
readPrec :: ReadPrec CreateIPSet
$creadPrec :: ReadPrec CreateIPSet
readList :: ReadS [CreateIPSet]
$creadList :: ReadS [CreateIPSet]
readsPrec :: Int -> ReadS CreateIPSet
$creadsPrec :: Int -> ReadS CreateIPSet
Prelude.Read, Int -> CreateIPSet -> ShowS
[CreateIPSet] -> ShowS
CreateIPSet -> String
(Int -> CreateIPSet -> ShowS)
-> (CreateIPSet -> String)
-> ([CreateIPSet] -> ShowS)
-> Show CreateIPSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateIPSet] -> ShowS
$cshowList :: [CreateIPSet] -> ShowS
show :: CreateIPSet -> String
$cshow :: CreateIPSet -> String
showsPrec :: Int -> CreateIPSet -> ShowS
$cshowsPrec :: Int -> CreateIPSet -> ShowS
Prelude.Show, (forall x. CreateIPSet -> Rep CreateIPSet x)
-> (forall x. Rep CreateIPSet x -> CreateIPSet)
-> Generic CreateIPSet
forall x. Rep CreateIPSet x -> CreateIPSet
forall x. CreateIPSet -> Rep CreateIPSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateIPSet x -> CreateIPSet
$cfrom :: forall x. CreateIPSet -> Rep CreateIPSet x
Prelude.Generic)
newCreateIPSet ::
Prelude.Text ->
Prelude.Text ->
CreateIPSet
newCreateIPSet :: Text -> Text -> CreateIPSet
newCreateIPSet Text
pName_ Text
pChangeToken_ =
CreateIPSet' :: Text -> Text -> CreateIPSet
CreateIPSet'
{ $sel:name:CreateIPSet' :: Text
name = Text
pName_,
$sel:changeToken:CreateIPSet' :: Text
changeToken = Text
pChangeToken_
}
createIPSet_name :: Lens.Lens' CreateIPSet Prelude.Text
createIPSet_name :: (Text -> f Text) -> CreateIPSet -> f CreateIPSet
createIPSet_name = (CreateIPSet -> Text)
-> (CreateIPSet -> Text -> CreateIPSet)
-> Lens CreateIPSet CreateIPSet Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIPSet' {Text
name :: Text
$sel:name:CreateIPSet' :: CreateIPSet -> Text
name} -> Text
name) (\s :: CreateIPSet
s@CreateIPSet' {} Text
a -> CreateIPSet
s {$sel:name:CreateIPSet' :: Text
name = Text
a} :: CreateIPSet)
createIPSet_changeToken :: Lens.Lens' CreateIPSet Prelude.Text
createIPSet_changeToken :: (Text -> f Text) -> CreateIPSet -> f CreateIPSet
createIPSet_changeToken = (CreateIPSet -> Text)
-> (CreateIPSet -> Text -> CreateIPSet)
-> Lens CreateIPSet CreateIPSet Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIPSet' {Text
changeToken :: Text
$sel:changeToken:CreateIPSet' :: CreateIPSet -> Text
changeToken} -> Text
changeToken) (\s :: CreateIPSet
s@CreateIPSet' {} Text
a -> CreateIPSet
s {$sel:changeToken:CreateIPSet' :: Text
changeToken = Text
a} :: CreateIPSet)
instance Core.AWSRequest CreateIPSet where
type AWSResponse CreateIPSet = CreateIPSetResponse
request :: CreateIPSet -> Request CreateIPSet
request = Service -> CreateIPSet -> Request CreateIPSet
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateIPSet
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateIPSet)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateIPSet))
-> Logger
-> Service
-> Proxy CreateIPSet
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateIPSet)))
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 Text -> Maybe IPSet -> Int -> CreateIPSetResponse
CreateIPSetResponse'
(Maybe Text -> Maybe IPSet -> Int -> CreateIPSetResponse)
-> Either String (Maybe Text)
-> Either String (Maybe IPSet -> Int -> CreateIPSetResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ChangeToken")
Either String (Maybe IPSet -> Int -> CreateIPSetResponse)
-> Either String (Maybe IPSet)
-> Either String (Int -> CreateIPSetResponse)
forall (f :: * -> *) a b. Applicative f => 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 -> CreateIPSetResponse)
-> Either String Int -> Either String CreateIPSetResponse
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 CreateIPSet
instance Prelude.NFData CreateIPSet
instance Core.ToHeaders CreateIPSet where
toHeaders :: CreateIPSet -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateIPSet -> 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_20150824.CreateIPSet" ::
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 CreateIPSet where
toJSON :: CreateIPSet -> Value
toJSON CreateIPSet' {Text
changeToken :: Text
name :: Text
$sel:changeToken:CreateIPSet' :: CreateIPSet -> Text
$sel:name:CreateIPSet' :: CreateIPSet -> 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
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ChangeToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
changeToken)
]
)
instance Core.ToPath CreateIPSet where
toPath :: CreateIPSet -> ByteString
toPath = ByteString -> CreateIPSet -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateIPSet where
toQuery :: CreateIPSet -> QueryString
toQuery = QueryString -> CreateIPSet -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateIPSetResponse = CreateIPSetResponse'
{
CreateIPSetResponse -> Maybe Text
changeToken :: Prelude.Maybe Prelude.Text,
CreateIPSetResponse -> Maybe IPSet
iPSet :: Prelude.Maybe IPSet,
CreateIPSetResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateIPSetResponse -> CreateIPSetResponse -> Bool
(CreateIPSetResponse -> CreateIPSetResponse -> Bool)
-> (CreateIPSetResponse -> CreateIPSetResponse -> Bool)
-> Eq CreateIPSetResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateIPSetResponse -> CreateIPSetResponse -> Bool
$c/= :: CreateIPSetResponse -> CreateIPSetResponse -> Bool
== :: CreateIPSetResponse -> CreateIPSetResponse -> Bool
$c== :: CreateIPSetResponse -> CreateIPSetResponse -> Bool
Prelude.Eq, ReadPrec [CreateIPSetResponse]
ReadPrec CreateIPSetResponse
Int -> ReadS CreateIPSetResponse
ReadS [CreateIPSetResponse]
(Int -> ReadS CreateIPSetResponse)
-> ReadS [CreateIPSetResponse]
-> ReadPrec CreateIPSetResponse
-> ReadPrec [CreateIPSetResponse]
-> Read CreateIPSetResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateIPSetResponse]
$creadListPrec :: ReadPrec [CreateIPSetResponse]
readPrec :: ReadPrec CreateIPSetResponse
$creadPrec :: ReadPrec CreateIPSetResponse
readList :: ReadS [CreateIPSetResponse]
$creadList :: ReadS [CreateIPSetResponse]
readsPrec :: Int -> ReadS CreateIPSetResponse
$creadsPrec :: Int -> ReadS CreateIPSetResponse
Prelude.Read, Int -> CreateIPSetResponse -> ShowS
[CreateIPSetResponse] -> ShowS
CreateIPSetResponse -> String
(Int -> CreateIPSetResponse -> ShowS)
-> (CreateIPSetResponse -> String)
-> ([CreateIPSetResponse] -> ShowS)
-> Show CreateIPSetResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateIPSetResponse] -> ShowS
$cshowList :: [CreateIPSetResponse] -> ShowS
show :: CreateIPSetResponse -> String
$cshow :: CreateIPSetResponse -> String
showsPrec :: Int -> CreateIPSetResponse -> ShowS
$cshowsPrec :: Int -> CreateIPSetResponse -> ShowS
Prelude.Show, (forall x. CreateIPSetResponse -> Rep CreateIPSetResponse x)
-> (forall x. Rep CreateIPSetResponse x -> CreateIPSetResponse)
-> Generic CreateIPSetResponse
forall x. Rep CreateIPSetResponse x -> CreateIPSetResponse
forall x. CreateIPSetResponse -> Rep CreateIPSetResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateIPSetResponse x -> CreateIPSetResponse
$cfrom :: forall x. CreateIPSetResponse -> Rep CreateIPSetResponse x
Prelude.Generic)
newCreateIPSetResponse ::
Prelude.Int ->
CreateIPSetResponse
newCreateIPSetResponse :: Int -> CreateIPSetResponse
newCreateIPSetResponse Int
pHttpStatus_ =
CreateIPSetResponse' :: Maybe Text -> Maybe IPSet -> Int -> CreateIPSetResponse
CreateIPSetResponse'
{ $sel:changeToken:CreateIPSetResponse' :: Maybe Text
changeToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:iPSet:CreateIPSetResponse' :: Maybe IPSet
iPSet = Maybe IPSet
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateIPSetResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createIPSetResponse_changeToken :: Lens.Lens' CreateIPSetResponse (Prelude.Maybe Prelude.Text)
createIPSetResponse_changeToken :: (Maybe Text -> f (Maybe Text))
-> CreateIPSetResponse -> f CreateIPSetResponse
createIPSetResponse_changeToken = (CreateIPSetResponse -> Maybe Text)
-> (CreateIPSetResponse -> Maybe Text -> CreateIPSetResponse)
-> Lens
CreateIPSetResponse CreateIPSetResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIPSetResponse' {Maybe Text
changeToken :: Maybe Text
$sel:changeToken:CreateIPSetResponse' :: CreateIPSetResponse -> Maybe Text
changeToken} -> Maybe Text
changeToken) (\s :: CreateIPSetResponse
s@CreateIPSetResponse' {} Maybe Text
a -> CreateIPSetResponse
s {$sel:changeToken:CreateIPSetResponse' :: Maybe Text
changeToken = Maybe Text
a} :: CreateIPSetResponse)
createIPSetResponse_iPSet :: Lens.Lens' CreateIPSetResponse (Prelude.Maybe IPSet)
createIPSetResponse_iPSet :: (Maybe IPSet -> f (Maybe IPSet))
-> CreateIPSetResponse -> f CreateIPSetResponse
createIPSetResponse_iPSet = (CreateIPSetResponse -> Maybe IPSet)
-> (CreateIPSetResponse -> Maybe IPSet -> CreateIPSetResponse)
-> Lens
CreateIPSetResponse CreateIPSetResponse (Maybe IPSet) (Maybe IPSet)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIPSetResponse' {Maybe IPSet
iPSet :: Maybe IPSet
$sel:iPSet:CreateIPSetResponse' :: CreateIPSetResponse -> Maybe IPSet
iPSet} -> Maybe IPSet
iPSet) (\s :: CreateIPSetResponse
s@CreateIPSetResponse' {} Maybe IPSet
a -> CreateIPSetResponse
s {$sel:iPSet:CreateIPSetResponse' :: Maybe IPSet
iPSet = Maybe IPSet
a} :: CreateIPSetResponse)
createIPSetResponse_httpStatus :: Lens.Lens' CreateIPSetResponse Prelude.Int
createIPSetResponse_httpStatus :: (Int -> f Int) -> CreateIPSetResponse -> f CreateIPSetResponse
createIPSetResponse_httpStatus = (CreateIPSetResponse -> Int)
-> (CreateIPSetResponse -> Int -> CreateIPSetResponse)
-> Lens CreateIPSetResponse CreateIPSetResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIPSetResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateIPSetResponse' :: CreateIPSetResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateIPSetResponse
s@CreateIPSetResponse' {} Int
a -> CreateIPSetResponse
s {$sel:httpStatus:CreateIPSetResponse' :: Int
httpStatus = Int
a} :: CreateIPSetResponse)
instance Prelude.NFData CreateIPSetResponse