{-# 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.ListOrganizationalUnitsForParent
-- 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 organizational units (OUs) in a parent organizational unit or
-- root.
--
-- 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.ListOrganizationalUnitsForParent
  ( -- * Creating a Request
    ListOrganizationalUnitsForParent (..),
    newListOrganizationalUnitsForParent,

    -- * Request Lenses
    listOrganizationalUnitsForParent_nextToken,
    listOrganizationalUnitsForParent_maxResults,
    listOrganizationalUnitsForParent_parentId,

    -- * Destructuring the Response
    ListOrganizationalUnitsForParentResponse (..),
    newListOrganizationalUnitsForParentResponse,

    -- * Response Lenses
    listOrganizationalUnitsForParentResponse_nextToken,
    listOrganizationalUnitsForParentResponse_organizationalUnits,
    listOrganizationalUnitsForParentResponse_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:/ 'newListOrganizationalUnitsForParent' smart constructor.
data ListOrganizationalUnitsForParent = ListOrganizationalUnitsForParent'
  { -- | 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.
    ListOrganizationalUnitsForParent -> 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.
    ListOrganizationalUnitsForParent -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The unique identifier (ID) of the root or OU whose child OUs you want to
    -- list.
    --
    -- The <http://wikipedia.org/wiki/regex regex pattern> for a parent ID
    -- string requires one of the following:
    --
    -- -   __Root__ - A string that begins with \"r-\" followed by from 4 to 32
    --     lowercase letters or digits.
    --
    -- -   __Organizational unit (OU)__ - A string that begins with \"ou-\"
    --     followed by from 4 to 32 lowercase letters or digits (the ID of the
    --     root that the OU is in). This string is followed by a second \"-\"
    --     dash and from 8 to 32 additional lowercase letters or digits.
    ListOrganizationalUnitsForParent -> Text
parentId :: Prelude.Text
  }
  deriving (ListOrganizationalUnitsForParent
-> ListOrganizationalUnitsForParent -> Bool
(ListOrganizationalUnitsForParent
 -> ListOrganizationalUnitsForParent -> Bool)
-> (ListOrganizationalUnitsForParent
    -> ListOrganizationalUnitsForParent -> Bool)
-> Eq ListOrganizationalUnitsForParent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListOrganizationalUnitsForParent
-> ListOrganizationalUnitsForParent -> Bool
$c/= :: ListOrganizationalUnitsForParent
-> ListOrganizationalUnitsForParent -> Bool
== :: ListOrganizationalUnitsForParent
-> ListOrganizationalUnitsForParent -> Bool
$c== :: ListOrganizationalUnitsForParent
-> ListOrganizationalUnitsForParent -> Bool
Prelude.Eq, ReadPrec [ListOrganizationalUnitsForParent]
ReadPrec ListOrganizationalUnitsForParent
Int -> ReadS ListOrganizationalUnitsForParent
ReadS [ListOrganizationalUnitsForParent]
(Int -> ReadS ListOrganizationalUnitsForParent)
-> ReadS [ListOrganizationalUnitsForParent]
-> ReadPrec ListOrganizationalUnitsForParent
-> ReadPrec [ListOrganizationalUnitsForParent]
-> Read ListOrganizationalUnitsForParent
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListOrganizationalUnitsForParent]
$creadListPrec :: ReadPrec [ListOrganizationalUnitsForParent]
readPrec :: ReadPrec ListOrganizationalUnitsForParent
$creadPrec :: ReadPrec ListOrganizationalUnitsForParent
readList :: ReadS [ListOrganizationalUnitsForParent]
$creadList :: ReadS [ListOrganizationalUnitsForParent]
readsPrec :: Int -> ReadS ListOrganizationalUnitsForParent
$creadsPrec :: Int -> ReadS ListOrganizationalUnitsForParent
Prelude.Read, Int -> ListOrganizationalUnitsForParent -> ShowS
[ListOrganizationalUnitsForParent] -> ShowS
ListOrganizationalUnitsForParent -> String
(Int -> ListOrganizationalUnitsForParent -> ShowS)
-> (ListOrganizationalUnitsForParent -> String)
-> ([ListOrganizationalUnitsForParent] -> ShowS)
-> Show ListOrganizationalUnitsForParent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListOrganizationalUnitsForParent] -> ShowS
$cshowList :: [ListOrganizationalUnitsForParent] -> ShowS
show :: ListOrganizationalUnitsForParent -> String
$cshow :: ListOrganizationalUnitsForParent -> String
showsPrec :: Int -> ListOrganizationalUnitsForParent -> ShowS
$cshowsPrec :: Int -> ListOrganizationalUnitsForParent -> ShowS
Prelude.Show, (forall x.
 ListOrganizationalUnitsForParent
 -> Rep ListOrganizationalUnitsForParent x)
-> (forall x.
    Rep ListOrganizationalUnitsForParent x
    -> ListOrganizationalUnitsForParent)
-> Generic ListOrganizationalUnitsForParent
forall x.
Rep ListOrganizationalUnitsForParent x
-> ListOrganizationalUnitsForParent
forall x.
ListOrganizationalUnitsForParent
-> Rep ListOrganizationalUnitsForParent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListOrganizationalUnitsForParent x
-> ListOrganizationalUnitsForParent
$cfrom :: forall x.
ListOrganizationalUnitsForParent
-> Rep ListOrganizationalUnitsForParent x
Prelude.Generic)

