{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Organizations.ListAccountsForParent
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists the accounts in an organization that are contained by the
-- specified target root or organizational unit (OU). If you specify the
-- root, you get a list of all the accounts that aren\'t in any OU. If you
-- specify an OU, you get a list of all the accounts in only that OU and
-- not in any child OUs. To get a list of all accounts in the organization,
-- use the ListAccounts operation.
--
-- Always check the @NextToken@ response parameter for a @null@ value when
-- calling a @List*@ operation. These operations can occasionally return an
-- empty set of results even when there are more results available. The
-- @NextToken@ response parameter value is @null@ /only/ when there are no
-- more results to display.
--
-- This operation can be called only from the organization\'s management
-- account or by a member account that is a delegated administrator for an
-- AWS service.
--
-- This operation returns paginated results.
module Amazonka.Organizations.ListAccountsForParent
  ( -- * Creating a Request
    ListAccountsForParent (..),
    newListAccountsForParent,

    -- * Request Lenses
    listAccountsForParent_nextToken,
    listAccountsForParent_maxResults,
    listAccountsForParent_parentId,

    -- * Destructuring the Response
    ListAccountsForParentResponse (..),
    newListAccountsForParentResponse,

    -- * Response Lenses
    listAccountsForParentResponse_accounts,
    listAccountsForParentResponse_nextToken,
    listAccountsForParentResponse_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

-- | /See:/ 'newListAccountsForParent' smart constructor.
data ListAccountsForParent = ListAccountsForParent'
  { -- | The parameter for receiving additional results if you receive a
    -- @NextToken@ response in a previous request. A @NextToken@ response
    -- indicates that more output is available. Set this parameter to the value
    -- of the previous call\'s @NextToken@ response to indicate where the
    -- output should continue from.
    ListAccountsForParent -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The total number of results that you want included on each page of the
    -- response. If you do not include this parameter, it defaults to a value
    -- that is specific to the operation. If additional items exist beyond the
    -- maximum you specify, the @NextToken@ response element is present and has
    -- a value (is not null). Include that value as the @NextToken@ request
    -- parameter in the next call to the operation to get the next part of the
    -- results. Note that Organizations might return fewer results than the
    -- maximum even when there are more results available. You should check
    -- @NextToken@ after every operation to ensure that you receive all of the
    -- results.
    ListAccountsForParent -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The unique identifier (ID) for the parent root or organization unit (OU)
    -- whose accounts you want to list.
    ListAccountsForParent -> Text
parentId :: Prelude.Text
  }
  deriving (ListAccountsForParent -> ListAccountsForParent -> Bool
(ListAccountsForParent -> ListAccountsForParent -> Bool)
-> (ListAccountsForParent -> ListAccountsForParent -> Bool)
-> Eq ListAccountsForParent
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]
(Int -> ReadS ListAccountsForParent)
-> ReadS [ListAccountsForParent]
-> ReadPrec ListAccountsForParent
-> ReadPrec [ListAccountsForParent]
-> Read 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
(Int -> ListAccountsForParent -> ShowS)
-> (ListAccountsForParent -> String)
-> ([ListAccountsForParent] -> ShowS)
-> Show ListAccountsForParent
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. ListAccountsForParent -> Rep ListAccountsForParent x)
-> (forall x. Rep ListAccountsForParent x -> ListAccountsForParent)
-> Generic ListAccountsForParent
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)

-- |
-- Create a value of 'ListAccountsForParent' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'nextToken', 'listAccountsForParent_nextToken' - The parameter for receiving additional results if you receive a
-- @NextToken@ response in a previous request. A @NextToken@ response
-- indicates that more output is available. Set this parameter to the value
-- of the previous call\'s @NextToken@ response to indicate where the
-- output should continue from.
--
-- 'maxResults', 'listAccountsForParent_maxResults' - The total number of results that you want included on each page of the
-- response. If you do not include this parameter, it defaults to a value
-- that is specific to the operation. If additional items exist beyond the
-- maximum you specify, the @NextToken@ response element is present and has
-- a value (is not null). Include that value as the @NextToken@ request
-- parameter in the next call to the operation to get the next part of the
-- results. Note that Organizations might return fewer results than the
-- maximum even when there are more results available. You should check
-- @NextToken@ after every operation to ensure that you receive all of the
-- results.
--
-- 'parentId', 'listAccountsForParent_parentId' - The unique identifier (ID) for the parent root or organization unit (OU)
-- whose accounts you want to list.
newListAccountsForParent ::
  -- | 'parentId'
  Prelude.Text ->
  ListAccountsForParent
newListAccountsForParent :: Text -> ListAccountsForParent
newListAccountsForParent Text
pParentId_ =
  ListAccountsForParent' :: Maybe Text -> Maybe Natural -> Text -> ListAccountsForParent
ListAccountsForParent'
    { $sel:nextToken:ListAccountsForParent' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListAccountsForParent' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:parentId:ListAccountsForParent' :: Text
parentId = Text
pParentId_
    }

-- | The parameter for receiving additional results if you receive a
-- @NextToken@ response in a previous request. A @NextToken@ response
-- indicates that more output is available. Set this parameter to the value
-- of the previous call\'s @NextToken@ response to indicate where the
-- output should continue from.
listAccountsForParent_nextToken :: Lens.Lens' ListAccountsForParent (Prelude.Maybe Prelude.Text)
listAccountsForParent_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListAccountsForParent -> f ListAccountsForParent
listAccountsForParent_nextToken = (ListAccountsForParent -> Maybe Text)
-> (ListAccountsForParent -> Maybe Text -> ListAccountsForParent)
-> Lens
     ListAccountsForParent
     ListAccountsForParent
     (Maybe Text)
     (Maybe Text)
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)

-- | The total number of results that you want included on each page of the
-- response. If you do not include this parameter, it defaults to a value
-- that is specific to the operation. If additional items exist beyond the
-- maximum you specify, the @NextToken@ response element is present and has
-- a value (is not null). Include that value as the @NextToken@ request
-- parameter in the next call to the operation to get the next part of the
-- results. Note that Organizations might return fewer results than the
-- maximum even when there are more results available. You should check
-- @NextToken@ after every operation to ensure that you receive all of the
-- results.
listAccountsForParent_maxResults :: Lens.Lens' ListAccountsForParent (Prelude.Maybe Prelude.Natural)
listAccountsForParent_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListAccountsForParent -> f ListAccountsForParent
listAccountsForParent_maxResults = (ListAccountsForParent -> Maybe Natural)
-> (ListAccountsForParent
    -> Maybe Natural -> ListAccountsForParent)
-> Lens
     ListAccountsForParent
     ListAccountsForParent
     (Maybe Natural)
     (Maybe Natural)
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)

-- | The unique identifier (ID) for the parent root or organization unit (OU)
-- whose accounts you want to list.
listAccountsForParent_parentId :: Lens.Lens' ListAccountsForParent Prelude.Text
listAccountsForParent_parentId :: (Text -> f Text)
-> ListAccountsForParent -> f ListAccountsForParent
listAccountsForParent_parentId = (ListAccountsForParent -> Text)
-> (ListAccountsForParent -> Text -> ListAccountsForParent)
-> Lens ListAccountsForParent ListAccountsForParent Text Text
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
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListAccountsForParent
ListAccountsForParentResponse
rs
            ListAccountsForParentResponse
-> Getting (First Text) ListAccountsForParentResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListAccountsForParentResponse
-> Const (First Text) ListAccountsForParentResponse
Lens' ListAccountsForParentResponse (Maybe Text)
listAccountsForParentResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListAccountsForParentResponse
 -> Const (First Text) ListAccountsForParentResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListAccountsForParentResponse 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 ListAccountsForParent
forall a. Maybe a
Prelude.Nothing
    | Maybe [Account] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListAccountsForParent
ListAccountsForParentResponse
rs
            ListAccountsForParentResponse
-> Getting
     (First [Account]) ListAccountsForParentResponse [Account]
-> Maybe [Account]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Account] -> Const (First [Account]) (Maybe [Account]))
-> ListAccountsForParentResponse
-> Const (First [Account]) ListAccountsForParentResponse
Lens' ListAccountsForParentResponse (Maybe [Account])
listAccountsForParentResponse_accounts
              ((Maybe [Account] -> Const (First [Account]) (Maybe [Account]))
 -> ListAccountsForParentResponse
 -> Const (First [Account]) ListAccountsForParentResponse)
