{-# 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_nextToken,
listTopicsResponse_topics,
listTopicsResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
$c== :: ListTopics -> ListTopics -> Bool
== :: ListTopics -> ListTopics -> Bool
$c/= :: ListTopics -> ListTopics -> Bool
/= :: 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
$creadsPrec :: Int -> ReadS ListTopics
readsPrec :: Int -> ReadS ListTopics
$creadList :: ReadS [ListTopics]
readList :: ReadS [ListTopics]
$creadPrec :: ReadPrec ListTopics
readPrec :: ReadPrec ListTopics
$creadListPrec :: ReadPrec [ListTopics]
readListPrec :: ReadPrec [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
$cshowsPrec :: Int -> ListTopics -> ShowS
showsPrec :: Int -> ListTopics -> ShowS
$cshow :: ListTopics -> String
show :: ListTopics -> String
$cshowList :: [ListTopics] -> ShowS
showList :: [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
$cfrom :: forall x. ListTopics -> Rep ListTopics x
from :: forall x. ListTopics -> Rep ListTopics x
$cto :: forall x. Rep ListTopics x -> ListTopics
to :: forall x. Rep ListTopics x -> ListTopics
Prelude.Generic)
newListTopics ::
ListTopics
newListTopics :: ListTopics
newListTopics =
ListTopics' {nextToken :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing}
listTopics_nextToken :: Lens.Lens' ListTopics (Prelude.Maybe Prelude.Text)
listTopics_nextToken :: Lens' ListTopics (Maybe Text)
listTopics_nextToken = (ListTopics -> Maybe Text)
-> (ListTopics -> Maybe Text -> ListTopics)
-> Lens' ListTopics (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTopics' {Maybe Text
nextToken :: ListTopics -> Maybe Text
nextToken :: Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListTopics
s@ListTopics' {} Maybe Text
a -> ListTopics
s {nextToken = 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 a' (f :: * -> *).
Applicative f =>
(a -> f a') -> Maybe a -> f (Maybe a')
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 a' (f :: * -> *).
Applicative f =>
(a -> f a') -> Maybe a -> f (Maybe a')
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 (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 a' (f :: * -> *).
Applicative f =>
(a -> f a') -> Maybe a -> f (Maybe a')
Lens._Just
instance Core.AWSRequest ListTopics where
type AWSResponse ListTopics = ListTopicsResponse
request :: (Service -> Service) -> ListTopics -> Request ListTopics
request Service -> Service
overrides =
Service -> ListTopics -> Request ListTopics
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListTopics
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListTopics)))
response =
Text
-> (Int
-> ResponseHeaders
-> [Node]
-> Either String (AWSResponse ListTopics))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListTopics
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListTopics)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
-> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
Text
"ListTopicsResult"
( \Int
s ResponseHeaders
h [Node]
x ->
Maybe Text -> Maybe [Topic] -> Int -> ListTopicsResponse
ListTopicsResponse'
(Maybe Text -> Maybe [Topic] -> Int -> ListTopicsResponse)
-> Either String (Maybe Text)
-> Either String (Maybe [Topic] -> Int -> ListTopicsResponse)
forall (f :: * -> *) a b. Functor 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)
Data..@? Text
"NextToken")
Either String (Maybe [Topic] -> Int -> ListTopicsResponse)
-> Either String (Maybe [Topic])
-> Either String (Int -> ListTopicsResponse)
forall a b.
Either String (a -> b) -> Either String a -> Either String b
forall (f :: * -> *) a b. Applicative f => 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)
Data..@? 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 a b.
Either String a -> (a -> Either String b) -> Either String b
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]
Data.parseXMLList Text
"member")
)
Either String (Int -> ListTopicsResponse)
-> Either String Int -> Either String ListTopicsResponse
forall a b.
Either String (a -> b) -> Either String a -> Either String b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall a. a -> Either String a
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 where
hashWithSalt :: Int -> ListTopics -> Int
hashWithSalt Int
_salt ListTopics' {Maybe Text
nextToken :: ListTopics -> Maybe Text
nextToken :: Maybe Text
..} =
Int
_salt Int -> Maybe Text -> Int
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
instance Prelude.NFData ListTopics where
rnf :: ListTopics -> ()
rnf ListTopics' {Maybe Text
nextToken :: ListTopics -> Maybe Text
nextToken :: Maybe Text
..} = Maybe Text -> ()
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
instance Data.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 Data.ToPath ListTopics where
toPath :: ListTopics -> ByteString
toPath = ByteString -> ListTopics -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery ListTopics where
toQuery :: ListTopics -> QueryString
toQuery ListTopics' {Maybe Text
nextToken :: ListTopics -> Maybe Text
nextToken :: Maybe Text
..} =
[QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"Action"
ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"ListTopics" :: Prelude.ByteString),
ByteString
"Version"
ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-03-31" :: Prelude.ByteString),
ByteString
"NextToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
]
data ListTopicsResponse = ListTopicsResponse'
{
ListTopicsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
ListTopicsResponse -> Maybe [Topic]
topics :: Prelude.Maybe [Topic],
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
$c== :: ListTopicsResponse -> ListTopicsResponse -> Bool
== :: ListTopicsResponse -> ListTopicsResponse -> Bool
$c/= :: ListTopicsResponse -> ListTopicsResponse -> Bool
/= :: 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
$creadsPrec :: Int -> ReadS ListTopicsResponse
readsPrec :: Int -> ReadS ListTopicsResponse
$creadList :: ReadS [ListTopicsResponse]
readList :: ReadS [ListTopicsResponse]
$creadPrec :: ReadPrec ListTopicsResponse
readPrec :: ReadPrec ListTopicsResponse
$creadListPrec :: ReadPrec [ListTopicsResponse]
readListPrec :: ReadPrec [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
$cshowsPrec :: Int -> ListTopicsResponse -> ShowS
showsPrec :: Int -> ListTopicsResponse -> ShowS
$cshow :: ListTopicsResponse -> String
show :: ListTopicsResponse -> String
$cshowList :: [ListTopicsResponse] -> ShowS
showList :: [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
$cfrom :: forall x. ListTopicsResponse -> Rep ListTopicsResponse x
from :: forall x. ListTopicsResponse -> Rep ListTopicsResponse x
$cto :: forall x. Rep ListTopicsResponse x -> ListTopicsResponse
to :: forall x. Rep ListTopicsResponse x -> ListTopicsResponse
Prelude.Generic)
newListTopicsResponse ::
Prelude.Int ->
ListTopicsResponse
newListTopicsResponse :: Int -> ListTopicsResponse
newListTopicsResponse Int
pHttpStatus_ =
ListTopicsResponse'
{ nextToken :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
topics :: Maybe [Topic]
topics = Maybe [Topic]
forall a. Maybe a
Prelude.Nothing,
httpStatus :: Int
httpStatus = Int
pHttpStatus_
}
listTopicsResponse_nextToken :: Lens.Lens' ListTopicsResponse (Prelude.Maybe Prelude.Text)
listTopicsResponse_nextToken :: Lens' ListTopicsResponse (Maybe Text)
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 :: ListTopicsResponse -> Maybe Text
nextToken :: Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListTopicsResponse
s@ListTopicsResponse' {} Maybe Text
a -> ListTopicsResponse
s {nextToken = a} :: ListTopicsResponse)
listTopicsResponse_topics :: Lens.Lens' ListTopicsResponse (Prelude.Maybe [Topic])
listTopicsResponse_topics :: Lens' ListTopicsResponse (Maybe [Topic])
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 :: ListTopicsResponse -> Maybe [Topic]
topics :: Maybe [Topic]
topics} -> Maybe [Topic]
topics) (\s :: ListTopicsResponse
s@ListTopicsResponse' {} Maybe [Topic]
a -> ListTopicsResponse
s {topics = 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
Iso [Topic] [Topic] [Topic] [Topic]
Lens.coerced
listTopicsResponse_httpStatus :: Lens.Lens' ListTopicsResponse Prelude.Int
listTopicsResponse_httpStatus :: Lens' ListTopicsResponse Int
listTopicsResponse_httpStatus = (ListTopicsResponse -> Int)
-> (ListTopicsResponse -> Int -> ListTopicsResponse)
-> Lens' ListTopicsResponse Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTopicsResponse' {Int
httpStatus :: ListTopicsResponse -> Int
httpStatus :: Int
httpStatus} -> Int
httpStatus) (\s :: ListTopicsResponse
s@ListTopicsResponse' {} Int
a -> ListTopicsResponse
s {httpStatus = a} :: ListTopicsResponse)
instance Prelude.NFData ListTopicsResponse where
rnf :: ListTopicsResponse -> ()
rnf ListTopicsResponse' {Int
Maybe [Topic]
Maybe Text
nextToken :: ListTopicsResponse -> Maybe Text
topics :: ListTopicsResponse -> Maybe [Topic]
httpStatus :: ListTopicsResponse -> Int
nextToken :: Maybe Text
topics :: Maybe [Topic]
httpStatus :: Int
..} =
Maybe Text -> ()
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken () -> () -> ()
forall a b. a -> b -> b
`Prelude.seq`
Maybe [Topic] -> ()
forall a. NFData a => a -> ()
Prelude.rnf Maybe [Topic]
topics () -> () -> ()
forall a b. a -> b -> b
`Prelude.seq`
Int -> ()
forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus