{-# 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.UpdateRule
(
UpdateRule (..),
newUpdateRule,
updateRule_ruleId,
updateRule_changeToken,
updateRule_updates,
UpdateRuleResponse (..),
newUpdateRuleResponse,
updateRuleResponse_changeToken,
updateRuleResponse_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 UpdateRule = UpdateRule'
{
UpdateRule -> Text
ruleId :: Prelude.Text,
UpdateRule -> Text
changeToken :: Prelude.Text,
UpdateRule -> [RuleUpdate]
updates :: [RuleUpdate]
}
deriving (UpdateRule -> UpdateRule -> Bool
(UpdateRule -> UpdateRule -> Bool)
-> (UpdateRule -> UpdateRule -> Bool) -> Eq UpdateRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateRule -> UpdateRule -> Bool
$c/= :: UpdateRule -> UpdateRule -> Bool
== :: UpdateRule -> UpdateRule -> Bool
$c== :: UpdateRule -> UpdateRule -> Bool
Prelude.Eq, ReadPrec [UpdateRule]
ReadPrec UpdateRule
Int -> ReadS UpdateRule
ReadS [UpdateRule]
(Int -> ReadS UpdateRule)
-> ReadS [UpdateRule]
-> ReadPrec UpdateRule
-> ReadPrec [UpdateRule]
-> Read UpdateRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateRule]
$creadListPrec :: ReadPrec [UpdateRule]
readPrec :: ReadPrec UpdateRule
$creadPrec :: ReadPrec UpdateRule
readList :: ReadS [UpdateRule]
$creadList :: ReadS [UpdateRule]
readsPrec :: Int -> ReadS UpdateRule
$creadsPrec :: Int -> ReadS UpdateRule
Prelude.Read, Int -> UpdateRule -> ShowS
[UpdateRule] -> ShowS
UpdateRule -> String
(Int -> UpdateRule -> ShowS)
-> (UpdateRule -> String)
-> ([UpdateRule] -> ShowS)
-> Show UpdateRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateRule] -> ShowS
$cshowList :: [UpdateRule] -> ShowS
show :: UpdateRule -> String
$cshow :: UpdateRule -> String
showsPrec :: Int -> UpdateRule -> ShowS
$cshowsPrec :: Int -> UpdateRule -> ShowS
Prelude.Show, (forall x. UpdateRule -> Rep UpdateRule x)
-> (forall x. Rep UpdateRule x -> UpdateRule) -> Generic UpdateRule
forall x. Rep UpdateRule x -> UpdateRule
forall x. UpdateRule -> Rep UpdateRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateRule x -> UpdateRule
$cfrom :: forall x. UpdateRule -> Rep UpdateRule x
Prelude.Generic)
newUpdateRule ::
Prelude.Text ->
Prelude.Text ->
UpdateRule
newUpdateRule :: Text -> Text -> UpdateRule
newUpdateRule Text
pRuleId_ Text
pChangeToken_ =
UpdateRule' :: Text -> Text -> [RuleUpdate] -> UpdateRule
UpdateRule'
{ $sel:ruleId:UpdateRule' :: Text
ruleId = Text
pRuleId_,
$sel:changeToken:UpdateRule' :: Text
changeToken = Text
pChangeToken_,
$sel:updates:UpdateRule' :: [RuleUpdate]
updates = [RuleUpdate]
forall a. Monoid a => a
Prelude.mempty
}
updateRule_ruleId :: Lens.Lens' UpdateRule Prelude.Text
updateRule_ruleId :: (Text -> f Text) -> UpdateRule -> f UpdateRule
updateRule_ruleId = (UpdateRule -> Text)
-> (UpdateRule -> Text -> UpdateRule)
-> Lens UpdateRule UpdateRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRule' {Text
ruleId :: Text
$sel:ruleId:UpdateRule' :: UpdateRule -> Text
ruleId} -> Text
ruleId) (\s :: UpdateRule
s@UpdateRule' {} Text
a -> UpdateRule
s {$sel:ruleId:UpdateRule' :: Text
ruleId = Text
a} :: UpdateRule)
updateRule_changeToken :: Lens.Lens' UpdateRule Prelude.Text
updateRule_changeToken :: (Text -> f Text) -> UpdateRule -> f UpdateRule
updateRule_changeToken = (UpdateRule -> Text)
-> (UpdateRule -> Text -> UpdateRule)
-> Lens UpdateRule UpdateRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRule' {Text
changeToken :: Text
$sel:changeToken:UpdateRule' :: UpdateRule -> Text
changeToken} -> Text
changeToken) (\s :: UpdateRule
s@UpdateRule' {} Text
a -> UpdateRule
s {$sel:changeToken:UpdateRule' :: Text
changeToken = Text
a} :: UpdateRule)
updateRule_updates :: Lens.Lens' UpdateRule [RuleUpdate]
updateRule_updates :: ([RuleUpdate] -> f [RuleUpdate]) -> UpdateRule -> f UpdateRule
updateRule_updates = (UpdateRule -> [RuleUpdate])
-> (UpdateRule -> [RuleUpdate] -> UpdateRule)
-> Lens UpdateRule UpdateRule [RuleUpdate] [RuleUpdate]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRule' {[RuleUpdate]
updates :: [RuleUpdate]
$sel:updates:UpdateRule' :: UpdateRule -> [RuleUpdate]
updates} -> [RuleUpdate]
updates) (\s :: UpdateRule
s@UpdateRule' {} [RuleUpdate]
a -> UpdateRule
s {$sel:updates:UpdateRule' :: [RuleUpdate]
updates = [RuleUpdate]
a} :: UpdateRule) (([RuleUpdate] -> f [RuleUpdate]) -> UpdateRule -> f UpdateRule)
-> (([RuleUpdate] -> f [RuleUpdate])
-> [RuleUpdate] -> f [RuleUpdate])
-> ([RuleUpdate] -> f [RuleUpdate])
-> UpdateRule
-> f UpdateRule
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
instance Core.AWSRequest UpdateRule where
type AWSResponse UpdateRule = UpdateRuleResponse
request :: UpdateRule -> Request UpdateRule
request = Service -> UpdateRule -> Request UpdateRule
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy UpdateRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateRule)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse UpdateRule))
-> Logger
-> Service
-> Proxy UpdateRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateRule)))
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 -> UpdateRuleResponse
UpdateRuleResponse'
(Maybe Text -> Int -> UpdateRuleResponse)
-> Either String (Maybe Text)
-> Either String (Int -> UpdateRuleResponse)
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 -> UpdateRuleResponse)
-> Either String Int -> Either String UpdateRuleResponse
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 UpdateRule
instance Prelude.NFData UpdateRule
instance Core.ToHeaders UpdateRule where
toHeaders :: UpdateRule -> ResponseHeaders
toHeaders =
ResponseHeaders -> UpdateRule -> 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.UpdateRule" ::
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 UpdateRule where
toJSON :: UpdateRule -> Value
toJSON UpdateRule' {[RuleUpdate]
Text
updates :: [RuleUpdate]
changeToken :: Text
ruleId :: Text
$sel:updates:UpdateRule' :: UpdateRule -> [RuleUpdate]
$sel:changeToken:UpdateRule' :: UpdateRule -> Text
$sel:ruleId:UpdateRule' :: UpdateRule -> 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)
]
)
instance Core.ToPath UpdateRule where
toPath :: UpdateRule -> ByteString
toPath = ByteString -> UpdateRule -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery UpdateRule where
toQuery :: UpdateRule -> QueryString
toQuery = QueryString -> UpdateRule -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data UpdateRuleResponse = UpdateRuleResponse'
{
UpdateRuleResponse -> Maybe Text
changeToken :: Prelude.Maybe Prelude.Text,
UpdateRuleResponse -> Int
httpStatus :: Prelude.Int
}
deriving (UpdateRuleResponse -> UpdateRuleResponse -> Bool
(UpdateRuleResponse -> UpdateRuleResponse -> Bool)
-> (UpdateRuleResponse -> UpdateRuleResponse -> Bool)
-> Eq UpdateRuleResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateRuleResponse -> UpdateRuleResponse -> Bool
$c/= :: UpdateRuleResponse -> UpdateRuleResponse -> Bool
== :: UpdateRuleResponse -> UpdateRuleResponse -> Bool
$c== :: UpdateRuleResponse -> UpdateRuleResponse -> Bool
Prelude.Eq, ReadPrec [UpdateRuleResponse]
ReadPrec UpdateRuleResponse
Int -> ReadS UpdateRuleResponse
ReadS [UpdateRuleResponse]
(Int -> ReadS UpdateRuleResponse)
-> ReadS [UpdateRuleResponse]
-> ReadPrec UpdateRuleResponse
-> ReadPrec [UpdateRuleResponse]
-> Read UpdateRuleResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateRuleResponse]
$creadListPrec :: ReadPrec [UpdateRuleResponse]
readPrec :: ReadPrec UpdateRuleResponse
$creadPrec :: ReadPrec UpdateRuleResponse
readList :: ReadS [UpdateRuleResponse]
$creadList :: ReadS [UpdateRuleResponse]
readsPrec :: Int -> ReadS UpdateRuleResponse
$creadsPrec :: Int -> ReadS UpdateRuleResponse
Prelude.Read, Int -> UpdateRuleResponse -> ShowS
[UpdateRuleResponse] -> ShowS
UpdateRuleResponse -> String
(Int -> UpdateRuleResponse -> ShowS)
-> (UpdateRuleResponse -> String)
-> ([UpdateRuleResponse] -> ShowS)
-> Show UpdateRuleResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateRuleResponse] -> ShowS
$cshowList :: [UpdateRuleResponse] -> ShowS
show :: UpdateRuleResponse -> String
$cshow :: UpdateRuleResponse -> String
showsPrec :: Int -> UpdateRuleResponse -> ShowS
$cshowsPrec :: Int -> UpdateRuleResponse -> ShowS
Prelude.Show, (forall x. UpdateRuleResponse -> Rep UpdateRuleResponse x)
-> (forall x. Rep UpdateRuleResponse x -> UpdateRuleResponse)
-> Generic UpdateRuleResponse
forall x. Rep UpdateRuleResponse x -> UpdateRuleResponse
forall x. UpdateRuleResponse -> Rep UpdateRuleResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateRuleResponse x -> UpdateRuleResponse
$cfrom :: forall x. UpdateRuleResponse -> Rep UpdateRuleResponse x
Prelude.Generic)
newUpdateRuleResponse ::
Prelude.Int ->
UpdateRuleResponse
newUpdateRuleResponse :: Int -> UpdateRuleResponse
newUpdateRuleResponse Int
pHttpStatus_ =
UpdateRuleResponse' :: Maybe Text -> Int -> UpdateRuleResponse
UpdateRuleResponse'
{ $sel:changeToken:UpdateRuleResponse' :: Maybe Text
changeToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:UpdateRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
}
updateRuleResponse_changeToken :: Lens.Lens' UpdateRuleResponse (Prelude.Maybe Prelude.Text)
updateRuleResponse_changeToken :: (Maybe Text -> f (Maybe Text))
-> UpdateRuleResponse -> f UpdateRuleResponse
updateRuleResponse_changeToken = (UpdateRuleResponse -> Maybe Text)
-> (UpdateRuleResponse -> Maybe Text -> UpdateRuleResponse)
-> Lens
UpdateRuleResponse UpdateRuleResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRuleResponse' {Maybe Text
changeToken :: Maybe Text
$sel:changeToken:UpdateRuleResponse' :: UpdateRuleResponse -> Maybe Text
changeToken} -> Maybe Text
changeToken) (\s :: UpdateRuleResponse
s@UpdateRuleResponse' {} Maybe Text
a -> UpdateRuleResponse
s {$sel:changeToken:UpdateRuleResponse' :: Maybe Text
changeToken = Maybe Text
a} :: UpdateRuleResponse)
updateRuleResponse_httpStatus :: Lens.Lens' UpdateRuleResponse Prelude.Int
updateRuleResponse_httpStatus :: (Int -> f Int) -> UpdateRuleResponse -> f UpdateRuleResponse
updateRuleResponse_httpStatus = (UpdateRuleResponse -> Int)
-> (UpdateRuleResponse -> Int -> UpdateRuleResponse)
-> Lens UpdateRuleResponse UpdateRuleResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRuleResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateRuleResponse' :: UpdateRuleResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdateRuleResponse
s@UpdateRuleResponse' {} Int
a -> UpdateRuleResponse
s {$sel:httpStatus:UpdateRuleResponse' :: Int
httpStatus = Int
a} :: UpdateRuleResponse)
instance Prelude.NFData UpdateRuleResponse