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