{-# 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.GetEvent
(
GetEvent (..),
newGetEvent,
getEvent_eventId,
getEvent_eventTypeName,
GetEventResponse (..),
newGetEventResponse,
getEventResponse_event,
getEventResponse_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 GetEvent = GetEvent'
{
GetEvent -> Text
eventId :: Prelude.Text,
GetEvent -> Text
eventTypeName :: Prelude.Text
}
deriving (GetEvent -> GetEvent -> Bool
(GetEvent -> GetEvent -> Bool)
-> (GetEvent -> GetEvent -> Bool) -> Eq GetEvent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetEvent -> GetEvent -> Bool
$c/= :: GetEvent -> GetEvent -> Bool
== :: GetEvent -> GetEvent -> Bool
$c== :: GetEvent -> GetEvent -> Bool
Prelude.Eq, ReadPrec [GetEvent]
ReadPrec GetEvent
Int -> ReadS GetEvent
ReadS [GetEvent]
(Int -> ReadS GetEvent)
-> ReadS [GetEvent]
-> ReadPrec GetEvent
-> ReadPrec [GetEvent]
-> Read GetEvent
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetEvent]
$creadListPrec :: ReadPrec [GetEvent]
readPrec :: ReadPrec GetEvent
$creadPrec :: ReadPrec GetEvent
readList :: ReadS [GetEvent]
$creadList :: ReadS [GetEvent]
readsPrec :: Int -> ReadS GetEvent
$creadsPrec :: Int -> ReadS GetEvent
Prelude.Read, Int -> GetEvent -> ShowS
[GetEvent] -> ShowS
GetEvent -> String
(Int -> GetEvent -> ShowS)
-> (GetEvent -> String) -> ([GetEvent] -> ShowS) -> Show GetEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetEvent] -> ShowS
$cshowList :: [GetEvent] -> ShowS
show :: GetEvent -> String
$cshow :: GetEvent -> String
showsPrec :: Int -> GetEvent -> ShowS
$cshowsPrec :: Int -> GetEvent -> ShowS
Prelude.Show, (forall x. GetEvent -> Rep GetEvent x)
-> (forall x. Rep GetEvent x -> GetEvent) -> Generic GetEvent
forall x. Rep GetEvent x -> GetEvent
forall x. GetEvent -> Rep GetEvent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetEvent x -> GetEvent
$cfrom :: forall x. GetEvent -> Rep GetEvent x
Prelude.Generic)
newGetEvent ::
Prelude.Text ->
Prelude.Text ->
GetEvent
newGetEvent :: Text -> Text -> GetEvent
newGetEvent Text
pEventId_ Text
pEventTypeName_ =
GetEvent' :: Text -> Text -> GetEvent
GetEvent'
{ $sel:eventId:GetEvent' :: Text
eventId = Text
pEventId_,
$sel:eventTypeName:GetEvent' :: Text
eventTypeName = Text
pEventTypeName_
}
getEvent_eventId :: Lens.Lens' GetEvent Prelude.Text
getEvent_eventId :: (Text -> f Text) -> GetEvent -> f GetEvent
getEvent_eventId = (GetEvent -> Text)
-> (GetEvent -> Text -> GetEvent)
-> Lens GetEvent GetEvent Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEvent' {Text
eventId :: Text
$sel:eventId:GetEvent' :: GetEvent -> Text
eventId} -> Text
eventId) (\s :: GetEvent
s@GetEvent' {} Text
a -> GetEvent
s {$sel:eventId:GetEvent' :: Text
eventId = Text
a} :: GetEvent)
getEvent_eventTypeName :: Lens.Lens' GetEvent Prelude.Text
getEvent_eventTypeName :: (Text -> f Text) -> GetEvent -> f GetEvent
getEvent_eventTypeName = (GetEvent -> Text)
-> (GetEvent -> Text -> GetEvent)
-> Lens GetEvent GetEvent Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEvent' {Text
eventTypeName :: Text
$sel:eventTypeName:GetEvent' :: GetEvent -> Text
eventTypeName} -> Text
eventTypeName) (\s :: GetEvent
s@GetEvent' {} Text
a -> GetEvent
s {$sel:eventTypeName:GetEvent' :: Text
eventTypeName = Text
a} :: GetEvent)
instance Core.AWSRequest GetEvent where
type AWSResponse GetEvent = GetEventResponse
request :: GetEvent -> Request GetEvent
request = Service -> GetEvent -> Request GetEvent
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy GetEvent
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetEvent)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetEvent))
-> Logger
-> Service
-> Proxy GetEvent
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetEvent)))
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 Event -> Int -> GetEventResponse
GetEventResponse'
(Maybe Event -> Int -> GetEventResponse)
-> Either String (Maybe Event)
-> Either String (Int -> GetEventResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Event)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"event")
Either String (Int -> GetEventResponse)
-> Either String Int -> Either String GetEventResponse
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 GetEvent
instance Prelude.NFData GetEvent
instance Core.ToHeaders GetEvent where
toHeaders :: GetEvent -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetEvent -> 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.GetEvent" ::
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 GetEvent where
toJSON :: GetEvent -> Value
toJSON GetEvent' {Text
eventTypeName :: Text
eventId :: Text
$sel:eventTypeName:GetEvent' :: GetEvent -> Text
$sel:eventId:GetEvent' :: GetEvent -> 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
"eventId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
eventId),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"eventTypeName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
eventTypeName)
]
)
instance Core.ToPath GetEvent where
toPath :: GetEvent -> ByteString
toPath = ByteString -> GetEvent -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery GetEvent where
toQuery :: GetEvent -> QueryString
toQuery = QueryString -> GetEvent -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GetEventResponse = GetEventResponse'
{
GetEventResponse -> Maybe Event
event :: Prelude.Maybe Event,
GetEventResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetEventResponse -> GetEventResponse -> Bool
(GetEventResponse -> GetEventResponse -> Bool)
-> (GetEventResponse -> GetEventResponse -> Bool)
-> Eq GetEventResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetEventResponse -> GetEventResponse -> Bool
$c/= :: GetEventResponse -> GetEventResponse -> Bool
== :: GetEventResponse -> GetEventResponse -> Bool
$c== :: GetEventResponse -> GetEventResponse -> Bool
Prelude.Eq, Int -> GetEventResponse -> ShowS
[GetEventResponse] -> ShowS
GetEventResponse -> String
(Int -> GetEventResponse -> ShowS)
-> (GetEventResponse -> String)
-> ([GetEventResponse] -> ShowS)
-> Show GetEventResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetEventResponse] -> ShowS
$cshowList :: [GetEventResponse] -> ShowS
show :: GetEventResponse -> String
$cshow :: GetEventResponse -> String
showsPrec :: Int -> GetEventResponse -> ShowS
$cshowsPrec :: Int -> GetEventResponse -> ShowS
Prelude.Show, (forall x. GetEventResponse -> Rep GetEventResponse x)
-> (forall x. Rep GetEventResponse x -> GetEventResponse)
-> Generic GetEventResponse
forall x. Rep GetEventResponse x -> GetEventResponse
forall x. GetEventResponse -> Rep GetEventResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetEventResponse x -> GetEventResponse
$cfrom :: forall x. GetEventResponse -> Rep GetEventResponse x
Prelude.Generic)
newGetEventResponse ::
Prelude.Int ->
GetEventResponse
newGetEventResponse :: Int -> GetEventResponse
newGetEventResponse Int
pHttpStatus_ =
GetEventResponse' :: Maybe Event -> Int -> GetEventResponse
GetEventResponse'
{ $sel:event:GetEventResponse' :: Maybe Event
event = Maybe Event
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetEventResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getEventResponse_event :: Lens.Lens' GetEventResponse (Prelude.Maybe Event)
getEventResponse_event :: (Maybe Event -> f (Maybe Event))
-> GetEventResponse -> f GetEventResponse
getEventResponse_event = (GetEventResponse -> Maybe Event)
-> (GetEventResponse -> Maybe Event -> GetEventResponse)
-> Lens
GetEventResponse GetEventResponse (Maybe Event) (Maybe Event)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEventResponse' {Maybe Event
event :: Maybe Event
$sel:event:GetEventResponse' :: GetEventResponse -> Maybe Event
event} -> Maybe Event
event) (\s :: GetEventResponse
s@GetEventResponse' {} Maybe Event
a -> GetEventResponse
s {$sel:event:GetEventResponse' :: Maybe Event
event = Maybe Event
a} :: GetEventResponse)
getEventResponse_httpStatus :: Lens.Lens' GetEventResponse Prelude.Int
getEventResponse_httpStatus :: (Int -> f Int) -> GetEventResponse -> f GetEventResponse
getEventResponse_httpStatus = (GetEventResponse -> Int)
-> (GetEventResponse -> Int -> GetEventResponse)
-> Lens GetEventResponse GetEventResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEventResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetEventResponse' :: GetEventResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetEventResponse
s@GetEventResponse' {} Int
a -> GetEventResponse
s {$sel:httpStatus:GetEventResponse' :: Int
httpStatus = Int
a} :: GetEventResponse)
instance Prelude.NFData GetEventResponse