{-# 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.ListParents
-- 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 root or organizational units (OUs) that serve as the immediate
-- parent of the specified child OU or account. This operation, along with
-- ListChildren enables you to traverse the tree structure that makes up
-- this 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.
--
-- In the current release, a child can have only a single parent.
--
-- This operation returns paginated results.
module Amazonka.Organizations.ListParents
  ( -- * Creating a Request
    ListParents (..),
    newListParents,

    -- * Request Lenses
    listParents_nextToken,
    listParents_maxResults,
    listParents_childId,

    -- * Destructuring the Response
    ListParentsResponse (..),
    newListParentsResponse,

    -- * Response Lenses
    listParentsResponse_nextToken,
    listParentsResponse_parents,
    listParentsResponse_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:/ 'newListParents' smart constructor.
data ListParents = ListParents'
  { -- | 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.
    ListParents -> 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.
    ListParents -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The unique identifier (ID) of the OU or account whose parent containers
    -- you want to list. Don\'t specify a root.
    --
    -- The <http://wikipedia.org/wiki/regex regex pattern> for a child ID
    -- string requires one of the following:
    --
    -- -   __Account__ - A string that consists of exactly 12 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 contains the OU). This string is followed by a second
    --     \"-\" dash and from 8 to 32 additional lowercase letters or digits.
    ListParents -> Text
childId :: Prelude.Text
  }
  deriving (ListParents -> ListParents -> Bool
(ListParents -> ListParents -> Bool)
-> (ListParents -> ListParents -> Bool) -> Eq ListParents
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListParents -> ListParents -> Bool
$c/= :: ListParents -> ListParents -> Bool
== :: ListParents -> ListParents -> Bool
$c== :: ListParents -> ListParents -> Bool
Prelude.Eq, ReadPrec [ListParents]
ReadPrec ListParents
Int -> ReadS ListParents
ReadS [ListParents]
(Int -> ReadS ListParents)
-> ReadS [ListParents]
-> ReadPrec ListParents
-> ReadPrec [ListParents]
-> Read ListParents
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListParents]
$creadListPrec :: ReadPrec [ListParents]
readPrec :: ReadPrec ListParents
$creadPrec :: ReadPrec ListParents
readList :: ReadS [ListParents]
$creadList :: ReadS [ListParents]
readsPrec :: Int -> ReadS ListParents
$creadsPrec :: Int -> ReadS ListParents
Prelude.Read, Int -> ListParents -> ShowS
[ListParents] -> ShowS
ListParents -> String
(Int -> ListParents -> ShowS)
-> (ListParents -> String)
-> ([ListParents] -> ShowS)
-> Show ListParents
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListParents] -> ShowS
$cshowList :: [ListParents] -> ShowS
show :: ListParents -> String
$cshow :: ListParents -> String
showsPrec :: Int -> ListParents -> ShowS
$cshowsPrec :: Int -> ListParents -> ShowS
Prelude.Show, (forall x. ListParents -> Rep ListParents x)
-> (forall x. Rep ListParents x -> ListParents)
-> Generic ListParents
forall x. Rep ListParents x -> ListParents
forall x. ListParents -> Rep ListParents x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListParents x -> ListParents
$cfrom :: forall x. ListParents -> Rep ListParents x
Prelude.Generic)

-- |
-- Create a value of 'ListParents' 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', 'listParents_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', 'listParents_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.
--
-- 'childId', 'listParents_childId' - The unique identifier (ID) of the OU or account whose parent containers
-- you want to list. Don\'t specify a root.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for a child ID
-- string requires one of the following:
--
-- -   __Account__ - A string that consists of exactly 12 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 contains the OU). This string is followed by a second
--     \"-\" dash and from 8 to 32 additional lowercase letters or digits.
newListParents ::
  -- | 'childId'
  Prelude.Text ->
  ListParents
newListParents :: Text -> ListParents
newListParents Text
pChildId_ =
  ListParents' :: Maybe Text -> Maybe Natural -> Text -> ListParents
