{-# 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.GetRule
(
GetRule (..),
newGetRule,
getRule_ruleId,
GetRuleResponse (..),
newGetRuleResponse,
getRuleResponse_rule,
getRuleResponse_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.WAF.Types
data GetRule = GetRule'
{
GetRule -> Text
ruleId :: Prelude.Text
}
deriving (GetRule -> GetRule -> Bool
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]
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
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. 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' {$sel:ruleId:GetRule' :: Text
ruleId = Text
pRuleId_}
getRule_ruleId :: Lens.Lens' GetRule Prelude.Text
getRule_ruleId :: Lens' GetRule Text
getRule_ruleId = 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 :: (Service -> Service) -> GetRule -> Request GetRule
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 GetRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetRule)))
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 Rule -> Int -> GetRuleResponse
GetRuleResponse'
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
"Rule")
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 GetRule where
hashWithSalt :: Int -> GetRule -> Int
hashWithSalt Int
_salt GetRule' {Text
ruleId :: Text
$sel:ruleId:GetRule' :: GetRule -> Text
..} =
Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
ruleId
instance Prelude.NFData GetRule where
rnf :: GetRule -> ()
rnf GetRule' {Text
ruleId :: Text
$sel:ruleId:GetRule' :: GetRule -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
ruleId
instance Data.ToHeaders GetRule where
toHeaders :: GetRule -> 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_20150824.GetRule" :: 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 GetRule where
toJSON :: GetRule -> Value
toJSON GetRule' {Text
ruleId :: Text
$sel:ruleId:GetRule' :: GetRule -> 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)]
)
instance Data.ToPath GetRule where
toPath :: GetRule -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery GetRule where
toQuery :: GetRule -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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. 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'
{ $sel:rule:GetRuleResponse' :: Maybe Rule
rule = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getRuleResponse_rule :: Lens.Lens' GetRuleResponse (Prelude.Maybe Rule)
getRuleResponse_rule :: Lens' GetRuleResponse (Maybe Rule)
getRuleResponse_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 :: Lens' GetRuleResponse Int
getRuleResponse_httpStatus = 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 where
rnf :: GetRuleResponse -> ()
rnf GetRuleResponse' {Int
Maybe Rule
httpStatus :: Int
rule :: Maybe Rule
$sel:httpStatus:GetRuleResponse' :: GetRuleResponse -> Int
$sel:rule:GetRuleResponse' :: GetRuleResponse -> Maybe Rule
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Rule
rule
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus