{-# 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.FraudDetector.GetRules
(
GetRules (..),
newGetRules,
getRules_ruleVersion,
getRules_ruleId,
getRules_nextToken,
getRules_maxResults,
getRules_detectorId,
GetRulesResponse (..),
newGetRulesResponse,
getRulesResponse_ruleDetails,
getRulesResponse_nextToken,
getRulesResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import Amazonka.FraudDetector.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data GetRules = GetRules'
{
GetRules -> Maybe Text
ruleVersion :: Prelude.Maybe Prelude.Text,
GetRules -> Maybe Text
ruleId :: Prelude.Maybe Prelude.Text,
GetRules -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
GetRules -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
GetRules -> Text
detectorId :: Prelude.Text
}
deriving (GetRules -> GetRules -> Bool
(GetRules -> GetRules -> Bool)
-> (GetRules -> GetRules -> Bool) -> Eq GetRules
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRules -> GetRules -> Bool
$c/= :: GetRules -> GetRules -> Bool
== :: GetRules -> GetRules -> Bool
$c== :: GetRules -> GetRules -> Bool
Prelude.Eq, ReadPrec [GetRules]
ReadPrec GetRules
Int -> ReadS GetRules
ReadS [GetRules]
(Int -> ReadS GetRules)
-> ReadS [GetRules]
-> ReadPrec GetRules
-> ReadPrec [GetRules]
-> Read GetRules
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRules]
$creadListPrec :: ReadPrec [GetRules]
readPrec :: ReadPrec GetRules
$creadPrec :: ReadPrec GetRules
readList :: ReadS [GetRules]
$creadList :: ReadS [GetRules]
readsPrec :: Int -> ReadS GetRules
$creadsPrec :: Int -> ReadS GetRules
Prelude.Read, Int -> GetRules -> ShowS
[GetRules] -> ShowS
GetRules -> String
(Int -> GetRules -> ShowS)
-> (GetRules -> String) -> ([GetRules] -> ShowS) -> Show GetRules
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRules] -> ShowS
$cshowList :: [GetRules] -> ShowS
show :: GetRules -> String
$cshow :: GetRules -> String
showsPrec :: Int -> GetRules -> ShowS
$cshowsPrec :: Int -> GetRules -> ShowS
Prelude.Show, (forall x. GetRules -> Rep GetRules x)
-> (forall x. Rep GetRules x -> GetRules) -> Generic GetRules
forall x. Rep GetRules x -> GetRules
forall x. GetRules -> Rep GetRules x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetRules x -> GetRules
$cfrom :: forall x. GetRules -> Rep GetRules x
Prelude.Generic)
newGetRules ::
Prelude.Text ->
GetRules
newGetRules :: Text -> GetRules
newGetRules Text
pDetectorId_ =
GetRules' :: Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Natural -> Text -> GetRules
GetRules'
{ $sel:ruleVersion:GetRules' :: Maybe Text
ruleVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:ruleId:GetRules' :: Maybe Text
ruleId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:nextToken:GetRules' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:maxResults:GetRules' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
$sel:detectorId:GetRules' :: Text
detectorId = Text
pDetectorId_
}
getRules_ruleVersion :: Lens.Lens' GetRules (Prelude.Maybe Prelude.Text)
getRules_ruleVersion :: (Maybe Text -> f (Maybe Text)) -> GetRules -> f GetRules
getRules_ruleVersion = (GetRules -> Maybe Text)
-> (GetRules -> Maybe Text -> GetRules)
-> Lens GetRules GetRules (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRules' {Maybe Text
ruleVersion :: Maybe Text
$sel:ruleVersion:GetRules' :: GetRules -> Maybe Text
ruleVersion} -> Maybe Text
ruleVersion) (\s :: GetRules
s@GetRules' {} Maybe Text
a -> GetRules
s {$sel:ruleVersion:GetRules' :: Maybe Text
ruleVersion = Maybe Text
a} :: GetRules)
getRules_ruleId :: Lens.Lens' GetRules (Prelude.Maybe Prelude.Text)
getRules_ruleId :: (Maybe Text -> f (Maybe Text)) -> GetRules -> f GetRules
getRules_ruleId = (GetRules -> Maybe Text)
-> (GetRules -> Maybe Text -> GetRules)
-> Lens GetRules GetRules (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRules' {Maybe Text
ruleId :: Maybe Text
$sel:ruleId:GetRules' :: GetRules -> Maybe Text
ruleId} -> Maybe Text
ruleId) (\s :: GetRules
s@GetRules' {} Maybe Text
a -> GetRules
s {$sel:ruleId:GetRules' :: Maybe Text
ruleId = Maybe Text
a} :: GetRules)
getRules_nextToken :: Lens.Lens' GetRules (Prelude.Maybe Prelude.Text)
getRules_nextToken :: (Maybe Text -> f (Maybe Text)) -> GetRules -> f GetRules
getRules_nextToken = (GetRules -> Maybe Text)
-> (GetRules -> Maybe Text -> GetRules)
-> Lens GetRules GetRules (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRules' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetRules' :: GetRules -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetRules
s@GetRules' {} Maybe Text
a -> GetRules
s {$sel:nextToken:GetRules' :: Maybe Text
nextToken = Maybe Text
a} :: GetRules)
getRules_maxResults :: Lens.Lens' GetRules (Prelude.Maybe Prelude.Natural)
getRules_maxResults :: (Maybe Natural -> f (Maybe Natural)) -> GetRules -> f GetRules
getRules_maxResults = (GetRules -> Maybe Natural)
-> (GetRules -> Maybe Natural -> GetRules)
-> Lens GetRules GetRules (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRules' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:GetRules' :: GetRules -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: GetRules
s@GetRules' {} Maybe Natural
a -> GetRules
s {$sel:maxResults:GetRules' :: Maybe Natural
maxResults = Maybe Natural
a} :: GetRules)
getRules_detectorId :: Lens.Lens' GetRules Prelude.Text
getRules_detectorId :: (Text -> f Text) -> GetRules -> f GetRules
getRules_detectorId = (GetRules -> Text)
-> (GetRules -> Text -> GetRules)
-> Lens GetRules GetRules Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRules' {Text
detectorId :: Text
$sel:detectorId:GetRules' :: GetRules -> Text
detectorId} -> Text
detectorId) (\s :: GetRules
s@GetRules' {} Text
a -> GetRules
s {$sel:detectorId:GetRules' :: Text
detectorId = Text
a} :: GetRules)
instance Core.AWSRequest GetRules where
type AWSResponse GetRules = GetRulesResponse
request :: GetRules -> Request GetRules
request = Service -> GetRules -> Request GetRules
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy GetRules
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetRules)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetRules))
-> Logger
-> Service
-> Proxy GetRules
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetRules)))
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 [RuleDetail] -> Maybe Text -> Int -> GetRulesResponse
GetRulesResponse'
(Maybe [RuleDetail] -> Maybe Text -> Int -> GetRulesResponse)
-> Either String (Maybe [RuleDetail])
-> Either String (Maybe Text -> Int -> GetRulesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [RuleDetail]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ruleDetails" Either String (Maybe (Maybe [RuleDetail]))
-> Maybe [RuleDetail] -> Either String (Maybe [RuleDetail])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [RuleDetail]
forall a. Monoid a => a
Prelude.mempty)
Either String (Maybe Text -> Int -> GetRulesResponse)
-> Either String (Maybe Text)
-> Either String (Int -> GetRulesResponse)
forall (f :: * -> *) a b. Applicative f => 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
"nextToken")
Either String (Int -> GetRulesResponse)
-> Either String Int -> Either String GetRulesResponse
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 GetRules
instance Prelude.NFData GetRules
instance Core.ToHeaders GetRules where
toHeaders :: GetRules -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetRules -> 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
"AWSHawksNestServiceFacade.GetRules" ::
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 GetRules where
toJSON :: GetRules -> Value
toJSON GetRules' {Maybe Natural
Maybe Text
Text
detectorId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
ruleId :: Maybe Text
ruleVersion :: Maybe Text
$sel:detectorId:GetRules' :: GetRules -> Text
$sel:maxResults:GetRules' :: GetRules -> Maybe Natural
$sel:nextToken:GetRules' :: GetRules -> Maybe Text
$sel:ruleId:GetRules' :: GetRules -> Maybe Text
$sel:ruleVersion:GetRules' :: GetRules -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"ruleVersion" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
ruleVersion,
(Text
"ruleId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
ruleId,
(Text
"nextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
(Text
"maxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"detectorId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
detectorId)
]
)
instance Core.ToPath GetRules where
toPath :: GetRules -> ByteString
toPath = ByteString -> GetRules -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery GetRules where
toQuery :: GetRules -> QueryString
toQuery = QueryString -> GetRules -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GetRulesResponse = GetRulesResponse'
{
GetRulesResponse -> Maybe [RuleDetail]
ruleDetails :: Prelude.Maybe [RuleDetail],
GetRulesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
GetRulesResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetRulesResponse -> GetRulesResponse -> Bool
(GetRulesResponse -> GetRulesResponse -> Bool)
-> (GetRulesResponse -> GetRulesResponse -> Bool)
-> Eq GetRulesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRulesResponse -> GetRulesResponse -> Bool
$c/= :: GetRulesResponse -> GetRulesResponse -> Bool
== :: GetRulesResponse -> GetRulesResponse -> Bool
$c== :: GetRulesResponse -> GetRulesResponse -> Bool
Prelude.Eq, Int -> GetRulesResponse -> ShowS
[GetRulesResponse] -> ShowS
GetRulesResponse -> String
(Int -> GetRulesResponse -> ShowS)
-> (GetRulesResponse -> String)
-> ([GetRulesResponse] -> ShowS)
-> Show GetRulesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRulesResponse] -> ShowS
$cshowList :: [GetRulesResponse] -> ShowS
show :: GetRulesResponse -> String
$cshow :: GetRulesResponse -> String
showsPrec :: Int -> GetRulesResponse -> ShowS
$cshowsPrec :: Int -> GetRulesResponse -> ShowS
Prelude.Show, (forall x. GetRulesResponse -> Rep GetRulesResponse x)
-> (forall x. Rep GetRulesResponse x -> GetRulesResponse)
-> Generic GetRulesResponse
forall x. Rep GetRulesResponse x -> GetRulesResponse
forall x. GetRulesResponse -> Rep GetRulesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetRulesResponse x -> GetRulesResponse
$cfrom :: forall x. GetRulesResponse -> Rep GetRulesResponse x
Prelude.Generic)
newGetRulesResponse ::
Prelude.Int ->
GetRulesResponse
newGetRulesResponse :: Int -> GetRulesResponse
newGetRulesResponse Int
pHttpStatus_ =
GetRulesResponse' :: Maybe [RuleDetail] -> Maybe Text -> Int -> GetRulesResponse
GetRulesResponse'
{ $sel:ruleDetails:GetRulesResponse' :: Maybe [RuleDetail]
ruleDetails = Maybe [RuleDetail]
forall a. Maybe a
Prelude.Nothing,
$sel:nextToken:GetRulesResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetRulesResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getRulesResponse_ruleDetails :: Lens.Lens' GetRulesResponse (Prelude.Maybe [RuleDetail])
getRulesResponse_ruleDetails :: (Maybe [RuleDetail] -> f (Maybe [RuleDetail]))
-> GetRulesResponse -> f GetRulesResponse
getRulesResponse_ruleDetails = (GetRulesResponse -> Maybe [RuleDetail])
-> (GetRulesResponse -> Maybe [RuleDetail] -> GetRulesResponse)
-> Lens
GetRulesResponse
GetRulesResponse
(Maybe [RuleDetail])
(Maybe [RuleDetail])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRulesResponse' {Maybe [RuleDetail]
ruleDetails :: Maybe [RuleDetail]
$sel:ruleDetails:GetRulesResponse' :: GetRulesResponse -> Maybe [RuleDetail]
ruleDetails} -> Maybe [RuleDetail]
ruleDetails) (\s :: GetRulesResponse
s@GetRulesResponse' {} Maybe [RuleDetail]
a -> GetRulesResponse
s {$sel:ruleDetails:GetRulesResponse' :: Maybe [RuleDetail]
ruleDetails = Maybe [RuleDetail]
a} :: GetRulesResponse) ((Maybe [RuleDetail] -> f (Maybe [RuleDetail]))
-> GetRulesResponse -> f GetRulesResponse)
-> ((Maybe [RuleDetail] -> f (Maybe [RuleDetail]))
-> Maybe [RuleDetail] -> f (Maybe [RuleDetail]))
-> (Maybe [RuleDetail] -> f (Maybe [RuleDetail]))
-> GetRulesResponse
-> f GetRulesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [RuleDetail] [RuleDetail] [RuleDetail] [RuleDetail]
-> Iso
(Maybe [RuleDetail])
(Maybe [RuleDetail])
(Maybe [RuleDetail])
(Maybe [RuleDetail])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [RuleDetail] [RuleDetail] [RuleDetail] [RuleDetail]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
getRulesResponse_nextToken :: Lens.Lens' GetRulesResponse (Prelude.Maybe Prelude.Text)
getRulesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetRulesResponse -> f GetRulesResponse
getRulesResponse_nextToken = (GetRulesResponse -> Maybe Text)
-> (GetRulesResponse -> Maybe Text -> GetRulesResponse)
-> Lens GetRulesResponse GetRulesResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRulesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetRulesResponse' :: GetRulesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetRulesResponse
s@GetRulesResponse' {} Maybe Text
a -> GetRulesResponse
s {$sel:nextToken:GetRulesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetRulesResponse)
getRulesResponse_httpStatus :: Lens.Lens' GetRulesResponse Prelude.Int
getRulesResponse_httpStatus :: (Int -> f Int) -> GetRulesResponse -> f GetRulesResponse
getRulesResponse_httpStatus = (GetRulesResponse -> Int)
-> (GetRulesResponse -> Int -> GetRulesResponse)
-> Lens GetRulesResponse GetRulesResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRulesResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetRulesResponse' :: GetRulesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetRulesResponse
s@GetRulesResponse' {} Int
a -> GetRulesResponse
s {$sel:httpStatus:GetRulesResponse' :: Int
httpStatus = Int
a} :: GetRulesResponse)
instance Prelude.NFData GetRulesResponse