{-# 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.GetRecords
(
GetRecords (..),
newGetRecords,
getRecords_limit,
getRecords_streamARN,
getRecords_shardIterator,
GetRecordsResponse (..),
newGetRecordsResponse,
getRecordsResponse_childShards,
getRecordsResponse_millisBehindLatest,
getRecordsResponse_nextShardIterator,
getRecordsResponse_httpStatus,
getRecordsResponse_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 GetRecords = GetRecords'
{
GetRecords -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
GetRecords -> Maybe Text
streamARN :: Prelude.Maybe Prelude.Text,
GetRecords -> Text
shardIterator :: Prelude.Text
}
deriving (GetRecords -> GetRecords -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRecords -> GetRecords -> Bool
$c/= :: GetRecords -> GetRecords -> Bool
== :: GetRecords -> GetRecords -> Bool
$c== :: GetRecords -> GetRecords -> Bool
Prelude.Eq, ReadPrec [GetRecords]
ReadPrec GetRecords
Int -> ReadS GetRecords
ReadS [GetRecords]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRecords]
$creadListPrec :: ReadPrec [GetRecords]
readPrec :: ReadPrec GetRecords
$creadPrec :: ReadPrec GetRecords
readList :: ReadS [GetRecords]
$creadList :: ReadS [GetRecords]
readsPrec :: Int -> ReadS GetRecords
$creadsPrec :: Int -> ReadS GetRecords
Prelude.Read, Int -> GetRecords -> ShowS
[GetRecords] -> ShowS
GetRecords -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRecords] -> ShowS
$cshowList :: [GetRecords] -> ShowS
show :: GetRecords -> String
$cshow :: GetRecords -> String
showsPrec :: Int -> GetRecords -> ShowS
$cshowsPrec :: Int -> GetRecords -> ShowS
Prelude.Show, forall x. Rep GetRecords x -> GetRecords
forall x. GetRecords -> Rep GetRecords x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetRecords x -> GetRecords
$cfrom :: forall x. GetRecords -> Rep GetRecords x
Prelude.Generic)
newGetRecords ::
Prelude.Text ->
GetRecords
newGetRecords :: Text -> GetRecords
newGetRecords Text
pShardIterator_ =
GetRecords'
{ $sel:limit:GetRecords' :: Maybe Natural
limit = forall a. Maybe a
Prelude.Nothing,
$sel:streamARN:GetRecords' :: Maybe Text
streamARN = forall a. Maybe a
Prelude.Nothing,
$sel:shardIterator:GetRecords' :: Text
shardIterator = Text
pShardIterator_
}
getRecords_limit :: Lens.Lens' GetRecords (Prelude.Maybe Prelude.Natural)
getRecords_limit :: Lens' GetRecords (Maybe Natural)
getRecords_limit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecords' {Maybe Natural
limit :: Maybe Natural
$sel:limit:GetRecords' :: GetRecords -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: GetRecords
s@GetRecords' {} Maybe Natural
a -> GetRecords
s {$sel:limit:GetRecords' :: Maybe Natural
limit = Maybe Natural
a} :: GetRecords)
getRecords_streamARN :: Lens.Lens' GetRecords (Prelude.Maybe Prelude.Text)
getRecords_streamARN :: Lens' GetRecords (Maybe Text)
getRecords_streamARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecords' {Maybe Text
streamARN :: Maybe Text
$sel:streamARN:GetRecords' :: GetRecords -> Maybe Text
streamARN} -> Maybe Text
streamARN) (\s :: GetRecords
s@GetRecords' {} Maybe Text
a -> GetRecords
s {$sel:streamARN:GetRecords' :: Maybe Text
streamARN = Maybe Text
a} :: GetRecords)
getRecords_shardIterator :: Lens.Lens' GetRecords Prelude.Text
getRecords_shardIterator :: Lens' GetRecords Text
getRecords_shardIterator = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecords' {Text
shardIterator :: Text
$sel:shardIterator:GetRecords' :: GetRecords -> Text
shardIterator} -> Text
shardIterator) (\s :: GetRecords
s@GetRecords' {} Text
a -> GetRecords
s {$sel:shardIterator:GetRecords' :: Text
shardIterator = Text
a} :: GetRecords)
instance Core.AWSRequest GetRecords where
type AWSResponse GetRecords = GetRecordsResponse
request :: (Service -> Service) -> GetRecords -> Request GetRecords
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 GetRecords
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetRecords)))
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 [ChildShard]
-> Maybe Natural
-> Maybe Text
-> Int
-> [Record]
-> GetRecordsResponse
GetRecordsResponse'
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
"ChildShards" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
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
"MillisBehindLatest")
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
"NextShardIterator")
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 (Maybe a)
Data..?> Key
"Records" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
)
instance Prelude.Hashable GetRecords where
hashWithSalt :: Int -> GetRecords -> Int
hashWithSalt Int
_salt GetRecords' {Maybe Natural
Maybe Text
Text
shardIterator :: Text
streamARN :: Maybe Text
limit :: Maybe Natural
$sel:shardIterator:GetRecords' :: GetRecords -> Text
$sel:streamARN:GetRecords' :: GetRecords -> Maybe Text
$sel:limit:GetRecords' :: GetRecords -> Maybe Natural
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
limit
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
streamARN
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
shardIterator
instance Prelude.NFData GetRecords where
rnf :: GetRecords -> ()
rnf GetRecords' {Maybe Natural
Maybe Text
Text
shardIterator :: Text
streamARN :: Maybe Text
limit :: Maybe Natural
$sel:shardIterator:GetRecords' :: GetRecords -> Text
$sel:streamARN:GetRecords' :: GetRecords -> Maybe Text
$sel:limit:GetRecords' :: GetRecords -> Maybe Natural
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
limit
seq :: forall a b. a -> b -> b
`Prelude.seq` 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 Text
shardIterator
instance Data.ToHeaders GetRecords where
toHeaders :: GetRecords -> 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.GetRecords" ::
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 GetRecords where
toJSON :: GetRecords -> Value
toJSON GetRecords' {Maybe Natural
Maybe Text
Text
shardIterator :: Text
streamARN :: Maybe Text
limit :: Maybe Natural
$sel:shardIterator:GetRecords' :: GetRecords -> Text
$sel:streamARN:GetRecords' :: GetRecords -> Maybe Text
$sel:limit:GetRecords' :: GetRecords -> Maybe Natural
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"Limit" 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 Natural
limit,
(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,
forall a. a -> Maybe a
Prelude.Just
(Key
"ShardIterator" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
shardIterator)
]
)
instance Data.ToPath GetRecords where
toPath :: GetRecords -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery GetRecords where
toQuery :: GetRecords -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data GetRecordsResponse = GetRecordsResponse'
{
GetRecordsResponse -> Maybe [ChildShard]
childShards :: Prelude.Maybe [ChildShard],
GetRecordsResponse -> Maybe Natural
millisBehindLatest :: Prelude.Maybe Prelude.Natural,
GetRecordsResponse -> Maybe Text
nextShardIterator :: Prelude.Maybe Prelude.Text,
GetRecordsResponse -> Int
httpStatus :: Prelude.Int,
GetRecordsResponse -> [Record]
records :: [Record]
}
deriving (GetRecordsResponse -> GetRecordsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRecordsResponse -> GetRecordsResponse -> Bool
$c/= :: GetRecordsResponse -> GetRecordsResponse -> Bool
== :: GetRecordsResponse -> GetRecordsResponse -> Bool
$c== :: GetRecordsResponse -> GetRecordsResponse -> Bool
Prelude.Eq, ReadPrec [GetRecordsResponse]
ReadPrec GetRecordsResponse
Int -> ReadS GetRecordsResponse
ReadS [GetRecordsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRecordsResponse]
$creadListPrec :: ReadPrec [GetRecordsResponse]
readPrec :: ReadPrec GetRecordsResponse
$creadPrec :: ReadPrec GetRecordsResponse
readList :: ReadS [GetRecordsResponse]
$creadList :: ReadS [GetRecordsResponse]
readsPrec :: Int -> ReadS GetRecordsResponse
$creadsPrec :: Int -> ReadS GetRecordsResponse
Prelude.Read, Int -> GetRecordsResponse -> ShowS
[GetRecordsResponse] -> ShowS
GetRecordsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRecordsResponse] -> ShowS
$cshowList :: [GetRecordsResponse] -> ShowS
show :: GetRecordsResponse -> String
$cshow :: GetRecordsResponse -> String
showsPrec :: Int -> GetRecordsResponse -> ShowS
$cshowsPrec :: Int -> GetRecordsResponse -> ShowS
Prelude.Show, forall x. Rep GetRecordsResponse x -> GetRecordsResponse
forall x. GetRecordsResponse -> Rep GetRecordsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetRecordsResponse x -> GetRecordsResponse
$cfrom :: forall x. GetRecordsResponse -> Rep GetRecordsResponse x
Prelude.Generic)
newGetRecordsResponse ::
Prelude.Int ->
GetRecordsResponse
newGetRecordsResponse :: Int -> GetRecordsResponse
newGetRecordsResponse Int
pHttpStatus_ =
GetRecordsResponse'
{ $sel:childShards:GetRecordsResponse' :: Maybe [ChildShard]
childShards = forall a. Maybe a
Prelude.Nothing,
$sel:millisBehindLatest:GetRecordsResponse' :: Maybe Natural
millisBehindLatest = forall a. Maybe a
Prelude.Nothing,
$sel:nextShardIterator:GetRecordsResponse' :: Maybe Text
nextShardIterator = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetRecordsResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:records:GetRecordsResponse' :: [Record]
records = forall a. Monoid a => a
Prelude.mempty
}
getRecordsResponse_childShards :: Lens.Lens' GetRecordsResponse (Prelude.Maybe [ChildShard])
getRecordsResponse_childShards :: Lens' GetRecordsResponse (Maybe [ChildShard])
getRecordsResponse_childShards = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecordsResponse' {Maybe [ChildShard]
childShards :: Maybe [ChildShard]
$sel:childShards:GetRecordsResponse' :: GetRecordsResponse -> Maybe [ChildShard]
childShards} -> Maybe [ChildShard]
childShards) (\s :: GetRecordsResponse
s@GetRecordsResponse' {} Maybe [ChildShard]
a -> GetRecordsResponse
s {$sel:childShards:GetRecordsResponse' :: Maybe [ChildShard]
childShards = Maybe [ChildShard]
a} :: GetRecordsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
getRecordsResponse_millisBehindLatest :: Lens.Lens' GetRecordsResponse (Prelude.Maybe Prelude.Natural)
getRecordsResponse_millisBehindLatest :: Lens' GetRecordsResponse (Maybe Natural)
getRecordsResponse_millisBehindLatest = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecordsResponse' {Maybe Natural
millisBehindLatest :: Maybe Natural
$sel:millisBehindLatest:GetRecordsResponse' :: GetRecordsResponse -> Maybe Natural
millisBehindLatest} -> Maybe Natural
millisBehindLatest) (\s :: GetRecordsResponse
s@GetRecordsResponse' {} Maybe Natural
a -> GetRecordsResponse
s {$sel:millisBehindLatest:GetRecordsResponse' :: Maybe Natural
millisBehindLatest = Maybe Natural
a} :: GetRecordsResponse)
getRecordsResponse_nextShardIterator :: Lens.Lens' GetRecordsResponse (Prelude.Maybe Prelude.Text)
getRecordsResponse_nextShardIterator :: Lens' GetRecordsResponse (Maybe Text)
getRecordsResponse_nextShardIterator = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecordsResponse' {Maybe Text
nextShardIterator :: Maybe Text
$sel:nextShardIterator:GetRecordsResponse' :: GetRecordsResponse -> Maybe Text
nextShardIterator} -> Maybe Text
nextShardIterator) (\s :: GetRecordsResponse
s@GetRecordsResponse' {} Maybe Text
a -> GetRecordsResponse
s {$sel:nextShardIterator:GetRecordsResponse' :: Maybe Text
nextShardIterator = Maybe Text
a} :: GetRecordsResponse)
getRecordsResponse_httpStatus :: Lens.Lens' GetRecordsResponse Prelude.Int
getRecordsResponse_httpStatus :: Lens' GetRecordsResponse Int
getRecordsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecordsResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetRecordsResponse' :: GetRecordsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetRecordsResponse
s@GetRecordsResponse' {} Int
a -> GetRecordsResponse
s {$sel:httpStatus:GetRecordsResponse' :: Int
httpStatus = Int
a} :: GetRecordsResponse)
getRecordsResponse_records :: Lens.Lens' GetRecordsResponse [Record]
getRecordsResponse_records :: Lens' GetRecordsResponse [Record]
getRecordsResponse_records = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecordsResponse' {[Record]
records :: [Record]
$sel:records:GetRecordsResponse' :: GetRecordsResponse -> [Record]
records} -> [Record]
records) (\s :: GetRecordsResponse
s@GetRecordsResponse' {} [Record]
a -> GetRecordsResponse
s {$sel:records:GetRecordsResponse' :: [Record]
records = [Record]
a} :: GetRecordsResponse) 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 GetRecordsResponse where
rnf :: GetRecordsResponse -> ()
rnf GetRecordsResponse' {Int
[Record]
Maybe Natural
Maybe [ChildShard]
Maybe Text
records :: [Record]
httpStatus :: Int
nextShardIterator :: Maybe Text
millisBehindLatest :: Maybe Natural
childShards :: Maybe [ChildShard]
$sel:records:GetRecordsResponse' :: GetRecordsResponse -> [Record]
$sel:httpStatus:GetRecordsResponse' :: GetRecordsResponse -> Int
$sel:nextShardIterator:GetRecordsResponse' :: GetRecordsResponse -> Maybe Text
$sel:millisBehindLatest:GetRecordsResponse' :: GetRecordsResponse -> Maybe Natural
$sel:childShards:GetRecordsResponse' :: GetRecordsResponse -> Maybe [ChildShard]
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe [ChildShard]
childShards
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
millisBehindLatest
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextShardIterator
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 [Record]
records