-> (([Account] -> Const (First [Account]) [Account])
    -> Maybe [Account] -> Const (First [Account]) (Maybe [Account]))
-> Getting
     (First [Account]) ListAccountsForParentResponse [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 ListAccountsForParent
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListAccountsForParent -> Maybe ListAccountsForParent
forall a. a -> Maybe a
Prelude.Just (ListAccountsForParent -> Maybe ListAccountsForParent)
-> ListAccountsForParent -> Maybe ListAccountsForParent
forall a b. (a -> b) -> a -> b
Prelude.$
        ListAccountsForParent
rq
          ListAccountsForParent
-> (ListAccountsForParent -> ListAccountsForParent)
-> ListAccountsForParent
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListAccountsForParent -> Identity ListAccountsForParent
Lens
  ListAccountsForParent
  ListAccountsForParent
  (Maybe Text)
  (Maybe Text)
listAccountsForParent_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListAccountsForParent -> Identity ListAccountsForParent)
-> Maybe Text -> ListAccountsForParent -> ListAccountsForParent
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListAccountsForParent
ListAccountsForParentResponse
rs
          ListAccountsForParentResponse
-> Getting (First Text) ListAccountsForParentResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListAccountsForParentResponse
-> Const (First Text) ListAccountsForParentResponse
Lens' ListAccountsForParentResponse (Maybe Text)
listAccountsForParentResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListAccountsForParentResponse
 -> Const (First Text) ListAccountsForParentResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListAccountsForParentResponse 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 ListAccountsForParent where
  type
    AWSResponse ListAccountsForParent =
      ListAccountsForParentResponse
  request :: ListAccountsForParent -> Request ListAccountsForParent
request = Service -> ListAccountsForParent -> Request ListAccountsForParent
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListAccountsForParent
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListAccountsForParent)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListAccountsForParent))
-> Logger
-> Service
-> Proxy ListAccountsForParent
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListAccountsForParent)))
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 -> ListAccountsForParentResponse
ListAccountsForParentResponse'
            (Maybe [Account]
 -> Maybe Text -> Int -> ListAccountsForParentResponse)
-> Either String (Maybe [Account])
-> Either
     String (Maybe Text -> Int -> ListAccountsForParentResponse)
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 -> ListAccountsForParentResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ListAccountsForParentResponse)
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 -> ListAccountsForParentResponse)
-> Either String Int -> Either String ListAccountsForParentResponse
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 ListAccountsForParent

instance Prelude.NFData ListAccountsForParent

instance Core.ToHeaders ListAccountsForParent where
  toHeaders :: ListAccountsForParent -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListAccountsForParent -> 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.ListAccountsForParent" ::
                          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 ListAccountsForParent where
  toJSON :: ListAccountsForParent -> Value
toJSON ListAccountsForParent' {Maybe Natural
Maybe Text
Text
parentId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:parentId:ListAccountsForParent' :: ListAccountsForParent -> Text
$sel:maxResults:ListAccountsForParent' :: ListAccountsForParent -> Maybe Natural
$sel:nextToken:ListAccountsForParent' :: ListAccountsForParent -> 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,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ParentId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
parentId)
          ]
      )

instance Core.ToPath ListAccountsForParent where
  toPath :: ListAccountsForParent -> ByteString
toPath = ByteString -> ListAccountsForParent -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery ListAccountsForParent where
  toQuery :: ListAccountsForParent -> QueryString
toQuery = QueryString -> ListAccountsForParent -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newListAccountsForParentResponse' smart constructor.
data ListAccountsForParentResponse = ListAccountsForParentResponse'
  { -- | A list of the accounts in the specified root or OU.
    ListAccountsForParentResponse -> Maybe [Account]
accounts :: Prelude.Maybe [Account],
    -- | If present, indicates that more output is available than is included in
    -- the current response. Use this value in the @NextToken@ request
    -- parameter in a subsequent call to the operation to get the next part of
    -- the output. You should repeat this until the @NextToken@ response
    -- element comes back as @null@.
    ListAccountsForParentResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListAccountsForParentResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListAccountsForParentResponse
-> ListAccountsForParentResponse -> Bool
(ListAccountsForParentResponse
 -> ListAccountsForParentResponse -> Bool)
-> (ListAccountsForParentResponse
    -> ListAccountsForParentResponse -> Bool)
-> Eq ListAccountsForParentResponse
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
(Int -> ListAccountsForParentResponse -> ShowS)
-> (ListAccountsForParentResponse -> String)
-> ([ListAccountsForParentResponse] -> ShowS)
-> Show ListAccountsForParentResponse
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.
 ListAccountsForParentResponse
 -> Rep ListAccountsForParentResponse x)
-> (forall x.
    Rep ListAccountsForParentResponse x
    -> ListAccountsForParentResponse)
-> Generic ListAccountsForParentResponse
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)

-- |
-- Create a value of 'ListAccountsForParentResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'accounts', 'listAccountsForParentResponse_accounts' - A list of the accounts in the specified root or OU.
--
-- 'nextToken', 'listAccountsForParentResponse_nextToken' - If present, indicates that more output is available than is included in
-- the current response. Use this value in the @NextToken@ request
-- parameter in a subsequent call to the operation to get the next part of
-- the output. You should repeat this until the @NextToken@ response
-- element comes back as @null@.
--
-- 'httpStatus', 'listAccountsForParentResponse_httpStatus' - The response's http status code.
newListAccountsForParentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListAccountsForParentResponse
newListAccountsForParentResponse :: Int -> ListAccountsForParentResponse
newListAccountsForParentResponse Int
pHttpStatus_ =
  ListAccountsForParentResponse' :: Maybe [Account]
-> Maybe Text -> Int -> ListAccountsForParentResponse
ListAccountsForParentResponse'
    { $sel:accounts:ListAccountsForParentResponse' :: Maybe [Account]
accounts =
        Maybe [Account]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAccountsForParentResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListAccountsForParentResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of the accounts in the specified root or OU.
listAccountsForParentResponse_accounts :: Lens.Lens' ListAccountsForParentResponse (Prelude.Maybe [Account])
listAccountsForParentResponse_accounts :: (Maybe [Account] -> f (Maybe [Account]))
-> ListAccountsForParentResponse -> f ListAccountsForParentResponse
listAccountsForParentResponse_accounts = (ListAccountsForParentResponse -> Maybe [Account])
-> (ListAccountsForParentResponse
    -> Maybe [Account] -> ListAccountsForParentResponse)
-> Lens' ListAccountsForParentResponse (Maybe [Account])
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) ((Maybe [Account] -> f (Maybe [Account]))
 -> ListAccountsForParentResponse
 -> f ListAccountsForParentResponse)
-> ((Maybe [Account] -> f (Maybe [Account]))
    -> Maybe [Account] -> f (Maybe [Account]))
-> (Maybe [Account] -> f (Maybe [Account]))
-> ListAccountsForParentResponse
-> f ListAccountsForParentResponse
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

-- | If present, indicates that more output is available than is included in
-- the current response. Use this value in the @NextToken@ request
-- parameter in a subsequent call to the operation to get the next part of
-- the output. You should repeat this until the @NextToken@ response
-- element comes back as @null@.
listAccountsForParentResponse_nextToken :: Lens.Lens' ListAccountsForParentResponse (Prelude.Maybe Prelude.Text)
listAccountsForParentResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListAccountsForParentResponse -> f ListAccountsForParentResponse
listAccountsForParentResponse_nextToken = (ListAccountsForParentResponse -> Maybe Text)
-> (ListAccountsForParentResponse
    -> Maybe Text -> ListAccountsForParentResponse)
-> Lens' ListAccountsForParentResponse (Maybe Text)
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)

-- | The response's http status code.
listAccountsForParentResponse_httpStatus :: Lens.Lens' ListAccountsForParentResponse Prelude.Int
listAccountsForParentResponse_httpStatus :: (Int -> f Int)
-> ListAccountsForParentResponse -> f ListAccountsForParentResponse
listAccountsForParentResponse_httpStatus = (ListAccountsForParentResponse -> Int)
-> (ListAccountsForParentResponse
    -> Int -> ListAccountsForParentResponse)
-> Lens
     ListAccountsForParentResponse ListAccountsForParentResponse Int Int
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