-- |
-- Create a value of 'ListOrganizationalUnitsForParent' 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', 'listOrganizationalUnitsForParent_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', 'listOrganizationalUnitsForParent_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', 'listOrganizationalUnitsForParent_parentId' - The unique identifier (ID) of the root or OU whose child OUs you want to
-- list.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for a parent ID
-- string requires one of the following:
--
-- -   __Root__ - A string that begins with \"r-\" followed by from 4 to 32
--     lowercase letters or digits.
--
-- -   __Organizational unit (OU)__ - A string that begins with \"ou-\"
--     followed by from 4 to 32 lowercase letters or digits (the ID of the
--     root that the OU is in). This string is followed by a second \"-\"
--     dash and from 8 to 32 additional lowercase letters or digits.
newListOrganizationalUnitsForParent ::
  -- | 'parentId'
  Prelude.Text ->
  ListOrganizationalUnitsForParent
newListOrganizationalUnitsForParent :: Text -> ListOrganizationalUnitsForParent
newListOrganizationalUnitsForParent Text
pParentId_ =
  ListOrganizationalUnitsForParent' :: Maybe Text
-> Maybe Natural -> Text -> ListOrganizationalUnitsForParent
ListOrganizationalUnitsForParent'
    { $sel:nextToken:ListOrganizationalUnitsForParent' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListOrganizationalUnitsForParent' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:parentId:ListOrganizationalUnitsForParent' :: 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.
listOrganizationalUnitsForParent_nextToken :: Lens.Lens' ListOrganizationalUnitsForParent (Prelude.Maybe Prelude.Text)
listOrganizationalUnitsForParent_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListOrganizationalUnitsForParent
-> f ListOrganizationalUnitsForParent
listOrganizationalUnitsForParent_nextToken = (ListOrganizationalUnitsForParent -> Maybe Text)
-> (ListOrganizationalUnitsForParent
    -> Maybe Text -> ListOrganizationalUnitsForParent)
-> Lens
     ListOrganizationalUnitsForParent
     ListOrganizationalUnitsForParent
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListOrganizationalUnitsForParent' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListOrganizationalUnitsForParent' :: ListOrganizationalUnitsForParent -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListOrganizationalUnitsForParent
s@ListOrganizationalUnitsForParent' {} Maybe Text
a -> ListOrganizationalUnitsForParent
s {$sel:nextToken:ListOrganizationalUnitsForParent' :: Maybe Text
nextToken = Maybe Text
a} :: ListOrganizationalUnitsForParent)

-- | 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.
listOrganizationalUnitsForParent_maxResults :: Lens.Lens' ListOrganizationalUnitsForParent (Prelude.Maybe Prelude.Natural)
listOrganizationalUnitsForParent_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListOrganizationalUnitsForParent
-> f ListOrganizationalUnitsForParent
listOrganizationalUnitsForParent_maxResults = (ListOrganizationalUnitsForParent -> Maybe Natural)
-> (ListOrganizationalUnitsForParent
    -> Maybe Natural -> ListOrganizationalUnitsForParent)
-> Lens
     ListOrganizationalUnitsForParent
     ListOrganizationalUnitsForParent
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListOrganizationalUnitsForParent' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListOrganizationalUnitsForParent' :: ListOrganizationalUnitsForParent -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListOrganizationalUnitsForParent
s@ListOrganizationalUnitsForParent' {} Maybe Natural
a -> ListOrganizationalUnitsForParent
s {$sel:maxResults:ListOrganizationalUnitsForParent' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListOrganizationalUnitsForParent)

-- | The unique identifier (ID) of the root or OU whose child OUs you want to
-- list.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for a parent ID
-- string requires one of the following:
--
-- -   __Root__ - A string that begins with \"r-\" followed by from 4 to 32
--     lowercase letters or digits.
--
-- -   __Organizational unit (OU)__ - A string that begins with \"ou-\"
--     followed by from 4 to 32 lowercase letters or digits (the ID of the
--     root that the OU is in). This string is followed by a second \"-\"
--     dash and from 8 to 32 additional lowercase letters or digits.
listOrganizationalUnitsForParent_parentId :: Lens.Lens' ListOrganizationalUnitsForParent Prelude.Text
listOrganizationalUnitsForParent_parentId :: (Text -> f Text)
-> ListOrganizationalUnitsForParent
-> f ListOrganizationalUnitsForParent
listOrganizationalUnitsForParent_parentId = (ListOrganizationalUnitsForParent -> Text)
-> (ListOrganizationalUnitsForParent
    -> Text -> ListOrganizationalUnitsForParent)
-> Lens
     ListOrganizationalUnitsForParent
     ListOrganizationalUnitsForParent
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListOrganizationalUnitsForParent' {Text
parentId :: Text
$sel:parentId:ListOrganizationalUnitsForParent' :: ListOrganizationalUnitsForParent -> Text
parentId} -> Text
parentId) (\s :: ListOrganizationalUnitsForParent
s@ListOrganizationalUnitsForParent' {} Text
a -> ListOrganizationalUnitsForParent
s {$sel:parentId:ListOrganizationalUnitsForParent' :: Text
parentId = Text
a} :: ListOrganizationalUnitsForParent)

instance
  Core.AWSPager
    ListOrganizationalUnitsForParent
  where
  page :: ListOrganizationalUnitsForParent
-> AWSResponse ListOrganizationalUnitsForParent
-> Maybe ListOrganizationalUnitsForParent
page ListOrganizationalUnitsForParent
rq AWSResponse ListOrganizationalUnitsForParent
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListOrganizationalUnitsForParent
ListOrganizationalUnitsForParentResponse
rs
            ListOrganizationalUnitsForParentResponse
-> Getting
     (First Text) ListOrganizationalUnitsForParentResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListOrganizationalUnitsForParentResponse
-> Const (First Text) ListOrganizationalUnitsForParentResponse
Lens' ListOrganizationalUnitsForParentResponse (Maybe Text)
listOrganizationalUnitsForParentResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListOrganizationalUnitsForParentResponse
 -> Const (First Text) ListOrganizationalUnitsForParentResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting
     (First Text) ListOrganizationalUnitsForParentResponse 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 ListOrganizationalUnitsForParent
forall a. Maybe a
Prelude.Nothing
    | Maybe [OrganizationalUnit] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListOrganizationalUnitsForParent
ListOrganizationalUnitsForParentResponse
rs
            ListOrganizationalUnitsForParentResponse
-> Getting
     (First [OrganizationalUnit])
     ListOrganizationalUnitsForParentResponse
     [OrganizationalUnit]
-> Maybe [OrganizationalUnit]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [OrganizationalUnit]
 -> Const (First [OrganizationalUnit]) (Maybe [OrganizationalUnit]))
-> ListOrganizationalUnitsForParentResponse
-> Const
     (First [OrganizationalUnit])
     ListOrganizationalUnitsForParentResponse
Lens'
  ListOrganizationalUnitsForParentResponse
  (Maybe [OrganizationalUnit])
listOrganizationalUnitsForParentResponse_organizationalUnits
              ((Maybe [OrganizationalUnit]
  -> Const (First [OrganizationalUnit]) (Maybe [OrganizationalUnit]))
 -> ListOrganizationalUnitsForParentResponse
 -> Const
      (First [OrganizationalUnit])
      ListOrganizationalUnitsForParentResponse)
-> (([OrganizationalUnit]
     -> Const (First [OrganizationalUnit]) [OrganizationalUnit])
    -> Maybe [OrganizationalUnit]
    -> Const (First [OrganizationalUnit]) (Maybe [OrganizationalUnit]))
-> Getting
     (First [OrganizationalUnit])
     ListOrganizationalUnitsForParentResponse
     [OrganizationalUnit]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([OrganizationalUnit]
 -> Const (First [OrganizationalUnit]) [OrganizationalUnit])
-> Maybe [OrganizationalUnit]
-> Const (First [OrganizationalUnit]) (Maybe [OrganizationalUnit])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListOrganizationalUnitsForParent
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListOrganizationalUnitsForParent
-> Maybe ListOrganizationalUnitsForParent
forall a. a -> Maybe a
Prelude.Just (ListOrganizationalUnitsForParent
 -> Maybe ListOrganizationalUnitsForParent)
-> ListOrganizationalUnitsForParent
-> Maybe ListOrganizationalUnitsForParent
forall a b. (a -> b) -> a -> b
Prelude.$
        ListOrganizationalUnitsForParent
rq
          ListOrganizationalUnitsForParent
-> (ListOrganizationalUnitsForParent
    -> ListOrganizationalUnitsForParent)
-> ListOrganizationalUnitsForParent
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListOrganizationalUnitsForParent
-> Identity ListOrganizationalUnitsForParent
Lens
  ListOrganizationalUnitsForParent
  ListOrganizationalUnitsForParent
  (Maybe Text)
  (Maybe Text)
listOrganizationalUnitsForParent_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListOrganizationalUnitsForParent
 -> Identity ListOrganizationalUnitsForParent)
-> Maybe Text
-> ListOrganizationalUnitsForParent
-> ListOrganizationalUnitsForParent
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListOrganizationalUnitsForParent
ListOrganizationalUnitsForParentResponse
rs
          ListOrganizationalUnitsForParentResponse
-> Getting
     (First Text) ListOrganizationalUnitsForParentResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListOrganizationalUnitsForParentResponse
-> Const (First Text) ListOrganizationalUnitsForParentResponse
Lens' ListOrganizationalUnitsForParentResponse (Maybe Text)
listOrganizationalUnitsForParentResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListOrganizationalUnitsForParentResponse
 -> Const (First Text) ListOrganizationalUnitsForParentResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting
     (First Text) ListOrganizationalUnitsForParentResponse 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
    ListOrganizationalUnitsForParent
  where
  type
    AWSResponse ListOrganizationalUnitsForParent =
      ListOrganizationalUnitsForParentResponse
  request :: ListOrganizationalUnitsForParent
-> Request ListOrganizationalUnitsForParent
request = Service
-> ListOrganizationalUnitsForParent
-> Request ListOrganizationalUnitsForParent
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListOrganizationalUnitsForParent
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse ListOrganizationalUnitsForParent)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListOrganizationalUnitsForParent))
-> Logger
-> Service
-> Proxy ListOrganizationalUnitsForParent
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse ListOrganizationalUnitsForParent)))
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 Text
-> Maybe [OrganizationalUnit]
-> Int
-> ListOrganizationalUnitsForParentResponse
ListOrganizationalUnitsForParentResponse'
            (Maybe Text
 -> Maybe [OrganizationalUnit]
 -> Int
 -> ListOrganizationalUnitsForParentResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe [OrganizationalUnit]
      -> Int -> ListOrganizationalUnitsForParentResponse)
forall (f :: * -> *) a b. Functor 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
  (Maybe [OrganizationalUnit]
   -> Int -> ListOrganizationalUnitsForParentResponse)
-> Either String (Maybe [OrganizationalUnit])
-> Either String (Int -> ListOrganizationalUnitsForParentResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text -> Either String (Maybe (Maybe [OrganizationalUnit]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"OrganizationalUnits"
                            Either String (Maybe (Maybe [OrganizationalUnit]))
-> Maybe [OrganizationalUnit]
-> Either String (Maybe [OrganizationalUnit])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [OrganizationalUnit]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Int -> ListOrganizationalUnitsForParentResponse)
-> Either String Int
-> Either String ListOrganizationalUnitsForParentResponse
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
    ListOrganizationalUnitsForParent

instance
  Prelude.NFData
    ListOrganizationalUnitsForParent

instance
  Core.ToHeaders
    ListOrganizationalUnitsForParent
  where
  toHeaders :: ListOrganizationalUnitsForParent -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> ListOrganizationalUnitsForParent -> 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.ListOrganizationalUnitsForParent" ::
                          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 ListOrganizationalUnitsForParent where
  toJSON :: ListOrganizationalUnitsForParent -> Value
toJSON ListOrganizationalUnitsForParent' {Maybe Natural
Maybe Text
Text
parentId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:parentId:ListOrganizationalUnitsForParent' :: ListOrganizationalUnitsForParent -> Text
$sel:maxResults:ListOrganizationalUnitsForParent' :: ListOrganizationalUnitsForParent -> Maybe Natural
$sel:nextToken:ListOrganizationalUnitsForParent' :: ListOrganizationalUnitsForParent -> 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 ListOrganizationalUnitsForParent where
  toPath :: ListOrganizationalUnitsForParent -> ByteString
toPath = ByteString -> ListOrganizationalUnitsForParent -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newListOrganizationalUnitsForParentResponse' smart constructor.
data ListOrganizationalUnitsForParentResponse = ListOrganizationalUnitsForParentResponse'
  { -- | 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@.
    ListOrganizationalUnitsForParentResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A list of the OUs in the specified root or parent OU.
    ListOrganizationalUnitsForParentResponse
-> Maybe [OrganizationalUnit]
organizationalUnits :: Prelude.Maybe [OrganizationalUnit],
    -- | The response's http status code.
    ListOrganizationalUnitsForParentResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListOrganizationalUnitsForParentResponse
-> ListOrganizationalUnitsForParentResponse -> Bool
(ListOrganizationalUnitsForParentResponse
 -> ListOrganizationalUnitsForParentResponse -> Bool)
-> (ListOrganizationalUnitsForParentResponse
    -> ListOrganizationalUnitsForParentResponse -> Bool)
-> Eq ListOrganizationalUnitsForParentResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListOrganizationalUnitsForParentResponse
-> ListOrganizationalUnitsForParentResponse -> Bool
$c/= :: ListOrganizationalUnitsForParentResponse
-> ListOrganizationalUnitsForParentResponse -> Bool
== :: ListOrganizationalUnitsForParentResponse
-> ListOrganizationalUnitsForParentResponse -> Bool
$c== :: ListOrganizationalUnitsForParentResponse
-> ListOrganizationalUnitsForParentResponse -> Bool
Prelude.Eq, ReadPrec [ListOrganizationalUnitsForParentResponse]
ReadPrec ListOrganizationalUnitsForParentResponse
Int -> ReadS ListOrganizationalUnitsForParentResponse
ReadS [ListOrganizationalUnitsForParentResponse]
(Int -> ReadS ListOrganizationalUnitsForParentResponse)
-> ReadS [ListOrganizationalUnitsForParentResponse]
-> ReadPrec ListOrganizationalUnitsForParentResponse
-> ReadPrec [ListOrganizationalUnitsForParentResponse]
-> Read ListOrganizationalUnitsForParentResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListOrganizationalUnitsForParentResponse]
$creadListPrec :: ReadPrec [ListOrganizationalUnitsForParentResponse]
readPrec :: ReadPrec ListOrganizationalUnitsForParentResponse
$creadPrec :: ReadPrec ListOrganizationalUnitsForParentResponse
readList :: ReadS [ListOrganizationalUnitsForParentResponse]
$creadList :: ReadS [ListOrganizationalUnitsForParentResponse]
readsPrec :: Int -> ReadS ListOrganizationalUnitsForParentResponse
$creadsPrec :: Int -> ReadS ListOrganizationalUnitsForParentResponse
Prelude.Read, Int -> ListOrganizationalUnitsForParentResponse -> ShowS
[ListOrganizationalUnitsForParentResponse] -> ShowS
ListOrganizationalUnitsForParentResponse -> String
(Int -> ListOrganizationalUnitsForParentResponse -> ShowS)
-> (ListOrganizationalUnitsForParentResponse -> String)
-> ([ListOrganizationalUnitsForParentResponse] -> ShowS)
-> Show ListOrganizationalUnitsForParentResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListOrganizationalUnitsForParentResponse] -> ShowS
$cshowList :: [ListOrganizationalUnitsForParentResponse] -> ShowS
show :: ListOrganizationalUnitsForParentResponse -> String
$cshow :: ListOrganizationalUnitsForParentResponse -> String
showsPrec :: Int -> ListOrganizationalUnitsForParentResponse -> ShowS
$cshowsPrec :: Int -> ListOrganizationalUnitsForParentResponse -> ShowS
Prelude.Show, (forall x.
 ListOrganizationalUnitsForParentResponse
 -> Rep ListOrganizationalUnitsForParentResponse x)
-> (forall x.
    Rep ListOrganizationalUnitsForParentResponse x
    -> ListOrganizationalUnitsForParentResponse)
-> Generic ListOrganizationalUnitsForParentResponse
forall x.
Rep ListOrganizationalUnitsForParentResponse x
-> ListOrganizationalUnitsForParentResponse
forall x.
ListOrganizationalUnitsForParentResponse
-> Rep ListOrganizationalUnitsForParentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListOrganizationalUnitsForParentResponse x
-> ListOrganizationalUnitsForParentResponse
$cfrom :: forall x.
ListOrganizationalUnitsForParentResponse
-> Rep ListOrganizationalUnitsForParentResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListOrganizationalUnitsForParentResponse' 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', 'listOrganizationalUnitsForParentResponse_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@.
--
-- 'organizationalUnits', 'listOrganizationalUnitsForParentResponse_organizationalUnits' - A list of the OUs in the specified root or parent OU.
--
-- 'httpStatus', 'listOrganizationalUnitsForParentResponse_httpStatus' - The response's http status code.
newListOrganizationalUnitsForParentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListOrganizationalUnitsForParentResponse
newListOrganizationalUnitsForParentResponse :: Int -> ListOrganizationalUnitsForParentResponse
newListOrganizationalUnitsForParentResponse
  Int
pHttpStatus_ =
    ListOrganizationalUnitsForParentResponse' :: Maybe Text
-> Maybe [OrganizationalUnit]
-> Int
-> ListOrganizationalUnitsForParentResponse
ListOrganizationalUnitsForParentResponse'
      { $sel:nextToken:ListOrganizationalUnitsForParentResponse' :: Maybe Text
nextToken =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:organizationalUnits:ListOrganizationalUnitsForParentResponse' :: Maybe [OrganizationalUnit]
organizationalUnits =
          Maybe [OrganizationalUnit]
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:ListOrganizationalUnitsForParentResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | 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@.
listOrganizationalUnitsForParentResponse_nextToken :: Lens.Lens' ListOrganizationalUnitsForParentResponse (Prelude.Maybe Prelude.Text)
listOrganizationalUnitsForParentResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListOrganizationalUnitsForParentResponse
-> f ListOrganizationalUnitsForParentResponse
listOrganizationalUnitsForParentResponse_nextToken = (ListOrganizationalUnitsForParentResponse -> Maybe Text)
-> (ListOrganizationalUnitsForParentResponse
    -> Maybe Text -> ListOrganizationalUnitsForParentResponse)
-> Lens' ListOrganizationalUnitsForParentResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListOrganizationalUnitsForParentResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListOrganizationalUnitsForParentResponse' :: ListOrganizationalUnitsForParentResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListOrganizationalUnitsForParentResponse
s@ListOrganizationalUnitsForParentResponse' {} Maybe Text
a -> ListOrganizationalUnitsForParentResponse
s {$sel:nextToken:ListOrganizationalUnitsForParentResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListOrganizationalUnitsForParentResponse)

-- | A list of the OUs in the specified root or parent OU.
listOrganizationalUnitsForParentResponse_organizationalUnits :: Lens.Lens' ListOrganizationalUnitsForParentResponse (Prelude.Maybe [OrganizationalUnit])
listOrganizationalUnitsForParentResponse_organizationalUnits :: (Maybe [OrganizationalUnit] -> f (Maybe [OrganizationalUnit]))
-> ListOrganizationalUnitsForParentResponse
-> f ListOrganizationalUnitsForParentResponse
listOrganizationalUnitsForParentResponse_organizationalUnits = (ListOrganizationalUnitsForParentResponse
 -> Maybe [OrganizationalUnit])
-> (ListOrganizationalUnitsForParentResponse
    -> Maybe [OrganizationalUnit]
    -> ListOrganizationalUnitsForParentResponse)
-> Lens'
     ListOrganizationalUnitsForParentResponse
     (Maybe [OrganizationalUnit])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListOrganizationalUnitsForParentResponse' {Maybe [OrganizationalUnit]
organizationalUnits :: Maybe [OrganizationalUnit]
$sel:organizationalUnits:ListOrganizationalUnitsForParentResponse' :: ListOrganizationalUnitsForParentResponse
-> Maybe [OrganizationalUnit]
organizationalUnits} -> Maybe [OrganizationalUnit]
organizationalUnits) (\s :: ListOrganizationalUnitsForParentResponse
s@ListOrganizationalUnitsForParentResponse' {} Maybe [OrganizationalUnit]
a -> ListOrganizationalUnitsForParentResponse
s {$sel:organizationalUnits:ListOrganizationalUnitsForParentResponse' :: Maybe [OrganizationalUnit]
organizationalUnits = Maybe [OrganizationalUnit]
a} :: ListOrganizationalUnitsForParentResponse) ((Maybe [OrganizationalUnit] -> f (Maybe [OrganizationalUnit]))
 -> ListOrganizationalUnitsForParentResponse
 -> f ListOrganizationalUnitsForParentResponse)
