{-# 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.UpdateRuleGroup
(
UpdateRuleGroup (..),
newUpdateRuleGroup,
updateRuleGroup_ruleGroupId,
updateRuleGroup_updates,
updateRuleGroup_changeToken,
UpdateRuleGroupResponse (..),
newUpdateRuleGroupResponse,
updateRuleGroupResponse_changeToken,
updateRuleGroupResponse_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 UpdateRuleGroup = UpdateRuleGroup'
{
UpdateRuleGroup -> Text
ruleGroupId :: Prelude.Text,
UpdateRuleGroup -> NonEmpty RuleGroupUpdate
updates :: Prelude.NonEmpty RuleGroupUpdate,
UpdateRuleGroup -> Text
changeToken :: Prelude.Text
}
deriving (UpdateRuleGroup -> UpdateRuleGroup -> Bool
(UpdateRuleGroup -> UpdateRuleGroup -> Bool)
-> (UpdateRuleGroup -> UpdateRuleGroup -> Bool)
-> Eq UpdateRuleGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateRuleGroup -> UpdateRuleGroup -> Bool
$c/= :: UpdateRuleGroup -> UpdateRuleGroup -> Bool
== :: UpdateRuleGroup -> UpdateRuleGroup -> Bool
$c== :: UpdateRuleGroup -> UpdateRuleGroup -> Bool
Prelude.Eq, ReadPrec [UpdateRuleGroup]
ReadPrec UpdateRuleGroup
Int -> ReadS UpdateRuleGroup
ReadS [UpdateRuleGroup]
(Int -> ReadS UpdateRuleGroup)
-> ReadS [UpdateRuleGroup]
-> ReadPrec UpdateRuleGroup
-> ReadPrec [UpdateRuleGroup]
-> Read UpdateRuleGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateRuleGroup]
$creadListPrec :: ReadPrec [UpdateRuleGroup]
readPrec :: ReadPrec UpdateRuleGroup
$creadPrec :: ReadPrec UpdateRuleGroup
readList :: ReadS [UpdateRuleGroup]
$creadList :: ReadS [UpdateRuleGroup]
readsPrec :: Int -> ReadS UpdateRuleGroup
$creadsPrec :: Int -> ReadS UpdateRuleGroup
Prelude.Read, Int -> UpdateRuleGroup -> ShowS
[UpdateRuleGroup] -> ShowS
UpdateRuleGroup -> String
(Int -> UpdateRuleGroup -> ShowS)
-> (UpdateRuleGroup -> String)
-> ([UpdateRuleGroup] -> ShowS)
-> Show UpdateRuleGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateRuleGroup] -> ShowS
$cshowList :: [UpdateRuleGroup] -> ShowS
show :: UpdateRuleGroup -> String
$cshow :: UpdateRuleGroup -> String
showsPrec :: Int -> UpdateRuleGroup -> ShowS
$cshowsPrec :: Int -> UpdateRuleGroup -> ShowS
Prelude.Show, (forall x. UpdateRuleGroup -> Rep UpdateRuleGroup x)
-> (forall x. Rep UpdateRuleGroup x -> UpdateRuleGroup)
-> Generic UpdateRuleGroup
forall x. Rep UpdateRuleGroup x -> UpdateRuleGroup
forall x. UpdateRuleGroup -> Rep UpdateRuleGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateRuleGroup x -> UpdateRuleGroup
$cfrom :: forall x. UpdateRuleGroup -> Rep UpdateRuleGroup x
Prelude.Generic)
newUpdateRuleGroup ::
Prelude.Text ->
Prelude.NonEmpty RuleGroupUpdate ->
Prelude.Text ->
UpdateRuleGroup
newUpdateRuleGroup :: Text -> NonEmpty RuleGroupUpdate -> Text -> UpdateRuleGroup
newUpdateRuleGroup
Text
pRuleGroupId_
NonEmpty RuleGroupUpdate
pUpdates_
Text
pChangeToken_ =
UpdateRuleGroup' :: Text -> NonEmpty RuleGroupUpdate -> Text -> UpdateRuleGroup
UpdateRuleGroup'
{ $sel:ruleGroupId:UpdateRuleGroup' :: Text
ruleGroupId = Text
pRuleGroupId_,
$sel:updates:UpdateRuleGroup' :: NonEmpty RuleGroupUpdate
updates = Tagged
(NonEmpty RuleGroupUpdate) (Identity (NonEmpty RuleGroupUpdate))
-> Tagged
(NonEmpty RuleGroupUpdate) (Identity (NonEmpty RuleGroupUpdate))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
(NonEmpty RuleGroupUpdate) (Identity (NonEmpty RuleGroupUpdate))
-> Tagged
(NonEmpty RuleGroupUpdate) (Identity (NonEmpty RuleGroupUpdate)))
-> NonEmpty RuleGroupUpdate -> NonEmpty RuleGroupUpdate
forall t b. AReview t b -> b -> t
Lens.# NonEmpty RuleGroupUpdate
pUpdates_,
$sel:changeToken:UpdateRuleGroup' :: Text
changeToken = Text
pChangeToken_
}
updateRuleGroup_ruleGroupId :: Lens.Lens' UpdateRuleGroup Prelude.Text
updateRuleGroup_ruleGroupId :: (Text -> f Text) -> UpdateRuleGroup -> f UpdateRuleGroup
updateRuleGroup_ruleGroupId = (UpdateRuleGroup -> Text)
-> (UpdateRuleGroup -> Text -> UpdateRuleGroup)
-> Lens UpdateRuleGroup UpdateRuleGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRuleGroup' {Text
ruleGroupId :: Text
$sel:ruleGroupId:UpdateRuleGroup' :: UpdateRuleGroup -> Text
ruleGroupId} -> Text
ruleGroupId) (\s :: UpdateRuleGroup
s@UpdateRuleGroup' {} Text
a -> UpdateRuleGroup
s {$sel:ruleGroupId:UpdateRuleGroup' :: Text
ruleGroupId = Text
a} :: UpdateRuleGroup)
updateRuleGroup_updates :: Lens.Lens' UpdateRuleGroup (Prelude.NonEmpty RuleGroupUpdate)
updateRuleGroup_updates :: (NonEmpty RuleGroupUpdate -> f (NonEmpty RuleGroupUpdate))
-> UpdateRuleGroup -> f UpdateRuleGroup
updateRuleGroup_updates = (UpdateRuleGroup -> NonEmpty RuleGroupUpdate)
-> (UpdateRuleGroup -> NonEmpty RuleGroupUpdate -> UpdateRuleGroup)
-> Lens
UpdateRuleGroup
UpdateRuleGroup
(NonEmpty RuleGroupUpdate)
(NonEmpty RuleGroupUpdate)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRuleGroup' {NonEmpty RuleGroupUpdate
updates :: NonEmpty RuleGroupUpdate
$sel:updates:UpdateRuleGroup' :: UpdateRuleGroup -> NonEmpty RuleGroupUpdate
updates} -> NonEmpty RuleGroupUpdate
updates) (\s :: UpdateRuleGroup
s@UpdateRuleGroup' {} NonEmpty RuleGroupUpdate
a -> UpdateRuleGroup
s {$sel:updates:UpdateRuleGroup' :: NonEmpty RuleGroupUpdate
updates = NonEmpty RuleGroupUpdate
a} :: UpdateRuleGroup) ((NonEmpty RuleGroupUpdate -> f (NonEmpty RuleGroupUpdate))
-> UpdateRuleGroup -> f UpdateRuleGroup)
-> ((NonEmpty RuleGroupUpdate -> f (NonEmpty RuleGroupUpdate))
-> NonEmpty RuleGroupUpdate -> f (NonEmpty RuleGroupUpdate))
-> (NonEmpty RuleGroupUpdate -> f (NonEmpty RuleGroupUpdate))
-> UpdateRuleGroup
-> f UpdateRuleGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty RuleGroupUpdate -> f (NonEmpty RuleGroupUpdate))
-> NonEmpty RuleGroupUpdate -> f (NonEmpty RuleGroupUpdate)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
updateRuleGroup_changeToken :: Lens.Lens' UpdateRuleGroup Prelude.Text
updateRuleGroup_changeToken :: (Text -> f Text) -> UpdateRuleGroup -> f UpdateRuleGroup
updateRuleGroup_changeToken = (UpdateRuleGroup -> Text)
-> (UpdateRuleGroup -> Text -> UpdateRuleGroup)
-> Lens UpdateRuleGroup UpdateRuleGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRuleGroup' {Text
changeToken :: Text
$sel:changeToken:UpdateRuleGroup' :: UpdateRuleGroup -> Text
changeToken} -> Text
changeToken) (\s :: UpdateRuleGroup
s@UpdateRuleGroup' {} Text
a -> UpdateRuleGroup
s {$sel:changeToken:UpdateRuleGroup' :: Text
changeToken = Text
a} :: UpdateRuleGroup)
instance Core.AWSRequest UpdateRuleGroup where
type
AWSResponse UpdateRuleGroup =
UpdateRuleGroupResponse
request :: UpdateRuleGroup -> Request UpdateRuleGroup
request = Service -> UpdateRuleGroup -> Request UpdateRuleGroup
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy UpdateRuleGroup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateRuleGroup)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse UpdateRuleGroup))
-> Logger
-> Service
-> Proxy UpdateRuleGroup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateRuleGroup)))
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 -> UpdateRuleGroupResponse
UpdateRuleGroupResponse'
(Maybe Text -> Int -> UpdateRuleGroupResponse)
-> Either String (Maybe Text)
-> Either String (Int -> UpdateRuleGroupResponse)
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 -> UpdateRuleGroupResponse)
-> Either String Int -> Either String UpdateRuleGroupResponse
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 UpdateRuleGroup
instance Prelude.NFData UpdateRuleGroup
instance Core.ToHeaders UpdateRuleGroup where
toHeaders :: UpdateRuleGroup -> ResponseHeaders
toHeaders =
ResponseHeaders -> UpdateRuleGroup -> 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.UpdateRuleGroup" ::
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 UpdateRuleGroup where
toJSON :: UpdateRuleGroup -> Value
toJSON UpdateRuleGroup' {NonEmpty RuleGroupUpdate
Text
changeToken :: Text
updates :: NonEmpty RuleGroupUpdate
ruleGroupId :: Text
$sel:changeToken:UpdateRuleGroup' :: UpdateRuleGroup -> Text
$sel:updates:UpdateRuleGroup' :: UpdateRuleGroup -> NonEmpty RuleGroupUpdate
$sel:ruleGroupId:UpdateRuleGroup' :: UpdateRuleGroup -> 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
"RuleGroupId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
ruleGroupId),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Updates" Text -> NonEmpty RuleGroupUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty RuleGroupUpdate
updates),
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 UpdateRuleGroup where
toPath :: UpdateRuleGroup -> ByteString
toPath = ByteString -> UpdateRuleGroup -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery UpdateRuleGroup where
toQuery :: UpdateRuleGroup -> QueryString
toQuery = QueryString -> UpdateRuleGroup -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data UpdateRuleGroupResponse = UpdateRuleGroupResponse'
{
UpdateRuleGroupResponse -> Maybe Text
changeToken :: Prelude.Maybe Prelude.Text,
UpdateRuleGroupResponse -> Int
httpStatus :: Prelude.Int
}
deriving (UpdateRuleGroupResponse -> UpdateRuleGroupResponse -> Bool
(UpdateRuleGroupResponse -> UpdateRuleGroupResponse -> Bool)
-> (UpdateRuleGroupResponse -> UpdateRuleGroupResponse -> Bool)
-> Eq UpdateRuleGroupResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateRuleGroupResponse -> UpdateRuleGroupResponse -> Bool
$c/= :: UpdateRuleGroupResponse -> UpdateRuleGroupResponse -> Bool
== :: UpdateRuleGroupResponse -> UpdateRuleGroupResponse -> Bool
$c== :: UpdateRuleGroupResponse -> UpdateRuleGroupResponse -> Bool
Prelude.Eq, ReadPrec [UpdateRuleGroupResponse]
ReadPrec UpdateRuleGroupResponse
Int -> ReadS UpdateRuleGroupResponse
ReadS [UpdateRuleGroupResponse]
(Int -> ReadS UpdateRuleGroupResponse)
-> ReadS [UpdateRuleGroupResponse]
-> ReadPrec UpdateRuleGroupResponse
-> ReadPrec [UpdateRuleGroupResponse]
-> Read UpdateRuleGroupResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateRuleGroupResponse]
$creadListPrec :: ReadPrec [UpdateRuleGroupResponse]
readPrec :: ReadPrec UpdateRuleGroupResponse
$creadPrec :: ReadPrec UpdateRuleGroupResponse
readList :: ReadS [UpdateRuleGroupResponse]
$creadList :: ReadS [UpdateRuleGroupResponse]
readsPrec :: Int -> ReadS UpdateRuleGroupResponse
$creadsPrec :: Int -> ReadS UpdateRuleGroupResponse
Prelude.Read, Int -> UpdateRuleGroupResponse -> ShowS
[UpdateRuleGroupResponse] -> ShowS
UpdateRuleGroupResponse -> String
(Int -> UpdateRuleGroupResponse -> ShowS)
-> (UpdateRuleGroupResponse -> String)
-> ([UpdateRuleGroupResponse] -> ShowS)
-> Show UpdateRuleGroupResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateRuleGroupResponse] -> ShowS
$cshowList :: [UpdateRuleGroupResponse] -> ShowS
show :: UpdateRuleGroupResponse -> String
$cshow :: UpdateRuleGroupResponse -> String
showsPrec :: Int -> UpdateRuleGroupResponse -> ShowS
$cshowsPrec :: Int -> UpdateRuleGroupResponse -> ShowS
Prelude.Show, (forall x.
UpdateRuleGroupResponse -> Rep UpdateRuleGroupResponse x)
-> (forall x.
Rep UpdateRuleGroupResponse x -> UpdateRuleGroupResponse)
-> Generic UpdateRuleGroupResponse
forall x. Rep UpdateRuleGroupResponse x -> UpdateRuleGroupResponse
forall x. UpdateRuleGroupResponse -> Rep UpdateRuleGroupResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateRuleGroupResponse x -> UpdateRuleGroupResponse
$cfrom :: forall x. UpdateRuleGroupResponse -> Rep UpdateRuleGroupResponse x
Prelude.Generic)
newUpdateRuleGroupResponse ::
Prelude.Int ->
UpdateRuleGroupResponse
newUpdateRuleGroupResponse :: Int -> UpdateRuleGroupResponse
newUpdateRuleGroupResponse Int
pHttpStatus_ =
UpdateRuleGroupResponse' :: Maybe Text -> Int -> UpdateRuleGroupResponse
UpdateRuleGroupResponse'
{ $sel:changeToken:UpdateRuleGroupResponse' :: Maybe Text
changeToken =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:UpdateRuleGroupResponse' :: Int
httpStatus = Int
pHttpStatus_
}
updateRuleGroupResponse_changeToken :: Lens.Lens' UpdateRuleGroupResponse (Prelude.Maybe Prelude.Text)
updateRuleGroupResponse_changeToken :: (Maybe Text -> f (Maybe Text))
-> UpdateRuleGroupResponse -> f UpdateRuleGroupResponse
updateRuleGroupResponse_changeToken = (UpdateRuleGroupResponse -> Maybe Text)
-> (UpdateRuleGroupResponse
-> Maybe Text -> UpdateRuleGroupResponse)
-> Lens
UpdateRuleGroupResponse
UpdateRuleGroupResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRuleGroupResponse' {Maybe Text
changeToken :: Maybe Text
$sel:changeToken:UpdateRuleGroupResponse' :: UpdateRuleGroupResponse -> Maybe Text
changeToken} -> Maybe Text
changeToken) (\s :: UpdateRuleGroupResponse
s@UpdateRuleGroupResponse' {} Maybe Text
a -> UpdateRuleGroupResponse
s {$sel:changeToken:UpdateRuleGroupResponse' :: Maybe Text
changeToken = Maybe Text
a} :: UpdateRuleGroupResponse)
updateRuleGroupResponse_httpStatus :: Lens.Lens' UpdateRuleGroupResponse Prelude.Int
updateRuleGroupResponse_httpStatus :: (Int -> f Int)
-> UpdateRuleGroupResponse -> f UpdateRuleGroupResponse
updateRuleGroupResponse_httpStatus = (UpdateRuleGroupResponse -> Int)
-> (UpdateRuleGroupResponse -> Int -> UpdateRuleGroupResponse)
-> Lens UpdateRuleGroupResponse UpdateRuleGroupResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRuleGroupResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateRuleGroupResponse' :: UpdateRuleGroupResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdateRuleGroupResponse
s@UpdateRuleGroupResponse' {} Int
a -> UpdateRuleGroupResponse
s {$sel:httpStatus:UpdateRuleGroupResponse' :: Int
httpStatus = Int
a} :: UpdateRuleGroupResponse)
instance Prelude.NFData UpdateRuleGroupResponse