{-# 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.ListStreams
(
ListStreams (..),
newListStreams,
listStreams_limit,
listStreams_exclusiveStartStreamName,
ListStreamsResponse (..),
newListStreamsResponse,
listStreamsResponse_httpStatus,
listStreamsResponse_streamNames,
listStreamsResponse_hasMoreStreams,
)
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 ListStreams = ListStreams'
{
ListStreams -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
ListStreams -> Maybe Text
exclusiveStartStreamName :: Prelude.Maybe Prelude.Text
}
deriving (ListStreams -> ListStreams -> Bool
(ListStreams -> ListStreams -> Bool)
-> (ListStreams -> ListStreams -> Bool) -> Eq ListStreams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListStreams -> ListStreams -> Bool
$c/= :: ListStreams -> ListStreams -> Bool
== :: ListStreams -> ListStreams -> Bool
$c== :: ListStreams -> ListStreams -> Bool
Prelude.Eq, ReadPrec [ListStreams]
ReadPrec ListStreams
Int -> ReadS ListStreams
ReadS [ListStreams]
(Int -> ReadS ListStreams)
-> ReadS [ListStreams]
-> ReadPrec ListStreams
-> ReadPrec [ListStreams]
-> Read ListStreams
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListStreams]
$creadListPrec :: ReadPrec [ListStreams]
readPrec :: ReadPrec ListStreams
$creadPrec :: ReadPrec ListStreams
readList :: ReadS [ListStreams]
$creadList :: ReadS [ListStreams]
readsPrec :: Int -> ReadS ListStreams
$creadsPrec :: Int -> ReadS ListStreams
Prelude.Read, Int -> ListStreams -> ShowS
[ListStreams] -> ShowS
ListStreams -> String
(Int -> ListStreams -> ShowS)
-> (ListStreams -> String)
-> ([ListStreams] -> ShowS)
-> Show ListStreams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListStreams] -> ShowS
$cshowList :: [ListStreams] -> ShowS
show :: ListStreams -> String
$cshow :: ListStreams -> String
showsPrec :: Int -> ListStreams -> ShowS
$cshowsPrec :: Int -> ListStreams -> ShowS
Prelude.Show, (forall x. ListStreams -> Rep ListStreams x)
-> (forall x. Rep ListStreams x -> ListStreams)
-> Generic ListStreams
forall x. Rep ListStreams x -> ListStreams
forall x. ListStreams -> Rep ListStreams x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListStreams x -> ListStreams
$cfrom :: forall x. ListStreams -> Rep ListStreams x
Prelude.Generic)
newListStreams ::
ListStreams
newListStreams :: ListStreams
newListStreams =
ListStreams' :: Maybe Natural -> Maybe Text -> ListStreams
ListStreams'
{ $sel:limit:ListStreams' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
$sel:exclusiveStartStreamName:ListStreams' :: Maybe Text
exclusiveStartStreamName = Maybe Text
forall a. Maybe a
Prelude.Nothing
}
listStreams_limit :: Lens.Lens' ListStreams (Prelude.Maybe Prelude.Natural)
listStreams_limit :: (Maybe Natural -> f (Maybe Natural))
-> ListStreams -> f ListStreams
listStreams_limit = (ListStreams -> Maybe Natural)
-> (ListStreams -> Maybe Natural -> ListStreams)
-> Lens ListStreams ListStreams (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStreams' {Maybe Natural
limit :: Maybe Natural
$sel:limit:ListStreams' :: ListStreams -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: ListStreams
s@ListStreams' {} Maybe Natural
a -> ListStreams
s {$sel:limit:ListStreams' :: Maybe Natural
limit = Maybe Natural
a} :: ListStreams)
listStreams_exclusiveStartStreamName :: Lens.Lens' ListStreams (Prelude.Maybe Prelude.Text)
listStreams_exclusiveStartStreamName :: (Maybe Text -> f (Maybe Text)) -> ListStreams -> f ListStreams
listStreams_exclusiveStartStreamName = (ListStreams -> Maybe Text)
-> (ListStreams -> Maybe Text -> ListStreams)
-> Lens ListStreams ListStreams (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStreams' {Maybe Text
exclusiveStartStreamName :: Maybe Text
$sel:exclusiveStartStreamName:ListStreams' :: ListStreams -> Maybe Text
exclusiveStartStreamName} -> Maybe Text
exclusiveStartStreamName) (\s :: ListStreams
s@ListStreams' {} Maybe Text
a -> ListStreams
s {$sel:exclusiveStartStreamName:ListStreams' :: Maybe Text
exclusiveStartStreamName = Maybe Text
a} :: ListStreams)
instance Core.AWSPager ListStreams where
page :: ListStreams -> AWSResponse ListStreams -> Maybe ListStreams
page ListStreams
rq AWSResponse ListStreams
rs
| Bool -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
(AWSResponse ListStreams
ListStreamsResponse
rs ListStreamsResponse
-> Getting Bool ListStreamsResponse Bool -> Bool
forall s a. s -> Getting a s a -> a
Lens.^. Getting Bool ListStreamsResponse Bool
Lens' ListStreamsResponse Bool
listStreamsResponse_hasMoreStreams) =
Maybe ListStreams
forall a. Maybe a
Prelude.Nothing
| Maybe Text -> Bool
forall a. Maybe a -> Bool
Prelude.isNothing
( AWSResponse ListStreams
ListStreamsResponse
rs
ListStreamsResponse
-> Getting (First Text) ListStreamsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? ([Text] -> Const (First Text) [Text])
-> ListStreamsResponse -> Const (First Text) ListStreamsResponse
Lens' ListStreamsResponse [Text]
listStreamsResponse_streamNames (([Text] -> Const (First Text) [Text])
-> ListStreamsResponse -> Const (First Text) ListStreamsResponse)
-> ((Text -> Const (First Text) Text)
-> [Text] -> Const (First Text) [Text])
-> Getting (First Text) ListStreamsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> [Text] -> Const (First Text) [Text]
forall s a. Snoc s s a a => Traversal' s a
Lens._last
) =
Maybe ListStreams
forall a. Maybe a
Prelude.Nothing
| Bool
Prelude.otherwise =
ListStreams -> Maybe ListStreams
forall a. a -> Maybe a
Prelude.Just (ListStreams -> Maybe ListStreams)
-> ListStreams -> Maybe ListStreams
forall a b. (a -> b) -> a -> b
Prelude.$
ListStreams
rq
ListStreams -> (ListStreams -> ListStreams) -> ListStreams
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListStreams -> Identity ListStreams
Lens ListStreams ListStreams (Maybe Text) (Maybe Text)
listStreams_exclusiveStartStreamName
((Maybe Text -> Identity (Maybe Text))
-> ListStreams -> Identity ListStreams)
-> Maybe Text -> ListStreams -> ListStreams
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListStreams
ListStreamsResponse
rs
ListStreamsResponse
-> Getting (First Text) ListStreamsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? ([Text] -> Const (First Text) [Text])
-> ListStreamsResponse -> Const (First Text) ListStreamsResponse
Lens' ListStreamsResponse [Text]
listStreamsResponse_streamNames (([Text] -> Const (First Text) [Text])
-> ListStreamsResponse -> Const (First Text) ListStreamsResponse)
-> ((Text -> Const (First Text) Text)
-> [Text] -> Const (First Text) [Text])
-> Getting (First Text) ListStreamsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> [Text] -> Const (First Text) [Text]
forall s a. Snoc s s a a => Traversal' s a
Lens._last
instance Core.AWSRequest ListStreams where
type AWSResponse ListStreams = ListStreamsResponse
request :: ListStreams -> Request ListStreams
request = Service -> ListStreams -> Request ListStreams
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy ListStreams
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListStreams)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse ListStreams))
-> Logger
-> Service
-> Proxy ListStreams
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListStreams)))
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 -> [Text] -> Bool -> ListStreamsResponse
ListStreamsResponse'
(Int -> [Text] -> Bool -> ListStreamsResponse)
-> Either String Int
-> Either String ([Text] -> Bool -> ListStreamsResponse)
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 ([Text] -> Bool -> ListStreamsResponse)
-> Either String [Text]
-> Either String (Bool -> ListStreamsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe [Text])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"StreamNames" Either String (Maybe [Text]) -> [Text] -> Either String [Text]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Text]
forall a. Monoid a => a
Prelude.mempty)
Either String (Bool -> ListStreamsResponse)
-> Either String Bool -> Either String ListStreamsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Bool
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"HasMoreStreams")
)
instance Prelude.Hashable ListStreams
instance Prelude.NFData ListStreams
instance Core.ToHeaders ListStreams where
toHeaders :: ListStreams -> ResponseHeaders
toHeaders =
ResponseHeaders -> ListStreams -> 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.ListStreams" ::
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 ListStreams where
toJSON :: ListStreams -> Value
toJSON ListStreams' {Maybe Natural
Maybe Text
exclusiveStartStreamName :: Maybe Text
limit :: Maybe Natural
$sel:exclusiveStartStreamName:ListStreams' :: ListStreams -> Maybe Text
$sel:limit:ListStreams' :: ListStreams -> Maybe Natural
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Limit" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
limit,
(Text
"ExclusiveStartStreamName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
exclusiveStartStreamName
]
)
instance Core.ToPath ListStreams where
toPath :: ListStreams -> ByteString
toPath = ByteString -> ListStreams -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery ListStreams where
toQuery :: ListStreams -> QueryString
toQuery = QueryString -> ListStreams -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data ListStreamsResponse = ListStreamsResponse'
{
ListStreamsResponse -> Int
httpStatus :: Prelude.Int,
ListStreamsResponse -> [Text]
streamNames :: [Prelude.Text],
ListStreamsResponse -> Bool
hasMoreStreams :: Prelude.Bool
}
deriving (ListStreamsResponse -> ListStreamsResponse -> Bool
(ListStreamsResponse -> ListStreamsResponse -> Bool)
-> (ListStreamsResponse -> ListStreamsResponse -> Bool)
-> Eq ListStreamsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListStreamsResponse -> ListStreamsResponse -> Bool
$c/= :: ListStreamsResponse -> ListStreamsResponse -> Bool
== :: ListStreamsResponse -> ListStreamsResponse -> Bool
$c== :: ListStreamsResponse -> ListStreamsResponse -> Bool
Prelude.Eq, ReadPrec [ListStreamsResponse]
ReadPrec ListStreamsResponse
Int -> ReadS ListStreamsResponse
ReadS [ListStreamsResponse]
(Int -> ReadS ListStreamsResponse)
-> ReadS [ListStreamsResponse]
-> ReadPrec ListStreamsResponse
-> ReadPrec [ListStreamsResponse]
-> Read ListStreamsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListStreamsResponse]
$creadListPrec :: ReadPrec [ListStreamsResponse]
readPrec :: ReadPrec ListStreamsResponse
$creadPrec :: ReadPrec ListStreamsResponse
readList :: ReadS [ListStreamsResponse]
$creadList :: ReadS [ListStreamsResponse]
readsPrec :: Int -> ReadS ListStreamsResponse
$creadsPrec :: Int -> ReadS ListStreamsResponse
Prelude.Read, Int -> ListStreamsResponse -> ShowS
[ListStreamsResponse] -> ShowS
ListStreamsResponse -> String
(Int -> ListStreamsResponse -> ShowS)
-> (ListStreamsResponse -> String)
-> ([ListStreamsResponse] -> ShowS)
-> Show ListStreamsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListStreamsResponse] -> ShowS
$cshowList :: [ListStreamsResponse] -> ShowS
show :: ListStreamsResponse -> String
$cshow :: ListStreamsResponse -> String
showsPrec :: Int -> ListStreamsResponse -> ShowS
$cshowsPrec :: Int -> ListStreamsResponse -> ShowS
Prelude.Show, (forall x. ListStreamsResponse -> Rep ListStreamsResponse x)
-> (forall x. Rep ListStreamsResponse x -> ListStreamsResponse)
-> Generic ListStreamsResponse
forall x. Rep ListStreamsResponse x -> ListStreamsResponse
forall x. ListStreamsResponse -> Rep ListStreamsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListStreamsResponse x -> ListStreamsResponse
$cfrom :: forall x. ListStreamsResponse -> Rep ListStreamsResponse x
Prelude.Generic)
newListStreamsResponse ::
Prelude.Int ->
Prelude.Bool ->
ListStreamsResponse
newListStreamsResponse :: Int -> Bool -> ListStreamsResponse
newListStreamsResponse Int
pHttpStatus_ Bool
pHasMoreStreams_ =
ListStreamsResponse' :: Int -> [Text] -> Bool -> ListStreamsResponse
ListStreamsResponse'
{ $sel:httpStatus:ListStreamsResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:streamNames:ListStreamsResponse' :: [Text]
streamNames = [Text]
forall a. Monoid a => a
Prelude.mempty,
$sel:hasMoreStreams:ListStreamsResponse' :: Bool
hasMoreStreams = Bool
pHasMoreStreams_
}
listStreamsResponse_httpStatus :: Lens.Lens' ListStreamsResponse Prelude.Int
listStreamsResponse_httpStatus :: (Int -> f Int) -> ListStreamsResponse -> f ListStreamsResponse
listStreamsResponse_httpStatus = (ListStreamsResponse -> Int)
-> (ListStreamsResponse -> Int -> ListStreamsResponse)
-> Lens ListStreamsResponse ListStreamsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStreamsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListStreamsResponse' :: ListStreamsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListStreamsResponse
s@ListStreamsResponse' {} Int
a -> ListStreamsResponse
s {$sel:httpStatus:ListStreamsResponse' :: Int
httpStatus = Int
a} :: ListStreamsResponse)
listStreamsResponse_streamNames :: Lens.Lens' ListStreamsResponse [Prelude.Text]
listStreamsResponse_streamNames :: ([Text] -> f [Text])
-> ListStreamsResponse -> f ListStreamsResponse
listStreamsResponse_streamNames = (ListStreamsResponse -> [Text])
-> (ListStreamsResponse -> [Text] -> ListStreamsResponse)
-> Lens' ListStreamsResponse [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStreamsResponse' {[Text]
streamNames :: [Text]
$sel:streamNames:ListStreamsResponse' :: ListStreamsResponse -> [Text]
streamNames} -> [Text]
streamNames) (\s :: ListStreamsResponse
s@ListStreamsResponse' {} [Text]
a -> ListStreamsResponse
s {$sel:streamNames:ListStreamsResponse' :: [Text]
streamNames = [Text]
a} :: ListStreamsResponse) (([Text] -> f [Text])
-> ListStreamsResponse -> f ListStreamsResponse)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> ListStreamsResponse
-> f ListStreamsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
listStreamsResponse_hasMoreStreams :: Lens.Lens' ListStreamsResponse Prelude.Bool
listStreamsResponse_hasMoreStreams :: (Bool -> f Bool) -> ListStreamsResponse -> f ListStreamsResponse
listStreamsResponse_hasMoreStreams = (ListStreamsResponse -> Bool)
-> (ListStreamsResponse -> Bool -> ListStreamsResponse)
-> Lens' ListStreamsResponse Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStreamsResponse' {Bool
hasMoreStreams :: Bool
$sel:hasMoreStreams:ListStreamsResponse' :: ListStreamsResponse -> Bool
hasMoreStreams} -> Bool
hasMoreStreams) (\s :: ListStreamsResponse
s@ListStreamsResponse' {} Bool
a -> ListStreamsResponse
s {$sel:hasMoreStreams:ListStreamsResponse' :: Bool
hasMoreStreams = Bool
a} :: ListStreamsResponse)
instance Prelude.NFData ListStreamsResponse