{-# 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.IoTAnalytics.BatchPutMessage
(
BatchPutMessage (..),
newBatchPutMessage,
batchPutMessage_channelName,
batchPutMessage_messages,
BatchPutMessageResponse (..),
newBatchPutMessageResponse,
batchPutMessageResponse_batchPutMessageErrorEntries,
batchPutMessageResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import Amazonka.IoTAnalytics.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 BatchPutMessage = BatchPutMessage'
{
BatchPutMessage -> Text
channelName :: Prelude.Text,
BatchPutMessage -> [Message]
messages :: [Message]
}
deriving (BatchPutMessage -> BatchPutMessage -> Bool
(BatchPutMessage -> BatchPutMessage -> Bool)
-> (BatchPutMessage -> BatchPutMessage -> Bool)
-> Eq BatchPutMessage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchPutMessage -> BatchPutMessage -> Bool
$c/= :: BatchPutMessage -> BatchPutMessage -> Bool
== :: BatchPutMessage -> BatchPutMessage -> Bool
$c== :: BatchPutMessage -> BatchPutMessage -> Bool
Prelude.Eq, ReadPrec [BatchPutMessage]
ReadPrec BatchPutMessage
Int -> ReadS BatchPutMessage
ReadS [BatchPutMessage]
(Int -> ReadS BatchPutMessage)
-> ReadS [BatchPutMessage]
-> ReadPrec BatchPutMessage
-> ReadPrec [BatchPutMessage]
-> Read BatchPutMessage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchPutMessage]
$creadListPrec :: ReadPrec [BatchPutMessage]
readPrec :: ReadPrec BatchPutMessage
$creadPrec :: ReadPrec BatchPutMessage
readList :: ReadS [BatchPutMessage]
$creadList :: ReadS [BatchPutMessage]
readsPrec :: Int -> ReadS BatchPutMessage
$creadsPrec :: Int -> ReadS BatchPutMessage
Prelude.Read, Int -> BatchPutMessage -> ShowS
[BatchPutMessage] -> ShowS
BatchPutMessage -> String
(Int -> BatchPutMessage -> ShowS)
-> (BatchPutMessage -> String)
-> ([BatchPutMessage] -> ShowS)
-> Show BatchPutMessage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchPutMessage] -> ShowS
$cshowList :: [BatchPutMessage] -> ShowS
show :: BatchPutMessage -> String
$cshow :: BatchPutMessage -> String
showsPrec :: Int -> BatchPutMessage -> ShowS
$cshowsPrec :: Int -> BatchPutMessage -> ShowS
Prelude.Show, (forall x. BatchPutMessage -> Rep BatchPutMessage x)
-> (forall x. Rep BatchPutMessage x -> BatchPutMessage)
-> Generic BatchPutMessage
forall x. Rep BatchPutMessage x -> BatchPutMessage
forall x. BatchPutMessage -> Rep BatchPutMessage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchPutMessage x -> BatchPutMessage
$cfrom :: forall x. BatchPutMessage -> Rep BatchPutMessage x
Prelude.Generic)
newBatchPutMessage ::
Prelude.Text ->
BatchPutMessage
newBatchPutMessage :: Text -> BatchPutMessage
newBatchPutMessage Text
pChannelName_ =
BatchPutMessage' :: Text -> [Message] -> BatchPutMessage
BatchPutMessage'
{ $sel:channelName:BatchPutMessage' :: Text
channelName = Text
pChannelName_,
$sel:messages:BatchPutMessage' :: [Message]
messages = [Message]
forall a. Monoid a => a
Prelude.mempty
}
batchPutMessage_channelName :: Lens.Lens' BatchPutMessage Prelude.Text
batchPutMessage_channelName :: (Text -> f Text) -> BatchPutMessage -> f BatchPutMessage
batchPutMessage_channelName = (BatchPutMessage -> Text)
-> (BatchPutMessage -> Text -> BatchPutMessage)
-> Lens BatchPutMessage BatchPutMessage Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchPutMessage' {Text
channelName :: Text
$sel:channelName:BatchPutMessage' :: BatchPutMessage -> Text
channelName} -> Text
channelName) (\s :: BatchPutMessage
s@BatchPutMessage' {} Text
a -> BatchPutMessage
s {$sel:channelName:BatchPutMessage' :: Text
channelName = Text
a} :: BatchPutMessage)
batchPutMessage_messages :: Lens.Lens' BatchPutMessage [Message]
batchPutMessage_messages :: ([Message] -> f [Message]) -> BatchPutMessage -> f BatchPutMessage
batchPutMessage_messages = (BatchPutMessage -> [Message])
-> (BatchPutMessage -> [Message] -> BatchPutMessage)
-> Lens BatchPutMessage BatchPutMessage [Message] [Message]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchPutMessage' {[Message]
messages :: [Message]
$sel:messages:BatchPutMessage' :: BatchPutMessage -> [Message]
messages} -> [Message]
messages) (\s :: BatchPutMessage
s@BatchPutMessage' {} [Message]
a -> BatchPutMessage
s {$sel:messages:BatchPutMessage' :: [Message]
messages = [Message]
a} :: BatchPutMessage) (([Message] -> f [Message])
-> BatchPutMessage -> f BatchPutMessage)
-> (([Message] -> f [Message]) -> [Message] -> f [Message])
-> ([Message] -> f [Message])
-> BatchPutMessage
-> f BatchPutMessage
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Message] -> f [Message]) -> [Message] -> f [Message]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest BatchPutMessage where
type
AWSResponse BatchPutMessage =
BatchPutMessageResponse
request :: BatchPutMessage -> Request BatchPutMessage
request = Service -> BatchPutMessage -> Request BatchPutMessage
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy BatchPutMessage
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BatchPutMessage)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse BatchPutMessage))
-> Logger
-> Service
-> Proxy BatchPutMessage
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BatchPutMessage)))
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 [BatchPutMessageErrorEntry] -> Int -> BatchPutMessageResponse
BatchPutMessageResponse'
(Maybe [BatchPutMessageErrorEntry]
-> Int -> BatchPutMessageResponse)
-> Either String (Maybe [BatchPutMessageErrorEntry])
-> Either String (Int -> BatchPutMessageResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object
-> Text
-> Either String (Maybe (Maybe [BatchPutMessageErrorEntry]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"batchPutMessageErrorEntries"
Either String (Maybe (Maybe [BatchPutMessageErrorEntry]))
-> Maybe [BatchPutMessageErrorEntry]
-> Either String (Maybe [BatchPutMessageErrorEntry])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [BatchPutMessageErrorEntry]
forall a. Monoid a => a
Prelude.mempty
)
Either String (Int -> BatchPutMessageResponse)
-> Either String Int -> Either String BatchPutMessageResponse
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 BatchPutMessage
instance Prelude.NFData BatchPutMessage
instance Core.ToHeaders BatchPutMessage where
toHeaders :: BatchPutMessage -> ResponseHeaders
toHeaders = ResponseHeaders -> BatchPutMessage -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToJSON BatchPutMessage where
toJSON :: BatchPutMessage -> Value
toJSON BatchPutMessage' {[Message]
Text
messages :: [Message]
channelName :: Text
$sel:messages:BatchPutMessage' :: BatchPutMessage -> [Message]
$sel:channelName:BatchPutMessage' :: BatchPutMessage -> 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
"channelName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
channelName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"messages" Text -> [Message] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Message]
messages)
]
)
instance Core.ToPath BatchPutMessage where
toPath :: BatchPutMessage -> ByteString
toPath = ByteString -> BatchPutMessage -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/messages/batch"
instance Core.ToQuery BatchPutMessage where
toQuery :: BatchPutMessage -> QueryString
toQuery = QueryString -> BatchPutMessage -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data BatchPutMessageResponse = BatchPutMessageResponse'
{
BatchPutMessageResponse -> Maybe [BatchPutMessageErrorEntry]
batchPutMessageErrorEntries :: Prelude.Maybe [BatchPutMessageErrorEntry],
BatchPutMessageResponse -> Int
httpStatus :: Prelude.Int
}
deriving (BatchPutMessageResponse -> BatchPutMessageResponse -> Bool
(BatchPutMessageResponse -> BatchPutMessageResponse -> Bool)
-> (BatchPutMessageResponse -> BatchPutMessageResponse -> Bool)
-> Eq BatchPutMessageResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchPutMessageResponse -> BatchPutMessageResponse -> Bool
$c/= :: BatchPutMessageResponse -> BatchPutMessageResponse -> Bool
== :: BatchPutMessageResponse -> BatchPutMessageResponse -> Bool
$c== :: BatchPutMessageResponse -> BatchPutMessageResponse -> Bool
Prelude.Eq, ReadPrec [BatchPutMessageResponse]
ReadPrec BatchPutMessageResponse
Int -> ReadS BatchPutMessageResponse
ReadS [BatchPutMessageResponse]
(Int -> ReadS BatchPutMessageResponse)
-> ReadS [BatchPutMessageResponse]
-> ReadPrec BatchPutMessageResponse
-> ReadPrec [BatchPutMessageResponse]
-> Read BatchPutMessageResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchPutMessageResponse]
$creadListPrec :: ReadPrec [BatchPutMessageResponse]
readPrec :: ReadPrec BatchPutMessageResponse
$creadPrec :: ReadPrec BatchPutMessageResponse
readList :: ReadS [BatchPutMessageResponse]
$creadList :: ReadS [BatchPutMessageResponse]
readsPrec :: Int -> ReadS BatchPutMessageResponse
$creadsPrec :: Int -> ReadS BatchPutMessageResponse
Prelude.Read, Int -> BatchPutMessageResponse -> ShowS
[BatchPutMessageResponse] -> ShowS
BatchPutMessageResponse -> String
(Int -> BatchPutMessageResponse -> ShowS)
-> (BatchPutMessageResponse -> String)
-> ([BatchPutMessageResponse] -> ShowS)
-> Show BatchPutMessageResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchPutMessageResponse] -> ShowS
$cshowList :: [BatchPutMessageResponse] -> ShowS
show :: BatchPutMessageResponse -> String
$cshow :: BatchPutMessageResponse -> String
showsPrec :: Int -> BatchPutMessageResponse -> ShowS
$cshowsPrec :: Int -> BatchPutMessageResponse -> ShowS
Prelude.Show, (forall x.
BatchPutMessageResponse -> Rep BatchPutMessageResponse x)
-> (forall x.
Rep BatchPutMessageResponse x -> BatchPutMessageResponse)
-> Generic BatchPutMessageResponse
forall x. Rep BatchPutMessageResponse x -> BatchPutMessageResponse
forall x. BatchPutMessageResponse -> Rep BatchPutMessageResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchPutMessageResponse x -> BatchPutMessageResponse
$cfrom :: forall x. BatchPutMessageResponse -> Rep BatchPutMessageResponse x
Prelude.Generic)
newBatchPutMessageResponse ::
Prelude.Int ->
BatchPutMessageResponse
newBatchPutMessageResponse :: Int -> BatchPutMessageResponse
newBatchPutMessageResponse Int
pHttpStatus_ =
BatchPutMessageResponse' :: Maybe [BatchPutMessageErrorEntry] -> Int -> BatchPutMessageResponse
BatchPutMessageResponse'
{ $sel:batchPutMessageErrorEntries:BatchPutMessageResponse' :: Maybe [BatchPutMessageErrorEntry]
batchPutMessageErrorEntries =
Maybe [BatchPutMessageErrorEntry]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:BatchPutMessageResponse' :: Int
httpStatus = Int
pHttpStatus_
}
batchPutMessageResponse_batchPutMessageErrorEntries :: Lens.Lens' BatchPutMessageResponse (Prelude.Maybe [BatchPutMessageErrorEntry])
batchPutMessageResponse_batchPutMessageErrorEntries :: (Maybe [BatchPutMessageErrorEntry]
-> f (Maybe [BatchPutMessageErrorEntry]))
-> BatchPutMessageResponse -> f BatchPutMessageResponse
batchPutMessageResponse_batchPutMessageErrorEntries = (BatchPutMessageResponse -> Maybe [BatchPutMessageErrorEntry])
-> (BatchPutMessageResponse
-> Maybe [BatchPutMessageErrorEntry] -> BatchPutMessageResponse)
-> Lens
BatchPutMessageResponse
BatchPutMessageResponse
(Maybe [BatchPutMessageErrorEntry])
(Maybe [BatchPutMessageErrorEntry])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchPutMessageResponse' {Maybe [BatchPutMessageErrorEntry]
batchPutMessageErrorEntries :: Maybe [BatchPutMessageErrorEntry]
$sel:batchPutMessageErrorEntries:BatchPutMessageResponse' :: BatchPutMessageResponse -> Maybe [BatchPutMessageErrorEntry]
batchPutMessageErrorEntries} -> Maybe [BatchPutMessageErrorEntry]
batchPutMessageErrorEntries) (\s :: BatchPutMessageResponse
s@BatchPutMessageResponse' {} Maybe [BatchPutMessageErrorEntry]
a -> BatchPutMessageResponse
s {$sel:batchPutMessageErrorEntries:BatchPutMessageResponse' :: Maybe [BatchPutMessageErrorEntry]
batchPutMessageErrorEntries = Maybe [BatchPutMessageErrorEntry]
a} :: BatchPutMessageResponse) ((Maybe [BatchPutMessageErrorEntry]
-> f (Maybe [BatchPutMessageErrorEntry]))
-> BatchPutMessageResponse -> f BatchPutMessageResponse)
-> ((Maybe [BatchPutMessageErrorEntry]
-> f (Maybe [BatchPutMessageErrorEntry]))
-> Maybe [BatchPutMessageErrorEntry]
-> f (Maybe [BatchPutMessageErrorEntry]))
-> (Maybe [BatchPutMessageErrorEntry]
-> f (Maybe [BatchPutMessageErrorEntry]))
-> BatchPutMessageResponse
-> f BatchPutMessageResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[BatchPutMessageErrorEntry]
[BatchPutMessageErrorEntry]
[BatchPutMessageErrorEntry]
[BatchPutMessageErrorEntry]
-> Iso
(Maybe [BatchPutMessageErrorEntry])
(Maybe [BatchPutMessageErrorEntry])
(Maybe [BatchPutMessageErrorEntry])
(Maybe [BatchPutMessageErrorEntry])
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
[BatchPutMessageErrorEntry]
[BatchPutMessageErrorEntry]
[BatchPutMessageErrorEntry]
[BatchPutMessageErrorEntry]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
batchPutMessageResponse_httpStatus :: Lens.Lens' BatchPutMessageResponse Prelude.Int
batchPutMessageResponse_httpStatus :: (Int -> f Int)
-> BatchPutMessageResponse -> f BatchPutMessageResponse
batchPutMessageResponse_httpStatus = (BatchPutMessageResponse -> Int)
-> (BatchPutMessageResponse -> Int -> BatchPutMessageResponse)
-> Lens BatchPutMessageResponse BatchPutMessageResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchPutMessageResponse' {Int
httpStatus :: Int
$sel:httpStatus:BatchPutMessageResponse' :: BatchPutMessageResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: BatchPutMessageResponse
s@BatchPutMessageResponse' {} Int
a -> BatchPutMessageResponse
s {$sel:httpStatus:BatchPutMessageResponse' :: Int
httpStatus = Int
a} :: BatchPutMessageResponse)
instance Prelude.NFData BatchPutMessageResponse