ListParents'
    { $sel:nextToken:ListParents' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListParents' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:childId:ListParents' :: Text
childId = Text
pChildId_
    }

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

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

-- | The unique identifier (ID) of the OU or account whose parent containers
-- you want to list. Don\'t specify a root.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for a child ID
-- string requires one of the following:
--
-- -   __Account__ - A string that consists of exactly 12 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 contains the OU). This string is followed by a second
--     \"-\" dash and from 8 to 32 additional lowercase letters or digits.
listParents_childId :: Lens.Lens' ListParents Prelude.Text
listParents_childId :: (Text -> f Text) -> ListParents -> f ListParents
listParents_childId = (ListParents -> Text)
-> (ListParents -> Text -> ListParents)
-> Lens ListParents ListParents Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListParents' {Text
childId :: Text
$sel:childId:ListParents' :: ListParents -> Text
childId} -> Text
childId) (\s :: ListParents
s@ListParents' {} Text
a -> ListParents
s {$sel:childId:ListParents' :: Text
childId = Text
a} :: ListParents)

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

instance Prelude.NFData ListParents

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

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

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

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

-- |
-- Create a value of 'ListParentsResponse' 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', 'listParentsResponse_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@.
--
-- 'parents', 'listParentsResponse_parents' - A list of parents for the specified child account or OU.
--
-- 'httpStatus', 'listParentsResponse_httpStatus' - The response's http status code.
newListParentsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListParentsResponse
newListParentsResponse :: Int -> ListParentsResponse
newListParentsResponse Int
pHttpStatus_ =
  ListParentsResponse' :: Maybe Text -> Maybe [Parent] -> Int -> ListParentsResponse
ListParentsResponse'
    { $sel:nextToken:ListParentsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:parents:ListParentsResponse' :: Maybe [Parent]
parents = Maybe [Parent]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListParentsResponse' :: 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@.
listParentsResponse_nextToken :: Lens.Lens' ListParentsResponse (Prelude.Maybe Prelude.Text)
listParentsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListParentsResponse -> f ListParentsResponse
listParentsResponse_nextToken = (ListParentsResponse -> Maybe Text)
-> (ListParentsResponse -> Maybe Text -> ListParentsResponse)
-> Lens' ListParentsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListParentsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListParentsResponse' :: ListParentsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListParentsResponse
s@ListParentsResponse' {} Maybe Text
a -> ListParentsResponse
s {$sel:nextToken:ListParentsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListParentsResponse)

-- | A list of parents for the specified child account or OU.
listParentsResponse_parents :: Lens.Lens' ListParentsResponse (Prelude.Maybe [Parent])
listParentsResponse_parents :: (Maybe [Parent] -> f (Maybe [Parent]))
-> ListParentsResponse -> f ListParentsResponse
listParentsResponse_parents = (ListParentsResponse -> Maybe [Parent])
-> (ListParentsResponse -> Maybe [Parent] -> ListParentsResponse)
-> Lens' ListParentsResponse (Maybe [Parent])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListParentsResponse' {Maybe [Parent]
parents :: Maybe [Parent]
$sel:parents:ListParentsResponse' :: ListParentsResponse -> Maybe [Parent]
parents} -> Maybe [Parent]
parents) (\s :: ListParentsResponse
s@ListParentsResponse' {} Maybe [Parent]
a -> ListParentsResponse
s {$sel:parents:ListParentsResponse' :: Maybe [Parent]
parents = Maybe [Parent]
a} :: ListParentsResponse) ((Maybe [Parent] -> f (Maybe [Parent]))
 -> ListParentsResponse -> f ListParentsResponse)
-> ((Maybe [Parent] -> f (Maybe [Parent]))
    -> Maybe [Parent] -> f (Maybe [Parent]))
-> (Maybe [Parent] -> f (Maybe [Parent]))
-> ListParentsResponse
-> f ListParentsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Parent] [Parent] [Parent] [Parent]
-> Iso
     (Maybe [Parent]) (Maybe [Parent]) (Maybe [Parent]) (Maybe [Parent])
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 [Parent] [Parent] [Parent] [Parent]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListParentsResponse