{-# 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.SNS.ListTopics
(
ListTopics (..),
newListTopics,
listTopics_nextToken,
ListTopicsResponse (..),
newListTopicsResponse,
listTopicsResponse_topics,
listTopicsResponse_nextToken,
listTopicsResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SNS.Types
data ListTopics = ListTopics'
{
ListTopics -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
}
deriving (ListTopics -> ListTopics -> Bool
(ListTopics -> ListTopics -> Bool)
-> (ListTopics -> ListTopics -> Bool) -> Eq ListTopics
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTopics -> ListTopics -> Bool
$c/= :: ListTopics -> ListTopics -> Bool
== :: ListTopics -> ListTopics -> Bool
$c== :: ListTopics -> ListTopics -> Bool
Prelude.Eq, ReadPrec [ListTopics]
ReadPrec ListTopics
Int -> ReadS ListTopics
ReadS [ListTopics]
(Int -> ReadS ListTopics)
-> ReadS [ListTopics]
-> ReadPrec ListTopics
-> ReadPrec [ListTopics]
-> Read ListTopics
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTopics]
$creadListPrec :: ReadPrec [ListTopics]
readPrec :: ReadPrec ListTopics
$creadPrec :: ReadPrec ListTopics
readList :: ReadS [ListTopics]
$creadList :: ReadS [ListTopics]
readsPrec :: Int -> ReadS ListTopics
$creadsPrec :: Int -> ReadS ListTopics
Prelude.Read, Int -> ListTopics -> ShowS
[ListTopics] -> ShowS
ListTopics -> String
(Int -> ListTopics -> ShowS)
-> (ListTopics -> String)
-> ([ListTopics] -> ShowS)
-> Show ListTopics
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTopics] -> ShowS
$cshowList :: [ListTopics] -> ShowS
show :: ListTopics -> String
$cshow :: ListTopics -> String
showsPrec :: Int -> ListTopics -> ShowS
$cshowsPrec :: Int -> ListTopics -> ShowS
Prelude.Show, (forall x. ListTopics -> Rep ListTopics x)
-> (forall x. Rep ListTopics x -> ListTopics) -> Generic ListTopics
forall x. Rep ListTopics x -> ListTopics
forall x. ListTopics -> Rep ListTopics x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListTopics x -> ListTopics
$cfrom :: forall x. ListTopics -> Rep ListTopics x
Prelude.Generic)
newListTopics ::
ListTopics
newListTopics :: ListTopics
newListTopics =
ListTopics' :: Maybe Text -> ListTopics
ListTopics' {$sel:nextToken:ListTopics' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing}
listTopics_nextToken :: Lens.Lens' ListTopics (Prelude.Maybe Prelude.Text)
listTopics_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListTopics -> f ListTopics
listTopics_nextToken = (ListTopics -> Maybe Text)
-> (ListTopics -> Maybe Text -> ListTopics)
-> Lens ListTopics ListTopics (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTopics' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListTopics' :: ListTopics -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListTopics
s@ListTopics' {} Maybe Text
a -> ListTopics
s {$sel:nextToken:ListTopics' :: Maybe Text
nextToken = Maybe Text
a} :: ListTopics)
instance Core.AWSPager ListTopics where
page :: ListTopics -> AWSResponse ListTopics -> Maybe ListTopics
page ListTopics
rq AWSResponse ListTopics
rs
| Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse ListTopics
ListTopicsResponse
rs
ListTopicsResponse
-> Getting (First Text) ListTopicsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListTopicsResponse -> Const (First Text) ListTopicsResponse
Lens' ListTopicsResponse (Maybe Text)
listTopicsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
-> ListTopicsResponse -> Const (First Text) ListTopicsResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListTopicsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
Maybe ListTopics
forall a. Maybe a
Prelude.Nothing
| Maybe [Topic] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse ListTopics
ListTopicsResponse
rs
ListTopicsResponse
-> Getting (First [Topic]) ListTopicsResponse [Topic]
-> Maybe [Topic]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Topic] -> Const (First [Topic]) (Maybe [Topic]))
-> ListTopicsResponse -> Const (First [Topic]) ListTopicsResponse
Lens' ListTopicsResponse (Maybe [Topic])
listTopicsResponse_topics ((Maybe [Topic] -> Const (First [Topic]) (Maybe [Topic]))
-> ListTopicsResponse -> Const (First [Topic]) ListTopicsResponse)
-> (([Topic] -> Const (First [Topic]) [Topic])
-> Maybe [Topic] -> Const (First [Topic]) (Maybe [Topic]))
-> Getting (First [Topic]) ListTopicsResponse [Topic]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Topic] -> Const (First [Topic]) [Topic])
-> Maybe [Topic] -> Const (First [Topic]) (Maybe [Topic])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
Maybe ListTopics
forall a. Maybe a
Prelude.Nothing
| Bool
Prelude.otherwise =
ListTopics -> Maybe ListTopics
forall a. a -> Maybe a
Prelude.Just (ListTopics -> Maybe ListTopics) -> ListTopics -> Maybe ListTopics
forall a b. (a -> b) -> a -> b
Prelude.$
ListTopics
rq
ListTopics -> (ListTopics -> ListTopics) -> ListTopics
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListTopics -> Identity ListTopics
Lens ListTopics ListTopics (Maybe Text) (Maybe Text)
listTopics_nextToken
((Maybe Text -> Identity (Maybe Text))
-> ListTopics -> Identity ListTopics)
-> Maybe Text -> ListTopics -> ListTopics
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListTopics
ListTopicsResponse
rs
ListTopicsResponse
-> Getting (First Text) ListTopicsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListTopicsResponse -> Const (First Text) ListTopicsResponse
Lens' ListTopicsResponse (Maybe Text)
listTopicsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
-> ListTopicsResponse -> Const (First Text) ListTopicsResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListTopicsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
instance Core.AWSRequest ListTopics where
type AWSResponse ListTopics = ListTopicsResponse
request :: ListTopics -> Request ListTopics
request = Service -> ListTopics -> Request ListTopics
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
response :: Logger
-> Service
-> Proxy ListTopics
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListTopics)))
response =
Text
-> (Int
-> ResponseHeaders
-> [Node]
-> Either String (AWSResponse ListTopics))
-> Logger
-> Service
-> Proxy ListTopics
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListTopics)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
-> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
Text
"ListTopicsResult"
( \Int
s ResponseHeaders
h [Node]
x ->
Maybe [Topic] -> Maybe Text -> Int -> ListTopicsResponse
ListTopicsResponse'
(Maybe [Topic] -> Maybe Text -> Int -> ListTopicsResponse)
-> Either String (Maybe [Topic])
-> Either String (Maybe Text -> Int -> ListTopicsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Topics" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
Either String [Node]
-> ([Node] -> Either String (Maybe [Topic]))
-> Either String (Maybe [Topic])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Topic])
-> [Node] -> Either String (Maybe [Topic])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Topic]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
)
Either String (Maybe Text -> Int -> ListTopicsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ListTopicsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"NextToken")
Either String (Int -> ListTopicsResponse)
-> Either String Int -> Either String ListTopicsResponse
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 ListTopics
instance Prelude.NFData ListTopics
instance Core.ToHeaders ListTopics where
toHeaders :: ListTopics -> ResponseHeaders
toHeaders = ResponseHeaders -> ListTopics -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToPath ListTopics where
toPath :: ListTopics -> ByteString
toPath = ByteString -> ListTopics -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery ListTopics where
toQuery :: ListTopics -> QueryString
toQuery ListTopics' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListTopics' :: ListTopics -> Maybe Text
..} =
[QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"Action"
ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"ListTopics" :: Prelude.ByteString),
ByteString
"Version"
ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-03-31" :: Prelude.ByteString),
ByteString
"NextToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nextToken
]
data ListTopicsResponse = ListTopicsResponse'
{
ListTopicsResponse -> Maybe [Topic]
topics :: Prelude.Maybe [Topic],
ListTopicsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
ListTopicsResponse -> Int
httpStatus :: Prelude.Int
}
deriving (ListTopicsResponse -> ListTopicsResponse -> Bool
(ListTopicsResponse -> ListTopicsResponse -> Bool)
-> (ListTopicsResponse -> ListTopicsResponse -> Bool)
-> Eq ListTopicsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTopicsResponse -> ListTopicsResponse -> Bool
$c/= :: ListTopicsResponse -> ListTopicsResponse -> Bool
== :: ListTopicsResponse -> ListTopicsResponse -> Bool
$c== :: ListTopicsResponse -> ListTopicsResponse -> Bool
Prelude.Eq, ReadPrec [ListTopicsResponse]
ReadPrec ListTopicsResponse
Int -> ReadS ListTopicsResponse
ReadS [ListTopicsResponse]
(Int -> ReadS ListTopicsResponse)
-> ReadS [ListTopicsResponse]
-> ReadPrec ListTopicsResponse
-> ReadPrec [ListTopicsResponse]
-> Read ListTopicsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTopicsResponse]
$creadListPrec :: ReadPrec [ListTopicsResponse]
readPrec :: ReadPrec ListTopicsResponse
$creadPrec :: ReadPrec ListTopicsResponse
readList :: ReadS [ListTopicsResponse]
$creadList :: ReadS [ListTopicsResponse]
readsPrec :: Int -> ReadS ListTopicsResponse
$creadsPrec :: Int -> ReadS ListTopicsResponse
Prelude.Read, Int -> ListTopicsResponse -> ShowS
[ListTopicsResponse] -> ShowS
ListTopicsResponse -> String
(Int -> ListTopicsResponse -> ShowS)
-> (ListTopicsResponse -> String)
-> ([ListTopicsResponse] -> ShowS)
-> Show ListTopicsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTopicsResponse] -> ShowS
$cshowList :: [ListTopicsResponse] -> ShowS
show :: ListTopicsResponse -> String
$cshow :: ListTopicsResponse -> String
showsPrec :: Int -> ListTopicsResponse -> ShowS
$cshowsPrec :: Int -> ListTopicsResponse -> ShowS
Prelude.Show, (forall x. ListTopicsResponse -> Rep ListTopicsResponse x)
-> (forall x. Rep ListTopicsResponse x -> ListTopicsResponse)
-> Generic ListTopicsResponse
forall x. Rep ListTopicsResponse x -> ListTopicsResponse
forall x. ListTopicsResponse -> Rep ListTopicsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListTopicsResponse x -> ListTopicsResponse
$cfrom :: forall x. ListTopicsResponse -> Rep ListTopicsResponse x
Prelude.Generic)
newListTopicsResponse ::
Prelude.Int ->
ListTopicsResponse
newListTopicsResponse :: Int -> ListTopicsResponse
newListTopicsResponse Int
pHttpStatus_ =
ListTopicsResponse' :: Maybe [Topic] -> Maybe Text -> Int -> ListTopicsResponse
ListTopicsResponse'
{ $sel:topics:ListTopicsResponse' :: Maybe [Topic]
topics = Maybe [Topic]
forall a. Maybe a
Prelude.Nothing,
$sel:nextToken:ListTopicsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:ListTopicsResponse' :: Int
httpStatus = Int
pHttpStatus_
}
listTopicsResponse_topics :: Lens.Lens' ListTopicsResponse (Prelude.Maybe [Topic])
listTopicsResponse_topics :: (Maybe [Topic] -> f (Maybe [Topic]))
-> ListTopicsResponse -> f ListTopicsResponse
listTopicsResponse_topics = (ListTopicsResponse -> Maybe [Topic])
-> (ListTopicsResponse -> Maybe [Topic] -> ListTopicsResponse)
-> Lens' ListTopicsResponse (Maybe [Topic])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTopicsResponse' {Maybe [Topic]
topics :: Maybe [Topic]
$sel:topics:ListTopicsResponse' :: ListTopicsResponse -> Maybe [Topic]
topics} -> Maybe [Topic]
topics) (\s :: ListTopicsResponse
s@ListTopicsResponse' {} Maybe [Topic]
a -> ListTopicsResponse
s {$sel:topics:ListTopicsResponse' :: Maybe [Topic]
topics = Maybe [Topic]
a} :: ListTopicsResponse) ((Maybe [Topic] -> f (Maybe [Topic]))
-> ListTopicsResponse -> f ListTopicsResponse)
-> ((Maybe [Topic] -> f (Maybe [Topic]))
-> Maybe [Topic] -> f (Maybe [Topic]))
-> (Maybe [Topic] -> f (Maybe [Topic]))
-> ListTopicsResponse
-> f ListTopicsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Topic] [Topic] [Topic] [Topic]
-> Iso
(Maybe [Topic]) (Maybe [Topic]) (Maybe [Topic]) (Maybe [Topic])
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 [Topic] [Topic] [Topic] [Topic]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
listTopicsResponse_nextToken :: Lens.Lens' ListTopicsResponse (Prelude.Maybe Prelude.Text)
listTopicsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListTopicsResponse -> f ListTopicsResponse
listTopicsResponse_nextToken = (ListTopicsResponse -> Maybe Text)
-> (ListTopicsResponse -> Maybe Text -> ListTopicsResponse)
-> Lens' ListTopicsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTopicsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListTopicsResponse' :: ListTopicsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListTopicsResponse
s@ListTopicsResponse' {} Maybe Text
a -> ListTopicsResponse
s {$sel:nextToken:ListTopicsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListTopicsResponse)
listTopicsResponse_httpStatus :: Lens.Lens' ListTopicsResponse Prelude.Int
listTopicsResponse_httpStatus :: (Int -> f Int) -> ListTopicsResponse -> f ListTopicsResponse
listTopicsResponse_httpStatus = (ListTopicsResponse -> Int)
-> (ListTopicsResponse -> Int -> ListTopicsResponse)
-> Lens ListTopicsResponse ListTopicsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTopicsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListTopicsResponse' :: ListTopicsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListTopicsResponse
s@ListTopicsResponse' {} Int
a -> ListTopicsResponse
s {$sel:httpStatus:ListTopicsResponse' :: Int
httpStatus = Int
a} :: ListTopicsResponse)
instance Prelude.NFData ListTopicsResponse