{-# 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.ListAccountsForParent
(
ListAccountsForParent (..),
newListAccountsForParent,
listAccountsForParent_maxResults,
listAccountsForParent_nextToken,
listAccountsForParent_parentId,
ListAccountsForParentResponse (..),
newListAccountsForParentResponse,
listAccountsForParentResponse_accounts,
listAccountsForParentResponse_nextToken,
listAccountsForParentResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Organizations.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data ListAccountsForParent = ListAccountsForParent'
{
ListAccountsForParent -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
ListAccountsForParent -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
ListAccountsForParent -> Text
parentId :: Prelude.Text
}
deriving (ListAccountsForParent -> ListAccountsForParent -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAccountsForParent -> ListAccountsForParent -> Bool
$c/= :: ListAccountsForParent -> ListAccountsForParent -> Bool
== :: ListAccountsForParent -> ListAccountsForParent -> Bool
$c== :: ListAccountsForParent -> ListAccountsForParent -> Bool
Prelude.Eq, ReadPrec [ListAccountsForParent]
ReadPrec ListAccountsForParent
Int -> ReadS ListAccountsForParent
ReadS [ListAccountsForParent]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAccountsForParent]
$creadListPrec :: ReadPrec [ListAccountsForParent]
readPrec :: ReadPrec ListAccountsForParent
$creadPrec :: ReadPrec ListAccountsForParent
readList :: ReadS [ListAccountsForParent]
$creadList :: ReadS [ListAccountsForParent]
readsPrec :: Int -> ReadS ListAccountsForParent
$creadsPrec :: Int -> ReadS ListAccountsForParent
Prelude.Read, Int -> ListAccountsForParent -> ShowS
[ListAccountsForParent] -> ShowS
ListAccountsForParent -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAccountsForParent] -> ShowS
$cshowList :: [ListAccountsForParent] -> ShowS
show :: ListAccountsForParent -> String
$cshow :: ListAccountsForParent -> String
showsPrec :: Int -> ListAccountsForParent -> ShowS
$cshowsPrec :: Int -> ListAccountsForParent -> ShowS
Prelude.Show, forall x. Rep ListAccountsForParent x -> ListAccountsForParent
forall x. ListAccountsForParent -> Rep ListAccountsForParent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAccountsForParent x -> ListAccountsForParent
$cfrom :: forall x. ListAccountsForParent -> Rep ListAccountsForParent x
Prelude.Generic)
newListAccountsForParent ::
Prelude.Text ->
ListAccountsForParent
newListAccountsForParent :: Text -> ListAccountsForParent
newListAccountsForParent Text
pParentId_ =
ListAccountsForParent'
{ $sel:maxResults:ListAccountsForParent' :: Maybe Natural
maxResults =
forall a. Maybe a
Prelude.Nothing,
$sel:nextToken:ListAccountsForParent' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
$sel:parentId:ListAccountsForParent' :: Text
parentId = Text
pParentId_
}
listAccountsForParent_maxResults :: Lens.Lens' ListAccountsForParent (Prelude.Maybe Prelude.Natural)
listAccountsForParent_maxResults :: Lens' ListAccountsForParent (Maybe Natural)
listAccountsForParent_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccountsForParent' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListAccountsForParent' :: ListAccountsForParent -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListAccountsForParent
s@ListAccountsForParent' {} Maybe Natural
a -> ListAccountsForParent
s {$sel:maxResults:ListAccountsForParent' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListAccountsForParent)
listAccountsForParent_nextToken :: Lens.Lens' ListAccountsForParent (Prelude.Maybe Prelude.Text)
listAccountsForParent_nextToken :: Lens' ListAccountsForParent (Maybe Text)
listAccountsForParent_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccountsForParent' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAccountsForParent' :: ListAccountsForParent -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAccountsForParent
s@ListAccountsForParent' {} Maybe Text
a -> ListAccountsForParent
s {$sel:nextToken:ListAccountsForParent' :: Maybe Text
nextToken = Maybe Text
a} :: ListAccountsForParent)
listAccountsForParent_parentId :: Lens.Lens' ListAccountsForParent Prelude.Text
listAccountsForParent_parentId :: Lens' ListAccountsForParent Text
listAccountsForParent_parentId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccountsForParent' {Text
parentId :: Text
$sel:parentId:ListAccountsForParent' :: ListAccountsForParent -> Text
parentId} -> Text
parentId) (\s :: ListAccountsForParent
s@ListAccountsForParent' {} Text
a -> ListAccountsForParent
s {$sel:parentId:ListAccountsForParent' :: Text
parentId = Text
a} :: ListAccountsForParent)
instance Core.AWSPager ListAccountsForParent where
page :: ListAccountsForParent
-> AWSResponse ListAccountsForParent -> Maybe ListAccountsForParent
page ListAccountsForParent
rq AWSResponse ListAccountsForParent
rs
| forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse ListAccountsForParent
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListAccountsForParentResponse (Maybe Text)
listAccountsForParentResponse_nextToken
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
forall a. Maybe a
Prelude.Nothing
| forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse ListAccountsForParent
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListAccountsForParentResponse (Maybe [Account])
listAccountsForParentResponse_accounts
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
forall a. Maybe a
Prelude.Nothing
| Bool
Prelude.otherwise =
forall a. a -> Maybe a
Prelude.Just
forall a b. (a -> b) -> a -> b
Prelude.$ ListAccountsForParent
rq
forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListAccountsForParent (Maybe Text)
listAccountsForParent_nextToken
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListAccountsForParent
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListAccountsForParentResponse (Maybe Text)
listAccountsForParentResponse_nextToken
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
instance Core.AWSRequest ListAccountsForParent where
type
AWSResponse ListAccountsForParent =
ListAccountsForParentResponse
request :: (Service -> Service)
-> ListAccountsForParent -> Request ListAccountsForParent
request Service -> Service
overrides =
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListAccountsForParent
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse ListAccountsForParent)))
response =
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe [Account]
-> Maybe Text -> Int -> ListAccountsForParentResponse
ListAccountsForParentResponse'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Accounts" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"NextToken")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable ListAccountsForParent where
hashWithSalt :: Int -> ListAccountsForParent -> Int
hashWithSalt Int
_salt ListAccountsForParent' {Maybe Natural
Maybe Text
Text
parentId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:parentId:ListAccountsForParent' :: ListAccountsForParent -> Text
$sel:nextToken:ListAccountsForParent' :: ListAccountsForParent -> Maybe Text
$sel:maxResults:ListAccountsForParent' :: ListAccountsForParent -> Maybe Natural
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
parentId
instance Prelude.NFData ListAccountsForParent where
rnf :: ListAccountsForParent -> ()
rnf ListAccountsForParent' {Maybe Natural
Maybe Text
Text
parentId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:parentId:ListAccountsForParent' :: ListAccountsForParent -> Text
$sel:nextToken:ListAccountsForParent' :: ListAccountsForParent -> Maybe Text
$sel:maxResults:ListAccountsForParent' :: ListAccountsForParent -> Maybe Natural
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
parentId
instance Data.ToHeaders ListAccountsForParent where
toHeaders :: ListAccountsForParent -> ResponseHeaders
toHeaders =
forall a b. a -> b -> a
Prelude.const
( forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSOrganizationsV20161128.ListAccountsForParent" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON ListAccountsForParent where
toJSON :: ListAccountsForParent -> Value
toJSON ListAccountsForParent' {Maybe Natural
Maybe Text
Text
parentId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:parentId:ListAccountsForParent' :: ListAccountsForParent -> Text
$sel:nextToken:ListAccountsForParent' :: ListAccountsForParent -> Maybe Text
$sel:maxResults:ListAccountsForParent' :: ListAccountsForParent -> Maybe Natural
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"MaxResults" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
(Key
"NextToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
forall a. a -> Maybe a
Prelude.Just (Key
"ParentId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
parentId)
]
)
instance Data.ToPath ListAccountsForParent where
toPath :: ListAccountsForParent -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery ListAccountsForParent where
toQuery :: ListAccountsForParent -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data ListAccountsForParentResponse = ListAccountsForParentResponse'
{
ListAccountsForParentResponse -> Maybe [Account]
accounts :: Prelude.Maybe [Account],
ListAccountsForParentResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
ListAccountsForParentResponse -> Int
httpStatus :: Prelude.Int
}
deriving (ListAccountsForParentResponse
-> ListAccountsForParentResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAccountsForParentResponse
-> ListAccountsForParentResponse -> Bool
$c/= :: ListAccountsForParentResponse
-> ListAccountsForParentResponse -> Bool
== :: ListAccountsForParentResponse
-> ListAccountsForParentResponse -> Bool
$c== :: ListAccountsForParentResponse
-> ListAccountsForParentResponse -> Bool
Prelude.Eq, Int -> ListAccountsForParentResponse -> ShowS
[ListAccountsForParentResponse] -> ShowS
ListAccountsForParentResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAccountsForParentResponse] -> ShowS
$cshowList :: [ListAccountsForParentResponse] -> ShowS
show :: ListAccountsForParentResponse -> String
$cshow :: ListAccountsForParentResponse -> String
showsPrec :: Int -> ListAccountsForParentResponse -> ShowS
$cshowsPrec :: Int -> ListAccountsForParentResponse -> ShowS
Prelude.Show, forall x.
Rep ListAccountsForParentResponse x
-> ListAccountsForParentResponse
forall x.
ListAccountsForParentResponse
-> Rep ListAccountsForParentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListAccountsForParentResponse x
-> ListAccountsForParentResponse
$cfrom :: forall x.
ListAccountsForParentResponse
-> Rep ListAccountsForParentResponse x
Prelude.Generic)
newListAccountsForParentResponse ::
Prelude.Int ->
ListAccountsForParentResponse
newListAccountsForParentResponse :: Int -> ListAccountsForParentResponse
newListAccountsForParentResponse Int
pHttpStatus_ =
ListAccountsForParentResponse'
{ $sel:accounts:ListAccountsForParentResponse' :: Maybe [Account]
accounts =
forall a. Maybe a
Prelude.Nothing,
$sel:nextToken:ListAccountsForParentResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:ListAccountsForParentResponse' :: Int
httpStatus = Int
pHttpStatus_
}
listAccountsForParentResponse_accounts :: Lens.Lens' ListAccountsForParentResponse (Prelude.Maybe [Account])
listAccountsForParentResponse_accounts :: Lens' ListAccountsForParentResponse (Maybe [Account])
listAccountsForParentResponse_accounts = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccountsForParentResponse' {Maybe [Account]
accounts :: Maybe [Account]
$sel:accounts:ListAccountsForParentResponse' :: ListAccountsForParentResponse -> Maybe [Account]
accounts} -> Maybe [Account]
accounts) (\s :: ListAccountsForParentResponse
s@ListAccountsForParentResponse' {} Maybe [Account]
a -> ListAccountsForParentResponse
s {$sel:accounts:ListAccountsForParentResponse' :: Maybe [Account]
accounts = Maybe [Account]
a} :: ListAccountsForParentResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
listAccountsForParentResponse_nextToken :: Lens.Lens' ListAccountsForParentResponse (Prelude.Maybe Prelude.Text)
listAccountsForParentResponse_nextToken :: Lens' ListAccountsForParentResponse (Maybe Text)
listAccountsForParentResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccountsForParentResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAccountsForParentResponse' :: ListAccountsForParentResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAccountsForParentResponse
s@ListAccountsForParentResponse' {} Maybe Text
a -> ListAccountsForParentResponse
s {$sel:nextToken:ListAccountsForParentResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListAccountsForParentResponse)
listAccountsForParentResponse_httpStatus :: Lens.Lens' ListAccountsForParentResponse Prelude.Int
listAccountsForParentResponse_httpStatus :: Lens' ListAccountsForParentResponse Int
listAccountsForParentResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccountsForParentResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListAccountsForParentResponse' :: ListAccountsForParentResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListAccountsForParentResponse
s@ListAccountsForParentResponse' {} Int
a -> ListAccountsForParentResponse
s {$sel:httpStatus:ListAccountsForParentResponse' :: Int
httpStatus = Int
a} :: ListAccountsForParentResponse)
instance Prelude.NFData ListAccountsForParentResponse where
rnf :: ListAccountsForParentResponse -> ()
rnf ListAccountsForParentResponse' {Int
Maybe [Account]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
accounts :: Maybe [Account]
$sel:httpStatus:ListAccountsForParentResponse' :: ListAccountsForParentResponse -> Int
$sel:nextToken:ListAccountsForParentResponse' :: ListAccountsForParentResponse -> Maybe Text
$sel:accounts:ListAccountsForParentResponse' :: ListAccountsForParentResponse -> Maybe [Account]
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe [Account]
accounts
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus