{-# 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.Pinpoint.PutEventStream
(
PutEventStream (..),
newPutEventStream,
putEventStream_applicationId,
putEventStream_writeEventStream,
PutEventStreamResponse (..),
newPutEventStreamResponse,
putEventStreamResponse_httpStatus,
putEventStreamResponse_eventStream,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data PutEventStream = PutEventStream'
{
PutEventStream -> Text
applicationId :: Prelude.Text,
PutEventStream -> WriteEventStream
writeEventStream :: WriteEventStream
}
deriving (PutEventStream -> PutEventStream -> Bool
(PutEventStream -> PutEventStream -> Bool)
-> (PutEventStream -> PutEventStream -> Bool) -> Eq PutEventStream
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutEventStream -> PutEventStream -> Bool
$c/= :: PutEventStream -> PutEventStream -> Bool
== :: PutEventStream -> PutEventStream -> Bool
$c== :: PutEventStream -> PutEventStream -> Bool
Prelude.Eq, ReadPrec [PutEventStream]
ReadPrec PutEventStream
Int -> ReadS PutEventStream
ReadS [PutEventStream]
(Int -> ReadS PutEventStream)
-> ReadS [PutEventStream]
-> ReadPrec PutEventStream
-> ReadPrec [PutEventStream]
-> Read PutEventStream
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutEventStream]
$creadListPrec :: ReadPrec [PutEventStream]
readPrec :: ReadPrec PutEventStream
$creadPrec :: ReadPrec PutEventStream
readList :: ReadS [PutEventStream]
$creadList :: ReadS [PutEventStream]
readsPrec :: Int -> ReadS PutEventStream
$creadsPrec :: Int -> ReadS PutEventStream
Prelude.Read, Int -> PutEventStream -> ShowS
[PutEventStream] -> ShowS
PutEventStream -> String
(Int -> PutEventStream -> ShowS)
-> (PutEventStream -> String)
-> ([PutEventStream] -> ShowS)
-> Show PutEventStream
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutEventStream] -> ShowS
$cshowList :: [PutEventStream] -> ShowS
show :: PutEventStream -> String
$cshow :: PutEventStream -> String
showsPrec :: Int -> PutEventStream -> ShowS
$cshowsPrec :: Int -> PutEventStream -> ShowS
Prelude.Show, (forall x. PutEventStream -> Rep PutEventStream x)
-> (forall x. Rep PutEventStream x -> PutEventStream)
-> Generic PutEventStream
forall x. Rep PutEventStream x -> PutEventStream
forall x. PutEventStream -> Rep PutEventStream x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutEventStream x -> PutEventStream
$cfrom :: forall x. PutEventStream -> Rep PutEventStream x
Prelude.Generic)
newPutEventStream ::
Prelude.Text ->
WriteEventStream ->
PutEventStream
newPutEventStream :: Text -> WriteEventStream -> PutEventStream
newPutEventStream Text
pApplicationId_ WriteEventStream
pWriteEventStream_ =
PutEventStream' :: Text -> WriteEventStream -> PutEventStream
PutEventStream'
{ $sel:applicationId:PutEventStream' :: Text
applicationId = Text
pApplicationId_,
$sel:writeEventStream:PutEventStream' :: WriteEventStream
writeEventStream = WriteEventStream
pWriteEventStream_
}
putEventStream_applicationId :: Lens.Lens' PutEventStream Prelude.Text
putEventStream_applicationId :: (Text -> f Text) -> PutEventStream -> f PutEventStream
putEventStream_applicationId = (PutEventStream -> Text)
-> (PutEventStream -> Text -> PutEventStream)
-> Lens PutEventStream PutEventStream Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEventStream' {Text
applicationId :: Text
$sel:applicationId:PutEventStream' :: PutEventStream -> Text
applicationId} -> Text
applicationId) (\s :: PutEventStream
s@PutEventStream' {} Text
a -> PutEventStream
s {$sel:applicationId:PutEventStream' :: Text
applicationId = Text
a} :: PutEventStream)
putEventStream_writeEventStream :: Lens.Lens' PutEventStream WriteEventStream
putEventStream_writeEventStream :: (WriteEventStream -> f WriteEventStream)
-> PutEventStream -> f PutEventStream
putEventStream_writeEventStream = (PutEventStream -> WriteEventStream)
-> (PutEventStream -> WriteEventStream -> PutEventStream)
-> Lens
PutEventStream PutEventStream WriteEventStream WriteEventStream
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEventStream' {WriteEventStream
writeEventStream :: WriteEventStream
$sel:writeEventStream:PutEventStream' :: PutEventStream -> WriteEventStream
writeEventStream} -> WriteEventStream
writeEventStream) (\s :: PutEventStream
s@PutEventStream' {} WriteEventStream
a -> PutEventStream
s {$sel:writeEventStream:PutEventStream' :: WriteEventStream
writeEventStream = WriteEventStream
a} :: PutEventStream)
instance Core.AWSRequest PutEventStream where
type
AWSResponse PutEventStream =
PutEventStreamResponse
request :: PutEventStream -> Request PutEventStream
request = Service -> PutEventStream -> Request PutEventStream
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy PutEventStream
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutEventStream)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse PutEventStream))
-> Logger
-> Service
-> Proxy PutEventStream
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutEventStream)))
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 ->
Int -> EventStream -> PutEventStreamResponse
PutEventStreamResponse'
(Int -> EventStream -> PutEventStreamResponse)
-> Either String Int
-> Either String (EventStream -> PutEventStreamResponse)
forall (f :: * -> *) a b. Functor 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))
Either String (EventStream -> PutEventStreamResponse)
-> Either String EventStream
-> Either String PutEventStreamResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String EventStream
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
)
instance Prelude.Hashable PutEventStream
instance Prelude.NFData PutEventStream
instance Core.ToHeaders PutEventStream where
toHeaders :: PutEventStream -> ResponseHeaders
toHeaders =
ResponseHeaders -> PutEventStream -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ 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 PutEventStream where
toJSON :: PutEventStream -> Value
toJSON PutEventStream' {Text
WriteEventStream
writeEventStream :: WriteEventStream
applicationId :: Text
$sel:writeEventStream:PutEventStream' :: PutEventStream -> WriteEventStream
$sel:applicationId:PutEventStream' :: PutEventStream -> 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
"WriteEventStream" Text -> WriteEventStream -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= WriteEventStream
writeEventStream)
]
)
instance Core.ToPath PutEventStream where
toPath :: PutEventStream -> ByteString
toPath PutEventStream' {Text
WriteEventStream
writeEventStream :: WriteEventStream
applicationId :: Text
$sel:writeEventStream:PutEventStream' :: PutEventStream -> WriteEventStream
$sel:applicationId:PutEventStream' :: PutEventStream -> Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"/v1/apps/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
applicationId,
ByteString
"/eventstream"
]
instance Core.ToQuery PutEventStream where
toQuery :: PutEventStream -> QueryString
toQuery = QueryString -> PutEventStream -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data PutEventStreamResponse = PutEventStreamResponse'
{
PutEventStreamResponse -> Int
httpStatus :: Prelude.Int,
PutEventStreamResponse -> EventStream
eventStream :: EventStream
}
deriving (PutEventStreamResponse -> PutEventStreamResponse -> Bool
(PutEventStreamResponse -> PutEventStreamResponse -> Bool)
-> (PutEventStreamResponse -> PutEventStreamResponse -> Bool)
-> Eq PutEventStreamResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutEventStreamResponse -> PutEventStreamResponse -> Bool
$c/= :: PutEventStreamResponse -> PutEventStreamResponse -> Bool
== :: PutEventStreamResponse -> PutEventStreamResponse -> Bool
$c== :: PutEventStreamResponse -> PutEventStreamResponse -> Bool
Prelude.Eq, ReadPrec [PutEventStreamResponse]
ReadPrec PutEventStreamResponse
Int -> ReadS PutEventStreamResponse
ReadS [PutEventStreamResponse]
(Int -> ReadS PutEventStreamResponse)
-> ReadS [PutEventStreamResponse]
-> ReadPrec PutEventStreamResponse
-> ReadPrec [PutEventStreamResponse]
-> Read PutEventStreamResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutEventStreamResponse]
$creadListPrec :: ReadPrec [PutEventStreamResponse]
readPrec :: ReadPrec PutEventStreamResponse
$creadPrec :: ReadPrec PutEventStreamResponse
readList :: ReadS [PutEventStreamResponse]
$creadList :: ReadS [PutEventStreamResponse]
readsPrec :: Int -> ReadS PutEventStreamResponse
$creadsPrec :: Int -> ReadS PutEventStreamResponse
Prelude.Read, Int -> PutEventStreamResponse -> ShowS
[PutEventStreamResponse] -> ShowS
PutEventStreamResponse -> String
(Int -> PutEventStreamResponse -> ShowS)
-> (PutEventStreamResponse -> String)
-> ([PutEventStreamResponse] -> ShowS)
-> Show PutEventStreamResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutEventStreamResponse] -> ShowS
$cshowList :: [PutEventStreamResponse] -> ShowS
show :: PutEventStreamResponse -> String
$cshow :: PutEventStreamResponse -> String
showsPrec :: Int -> PutEventStreamResponse -> ShowS
$cshowsPrec :: Int -> PutEventStreamResponse -> ShowS
Prelude.Show, (forall x. PutEventStreamResponse -> Rep PutEventStreamResponse x)
-> (forall x.
Rep PutEventStreamResponse x -> PutEventStreamResponse)
-> Generic PutEventStreamResponse
forall x. Rep PutEventStreamResponse x -> PutEventStreamResponse
forall x. PutEventStreamResponse -> Rep PutEventStreamResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutEventStreamResponse x -> PutEventStreamResponse
$cfrom :: forall x. PutEventStreamResponse -> Rep PutEventStreamResponse x
Prelude.Generic)
newPutEventStreamResponse ::
Prelude.Int ->
EventStream ->
PutEventStreamResponse
newPutEventStreamResponse :: Int -> EventStream -> PutEventStreamResponse
newPutEventStreamResponse Int
pHttpStatus_ EventStream
pEventStream_ =
PutEventStreamResponse' :: Int -> EventStream -> PutEventStreamResponse
PutEventStreamResponse'
{ $sel:httpStatus:PutEventStreamResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:eventStream:PutEventStreamResponse' :: EventStream
eventStream = EventStream
pEventStream_
}
putEventStreamResponse_httpStatus :: Lens.Lens' PutEventStreamResponse Prelude.Int
putEventStreamResponse_httpStatus :: (Int -> f Int)
-> PutEventStreamResponse -> f PutEventStreamResponse
putEventStreamResponse_httpStatus = (PutEventStreamResponse -> Int)
-> (PutEventStreamResponse -> Int -> PutEventStreamResponse)
-> Lens PutEventStreamResponse PutEventStreamResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEventStreamResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutEventStreamResponse' :: PutEventStreamResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: PutEventStreamResponse
s@PutEventStreamResponse' {} Int
a -> PutEventStreamResponse
s {$sel:httpStatus:PutEventStreamResponse' :: Int
httpStatus = Int
a} :: PutEventStreamResponse)
putEventStreamResponse_eventStream :: Lens.Lens' PutEventStreamResponse EventStream
putEventStreamResponse_eventStream :: (EventStream -> f EventStream)
-> PutEventStreamResponse -> f PutEventStreamResponse
putEventStreamResponse_eventStream = (PutEventStreamResponse -> EventStream)
-> (PutEventStreamResponse
-> EventStream -> PutEventStreamResponse)
-> Lens
PutEventStreamResponse
PutEventStreamResponse
EventStream
EventStream
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEventStreamResponse' {EventStream
eventStream :: EventStream
$sel:eventStream:PutEventStreamResponse' :: PutEventStreamResponse -> EventStream
eventStream} -> EventStream
eventStream) (\s :: PutEventStreamResponse
s@PutEventStreamResponse' {} EventStream
a -> PutEventStreamResponse
s {$sel:eventStream:PutEventStreamResponse' :: EventStream
eventStream = EventStream
a} :: PutEventStreamResponse)
instance Prelude.NFData PutEventStreamResponse