{-# 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.Organizations.ListAccounts
(
ListAccounts (..),
newListAccounts,
listAccounts_nextToken,
listAccounts_maxResults,
ListAccountsResponse (..),
newListAccountsResponse,
listAccountsResponse_accounts,
listAccountsResponse_nextToken,
listAccountsResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Organizations.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data ListAccounts = ListAccounts'
{
ListAccounts -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
ListAccounts -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
}
deriving (ListAccounts -> ListAccounts -> Bool
(ListAccounts -> ListAccounts -> Bool)
-> (ListAccounts -> ListAccounts -> Bool) -> Eq ListAccounts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAccounts -> ListAccounts -> Bool
$c/= :: ListAccounts -> ListAccounts -> Bool
== :: ListAccounts -> ListAccounts -> Bool
$c== :: ListAccounts -> ListAccounts -> Bool
Prelude.Eq, ReadPrec [ListAccounts]
ReadPrec ListAccounts
Int -> ReadS ListAccounts
ReadS [ListAccounts]
(Int -> ReadS ListAccounts)
-> ReadS [ListAccounts]
-> ReadPrec ListAccounts
-> ReadPrec [ListAccounts]
-> Read ListAccounts
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAccounts]
$creadListPrec :: ReadPrec [ListAccounts]
readPrec :: ReadPrec ListAccounts
$creadPrec :: ReadPrec ListAccounts
readList :: ReadS [ListAccounts]
$creadList :: ReadS [ListAccounts]
readsPrec :: Int -> ReadS ListAccounts
$creadsPrec :: Int -> ReadS ListAccounts
Prelude.Read, Int -> ListAccounts -> ShowS
[ListAccounts] -> ShowS
ListAccounts -> String
(Int -> ListAccounts -> ShowS)
-> (ListAccounts -> String)
-> ([ListAccounts] -> ShowS)
-> Show ListAccounts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAccounts] -> ShowS
$cshowList :: [ListAccounts] -> ShowS
show :: ListAccounts -> String
$cshow :: ListAccounts -> String
showsPrec :: Int -> ListAccounts -> ShowS
$cshowsPrec :: Int -> ListAccounts -> ShowS
Prelude.Show, (forall x. ListAccounts -> Rep ListAccounts x)
-> (forall x. Rep ListAccounts x -> ListAccounts)
-> Generic ListAccounts
forall x. Rep ListAccounts x -> ListAccounts
forall x. ListAccounts -> Rep ListAccounts x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAccounts x -> ListAccounts
$cfrom :: forall x. ListAccounts -> Rep ListAccounts x
Prelude.Generic)
newListAccounts ::
ListAccounts
newListAccounts :: ListAccounts
newListAccounts =
ListAccounts' :: Maybe Text -> Maybe Natural -> ListAccounts
ListAccounts'
{ $sel:nextToken:ListAccounts' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:maxResults:ListAccounts' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
}
listAccounts_nextToken :: Lens.Lens' ListAccounts (Prelude.Maybe Prelude.Text)
listAccounts_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListAccounts -> f ListAccounts
listAccounts_nextToken = (ListAccounts -> Maybe Text)
-> (ListAccounts -> Maybe Text -> ListAccounts)
-> Lens ListAccounts ListAccounts (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccounts' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAccounts' :: ListAccounts -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAccounts
s@ListAccounts' {} Maybe Text
a -> ListAccounts
s {$sel:nextToken:ListAccounts' :: Maybe Text
nextToken = Maybe Text
a} :: ListAccounts)
listAccounts_maxResults :: Lens.Lens' ListAccounts (Prelude.Maybe Prelude.Natural)
listAccounts_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListAccounts -> f ListAccounts
listAccounts_maxResults = (ListAccounts -> Maybe Natural)
-> (ListAccounts -> Maybe Natural -> ListAccounts)
-> Lens ListAccounts ListAccounts (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccounts' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListAccounts' :: ListAccounts -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListAccounts
s@ListAccounts' {} Maybe Natural
a -> ListAccounts
s {$sel:maxResults:ListAccounts' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListAccounts)
instance Core.AWSPager ListAccounts where
page :: ListAccounts -> AWSResponse ListAccounts -> Maybe ListAccounts
page ListAccounts
rq AWSResponse ListAccounts
rs
| Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse ListAccounts
ListAccountsResponse
rs
ListAccountsResponse
-> Getting (First Text) ListAccountsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListAccountsResponse -> Const (First Text) ListAccountsResponse
Lens' ListAccountsResponse (Maybe Text)
listAccountsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
-> ListAccountsResponse -> Const (First Text) ListAccountsResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListAccountsResponse 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 ListAccounts
forall a. Maybe a
Prelude.Nothing
| Maybe [Account] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse ListAccounts
ListAccountsResponse
rs
ListAccountsResponse
-> Getting (First [Account]) ListAccountsResponse [Account]
-> Maybe [Account]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Account] -> Const (First [Account]) (Maybe [Account]))
-> ListAccountsResponse
-> Const (First [Account]) ListAccountsResponse
Lens' ListAccountsResponse (Maybe [Account])
listAccountsResponse_accounts ((Maybe [Account] -> Const (First [Account]) (Maybe [Account]))
-> ListAccountsResponse
-> Const (First [Account]) ListAccountsResponse)
-> (([Account] -> Const (First [Account]) [Account])
-> Maybe [Account] -> Const (First [Account]) (Maybe [Account]))
-> Getting (First [Account]) ListAccountsResponse [Account]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Account] -> Const (First [Account]) [Account])
-> Maybe [Account] -> Const (First [Account]) (Maybe [Account])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
Maybe ListAccounts
forall a. Maybe a
Prelude.Nothing
| Bool
Prelude.otherwise =
ListAccounts -> Maybe ListAccounts
forall a. a -> Maybe a
Prelude.Just (ListAccounts -> Maybe ListAccounts)
-> ListAccounts -> Maybe ListAccounts
forall a b. (a -> b) -> a -> b
Prelude.$
ListAccounts
rq
ListAccounts -> (ListAccounts -> ListAccounts) -> ListAccounts
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListAccounts -> Identity ListAccounts
Lens ListAccounts ListAccounts (Maybe Text) (Maybe Text)
listAccounts_nextToken
((Maybe Text -> Identity (Maybe Text))
-> ListAccounts -> Identity ListAccounts)
-> Maybe Text -> ListAccounts -> ListAccounts
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListAccounts
ListAccountsResponse
rs
ListAccountsResponse
-> Getting (First Text) ListAccountsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListAccountsResponse -> Const (First Text) ListAccountsResponse
Lens' ListAccountsResponse (Maybe Text)
listAccountsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
-> ListAccountsResponse -> Const (First Text) ListAccountsResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListAccountsResponse 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 ListAccounts where
type AWSResponse ListAccounts = ListAccountsResponse
request :: ListAccounts -> Request ListAccounts
request = Service -> ListAccounts -> Request ListAccounts
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy ListAccounts
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListAccounts)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse ListAccounts))
-> Logger
-> Service
-> Proxy ListAccounts
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListAccounts)))
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 ->
Maybe [Account] -> Maybe Text -> Int -> ListAccountsResponse
ListAccountsResponse'
(Maybe [Account] -> Maybe Text -> Int -> ListAccountsResponse)
-> Either String (Maybe [Account])
-> Either String (Maybe Text -> Int -> ListAccountsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Account]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Accounts" Either String (Maybe (Maybe [Account]))
-> Maybe [Account] -> Either String (Maybe [Account])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Account]
forall a. Monoid a => a
Prelude.mempty)
Either String (Maybe Text -> Int -> ListAccountsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ListAccountsResponse)
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
"NextToken")
Either String (Int -> ListAccountsResponse)
-> Either String Int -> Either String ListAccountsResponse
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 ListAccounts
instance Prelude.NFData ListAccounts
instance Core.ToHeaders ListAccounts where
toHeaders :: ListAccounts -> ResponseHeaders
toHeaders =
ResponseHeaders -> ListAccounts -> 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
"AWSOrganizationsV20161128.ListAccounts" ::
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 ListAccounts where
toJSON :: ListAccounts -> Value
toJSON ListAccounts' {Maybe Natural
Maybe Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:maxResults:ListAccounts' :: ListAccounts -> Maybe Natural
$sel:nextToken:ListAccounts' :: ListAccounts -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"NextToken" 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
nextToken,
(Text
"MaxResults" 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
maxResults
]
)
instance Core.ToPath ListAccounts where
toPath :: ListAccounts -> ByteString
toPath = ByteString -> ListAccounts -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery ListAccounts where
toQuery :: ListAccounts -> QueryString
toQuery = QueryString -> ListAccounts -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data ListAccountsResponse = ListAccountsResponse'
{
ListAccountsResponse -> Maybe [Account]
accounts :: Prelude.Maybe [Account],
ListAccountsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
ListAccountsResponse -> Int
httpStatus :: Prelude.Int
}
deriving (ListAccountsResponse -> ListAccountsResponse -> Bool
(ListAccountsResponse -> ListAccountsResponse -> Bool)
-> (ListAccountsResponse -> ListAccountsResponse -> Bool)
-> Eq ListAccountsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAccountsResponse -> ListAccountsResponse -> Bool
$c/= :: ListAccountsResponse -> ListAccountsResponse -> Bool
== :: ListAccountsResponse -> ListAccountsResponse -> Bool
$c== :: ListAccountsResponse -> ListAccountsResponse -> Bool
Prelude.Eq, Int -> ListAccountsResponse -> ShowS
[ListAccountsResponse] -> ShowS
ListAccountsResponse -> String
(Int -> ListAccountsResponse -> ShowS)
-> (ListAccountsResponse -> String)
-> ([ListAccountsResponse] -> ShowS)
-> Show ListAccountsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAccountsResponse] -> ShowS
$cshowList :: [ListAccountsResponse] -> ShowS
show :: ListAccountsResponse -> String
$cshow :: ListAccountsResponse -> String
showsPrec :: Int -> ListAccountsResponse -> ShowS
$cshowsPrec :: Int -> ListAccountsResponse -> ShowS
Prelude.Show, (forall x. ListAccountsResponse -> Rep ListAccountsResponse x)
-> (forall x. Rep ListAccountsResponse x -> ListAccountsResponse)
-> Generic ListAccountsResponse
forall x. Rep ListAccountsResponse x -> ListAccountsResponse
forall x. ListAccountsResponse -> Rep ListAccountsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAccountsResponse x -> ListAccountsResponse
$cfrom :: forall x. ListAccountsResponse -> Rep ListAccountsResponse x
Prelude.Generic)
newListAccountsResponse ::
Prelude.Int ->
ListAccountsResponse
newListAccountsResponse :: Int -> ListAccountsResponse
newListAccountsResponse Int
pHttpStatus_ =
ListAccountsResponse' :: Maybe [Account] -> Maybe Text -> Int -> ListAccountsResponse
ListAccountsResponse'
{ $sel:accounts:ListAccountsResponse' :: Maybe [Account]
accounts = Maybe [Account]
forall a. Maybe a
Prelude.Nothing,
$sel:nextToken:ListAccountsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:ListAccountsResponse' :: Int
httpStatus = Int
pHttpStatus_
}
listAccountsResponse_accounts :: Lens.Lens' ListAccountsResponse (Prelude.Maybe [Account])
listAccountsResponse_accounts :: (Maybe [Account] -> f (Maybe [Account]))
-> ListAccountsResponse -> f ListAccountsResponse
listAccountsResponse_accounts = (ListAccountsResponse -> Maybe [Account])
-> (ListAccountsResponse
-> Maybe [Account] -> ListAccountsResponse)
-> Lens' ListAccountsResponse (Maybe [Account])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccountsResponse' {Maybe [Account]
accounts :: Maybe [Account]
$sel:accounts:ListAccountsResponse' :: ListAccountsResponse -> Maybe [Account]
accounts} -> Maybe [Account]
accounts) (\s :: ListAccountsResponse
s@ListAccountsResponse' {} Maybe [Account]
a -> ListAccountsResponse
s {$sel:accounts:ListAccountsResponse' :: Maybe [Account]
accounts = Maybe [Account]
a} :: ListAccountsResponse) ((Maybe [Account] -> f (Maybe [Account]))
-> ListAccountsResponse -> f ListAccountsResponse)
-> ((Maybe [Account] -> f (Maybe [Account]))
-> Maybe [Account] -> f (Maybe [Account]))
-> (Maybe [Account] -> f (Maybe [Account]))
-> ListAccountsResponse
-> f ListAccountsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Account] [Account] [Account] [Account]
-> Iso
(Maybe [Account])
(Maybe [Account])
(Maybe [Account])
(Maybe [Account])
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 [Account] [Account] [Account] [Account]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
listAccountsResponse_nextToken :: Lens.Lens' ListAccountsResponse (Prelude.Maybe Prelude.Text)
listAccountsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListAccountsResponse -> f ListAccountsResponse
listAccountsResponse_nextToken = (ListAccountsResponse -> Maybe Text)
-> (ListAccountsResponse -> Maybe Text -> ListAccountsResponse)
-> Lens' ListAccountsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccountsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAccountsResponse' :: ListAccountsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAccountsResponse
s@ListAccountsResponse' {} Maybe Text
a -> ListAccountsResponse
s {$sel:nextToken:ListAccountsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListAccountsResponse)
listAccountsResponse_httpStatus :: Lens.Lens' ListAccountsResponse Prelude.Int
listAccountsResponse_httpStatus :: (Int -> f Int) -> ListAccountsResponse -> f ListAccountsResponse
listAccountsResponse_httpStatus = (ListAccountsResponse -> Int)
-> (ListAccountsResponse -> Int -> ListAccountsResponse)
-> Lens ListAccountsResponse ListAccountsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccountsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListAccountsResponse' :: ListAccountsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListAccountsResponse
s@ListAccountsResponse' {} Int
a -> ListAccountsResponse
s {$sel:httpStatus:ListAccountsResponse' :: Int
httpStatus = Int
a} :: ListAccountsResponse)
instance Prelude.NFData ListAccountsResponse