{-# 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.ConnectParticipant.SendEvent
(
SendEvent (..),
newSendEvent,
sendEvent_clientToken,
sendEvent_content,
sendEvent_contentType,
sendEvent_connectionToken,
SendEventResponse (..),
newSendEventResponse,
sendEventResponse_absoluteTime,
sendEventResponse_id,
sendEventResponse_httpStatus,
)
where
import Amazonka.ConnectParticipant.Types
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
data SendEvent = SendEvent'
{
SendEvent -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
SendEvent -> Maybe Text
content :: Prelude.Maybe Prelude.Text,
SendEvent -> Text
contentType :: Prelude.Text,
SendEvent -> Text
connectionToken :: Prelude.Text
}
deriving (SendEvent -> SendEvent -> Bool
(SendEvent -> SendEvent -> Bool)
-> (SendEvent -> SendEvent -> Bool) -> Eq SendEvent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendEvent -> SendEvent -> Bool
$c/= :: SendEvent -> SendEvent -> Bool
== :: SendEvent -> SendEvent -> Bool
$c== :: SendEvent -> SendEvent -> Bool
Prelude.Eq, ReadPrec [SendEvent]
ReadPrec SendEvent
Int -> ReadS SendEvent
ReadS [SendEvent]
(Int -> ReadS SendEvent)
-> ReadS [SendEvent]
-> ReadPrec SendEvent
-> ReadPrec [SendEvent]
-> Read SendEvent
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SendEvent]
$creadListPrec :: ReadPrec [SendEvent]
readPrec :: ReadPrec SendEvent
$creadPrec :: ReadPrec SendEvent
readList :: ReadS [SendEvent]
$creadList :: ReadS [SendEvent]
readsPrec :: Int -> ReadS SendEvent
$creadsPrec :: Int -> ReadS SendEvent
Prelude.Read, Int -> SendEvent -> ShowS
[SendEvent] -> ShowS
SendEvent -> String
(Int -> SendEvent -> ShowS)
-> (SendEvent -> String)
-> ([SendEvent] -> ShowS)
-> Show SendEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendEvent] -> ShowS
$cshowList :: [SendEvent] -> ShowS
show :: SendEvent -> String
$cshow :: SendEvent -> String
showsPrec :: Int -> SendEvent -> ShowS
$cshowsPrec :: Int -> SendEvent -> ShowS
Prelude.Show, (forall x. SendEvent -> Rep SendEvent x)
-> (forall x. Rep SendEvent x -> SendEvent) -> Generic SendEvent
forall x. Rep SendEvent x -> SendEvent
forall x. SendEvent -> Rep SendEvent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SendEvent x -> SendEvent
$cfrom :: forall x. SendEvent -> Rep SendEvent x
Prelude.Generic)
newSendEvent ::
Prelude.Text ->
Prelude.Text ->
SendEvent
newSendEvent :: Text -> Text -> SendEvent
newSendEvent Text
pContentType_ Text
pConnectionToken_ =
SendEvent' :: Maybe Text -> Maybe Text -> Text -> Text -> SendEvent
SendEvent'
{ $sel:clientToken:SendEvent' :: Maybe Text
clientToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:content:SendEvent' :: Maybe Text
content = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:contentType:SendEvent' :: Text
contentType = Text
pContentType_,
$sel:connectionToken:SendEvent' :: Text
connectionToken = Text
pConnectionToken_
}
sendEvent_clientToken :: Lens.Lens' SendEvent (Prelude.Maybe Prelude.Text)
sendEvent_clientToken :: (Maybe Text -> f (Maybe Text)) -> SendEvent -> f SendEvent
sendEvent_clientToken = (SendEvent -> Maybe Text)
-> (SendEvent -> Maybe Text -> SendEvent)
-> Lens SendEvent SendEvent (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEvent' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:SendEvent' :: SendEvent -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: SendEvent
s@SendEvent' {} Maybe Text
a -> SendEvent
s {$sel:clientToken:SendEvent' :: Maybe Text
clientToken = Maybe Text
a} :: SendEvent)
sendEvent_content :: Lens.Lens' SendEvent (Prelude.Maybe Prelude.Text)
sendEvent_content :: (Maybe Text -> f (Maybe Text)) -> SendEvent -> f SendEvent
sendEvent_content = (SendEvent -> Maybe Text)
-> (SendEvent -> Maybe Text -> SendEvent)
-> Lens SendEvent SendEvent (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEvent' {Maybe Text
content :: Maybe Text
$sel:content:SendEvent' :: SendEvent -> Maybe Text
content} -> Maybe Text
content) (\s :: SendEvent
s@SendEvent' {} Maybe Text
a -> SendEvent
s {$sel:content:SendEvent' :: Maybe Text
content = Maybe Text
a} :: SendEvent)
sendEvent_contentType :: Lens.Lens' SendEvent Prelude.Text
sendEvent_contentType :: (Text -> f Text) -> SendEvent -> f SendEvent
sendEvent_contentType = (SendEvent -> Text)
-> (SendEvent -> Text -> SendEvent)
-> Lens SendEvent SendEvent Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEvent' {Text
contentType :: Text
$sel:contentType:SendEvent' :: SendEvent -> Text
contentType} -> Text
contentType) (\s :: SendEvent
s@SendEvent' {} Text
a -> SendEvent
s {$sel:contentType:SendEvent' :: Text
contentType = Text
a} :: SendEvent)
sendEvent_connectionToken :: Lens.Lens' SendEvent Prelude.Text
sendEvent_connectionToken :: (Text -> f Text) -> SendEvent -> f SendEvent
sendEvent_connectionToken = (SendEvent -> Text)
-> (SendEvent -> Text -> SendEvent)
-> Lens SendEvent SendEvent Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEvent' {Text
connectionToken :: Text
$sel:connectionToken:SendEvent' :: SendEvent -> Text
connectionToken} -> Text
connectionToken) (\s :: SendEvent
s@SendEvent' {} Text
a -> SendEvent
s {$sel:connectionToken:SendEvent' :: Text
connectionToken = Text
a} :: SendEvent)
instance Core.AWSRequest SendEvent where
type AWSResponse SendEvent = SendEventResponse
request :: SendEvent -> Request SendEvent
request = Service -> SendEvent -> Request SendEvent
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy SendEvent
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SendEvent)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse SendEvent))
-> Logger
-> Service
-> Proxy SendEvent
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SendEvent)))
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 Text -> Maybe Text -> Int -> SendEventResponse
SendEventResponse'
(Maybe Text -> Maybe Text -> Int -> SendEventResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> SendEventResponse)
forall (f :: * -> *) a b. Functor 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
"AbsoluteTime")
Either String (Maybe Text -> Int -> SendEventResponse)
-> Either String (Maybe Text)
-> Either String (Int -> SendEventResponse)
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
"Id")
Either String (Int -> SendEventResponse)
-> Either String Int -> Either String SendEventResponse
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 SendEvent
instance Prelude.NFData SendEvent
instance Core.ToHeaders SendEvent where
toHeaders :: SendEvent -> ResponseHeaders
toHeaders SendEvent' {Maybe Text
Text
connectionToken :: Text
contentType :: Text
content :: Maybe Text
clientToken :: Maybe Text
$sel:connectionToken:SendEvent' :: SendEvent -> Text
$sel:contentType:SendEvent' :: SendEvent -> Text
$sel:content:SendEvent' :: SendEvent -> Maybe Text
$sel:clientToken:SendEvent' :: SendEvent -> Maybe Text
..} =
[ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Bearer" HeaderName -> Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Text
connectionToken,
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 SendEvent where
toJSON :: SendEvent -> Value
toJSON SendEvent' {Maybe Text
Text
connectionToken :: Text
contentType :: Text
content :: Maybe Text
clientToken :: Maybe Text
$sel:connectionToken:SendEvent' :: SendEvent -> Text
$sel:contentType:SendEvent' :: SendEvent -> Text
$sel:content:SendEvent' :: SendEvent -> Maybe Text
$sel:clientToken:SendEvent' :: SendEvent -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"ClientToken" 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
clientToken,
(Text
"Content" 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
content,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ContentType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
contentType)
]
)
instance Core.ToPath SendEvent where
toPath :: SendEvent -> ByteString
toPath = ByteString -> SendEvent -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/participant/event"
instance Core.ToQuery SendEvent where
toQuery :: SendEvent -> QueryString
toQuery = QueryString -> SendEvent -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data SendEventResponse = SendEventResponse'
{
SendEventResponse -> Maybe Text
absoluteTime :: Prelude.Maybe Prelude.Text,
SendEventResponse -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
SendEventResponse -> Int
httpStatus :: Prelude.Int
}
deriving (SendEventResponse -> SendEventResponse -> Bool
(SendEventResponse -> SendEventResponse -> Bool)
-> (SendEventResponse -> SendEventResponse -> Bool)
-> Eq SendEventResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendEventResponse -> SendEventResponse -> Bool
$c/= :: SendEventResponse -> SendEventResponse -> Bool
== :: SendEventResponse -> SendEventResponse -> Bool
$c== :: SendEventResponse -> SendEventResponse -> Bool
Prelude.Eq, ReadPrec [SendEventResponse]
ReadPrec SendEventResponse
Int -> ReadS SendEventResponse
ReadS [SendEventResponse]
(Int -> ReadS SendEventResponse)
-> ReadS [SendEventResponse]
-> ReadPrec SendEventResponse
-> ReadPrec [SendEventResponse]
-> Read SendEventResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SendEventResponse]
$creadListPrec :: ReadPrec [SendEventResponse]
readPrec :: ReadPrec SendEventResponse
$creadPrec :: ReadPrec SendEventResponse
readList :: ReadS [SendEventResponse]
$creadList :: ReadS [SendEventResponse]
readsPrec :: Int -> ReadS SendEventResponse
$creadsPrec :: Int -> ReadS SendEventResponse
Prelude.Read, Int -> SendEventResponse -> ShowS
[SendEventResponse] -> ShowS
SendEventResponse -> String
(Int -> SendEventResponse -> ShowS)
-> (SendEventResponse -> String)
-> ([SendEventResponse] -> ShowS)
-> Show SendEventResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendEventResponse] -> ShowS
$cshowList :: [SendEventResponse] -> ShowS
show :: SendEventResponse -> String
$cshow :: SendEventResponse -> String
showsPrec :: Int -> SendEventResponse -> ShowS
$cshowsPrec :: Int -> SendEventResponse -> ShowS
Prelude.Show, (forall x. SendEventResponse -> Rep SendEventResponse x)
-> (forall x. Rep SendEventResponse x -> SendEventResponse)
-> Generic SendEventResponse
forall x. Rep SendEventResponse x -> SendEventResponse
forall x. SendEventResponse -> Rep SendEventResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SendEventResponse x -> SendEventResponse
$cfrom :: forall x. SendEventResponse -> Rep SendEventResponse x
Prelude.Generic)
newSendEventResponse ::
Prelude.Int ->
SendEventResponse
newSendEventResponse :: Int -> SendEventResponse
newSendEventResponse Int
pHttpStatus_ =
SendEventResponse' :: Maybe Text -> Maybe Text -> Int -> SendEventResponse
SendEventResponse'
{ $sel:absoluteTime:SendEventResponse' :: Maybe Text
absoluteTime = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:id:SendEventResponse' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:SendEventResponse' :: Int
httpStatus = Int
pHttpStatus_
}
sendEventResponse_absoluteTime :: Lens.Lens' SendEventResponse (Prelude.Maybe Prelude.Text)
sendEventResponse_absoluteTime :: (Maybe Text -> f (Maybe Text))
-> SendEventResponse -> f SendEventResponse
sendEventResponse_absoluteTime = (SendEventResponse -> Maybe Text)
-> (SendEventResponse -> Maybe Text -> SendEventResponse)
-> Lens
SendEventResponse SendEventResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEventResponse' {Maybe Text
absoluteTime :: Maybe Text
$sel:absoluteTime:SendEventResponse' :: SendEventResponse -> Maybe Text
absoluteTime} -> Maybe Text
absoluteTime) (\s :: SendEventResponse
s@SendEventResponse' {} Maybe Text
a -> SendEventResponse
s {$sel:absoluteTime:SendEventResponse' :: Maybe Text
absoluteTime = Maybe Text
a} :: SendEventResponse)
sendEventResponse_id :: Lens.Lens' SendEventResponse (Prelude.Maybe Prelude.Text)
sendEventResponse_id :: (Maybe Text -> f (Maybe Text))
-> SendEventResponse -> f SendEventResponse
sendEventResponse_id = (SendEventResponse -> Maybe Text)
-> (SendEventResponse -> Maybe Text -> SendEventResponse)
-> Lens
SendEventResponse SendEventResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEventResponse' {Maybe Text
id :: Maybe Text
$sel:id:SendEventResponse' :: SendEventResponse -> Maybe Text
id} -> Maybe Text
id) (\s :: SendEventResponse
s@SendEventResponse' {} Maybe Text
a -> SendEventResponse
s {$sel:id:SendEventResponse' :: Maybe Text
id = Maybe Text
a} :: SendEventResponse)
sendEventResponse_httpStatus :: Lens.Lens' SendEventResponse Prelude.Int
sendEventResponse_httpStatus :: (Int -> f Int) -> SendEventResponse -> f SendEventResponse
sendEventResponse_httpStatus = (SendEventResponse -> Int)
-> (SendEventResponse -> Int -> SendEventResponse)
-> Lens SendEventResponse SendEventResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEventResponse' {Int
httpStatus :: Int
$sel:httpStatus:SendEventResponse' :: SendEventResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: SendEventResponse
s@SendEventResponse' {} Int
a -> SendEventResponse
s {$sel:httpStatus:SendEventResponse' :: Int
httpStatus = Int
a} :: SendEventResponse)
instance Prelude.NFData SendEventResponse