{-# 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.GetRateBasedRule
(
GetRateBasedRule (..),
newGetRateBasedRule,
getRateBasedRule_ruleId,
GetRateBasedRuleResponse (..),
newGetRateBasedRuleResponse,
getRateBasedRuleResponse_rule,
getRateBasedRuleResponse_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 GetRateBasedRule = GetRateBasedRule'
{
GetRateBasedRule -> Text
ruleId :: Prelude.Text
}
deriving (GetRateBasedRule -> GetRateBasedRule -> Bool
(GetRateBasedRule -> GetRateBasedRule -> Bool)
-> (GetRateBasedRule -> GetRateBasedRule -> Bool)
-> Eq GetRateBasedRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRateBasedRule -> GetRateBasedRule -> Bool
$c/= :: GetRateBasedRule -> GetRateBasedRule -> Bool
== :: GetRateBasedRule -> GetRateBasedRule -> Bool
$c== :: GetRateBasedRule -> GetRateBasedRule -> Bool
Prelude.Eq, ReadPrec [GetRateBasedRule]
ReadPrec GetRateBasedRule
Int -> ReadS GetRateBasedRule
ReadS [GetRateBasedRule]
(Int -> ReadS GetRateBasedRule)
-> ReadS [GetRateBasedRule]
-> ReadPrec GetRateBasedRule
-> ReadPrec [GetRateBasedRule]
-> Read GetRateBasedRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRateBasedRule]
$creadListPrec :: ReadPrec [GetRateBasedRule]
readPrec :: ReadPrec GetRateBasedRule
$creadPrec :: ReadPrec GetRateBasedRule
readList :: ReadS [GetRateBasedRule]
$creadList :: ReadS [GetRateBasedRule]
readsPrec :: Int -> ReadS GetRateBasedRule
$creadsPrec :: Int -> ReadS GetRateBasedRule
Prelude.Read, Int -> GetRateBasedRule -> ShowS
[GetRateBasedRule] -> ShowS
GetRateBasedRule -> String
(Int -> GetRateBasedRule -> ShowS)
-> (GetRateBasedRule -> String)
-> ([GetRateBasedRule] -> ShowS)
-> Show GetRateBasedRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRateBasedRule] -> ShowS
$cshowList :: [GetRateBasedRule] -> ShowS
show :: GetRateBasedRule -> String
$cshow :: GetRateBasedRule -> String
showsPrec :: Int -> GetRateBasedRule -> ShowS
$cshowsPrec :: Int -> GetRateBasedRule -> ShowS
Prelude.Show, (forall x. GetRateBasedRule -> Rep GetRateBasedRule x)
-> (forall x. Rep GetRateBasedRule x -> GetRateBasedRule)
-> Generic GetRateBasedRule
forall x. Rep GetRateBasedRule x -> GetRateBasedRule
forall x. GetRateBasedRule -> Rep GetRateBasedRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetRateBasedRule x -> GetRateBasedRule
$cfrom :: forall x. GetRateBasedRule -> Rep GetRateBasedRule x
Prelude.Generic)
newGetRateBasedRule ::
Prelude.Text ->
GetRateBasedRule
newGetRateBasedRule :: Text -> GetRateBasedRule
newGetRateBasedRule Text
pRuleId_ =
GetRateBasedRule' :: Text -> GetRateBasedRule
GetRateBasedRule' {$sel:ruleId:GetRateBasedRule' :: Text
ruleId = Text
pRuleId_}
getRateBasedRule_ruleId :: Lens.Lens' GetRateBasedRule Prelude.Text
getRateBasedRule_ruleId :: (Text -> f Text) -> GetRateBasedRule -> f GetRateBasedRule
getRateBasedRule_ruleId = (GetRateBasedRule -> Text)
-> (GetRateBasedRule -> Text -> GetRateBasedRule)
-> Lens GetRateBasedRule GetRateBasedRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRateBasedRule' {Text
ruleId :: Text
$sel:ruleId:GetRateBasedRule' :: GetRateBasedRule -> Text
ruleId} -> Text
ruleId) (\s :: GetRateBasedRule
s@GetRateBasedRule' {} Text
a -> GetRateBasedRule
s {$sel:ruleId:GetRateBasedRule' :: Text
ruleId = Text
a} :: GetRateBasedRule)
instance Core.AWSRequest GetRateBasedRule where
type
AWSResponse GetRateBasedRule =
GetRateBasedRuleResponse
request :: GetRateBasedRule -> Request GetRateBasedRule
request = Service -> GetRateBasedRule -> Request GetRateBasedRule
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy GetRateBasedRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetRateBasedRule)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetRateBasedRule))
-> Logger
-> Service
-> Proxy GetRateBasedRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetRateBasedRule)))
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 RateBasedRule -> Int -> GetRateBasedRuleResponse
GetRateBasedRuleResponse'
(Maybe RateBasedRule -> Int -> GetRateBasedRuleResponse)
-> Either String (Maybe RateBasedRule)
-> Either String (Int -> GetRateBasedRuleResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe RateBasedRule)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Rule")
Either String (Int -> GetRateBasedRuleResponse)
-> Either String Int -> Either String GetRateBasedRuleResponse
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 GetRateBasedRule
instance Prelude.NFData GetRateBasedRule
instance Core.ToHeaders GetRateBasedRule where
toHeaders :: GetRateBasedRule -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetRateBasedRule -> 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.GetRateBasedRule" ::
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 GetRateBasedRule where
toJSON :: GetRateBasedRule -> Value
toJSON GetRateBasedRule' {Text
ruleId :: Text
$sel:ruleId:GetRateBasedRule' :: GetRateBasedRule -> 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)]
)
instance Core.ToPath GetRateBasedRule where
toPath :: GetRateBasedRule -> ByteString
toPath = ByteString -> GetRateBasedRule -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery GetRateBasedRule where
toQuery :: GetRateBasedRule -> QueryString
toQuery = QueryString -> GetRateBasedRule -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GetRateBasedRuleResponse = GetRateBasedRuleResponse'
{
GetRateBasedRuleResponse -> Maybe RateBasedRule
rule :: Prelude.Maybe RateBasedRule,
GetRateBasedRuleResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetRateBasedRuleResponse -> GetRateBasedRuleResponse -> Bool
(GetRateBasedRuleResponse -> GetRateBasedRuleResponse -> Bool)
-> (GetRateBasedRuleResponse -> GetRateBasedRuleResponse -> Bool)
-> Eq GetRateBasedRuleResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRateBasedRuleResponse -> GetRateBasedRuleResponse -> Bool
$c/= :: GetRateBasedRuleResponse -> GetRateBasedRuleResponse -> Bool
== :: GetRateBasedRuleResponse -> GetRateBasedRuleResponse -> Bool
$c== :: GetRateBasedRuleResponse -> GetRateBasedRuleResponse -> Bool
Prelude.Eq, ReadPrec [GetRateBasedRuleResponse]
ReadPrec GetRateBasedRuleResponse
Int -> ReadS GetRateBasedRuleResponse
ReadS [GetRateBasedRuleResponse]
(Int -> ReadS GetRateBasedRuleResponse)
-> ReadS [GetRateBasedRuleResponse]
-> ReadPrec GetRateBasedRuleResponse
-> ReadPrec [GetRateBasedRuleResponse]
-> Read GetRateBasedRuleResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRateBasedRuleResponse]
$creadListPrec :: ReadPrec [GetRateBasedRuleResponse]
readPrec :: ReadPrec GetRateBasedRuleResponse
$creadPrec :: ReadPrec GetRateBasedRuleResponse
readList :: ReadS [GetRateBasedRuleResponse]
$creadList :: ReadS [GetRateBasedRuleResponse]
readsPrec :: Int -> ReadS GetRateBasedRuleResponse
$creadsPrec :: Int -> ReadS GetRateBasedRuleResponse
Prelude.Read, Int -> GetRateBasedRuleResponse -> ShowS
[GetRateBasedRuleResponse] -> ShowS
GetRateBasedRuleResponse -> String
(Int -> GetRateBasedRuleResponse -> ShowS)
-> (GetRateBasedRuleResponse -> String)
-> ([GetRateBasedRuleResponse] -> ShowS)
-> Show GetRateBasedRuleResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRateBasedRuleResponse] -> ShowS
$cshowList :: [GetRateBasedRuleResponse] -> ShowS
show :: GetRateBasedRuleResponse -> String
$cshow :: GetRateBasedRuleResponse -> String
showsPrec :: Int -> GetRateBasedRuleResponse -> ShowS
$cshowsPrec :: Int -> GetRateBasedRuleResponse -> ShowS
Prelude.Show, (forall x.
GetRateBasedRuleResponse -> Rep GetRateBasedRuleResponse x)
-> (forall x.
Rep GetRateBasedRuleResponse x -> GetRateBasedRuleResponse)
-> Generic GetRateBasedRuleResponse
forall x.
Rep GetRateBasedRuleResponse x -> GetRateBasedRuleResponse
forall x.
GetRateBasedRuleResponse -> Rep GetRateBasedRuleResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetRateBasedRuleResponse x -> GetRateBasedRuleResponse
$cfrom :: forall x.
GetRateBasedRuleResponse -> Rep GetRateBasedRuleResponse x
Prelude.Generic)
newGetRateBasedRuleResponse ::
Prelude.Int ->
GetRateBasedRuleResponse
newGetRateBasedRuleResponse :: Int -> GetRateBasedRuleResponse
newGetRateBasedRuleResponse Int
pHttpStatus_ =
GetRateBasedRuleResponse' :: Maybe RateBasedRule -> Int -> GetRateBasedRuleResponse
GetRateBasedRuleResponse'
{ $sel:rule:GetRateBasedRuleResponse' :: Maybe RateBasedRule
rule = Maybe RateBasedRule
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetRateBasedRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getRateBasedRuleResponse_rule :: Lens.Lens' GetRateBasedRuleResponse (Prelude.Maybe RateBasedRule)
getRateBasedRuleResponse_rule :: (Maybe RateBasedRule -> f (Maybe RateBasedRule))
-> GetRateBasedRuleResponse -> f GetRateBasedRuleResponse
getRateBasedRuleResponse_rule = (GetRateBasedRuleResponse -> Maybe RateBasedRule)
-> (GetRateBasedRuleResponse
-> Maybe RateBasedRule -> GetRateBasedRuleResponse)
-> Lens
GetRateBasedRuleResponse
GetRateBasedRuleResponse
(Maybe RateBasedRule)
(Maybe RateBasedRule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRateBasedRuleResponse' {Maybe RateBasedRule
rule :: Maybe RateBasedRule
$sel:rule:GetRateBasedRuleResponse' :: GetRateBasedRuleResponse -> Maybe RateBasedRule
rule} -> Maybe RateBasedRule
rule) (\s :: GetRateBasedRuleResponse
s@GetRateBasedRuleResponse' {} Maybe RateBasedRule
a -> GetRateBasedRuleResponse
s {$sel:rule:GetRateBasedRuleResponse' :: Maybe RateBasedRule
rule = Maybe RateBasedRule
a} :: GetRateBasedRuleResponse)
getRateBasedRuleResponse_httpStatus :: Lens.Lens' GetRateBasedRuleResponse Prelude.Int
getRateBasedRuleResponse_httpStatus :: (Int -> f Int)
-> GetRateBasedRuleResponse -> f GetRateBasedRuleResponse
getRateBasedRuleResponse_httpStatus = (GetRateBasedRuleResponse -> Int)
-> (GetRateBasedRuleResponse -> Int -> GetRateBasedRuleResponse)
-> Lens GetRateBasedRuleResponse GetRateBasedRuleResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRateBasedRuleResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetRateBasedRuleResponse' :: GetRateBasedRuleResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetRateBasedRuleResponse
s@GetRateBasedRuleResponse' {} Int
a -> GetRateBasedRuleResponse
s {$sel:httpStatus:GetRateBasedRuleResponse' :: Int
httpStatus = Int
a} :: GetRateBasedRuleResponse)
instance Prelude.NFData GetRateBasedRuleResponse