{-# 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.SubscribeToShard
(
SubscribeToShard (..),
newSubscribeToShard,
subscribeToShard_consumerARN,
subscribeToShard_shardId,
subscribeToShard_startingPosition,
SubscribeToShardResponse (..),
newSubscribeToShardResponse,
subscribeToShardResponse_httpStatus,
subscribeToShardResponse_eventStream,
)
where
import qualified Amazonka.Core as Core
import Amazonka.Kinesis.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 SubscribeToShard = SubscribeToShard'
{
SubscribeToShard -> Text
consumerARN :: Prelude.Text,
SubscribeToShard -> Text
shardId :: Prelude.Text,
SubscribeToShard -> StartingPosition
startingPosition :: StartingPosition
}
deriving (SubscribeToShard -> SubscribeToShard -> Bool
(SubscribeToShard -> SubscribeToShard -> Bool)
-> (SubscribeToShard -> SubscribeToShard -> Bool)
-> Eq SubscribeToShard
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SubscribeToShard -> SubscribeToShard -> Bool
$c/= :: SubscribeToShard -> SubscribeToShard -> Bool
== :: SubscribeToShard -> SubscribeToShard -> Bool
$c== :: SubscribeToShard -> SubscribeToShard -> Bool
Prelude.Eq, ReadPrec [SubscribeToShard]
ReadPrec SubscribeToShard
Int -> ReadS SubscribeToShard
ReadS [SubscribeToShard]
(Int -> ReadS SubscribeToShard)
-> ReadS [SubscribeToShard]
-> ReadPrec SubscribeToShard
-> ReadPrec [SubscribeToShard]
-> Read SubscribeToShard
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SubscribeToShard]
$creadListPrec :: ReadPrec [SubscribeToShard]
readPrec :: ReadPrec SubscribeToShard
$creadPrec :: ReadPrec SubscribeToShard
readList :: ReadS [SubscribeToShard]
$creadList :: ReadS [SubscribeToShard]
readsPrec :: Int -> ReadS SubscribeToShard
$creadsPrec :: Int -> ReadS SubscribeToShard
Prelude.Read, Int -> SubscribeToShard -> ShowS
[SubscribeToShard] -> ShowS
SubscribeToShard -> String
(Int -> SubscribeToShard -> ShowS)
-> (SubscribeToShard -> String)
-> ([SubscribeToShard] -> ShowS)
-> Show SubscribeToShard
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SubscribeToShard] -> ShowS
$cshowList :: [SubscribeToShard] -> ShowS
show :: SubscribeToShard -> String
$cshow :: SubscribeToShard -> String
showsPrec :: Int -> SubscribeToShard -> ShowS
$cshowsPrec :: Int -> SubscribeToShard -> ShowS
Prelude.Show, (forall x. SubscribeToShard -> Rep SubscribeToShard x)
-> (forall x. Rep SubscribeToShard x -> SubscribeToShard)
-> Generic SubscribeToShard
forall x. Rep SubscribeToShard x -> SubscribeToShard
forall x. SubscribeToShard -> Rep SubscribeToShard x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SubscribeToShard x -> SubscribeToShard
$cfrom :: forall x. SubscribeToShard -> Rep SubscribeToShard x
Prelude.Generic)
newSubscribeToShard ::
Prelude.Text ->
Prelude.Text ->
StartingPosition ->
SubscribeToShard
newSubscribeToShard :: Text -> Text -> StartingPosition -> SubscribeToShard
newSubscribeToShard
Text
pConsumerARN_
Text
pShardId_
StartingPosition
pStartingPosition_ =
SubscribeToShard' :: Text -> Text -> StartingPosition -> SubscribeToShard
SubscribeToShard'
{ $sel:consumerARN:SubscribeToShard' :: Text
consumerARN = Text
pConsumerARN_,
$sel:shardId:SubscribeToShard' :: Text
shardId = Text
pShardId_,
$sel:startingPosition:SubscribeToShard' :: StartingPosition
startingPosition = StartingPosition
pStartingPosition_
}
subscribeToShard_consumerARN :: Lens.Lens' SubscribeToShard Prelude.Text
subscribeToShard_consumerARN :: (Text -> f Text) -> SubscribeToShard -> f SubscribeToShard
subscribeToShard_consumerARN = (SubscribeToShard -> Text)
-> (SubscribeToShard -> Text -> SubscribeToShard)
-> Lens SubscribeToShard SubscribeToShard Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubscribeToShard' {Text
consumerARN :: Text
$sel:consumerARN:SubscribeToShard' :: SubscribeToShard -> Text
consumerARN} -> Text
consumerARN) (\s :: SubscribeToShard
s@SubscribeToShard' {} Text
a -> SubscribeToShard
s {$sel:consumerARN:SubscribeToShard' :: Text
consumerARN = Text
a} :: SubscribeToShard)
subscribeToShard_shardId :: Lens.Lens' SubscribeToShard Prelude.Text
subscribeToShard_shardId :: (Text -> f Text) -> SubscribeToShard -> f SubscribeToShard
subscribeToShard_shardId = (SubscribeToShard -> Text)
-> (SubscribeToShard -> Text -> SubscribeToShard)
-> Lens SubscribeToShard SubscribeToShard Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubscribeToShard' {Text
shardId :: Text
$sel:shardId:SubscribeToShard' :: SubscribeToShard -> Text
shardId} -> Text
shardId) (\s :: SubscribeToShard
s@SubscribeToShard' {} Text
a -> SubscribeToShard
s {$sel:shardId:SubscribeToShard' :: Text
shardId = Text
a} :: SubscribeToShard)
subscribeToShard_startingPosition :: Lens.Lens' SubscribeToShard StartingPosition
subscribeToShard_startingPosition :: (StartingPosition -> f StartingPosition)
-> SubscribeToShard -> f SubscribeToShard
subscribeToShard_startingPosition = (SubscribeToShard -> StartingPosition)
-> (SubscribeToShard -> StartingPosition -> SubscribeToShard)
-> Lens
SubscribeToShard SubscribeToShard StartingPosition StartingPosition
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubscribeToShard' {StartingPosition
startingPosition :: StartingPosition
$sel:startingPosition:SubscribeToShard' :: SubscribeToShard -> StartingPosition
startingPosition} -> StartingPosition
startingPosition) (\s :: SubscribeToShard
s@SubscribeToShard' {} StartingPosition
a -> SubscribeToShard
s {$sel:startingPosition:SubscribeToShard' :: StartingPosition
startingPosition = StartingPosition
a} :: SubscribeToShard)
instance Core.AWSRequest SubscribeToShard where
type
AWSResponse SubscribeToShard =
SubscribeToShardResponse
request :: SubscribeToShard -> Request SubscribeToShard
request = Service -> SubscribeToShard -> Request SubscribeToShard
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy SubscribeToShard
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SubscribeToShard)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse SubscribeToShard))
-> Logger
-> Service
-> Proxy SubscribeToShard
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SubscribeToShard)))
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 -> Value -> SubscribeToShardResponse
SubscribeToShardResponse'
(Int -> Value -> SubscribeToShardResponse)
-> Either String Int
-> Either String (Value -> SubscribeToShardResponse)
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 (Value -> SubscribeToShardResponse)
-> Either String Value -> Either String SubscribeToShardResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Value
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"EventStream")
)
instance Prelude.Hashable SubscribeToShard
instance Prelude.NFData SubscribeToShard
instance Core.ToHeaders SubscribeToShard where
toHeaders :: SubscribeToShard -> ResponseHeaders
toHeaders =
ResponseHeaders -> SubscribeToShard -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"Kinesis_20131202.SubscribeToShard" ::
Prelude.ByteString
),
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 SubscribeToShard where
toJSON :: SubscribeToShard -> Value
toJSON SubscribeToShard' {Text
StartingPosition
startingPosition :: StartingPosition
shardId :: Text
consumerARN :: Text
$sel:startingPosition:SubscribeToShard' :: SubscribeToShard -> StartingPosition
$sel:shardId:SubscribeToShard' :: SubscribeToShard -> Text
$sel:consumerARN:SubscribeToShard' :: SubscribeToShard -> 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
"ConsumerARN" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
consumerARN),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ShardId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
shardId),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"StartingPosition" Text -> StartingPosition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= StartingPosition
startingPosition)
]
)
instance Core.ToPath SubscribeToShard where
toPath :: SubscribeToShard -> ByteString
toPath = ByteString -> SubscribeToShard -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery SubscribeToShard where
toQuery :: SubscribeToShard -> QueryString
toQuery = QueryString -> SubscribeToShard -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data SubscribeToShardResponse = SubscribeToShardResponse'
{
SubscribeToShardResponse -> Int
httpStatus :: Prelude.Int,
SubscribeToShardResponse -> Value
eventStream :: Core.Value
}
deriving ((forall x.
SubscribeToShardResponse -> Rep SubscribeToShardResponse x)
-> (forall x.
Rep SubscribeToShardResponse x -> SubscribeToShardResponse)
-> Generic SubscribeToShardResponse
forall x.
Rep SubscribeToShardResponse x -> SubscribeToShardResponse
forall x.
SubscribeToShardResponse -> Rep SubscribeToShardResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SubscribeToShardResponse x -> SubscribeToShardResponse
$cfrom :: forall x.
SubscribeToShardResponse -> Rep SubscribeToShardResponse x
Prelude.Generic)
newSubscribeToShardResponse ::
Prelude.Int ->
Core.Value ->
SubscribeToShardResponse
newSubscribeToShardResponse :: Int -> Value -> SubscribeToShardResponse
newSubscribeToShardResponse
Int
pHttpStatus_
Value
pEventStream_ =
SubscribeToShardResponse' :: Int -> Value -> SubscribeToShardResponse
SubscribeToShardResponse'
{ $sel:httpStatus:SubscribeToShardResponse' :: Int
httpStatus =
Int
pHttpStatus_,
$sel:eventStream:SubscribeToShardResponse' :: Value
eventStream = Value
pEventStream_
}
subscribeToShardResponse_httpStatus :: Lens.Lens' SubscribeToShardResponse Prelude.Int
subscribeToShardResponse_httpStatus :: (Int -> f Int)
-> SubscribeToShardResponse -> f SubscribeToShardResponse
subscribeToShardResponse_httpStatus = (SubscribeToShardResponse -> Int)
-> (SubscribeToShardResponse -> Int -> SubscribeToShardResponse)
-> Lens SubscribeToShardResponse SubscribeToShardResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubscribeToShardResponse' {Int
httpStatus :: Int
$sel:httpStatus:SubscribeToShardResponse' :: SubscribeToShardResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: SubscribeToShardResponse
s@SubscribeToShardResponse' {} Int
a -> SubscribeToShardResponse
s {$sel:httpStatus:SubscribeToShardResponse' :: Int
httpStatus = Int
a} :: SubscribeToShardResponse)
subscribeToShardResponse_eventStream :: Lens.Lens' SubscribeToShardResponse Core.Value
subscribeToShardResponse_eventStream :: (Value -> f Value)
-> SubscribeToShardResponse -> f SubscribeToShardResponse
subscribeToShardResponse_eventStream = (SubscribeToShardResponse -> Value)
-> (SubscribeToShardResponse -> Value -> SubscribeToShardResponse)
-> Lens
SubscribeToShardResponse SubscribeToShardResponse Value Value
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubscribeToShardResponse' {Value
eventStream :: Value
$sel:eventStream:SubscribeToShardResponse' :: SubscribeToShardResponse -> Value
eventStream} -> Value
eventStream) (\s :: SubscribeToShardResponse
s@SubscribeToShardResponse' {} Value
a -> SubscribeToShardResponse
s {$sel:eventStream:SubscribeToShardResponse' :: Value
eventStream = Value
a} :: SubscribeToShardResponse)
instance Prelude.NFData SubscribeToShardResponse