-> ((Maybe [OrganizationalUnit] -> f (Maybe [OrganizationalUnit]))
    -> Maybe [OrganizationalUnit] -> f (Maybe [OrganizationalUnit]))
-> (Maybe [OrganizationalUnit] -> f (Maybe [OrganizationalUnit]))
-> ListOrganizationalUnitsForParentResponse
-> f ListOrganizationalUnitsForParentResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [OrganizationalUnit]
  [OrganizationalUnit]
  [OrganizationalUnit]
  [OrganizationalUnit]
-> Iso
     (Maybe [OrganizationalUnit])
     (Maybe [OrganizationalUnit])
     (Maybe [OrganizationalUnit])
     (Maybe [OrganizationalUnit])
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
  [OrganizationalUnit]
  [OrganizationalUnit]
  [OrganizationalUnit]
  [OrganizationalUnit]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
listOrganizationalUnitsForParentResponse_httpStatus :: Lens.Lens' ListOrganizationalUnitsForParentResponse Prelude.Int
listOrganizationalUnitsForParentResponse_httpStatus :: (Int -> f Int)
-> ListOrganizationalUnitsForParentResponse
-> f ListOrganizationalUnitsForParentResponse
listOrganizationalUnitsForParentResponse_httpStatus = (ListOrganizationalUnitsForParentResponse -> Int)
-> (ListOrganizationalUnitsForParentResponse
    -> Int -> ListOrganizationalUnitsForParentResponse)
-> Lens
     ListOrganizationalUnitsForParentResponse
     ListOrganizationalUnitsForParentResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListOrganizationalUnitsForParentResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListOrganizationalUnitsForParentResponse' :: ListOrganizationalUnitsForParentResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListOrganizationalUnitsForParentResponse
s@ListOrganizationalUnitsForParentResponse' {} Int
a -> ListOrganizationalUnitsForParentResponse
s {$sel:httpStatus:ListOrganizationalUnitsForParentResponse' :: Int
httpStatus = Int
a} :: ListOrganizationalUnitsForParentResponse)

instance
  Prelude.NFData
    ListOrganizationalUnitsForParentResponse