{-# 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
{ $sel:ruleId:UpdateRule' :: Text
ruleId = Text
pRuleId_,
$sel:changeToken:UpdateRule' :: Text
changeToken = Text
pChangeToken_,
$sel:updates:UpdateRule' :: [RuleUpdate]
updates = forall a. Monoid a => a
Prelude.mempty
}
updateRule_ruleId :: Lens.Lens' UpdateRule Prelude.Text
updateRule_ruleId :: Lens' UpdateRule Text
updateRule_ruleId = 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 :: Lens' UpdateRule Text
updateRule_changeToken = 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 :: Lens' UpdateRule [RuleUpdate]
updateRule_updates = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 :: (Service -> Service) -> UpdateRule -> Request UpdateRule
request Service -> Service
overrides =
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateRule)))
response =
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe Text -> Int -> UpdateRuleResponse
UpdateRuleResponse'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ChangeToken")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable UpdateRule where
hashWithSalt :: Int -> UpdateRule -> Int
hashWithSalt Int
_salt UpdateRule' {[RuleUpdate]
Text
updates :: [RuleUpdate]
changeToken :: Text
ruleId :: Text
$sel:updates:UpdateRule' :: UpdateRule -> [RuleUpdate]
$sel:changeToken:UpdateRule' :: UpdateRule -> Text
$sel:ruleId:UpdateRule' :: UpdateRule -> Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
ruleId
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
changeToken
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [RuleUpdate]
updates
instance Prelude.NFData UpdateRule where
rnf :: UpdateRule -> ()
rnf UpdateRule' {[RuleUpdate]
Text
updates :: [RuleUpdate]
changeToken :: Text
ruleId :: Text
$sel:updates:UpdateRule' :: UpdateRule -> [RuleUpdate]
$sel:changeToken:UpdateRule' :: UpdateRule -> Text
$sel:ruleId:UpdateRule' :: UpdateRule -> Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Text
ruleId
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
changeToken
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [RuleUpdate]
updates
instance Data.ToHeaders UpdateRule where
toHeaders :: UpdateRule -> ResponseHeaders
toHeaders =
forall a b. a -> b -> a
Prelude.const
( forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSWAF_Regional_20161128.UpdateRule" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.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
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ forall a. a -> Maybe a
Prelude.Just (Key
"RuleId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
ruleId),
forall a. a -> Maybe a
Prelude.Just (Key
"ChangeToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
changeToken),
forall a. a -> Maybe a
Prelude.Just (Key
"Updates" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [RuleUpdate]
updates)
]
)
instance Data.ToPath UpdateRule where
toPath :: UpdateRule -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery UpdateRule where
toQuery :: UpdateRule -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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. 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'
{ $sel:changeToken:UpdateRuleResponse' :: Maybe Text
changeToken = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:UpdateRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
}
updateRuleResponse_changeToken :: Lens.Lens' UpdateRuleResponse (Prelude.Maybe Prelude.Text)
updateRuleResponse_changeToken :: Lens' UpdateRuleResponse (Maybe Text)
updateRuleResponse_changeToken = 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 :: Lens' UpdateRuleResponse Int
updateRuleResponse_httpStatus = 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 where
rnf :: UpdateRuleResponse -> ()
rnf UpdateRuleResponse' {Int
Maybe Text
httpStatus :: Int
changeToken :: Maybe Text
$sel:httpStatus:UpdateRuleResponse' :: UpdateRuleResponse -> Int
$sel:changeToken:UpdateRuleResponse' :: UpdateRuleResponse -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
changeToken
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus