{-# 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.Kinesis.PutRecords
(
PutRecords (..),
newPutRecords,
putRecords_streamARN,
putRecords_streamName,
putRecords_records,
PutRecordsResponse (..),
newPutRecordsResponse,
putRecordsResponse_encryptionType,
putRecordsResponse_failedRecordCount,
putRecordsResponse_httpStatus,
putRecordsResponse_records,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Kinesis.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data PutRecords = PutRecords'
{
PutRecords -> Maybe Text
streamARN :: Prelude.Maybe Prelude.Text,
PutRecords -> Maybe Text
streamName :: Prelude.Maybe Prelude.Text,
PutRecords -> NonEmpty PutRecordsRequestEntry
records :: Prelude.NonEmpty PutRecordsRequestEntry
}
deriving (PutRecords -> PutRecords -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutRecords -> PutRecords -> Bool
$c/= :: PutRecords -> PutRecords -> Bool
== :: PutRecords -> PutRecords -> Bool
$c== :: PutRecords -> PutRecords -> Bool
Prelude.Eq, ReadPrec [PutRecords]
ReadPrec PutRecords
Int -> ReadS PutRecords
ReadS [PutRecords]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutRecords]
$creadListPrec :: ReadPrec [PutRecords]
readPrec :: ReadPrec PutRecords
$creadPrec :: ReadPrec PutRecords
readList :: ReadS [PutRecords]
$creadList :: ReadS [PutRecords]
readsPrec :: Int -> ReadS PutRecords
$creadsPrec :: Int -> ReadS PutRecords
Prelude.Read, Int -> PutRecords -> ShowS
[PutRecords] -> ShowS
PutRecords -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutRecords] -> ShowS
$cshowList :: [PutRecords] -> ShowS
show :: PutRecords -> String
$cshow :: PutRecords -> String
showsPrec :: Int -> PutRecords -> ShowS
$cshowsPrec :: Int -> PutRecords -> ShowS
Prelude.Show, forall x. Rep PutRecords x -> PutRecords
forall x. PutRecords -> Rep PutRecords x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutRecords x -> PutRecords
$cfrom :: forall x. PutRecords -> Rep PutRecords x
Prelude.Generic)
newPutRecords ::
Prelude.NonEmpty PutRecordsRequestEntry ->
PutRecords
newPutRecords :: NonEmpty PutRecordsRequestEntry -> PutRecords
newPutRecords NonEmpty PutRecordsRequestEntry
pRecords_ =
PutRecords'
{ $sel:streamARN:PutRecords' :: Maybe Text
streamARN = forall a. Maybe a
Prelude.Nothing,
$sel:streamName:PutRecords' :: Maybe Text
streamName = forall a. Maybe a
Prelude.Nothing,
$sel:records:PutRecords' :: NonEmpty PutRecordsRequestEntry
records = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty PutRecordsRequestEntry
pRecords_
}
putRecords_streamARN :: Lens.Lens' PutRecords (Prelude.Maybe Prelude.Text)
putRecords_streamARN :: Lens' PutRecords (Maybe Text)
putRecords_streamARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRecords' {Maybe Text
streamARN :: Maybe Text
$sel:streamARN:PutRecords' :: PutRecords -> Maybe Text
streamARN} -> Maybe Text
streamARN) (\s :: PutRecords
s@PutRecords' {} Maybe Text
a -> PutRecords
s {$sel:streamARN:PutRecords' :: Maybe Text
streamARN = Maybe Text
a} :: PutRecords)
putRecords_streamName :: Lens.Lens' PutRecords (Prelude.Maybe Prelude.Text)
putRecords_streamName :: Lens' PutRecords (Maybe Text)
putRecords_streamName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRecords' {Maybe Text
streamName :: Maybe Text
$sel:streamName:PutRecords' :: PutRecords -> Maybe Text
streamName} -> Maybe Text
streamName) (\s :: PutRecords
s@PutRecords' {} Maybe Text
a -> PutRecords
s {$sel:streamName:PutRecords' :: Maybe Text
streamName = Maybe Text
a} :: PutRecords)
putRecords_records :: Lens.Lens' PutRecords (Prelude.NonEmpty PutRecordsRequestEntry)
putRecords_records :: Lens' PutRecords (NonEmpty PutRecordsRequestEntry)
putRecords_records = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRecords' {NonEmpty PutRecordsRequestEntry
records :: NonEmpty PutRecordsRequestEntry
$sel:records:PutRecords' :: PutRecords -> NonEmpty PutRecordsRequestEntry
records} -> NonEmpty PutRecordsRequestEntry
records) (\s :: PutRecords
s@PutRecords' {} NonEmpty PutRecordsRequestEntry
a -> PutRecords
s {$sel:records:PutRecords' :: NonEmpty PutRecordsRequestEntry
records = NonEmpty PutRecordsRequestEntry
a} :: PutRecords) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest PutRecords where
type AWSResponse PutRecords = PutRecordsResponse
request :: (Service -> Service) -> PutRecords -> Request PutRecords
request Service -> Service
overrides =
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy PutRecords
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutRecords)))
response =
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe EncryptionType
-> Maybe Natural
-> Int
-> NonEmpty PutRecordsResultEntry
-> PutRecordsResponse
PutRecordsResponse'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"EncryptionType")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"FailedRecordCount")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"Records")
)
instance Prelude.Hashable PutRecords where
hashWithSalt :: Int -> PutRecords -> Int
hashWithSalt Int
_salt PutRecords' {Maybe Text
NonEmpty PutRecordsRequestEntry
records :: NonEmpty PutRecordsRequestEntry
streamName :: Maybe Text
streamARN :: Maybe Text
$sel:records:PutRecords' :: PutRecords -> NonEmpty PutRecordsRequestEntry
$sel:streamName:PutRecords' :: PutRecords -> Maybe Text
$sel:streamARN:PutRecords' :: PutRecords -> Maybe Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
streamARN
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
streamName
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty PutRecordsRequestEntry
records
instance Prelude.NFData PutRecords where
rnf :: PutRecords -> ()
rnf PutRecords' {Maybe Text
NonEmpty PutRecordsRequestEntry
records :: NonEmpty PutRecordsRequestEntry
streamName :: Maybe Text
streamARN :: Maybe Text
$sel:records:PutRecords' :: PutRecords -> NonEmpty PutRecordsRequestEntry
$sel:streamName:PutRecords' :: PutRecords -> Maybe Text
$sel:streamARN:PutRecords' :: PutRecords -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
streamARN
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
streamName
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty PutRecordsRequestEntry
records
instance Data.ToHeaders PutRecords where
toHeaders :: PutRecords -> ResponseHeaders
toHeaders =
forall a b. a -> b -> a
Prelude.const
( forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"Kinesis_20131202.PutRecords" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON PutRecords where
toJSON :: PutRecords -> Value
toJSON PutRecords' {Maybe Text
NonEmpty PutRecordsRequestEntry
records :: NonEmpty PutRecordsRequestEntry
streamName :: Maybe Text
streamARN :: Maybe Text
$sel:records:PutRecords' :: PutRecords -> NonEmpty PutRecordsRequestEntry
$sel:streamName:PutRecords' :: PutRecords -> Maybe Text
$sel:streamARN:PutRecords' :: PutRecords -> Maybe Text
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"StreamARN" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
streamARN,
(Key
"StreamName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
streamName,
forall a. a -> Maybe a
Prelude.Just (Key
"Records" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty PutRecordsRequestEntry
records)
]
)
instance Data.ToPath PutRecords where
toPath :: PutRecords -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery PutRecords where
toQuery :: PutRecords -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data PutRecordsResponse = PutRecordsResponse'
{
PutRecordsResponse -> Maybe EncryptionType
encryptionType :: Prelude.Maybe EncryptionType,
PutRecordsResponse -> Maybe Natural
failedRecordCount :: Prelude.Maybe Prelude.Natural,
PutRecordsResponse -> Int
httpStatus :: Prelude.Int,
PutRecordsResponse -> NonEmpty PutRecordsResultEntry
records :: Prelude.NonEmpty PutRecordsResultEntry
}
deriving (PutRecordsResponse -> PutRecordsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutRecordsResponse -> PutRecordsResponse -> Bool
$c/= :: PutRecordsResponse -> PutRecordsResponse -> Bool
== :: PutRecordsResponse -> PutRecordsResponse -> Bool
$c== :: PutRecordsResponse -> PutRecordsResponse -> Bool
Prelude.Eq, ReadPrec [PutRecordsResponse]
ReadPrec PutRecordsResponse
Int -> ReadS PutRecordsResponse
ReadS [PutRecordsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutRecordsResponse]
$creadListPrec :: ReadPrec [PutRecordsResponse]
readPrec :: ReadPrec PutRecordsResponse
$creadPrec :: ReadPrec PutRecordsResponse
readList :: ReadS [PutRecordsResponse]
$creadList :: ReadS [PutRecordsResponse]
readsPrec :: Int -> ReadS PutRecordsResponse
$creadsPrec :: Int -> ReadS PutRecordsResponse
Prelude.Read, Int -> PutRecordsResponse -> ShowS
[PutRecordsResponse] -> ShowS
PutRecordsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutRecordsResponse] -> ShowS
$cshowList :: [PutRecordsResponse] -> ShowS
show :: PutRecordsResponse -> String
$cshow :: PutRecordsResponse -> String
showsPrec :: Int -> PutRecordsResponse -> ShowS
$cshowsPrec :: Int -> PutRecordsResponse -> ShowS
Prelude.Show, forall x. Rep PutRecordsResponse x -> PutRecordsResponse
forall x. PutRecordsResponse -> Rep PutRecordsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutRecordsResponse x -> PutRecordsResponse
$cfrom :: forall x. PutRecordsResponse -> Rep PutRecordsResponse x
Prelude.Generic)
newPutRecordsResponse ::
Prelude.Int ->
Prelude.NonEmpty PutRecordsResultEntry ->
PutRecordsResponse
newPutRecordsResponse :: Int -> NonEmpty PutRecordsResultEntry -> PutRecordsResponse
newPutRecordsResponse Int
pHttpStatus_ NonEmpty PutRecordsResultEntry
pRecords_ =
PutRecordsResponse'
{ $sel:encryptionType:PutRecordsResponse' :: Maybe EncryptionType
encryptionType =
forall a. Maybe a
Prelude.Nothing,
$sel:failedRecordCount:PutRecordsResponse' :: Maybe Natural
failedRecordCount = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:PutRecordsResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:records:PutRecordsResponse' :: NonEmpty PutRecordsResultEntry
records = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty PutRecordsResultEntry
pRecords_
}
putRecordsResponse_encryptionType :: Lens.Lens' PutRecordsResponse (Prelude.Maybe EncryptionType)
putRecordsResponse_encryptionType :: Lens' PutRecordsResponse (Maybe EncryptionType)
putRecordsResponse_encryptionType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRecordsResponse' {Maybe EncryptionType
encryptionType :: Maybe EncryptionType
$sel:encryptionType:PutRecordsResponse' :: PutRecordsResponse -> Maybe EncryptionType
encryptionType} -> Maybe EncryptionType
encryptionType) (\s :: PutRecordsResponse
s@PutRecordsResponse' {} Maybe EncryptionType
a -> PutRecordsResponse
s {$sel:encryptionType:PutRecordsResponse' :: Maybe EncryptionType
encryptionType = Maybe EncryptionType
a} :: PutRecordsResponse)
putRecordsResponse_failedRecordCount :: Lens.Lens' PutRecordsResponse (Prelude.Maybe Prelude.Natural)
putRecordsResponse_failedRecordCount :: Lens' PutRecordsResponse (Maybe Natural)
putRecordsResponse_failedRecordCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRecordsResponse' {Maybe Natural
failedRecordCount :: Maybe Natural
$sel:failedRecordCount:PutRecordsResponse' :: PutRecordsResponse -> Maybe Natural
failedRecordCount} -> Maybe Natural
failedRecordCount) (\s :: PutRecordsResponse
s@PutRecordsResponse' {} Maybe Natural
a -> PutRecordsResponse
s {$sel:failedRecordCount:PutRecordsResponse' :: Maybe Natural
failedRecordCount = Maybe Natural
a} :: PutRecordsResponse)
putRecordsResponse_httpStatus :: Lens.Lens' PutRecordsResponse Prelude.Int
putRecordsResponse_httpStatus :: Lens' PutRecordsResponse Int
putRecordsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRecordsResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutRecordsResponse' :: PutRecordsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: PutRecordsResponse
s@PutRecordsResponse' {} Int
a -> PutRecordsResponse
s {$sel:httpStatus:PutRecordsResponse' :: Int
httpStatus = Int
a} :: PutRecordsResponse)
putRecordsResponse_records :: Lens.Lens' PutRecordsResponse (Prelude.NonEmpty PutRecordsResultEntry)
putRecordsResponse_records :: Lens' PutRecordsResponse (NonEmpty PutRecordsResultEntry)
putRecordsResponse_records = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRecordsResponse' {NonEmpty PutRecordsResultEntry
records :: NonEmpty PutRecordsResultEntry
$sel:records:PutRecordsResponse' :: PutRecordsResponse -> NonEmpty PutRecordsResultEntry
records} -> NonEmpty PutRecordsResultEntry
records) (\s :: PutRecordsResponse
s@PutRecordsResponse' {} NonEmpty PutRecordsResultEntry
a -> PutRecordsResponse
s {$sel:records:PutRecordsResponse' :: NonEmpty PutRecordsResultEntry
records = NonEmpty PutRecordsResultEntry
a} :: PutRecordsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Prelude.NFData PutRecordsResponse where
rnf :: PutRecordsResponse -> ()
rnf PutRecordsResponse' {Int
Maybe Natural
Maybe EncryptionType
NonEmpty PutRecordsResultEntry
records :: NonEmpty PutRecordsResultEntry
httpStatus :: Int
failedRecordCount :: Maybe Natural
encryptionType :: Maybe EncryptionType
$sel:records:PutRecordsResponse' :: PutRecordsResponse -> NonEmpty PutRecordsResultEntry
$sel:httpStatus:PutRecordsResponse' :: PutRecordsResponse -> Int
$sel:failedRecordCount:PutRecordsResponse' :: PutRecordsResponse -> Maybe Natural
$sel:encryptionType:PutRecordsResponse' :: PutRecordsResponse -> Maybe EncryptionType
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe EncryptionType
encryptionType
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
failedRecordCount
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty PutRecordsResultEntry
records