{-# 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.CreateRule
(
CreateRule (..),
newCreateRule,
createRule_tags,
createRule_name,
createRule_metricName,
createRule_changeToken,
CreateRuleResponse (..),
newCreateRuleResponse,
createRuleResponse_rule,
createRuleResponse_changeToken,
createRuleResponse_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 CreateRule = CreateRule'
{ CreateRule -> Maybe (NonEmpty Tag)
tags :: Prelude.Maybe (Prelude.NonEmpty Tag),
CreateRule -> Text
name :: Prelude.Text,
CreateRule -> Text
metricName :: Prelude.Text,
CreateRule -> Text
changeToken :: Prelude.Text
}
deriving (CreateRule -> CreateRule -> Bool
(CreateRule -> CreateRule -> Bool)
-> (CreateRule -> CreateRule -> Bool) -> Eq CreateRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateRule -> CreateRule -> Bool
$c/= :: CreateRule -> CreateRule -> Bool
== :: CreateRule -> CreateRule -> Bool
$c== :: CreateRule -> CreateRule -> Bool
Prelude.Eq, ReadPrec [CreateRule]
ReadPrec CreateRule
Int -> ReadS CreateRule
ReadS [CreateRule]
(Int -> ReadS CreateRule)
-> ReadS [CreateRule]
-> ReadPrec CreateRule
-> ReadPrec [CreateRule]
-> Read CreateRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateRule]
$creadListPrec :: ReadPrec [CreateRule]
readPrec :: ReadPrec CreateRule
$creadPrec :: ReadPrec CreateRule
readList :: ReadS [CreateRule]
$creadList :: ReadS [CreateRule]
readsPrec :: Int -> ReadS CreateRule
$creadsPrec :: Int -> ReadS CreateRule
Prelude.Read, Int -> CreateRule -> ShowS
[CreateRule] -> ShowS
CreateRule -> String
(Int -> CreateRule -> ShowS)
-> (CreateRule -> String)
-> ([CreateRule] -> ShowS)
-> Show CreateRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateRule] -> ShowS
$cshowList :: [CreateRule] -> ShowS
show :: CreateRule -> String
$cshow :: CreateRule -> String
showsPrec :: Int -> CreateRule -> ShowS
$cshowsPrec :: Int -> CreateRule -> ShowS
Prelude.Show, (forall x. CreateRule -> Rep CreateRule x)
-> (forall x. Rep CreateRule x -> CreateRule) -> Generic CreateRule
forall x. Rep CreateRule x -> CreateRule
forall x. CreateRule -> Rep CreateRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateRule x -> CreateRule
$cfrom :: forall x. CreateRule -> Rep CreateRule x
Prelude.Generic)
newCreateRule ::
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
CreateRule
newCreateRule :: Text -> Text -> Text -> CreateRule
newCreateRule Text
pName_ Text
pMetricName_ Text
pChangeToken_ =
CreateRule' :: Maybe (NonEmpty Tag) -> Text -> Text -> Text -> CreateRule
CreateRule'
{ $sel:tags:CreateRule' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
forall a. Maybe a
Prelude.Nothing,
$sel:name:CreateRule' :: Text
name = Text
pName_,
$sel:metricName:CreateRule' :: Text
metricName = Text
pMetricName_,
$sel:changeToken:CreateRule' :: Text
changeToken = Text
pChangeToken_
}
createRule_tags :: Lens.Lens' CreateRule (Prelude.Maybe (Prelude.NonEmpty Tag))
createRule_tags :: (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateRule -> f CreateRule
createRule_tags = (CreateRule -> Maybe (NonEmpty Tag))
-> (CreateRule -> Maybe (NonEmpty Tag) -> CreateRule)
-> Lens
CreateRule CreateRule (Maybe (NonEmpty Tag)) (Maybe (NonEmpty Tag))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRule' {Maybe (NonEmpty Tag)
tags :: Maybe (NonEmpty Tag)
$sel:tags:CreateRule' :: CreateRule -> Maybe (NonEmpty Tag)
tags} -> Maybe (NonEmpty Tag)
tags) (\s :: CreateRule
s@CreateRule' {} Maybe (NonEmpty Tag)
a -> CreateRule
s {$sel:tags:CreateRule' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
a} :: CreateRule) ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateRule -> f CreateRule)
-> ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateRule
-> f CreateRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
-> Iso
(Maybe (NonEmpty Tag))
(Maybe (NonEmpty Tag))
(Maybe (NonEmpty Tag))
(Maybe (NonEmpty Tag))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createRule_name :: Lens.Lens' CreateRule Prelude.Text
createRule_name :: (Text -> f Text) -> CreateRule -> f CreateRule
createRule_name = (CreateRule -> Text)
-> (CreateRule -> Text -> CreateRule)
-> Lens CreateRule CreateRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRule' {Text
name :: Text
$sel:name:CreateRule' :: CreateRule -> Text
name} -> Text
name) (\s :: CreateRule
s@CreateRule' {} Text
a -> CreateRule
s {$sel:name:CreateRule' :: Text
name = Text
a} :: CreateRule)
createRule_metricName :: Lens.Lens' CreateRule Prelude.Text
createRule_metricName :: (Text -> f Text) -> CreateRule -> f CreateRule
createRule_metricName = (CreateRule -> Text)
-> (CreateRule -> Text -> CreateRule)
-> Lens CreateRule CreateRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRule' {Text
metricName :: Text
$sel:metricName:CreateRule' :: CreateRule -> Text
metricName} -> Text
metricName) (\s :: CreateRule
s@CreateRule' {} Text
a -> CreateRule
s {$sel:metricName:CreateRule' :: Text
metricName = Text
a} :: CreateRule)
createRule_changeToken :: Lens.Lens' CreateRule Prelude.Text
createRule_changeToken :: (Text -> f Text) -> CreateRule -> f CreateRule
createRule_changeToken = (CreateRule -> Text)
-> (CreateRule -> Text -> CreateRule)
-> Lens CreateRule CreateRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRule' {Text
changeToken :: Text
$sel:changeToken:CreateRule' :: CreateRule -> Text
changeToken} -> Text
changeToken) (\s :: CreateRule
s@CreateRule' {} Text
a -> CreateRule
s {$sel:changeToken:CreateRule' :: Text
changeToken = Text
a} :: CreateRule)
instance Core.AWSRequest CreateRule where
type AWSResponse CreateRule = CreateRuleResponse
request :: CreateRule -> Request CreateRule
request = Service -> CreateRule -> Request CreateRule
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateRule)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateRule))
-> Logger
-> Service
-> Proxy CreateRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateRule)))
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 Rule -> Maybe Text -> Int -> CreateRuleResponse
CreateRuleResponse'
(Maybe Rule -> Maybe Text -> Int -> CreateRuleResponse)
-> Either String (Maybe Rule)
-> Either String (Maybe Text -> Int -> CreateRuleResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Rule)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Rule")
Either String (Maybe Text -> Int -> CreateRuleResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateRuleResponse)
forall (f :: * -> *) a b. Applicative f => 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 (Int -> CreateRuleResponse)
-> Either String Int -> Either String CreateRuleResponse
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 CreateRule
instance Prelude.NFData CreateRule
instance Core.ToHeaders CreateRule where
toHeaders :: CreateRule -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateRule -> 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.CreateRule" ::
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 CreateRule where
toJSON :: CreateRule -> Value
toJSON CreateRule' {Maybe (NonEmpty Tag)
Text
changeToken :: Text
metricName :: Text
name :: Text
tags :: Maybe (NonEmpty Tag)
$sel:changeToken:CreateRule' :: CreateRule -> Text
$sel:metricName:CreateRule' :: CreateRule -> Text
$sel:name:CreateRule' :: CreateRule -> Text
$sel:tags:CreateRule' :: CreateRule -> Maybe (NonEmpty Tag)
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Tags" Text -> NonEmpty Tag -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Tag -> Pair) -> Maybe (NonEmpty Tag) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Tag)
tags,
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
"MetricName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
metricName),
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 CreateRule where
toPath :: CreateRule -> ByteString
toPath = ByteString -> CreateRule -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateRule where
toQuery :: CreateRule -> QueryString
toQuery = QueryString -> CreateRule -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateRuleResponse = CreateRuleResponse'
{
CreateRuleResponse -> Maybe Rule
rule :: Prelude.Maybe Rule,
CreateRuleResponse -> Maybe Text
changeToken :: Prelude.Maybe Prelude.Text,
CreateRuleResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateRuleResponse -> CreateRuleResponse -> Bool
(CreateRuleResponse -> CreateRuleResponse -> Bool)
-> (CreateRuleResponse -> CreateRuleResponse -> Bool)
-> Eq CreateRuleResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateRuleResponse -> CreateRuleResponse -> Bool
$c/= :: CreateRuleResponse -> CreateRuleResponse -> Bool
== :: CreateRuleResponse -> CreateRuleResponse -> Bool
$c== :: CreateRuleResponse -> CreateRuleResponse -> Bool
Prelude.Eq, ReadPrec [CreateRuleResponse]
ReadPrec CreateRuleResponse
Int -> ReadS CreateRuleResponse
ReadS [CreateRuleResponse]
(Int -> ReadS CreateRuleResponse)
-> ReadS [CreateRuleResponse]
-> ReadPrec CreateRuleResponse
-> ReadPrec [CreateRuleResponse]
-> Read CreateRuleResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateRuleResponse]
$creadListPrec :: ReadPrec [CreateRuleResponse]
readPrec :: ReadPrec CreateRuleResponse
$creadPrec :: ReadPrec CreateRuleResponse
readList :: ReadS [CreateRuleResponse]
$creadList :: ReadS [CreateRuleResponse]
readsPrec :: Int -> ReadS CreateRuleResponse
$creadsPrec :: Int -> ReadS CreateRuleResponse
Prelude.Read, Int -> CreateRuleResponse -> ShowS
[CreateRuleResponse] -> ShowS
CreateRuleResponse -> String
(Int -> CreateRuleResponse -> ShowS)
-> (CreateRuleResponse -> String)
-> ([CreateRuleResponse] -> ShowS)
-> Show CreateRuleResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateRuleResponse] -> ShowS
$cshowList :: [CreateRuleResponse] -> ShowS
show :: CreateRuleResponse -> String
$cshow :: CreateRuleResponse -> String
showsPrec :: Int -> CreateRuleResponse -> ShowS
$cshowsPrec :: Int -> CreateRuleResponse -> ShowS
Prelude.Show, (forall x. CreateRuleResponse -> Rep CreateRuleResponse x)
-> (forall x. Rep CreateRuleResponse x -> CreateRuleResponse)
-> Generic CreateRuleResponse
forall x. Rep CreateRuleResponse x -> CreateRuleResponse
forall x. CreateRuleResponse -> Rep CreateRuleResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateRuleResponse x -> CreateRuleResponse
$cfrom :: forall x. CreateRuleResponse -> Rep CreateRuleResponse x
Prelude.Generic)
newCreateRuleResponse ::
Prelude.Int ->
CreateRuleResponse
newCreateRuleResponse :: Int -> CreateRuleResponse
newCreateRuleResponse Int
pHttpStatus_ =
CreateRuleResponse' :: Maybe Rule -> Maybe Text -> Int -> CreateRuleResponse
CreateRuleResponse'
{ $sel:rule:CreateRuleResponse' :: Maybe Rule
rule = Maybe Rule
forall a. Maybe a
Prelude.Nothing,
$sel:changeToken:CreateRuleResponse' :: Maybe Text
changeToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createRuleResponse_rule :: Lens.Lens' CreateRuleResponse (Prelude.Maybe Rule)
createRuleResponse_rule :: (Maybe Rule -> f (Maybe Rule))
-> CreateRuleResponse -> f CreateRuleResponse
createRuleResponse_rule = (CreateRuleResponse -> Maybe Rule)
-> (CreateRuleResponse -> Maybe Rule -> CreateRuleResponse)
-> Lens
CreateRuleResponse CreateRuleResponse (Maybe Rule) (Maybe Rule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRuleResponse' {Maybe Rule
rule :: Maybe Rule
$sel:rule:CreateRuleResponse' :: CreateRuleResponse -> Maybe Rule
rule} -> Maybe Rule
rule) (\s :: CreateRuleResponse
s@CreateRuleResponse' {} Maybe Rule
a -> CreateRuleResponse
s {$sel:rule:CreateRuleResponse' :: Maybe Rule
rule = Maybe Rule
a} :: CreateRuleResponse)
createRuleResponse_changeToken :: Lens.Lens' CreateRuleResponse (Prelude.Maybe Prelude.Text)
createRuleResponse_changeToken :: (Maybe Text -> f (Maybe Text))
-> CreateRuleResponse -> f CreateRuleResponse
createRuleResponse_changeToken = (CreateRuleResponse -> Maybe Text)
-> (CreateRuleResponse -> Maybe Text -> CreateRuleResponse)
-> Lens
CreateRuleResponse CreateRuleResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRuleResponse' {Maybe Text
changeToken :: Maybe Text
$sel:changeToken:CreateRuleResponse' :: CreateRuleResponse -> Maybe Text
changeToken} -> Maybe Text
changeToken) (\s :: CreateRuleResponse
s@CreateRuleResponse' {} Maybe Text
a -> CreateRuleResponse
s {$sel:changeToken:CreateRuleResponse' :: Maybe Text
changeToken = Maybe Text
a} :: CreateRuleResponse)
createRuleResponse_httpStatus :: Lens.Lens' CreateRuleResponse Prelude.Int
createRuleResponse_httpStatus :: (Int -> f Int) -> CreateRuleResponse -> f CreateRuleResponse
createRuleResponse_httpStatus = (CreateRuleResponse -> Int)
-> (CreateRuleResponse -> Int -> CreateRuleResponse)
-> Lens CreateRuleResponse CreateRuleResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRuleResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateRuleResponse' :: CreateRuleResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateRuleResponse
s@CreateRuleResponse' {} Int
a -> CreateRuleResponse
s {$sel:httpStatus:CreateRuleResponse' :: Int
httpStatus = Int
a} :: CreateRuleResponse)
instance Prelude.NFData CreateRuleResponse