{-# 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.UpdateRateBasedRule
(
UpdateRateBasedRule (..),
newUpdateRateBasedRule,
updateRateBasedRule_ruleId,
updateRateBasedRule_changeToken,
updateRateBasedRule_updates,
updateRateBasedRule_rateLimit,
UpdateRateBasedRuleResponse (..),
newUpdateRateBasedRuleResponse,
updateRateBasedRuleResponse_changeToken,
updateRateBasedRuleResponse_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 UpdateRateBasedRule = UpdateRateBasedRule'
{
UpdateRateBasedRule -> Text
ruleId :: Prelude.Text,
UpdateRateBasedRule -> Text
changeToken :: Prelude.Text,
UpdateRateBasedRule -> [RuleUpdate]
updates :: [RuleUpdate],
UpdateRateBasedRule -> Natural
rateLimit :: Prelude.Natural
}
deriving (UpdateRateBasedRule -> UpdateRateBasedRule -> Bool
(UpdateRateBasedRule -> UpdateRateBasedRule -> Bool)
-> (UpdateRateBasedRule -> UpdateRateBasedRule -> Bool)
-> Eq UpdateRateBasedRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateRateBasedRule -> UpdateRateBasedRule -> Bool
$c/= :: UpdateRateBasedRule -> UpdateRateBasedRule -> Bool
== :: UpdateRateBasedRule -> UpdateRateBasedRule -> Bool
$c== :: UpdateRateBasedRule -> UpdateRateBasedRule -> Bool
Prelude.Eq, ReadPrec [UpdateRateBasedRule]
ReadPrec UpdateRateBasedRule
Int -> ReadS UpdateRateBasedRule
ReadS [UpdateRateBasedRule]
(Int -> ReadS UpdateRateBasedRule)
-> ReadS [UpdateRateBasedRule]
-> ReadPrec UpdateRateBasedRule
-> ReadPrec [UpdateRateBasedRule]
-> Read UpdateRateBasedRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateRateBasedRule]
$creadListPrec :: ReadPrec [UpdateRateBasedRule]
readPrec :: ReadPrec UpdateRateBasedRule
$creadPrec :: ReadPrec UpdateRateBasedRule
readList :: ReadS [UpdateRateBasedRule]
$creadList :: ReadS [UpdateRateBasedRule]
readsPrec :: Int -> ReadS UpdateRateBasedRule
$creadsPrec :: Int -> ReadS UpdateRateBasedRule
Prelude.Read, Int -> UpdateRateBasedRule -> ShowS
[UpdateRateBasedRule] -> ShowS
UpdateRateBasedRule -> String
(Int -> UpdateRateBasedRule -> ShowS)
-> (UpdateRateBasedRule -> String)
-> ([UpdateRateBasedRule] -> ShowS)
-> Show UpdateRateBasedRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateRateBasedRule] -> ShowS
$cshowList :: [UpdateRateBasedRule] -> ShowS
show :: UpdateRateBasedRule -> String
$cshow :: UpdateRateBasedRule -> String
showsPrec :: Int -> UpdateRateBasedRule -> ShowS
$cshowsPrec :: Int -> UpdateRateBasedRule -> ShowS
Prelude.Show, (forall x. UpdateRateBasedRule -> Rep UpdateRateBasedRule x)
-> (forall x. Rep UpdateRateBasedRule x -> UpdateRateBasedRule)
-> Generic UpdateRateBasedRule
forall x. Rep UpdateRateBasedRule x -> UpdateRateBasedRule
forall x. UpdateRateBasedRule -> Rep UpdateRateBasedRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateRateBasedRule x -> UpdateRateBasedRule
$cfrom :: forall x. UpdateRateBasedRule -> Rep UpdateRateBasedRule x
Prelude.Generic)
newUpdateRateBasedRule ::
Prelude.Text ->
Prelude.Text ->
Prelude.Natural ->
UpdateRateBasedRule
newUpdateRateBasedRule :: Text -> Text -> Natural -> UpdateRateBasedRule
newUpdateRateBasedRule
Text
pRuleId_
Text
pChangeToken_
Natural
pRateLimit_ =
UpdateRateBasedRule' :: Text -> Text -> [RuleUpdate] -> Natural -> UpdateRateBasedRule
UpdateRateBasedRule'
{ $sel:ruleId:UpdateRateBasedRule' :: Text
ruleId = Text
pRuleId_,
$sel:changeToken:UpdateRateBasedRule' :: Text
changeToken = Text
pChangeToken_,
$sel:updates:UpdateRateBasedRule' :: [RuleUpdate]
updates = [RuleUpdate]
forall a. Monoid a => a
Prelude.mempty,
$sel:rateLimit:UpdateRateBasedRule' :: Natural
rateLimit = Natural
pRateLimit_
}
updateRateBasedRule_ruleId :: Lens.Lens' UpdateRateBasedRule Prelude.Text
updateRateBasedRule_ruleId :: (Text -> f Text) -> UpdateRateBasedRule -> f UpdateRateBasedRule
updateRateBasedRule_ruleId = (UpdateRateBasedRule -> Text)
-> (UpdateRateBasedRule -> Text -> UpdateRateBasedRule)
-> Lens UpdateRateBasedRule UpdateRateBasedRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRateBasedRule' {Text
ruleId :: Text
$sel:ruleId:UpdateRateBasedRule' :: UpdateRateBasedRule -> Text
ruleId} -> Text
ruleId) (\s :: UpdateRateBasedRule
s@UpdateRateBasedRule' {} Text
a -> UpdateRateBasedRule
s {$sel:ruleId:UpdateRateBasedRule' :: Text
ruleId = Text
a} :: UpdateRateBasedRule)
updateRateBasedRule_changeToken :: Lens.Lens' UpdateRateBasedRule Prelude.Text
updateRateBasedRule_changeToken :: (Text -> f Text) -> UpdateRateBasedRule -> f UpdateRateBasedRule
updateRateBasedRule_changeToken = (UpdateRateBasedRule -> Text)
-> (UpdateRateBasedRule -> Text -> UpdateRateBasedRule)
-> Lens UpdateRateBasedRule UpdateRateBasedRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRateBasedRule' {Text
changeToken :: Text
$sel:changeToken:UpdateRateBasedRule' :: UpdateRateBasedRule -> Text
changeToken} -> Text
changeToken) (\s :: UpdateRateBasedRule
s@UpdateRateBasedRule' {} Text
a -> UpdateRateBasedRule
s {$sel:changeToken:UpdateRateBasedRule' :: Text
changeToken = Text
a} :: UpdateRateBasedRule)
updateRateBasedRule_updates :: Lens.Lens' UpdateRateBasedRule [RuleUpdate]
updateRateBasedRule_updates :: ([RuleUpdate] -> f [RuleUpdate])
-> UpdateRateBasedRule -> f UpdateRateBasedRule
updateRateBasedRule_updates = (UpdateRateBasedRule -> [RuleUpdate])
-> (UpdateRateBasedRule -> [RuleUpdate] -> UpdateRateBasedRule)
-> Lens
UpdateRateBasedRule UpdateRateBasedRule [RuleUpdate] [RuleUpdate]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRateBasedRule' {[RuleUpdate]
updates :: [RuleUpdate]
$sel:updates:UpdateRateBasedRule' :: UpdateRateBasedRule -> [RuleUpdate]
updates} -> [RuleUpdate]
updates) (\s :: UpdateRateBasedRule
s@UpdateRateBasedRule' {} [RuleUpdate]
a -> UpdateRateBasedRule
s {$sel:updates:UpdateRateBasedRule' :: [RuleUpdate]
updates = [RuleUpdate]
a} :: UpdateRateBasedRule) (([RuleUpdate] -> f [RuleUpdate])
-> UpdateRateBasedRule -> f UpdateRateBasedRule)
-> (([RuleUpdate] -> f [RuleUpdate])
-> [RuleUpdate] -> f [RuleUpdate])
-> ([RuleUpdate] -> f [RuleUpdate])
-> UpdateRateBasedRule
-> f UpdateRateBasedRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([RuleUpdate] -> f [RuleUpdate]) -> [RuleUpdate] -> f [RuleUpdate]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
updateRateBasedRule_rateLimit :: Lens.Lens' UpdateRateBasedRule Prelude.Natural
updateRateBasedRule_rateLimit :: (Natural -> f Natural)
-> UpdateRateBasedRule -> f UpdateRateBasedRule
updateRateBasedRule_rateLimit = (UpdateRateBasedRule -> Natural)
-> (UpdateRateBasedRule -> Natural -> UpdateRateBasedRule)
-> Lens UpdateRateBasedRule UpdateRateBasedRule Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRateBasedRule' {Natural
rateLimit :: Natural
$sel:rateLimit:UpdateRateBasedRule' :: UpdateRateBasedRule -> Natural
rateLimit} -> Natural
rateLimit) (\s :: UpdateRateBasedRule
s@UpdateRateBasedRule' {} Natural
a -> UpdateRateBasedRule
s {$sel:rateLimit:UpdateRateBasedRule' :: Natural
rateLimit = Natural
a} :: UpdateRateBasedRule)
instance Core.AWSRequest UpdateRateBasedRule where
type
AWSResponse UpdateRateBasedRule =
UpdateRateBasedRuleResponse
request :: UpdateRateBasedRule -> Request UpdateRateBasedRule
request = Service -> UpdateRateBasedRule -> Request UpdateRateBasedRule
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy UpdateRateBasedRule
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse UpdateRateBasedRule)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse UpdateRateBasedRule))
-> Logger
-> Service
-> Proxy UpdateRateBasedRule
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse UpdateRateBasedRule)))
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 -> Int -> UpdateRateBasedRuleResponse
UpdateRateBasedRuleResponse'
(Maybe Text -> Int -> UpdateRateBasedRuleResponse)
-> Either String (Maybe Text)
-> Either String (Int -> UpdateRateBasedRuleResponse)
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 (Int -> UpdateRateBasedRuleResponse)
-> Either String Int -> Either String UpdateRateBasedRuleResponse
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 UpdateRateBasedRule
instance Prelude.NFData UpdateRateBasedRule
instance Core.ToHeaders UpdateRateBasedRule where
toHeaders :: UpdateRateBasedRule -> ResponseHeaders
toHeaders =
ResponseHeaders -> UpdateRateBasedRule -> 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.UpdateRateBasedRule" ::
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 UpdateRateBasedRule where
toJSON :: UpdateRateBasedRule -> Value
toJSON UpdateRateBasedRule' {Natural
[RuleUpdate]
Text
rateLimit :: Natural
updates :: [RuleUpdate]
changeToken :: Text
ruleId :: Text
$sel:rateLimit:UpdateRateBasedRule' :: UpdateRateBasedRule -> Natural
$sel:updates:UpdateRateBasedRule' :: UpdateRateBasedRule -> [RuleUpdate]
$sel:changeToken:UpdateRateBasedRule' :: UpdateRateBasedRule -> Text
$sel:ruleId:UpdateRateBasedRule' :: UpdateRateBasedRule -> 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
"RuleId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
ruleId),
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),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Updates" Text -> [RuleUpdate] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [RuleUpdate]
updates),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"RateLimit" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
rateLimit)
]
)
instance Core.ToPath UpdateRateBasedRule where
toPath :: UpdateRateBasedRule -> ByteString
toPath = ByteString -> UpdateRateBasedRule -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery UpdateRateBasedRule where
toQuery :: UpdateRateBasedRule -> QueryString
toQuery = QueryString -> UpdateRateBasedRule -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data UpdateRateBasedRuleResponse = UpdateRateBasedRuleResponse'
{
UpdateRateBasedRuleResponse -> Maybe Text
changeToken :: Prelude.Maybe Prelude.Text,
UpdateRateBasedRuleResponse -> Int
httpStatus :: Prelude.Int
}
deriving (UpdateRateBasedRuleResponse -> UpdateRateBasedRuleResponse -> Bool
(UpdateRateBasedRuleResponse
-> UpdateRateBasedRuleResponse -> Bool)
-> (UpdateRateBasedRuleResponse
-> UpdateRateBasedRuleResponse -> Bool)
-> Eq UpdateRateBasedRuleResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateRateBasedRuleResponse -> UpdateRateBasedRuleResponse -> Bool
$c/= :: UpdateRateBasedRuleResponse -> UpdateRateBasedRuleResponse -> Bool
== :: UpdateRateBasedRuleResponse -> UpdateRateBasedRuleResponse -> Bool
$c== :: UpdateRateBasedRuleResponse -> UpdateRateBasedRuleResponse -> Bool
Prelude.Eq, ReadPrec [UpdateRateBasedRuleResponse]
ReadPrec UpdateRateBasedRuleResponse
Int -> ReadS UpdateRateBasedRuleResponse
ReadS [UpdateRateBasedRuleResponse]
(Int -> ReadS UpdateRateBasedRuleResponse)
-> ReadS [UpdateRateBasedRuleResponse]
-> ReadPrec UpdateRateBasedRuleResponse
-> ReadPrec [UpdateRateBasedRuleResponse]
-> Read UpdateRateBasedRuleResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateRateBasedRuleResponse]
$creadListPrec :: ReadPrec [UpdateRateBasedRuleResponse]
readPrec :: ReadPrec UpdateRateBasedRuleResponse
$creadPrec :: ReadPrec UpdateRateBasedRuleResponse
readList :: ReadS [UpdateRateBasedRuleResponse]
$creadList :: ReadS [UpdateRateBasedRuleResponse]
readsPrec :: Int -> ReadS UpdateRateBasedRuleResponse
$creadsPrec :: Int -> ReadS UpdateRateBasedRuleResponse
Prelude.Read, Int -> UpdateRateBasedRuleResponse -> ShowS
[UpdateRateBasedRuleResponse] -> ShowS
UpdateRateBasedRuleResponse -> String
(Int -> UpdateRateBasedRuleResponse -> ShowS)
-> (UpdateRateBasedRuleResponse -> String)
-> ([UpdateRateBasedRuleResponse] -> ShowS)
-> Show UpdateRateBasedRuleResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateRateBasedRuleResponse] -> ShowS
$cshowList :: [UpdateRateBasedRuleResponse] -> ShowS
show :: UpdateRateBasedRuleResponse -> String
$cshow :: UpdateRateBasedRuleResponse -> String
showsPrec :: Int -> UpdateRateBasedRuleResponse -> ShowS
$cshowsPrec :: Int -> UpdateRateBasedRuleResponse -> ShowS
Prelude.Show, (forall x.
UpdateRateBasedRuleResponse -> Rep UpdateRateBasedRuleResponse x)
-> (forall x.
Rep UpdateRateBasedRuleResponse x -> UpdateRateBasedRuleResponse)
-> Generic UpdateRateBasedRuleResponse
forall x.
Rep UpdateRateBasedRuleResponse x -> UpdateRateBasedRuleResponse
forall x.
UpdateRateBasedRuleResponse -> Rep UpdateRateBasedRuleResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateRateBasedRuleResponse x -> UpdateRateBasedRuleResponse
$cfrom :: forall x.
UpdateRateBasedRuleResponse -> Rep UpdateRateBasedRuleResponse x
Prelude.Generic)
newUpdateRateBasedRuleResponse ::
Prelude.Int ->
UpdateRateBasedRuleResponse
newUpdateRateBasedRuleResponse :: Int -> UpdateRateBasedRuleResponse
newUpdateRateBasedRuleResponse Int
pHttpStatus_ =
UpdateRateBasedRuleResponse' :: Maybe Text -> Int -> UpdateRateBasedRuleResponse
UpdateRateBasedRuleResponse'
{ $sel:changeToken:UpdateRateBasedRuleResponse' :: Maybe Text
changeToken =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:UpdateRateBasedRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
}
updateRateBasedRuleResponse_changeToken :: Lens.Lens' UpdateRateBasedRuleResponse (Prelude.Maybe Prelude.Text)
updateRateBasedRuleResponse_changeToken :: (Maybe Text -> f (Maybe Text))
-> UpdateRateBasedRuleResponse -> f UpdateRateBasedRuleResponse
updateRateBasedRuleResponse_changeToken = (UpdateRateBasedRuleResponse -> Maybe Text)
-> (UpdateRateBasedRuleResponse
-> Maybe Text -> UpdateRateBasedRuleResponse)
-> Lens
UpdateRateBasedRuleResponse
UpdateRateBasedRuleResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRateBasedRuleResponse' {Maybe Text
changeToken :: Maybe Text
$sel:changeToken:UpdateRateBasedRuleResponse' :: UpdateRateBasedRuleResponse -> Maybe Text
changeToken} -> Maybe Text
changeToken) (\s :: UpdateRateBasedRuleResponse
s@UpdateRateBasedRuleResponse' {} Maybe Text
a -> UpdateRateBasedRuleResponse
s {$sel:changeToken:UpdateRateBasedRuleResponse' :: Maybe Text
changeToken = Maybe Text
a} :: UpdateRateBasedRuleResponse)
updateRateBasedRuleResponse_httpStatus :: Lens.Lens' UpdateRateBasedRuleResponse Prelude.Int
updateRateBasedRuleResponse_httpStatus :: (Int -> f Int)
-> UpdateRateBasedRuleResponse -> f UpdateRateBasedRuleResponse
updateRateBasedRuleResponse_httpStatus = (UpdateRateBasedRuleResponse -> Int)
-> (UpdateRateBasedRuleResponse
-> Int -> UpdateRateBasedRuleResponse)
-> Lens
UpdateRateBasedRuleResponse UpdateRateBasedRuleResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRateBasedRuleResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateRateBasedRuleResponse' :: UpdateRateBasedRuleResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdateRateBasedRuleResponse
s@UpdateRateBasedRuleResponse' {} Int
a -> UpdateRateBasedRuleResponse
s {$sel:httpStatus:UpdateRateBasedRuleResponse' :: Int
httpStatus = Int
a} :: UpdateRateBasedRuleResponse)
instance Prelude.NFData UpdateRateBasedRuleResponse