{-# 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.ListDelegatedServicesForAccount
-- 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)
--
-- List the AWS services for which the specified account is a delegated
-- administrator.
--
-- 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.ListDelegatedServicesForAccount
  ( -- * Creating a Request
    ListDelegatedServicesForAccount (..),
    newListDelegatedServicesForAccount,

    -- * Request Lenses
    listDelegatedServicesForAccount_nextToken,
    listDelegatedServicesForAccount_maxResults,
    listDelegatedServicesForAccount_accountId,

    -- * Destructuring the Response
    ListDelegatedServicesForAccountResponse (..),
    newListDelegatedServicesForAccountResponse,

    -- * Response Lenses
    listDelegatedServicesForAccountResponse_delegatedServices,
    listDelegatedServicesForAccountResponse_nextToken,
    listDelegatedServicesForAccountResponse_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:/ 'newListDelegatedServicesForAccount' smart constructor.
data ListDelegatedServicesForAccount = ListDelegatedServicesForAccount'
  { -- | 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.
    ListDelegatedServicesForAccount -> 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.
    ListDelegatedServicesForAccount -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The account ID number of a delegated administrator account in the
    -- organization.
    ListDelegatedServicesForAccount -> Text
accountId :: Prelude.Text
  }
  deriving (ListDelegatedServicesForAccount
-> ListDelegatedServicesForAccount -> Bool
(ListDelegatedServicesForAccount
 -> ListDelegatedServicesForAccount -> Bool)
-> (ListDelegatedServicesForAccount
    -> ListDelegatedServicesForAccount -> Bool)
-> Eq ListDelegatedServicesForAccount
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDelegatedServicesForAccount
-> ListDelegatedServicesForAccount -> Bool
$c/= :: ListDelegatedServicesForAccount
-> ListDelegatedServicesForAccount -> Bool
== :: ListDelegatedServicesForAccount
-> ListDelegatedServicesForAccount -> Bool
$c== :: ListDelegatedServicesForAccount
-> ListDelegatedServicesForAccount -> Bool
Prelude.Eq, ReadPrec [ListDelegatedServicesForAccount]
ReadPrec ListDelegatedServicesForAccount
Int -> ReadS ListDelegatedServicesForAccount
ReadS [ListDelegatedServicesForAccount]
(Int -> ReadS ListDelegatedServicesForAccount)
-> ReadS [ListDelegatedServicesForAccount]
-> ReadPrec ListDelegatedServicesForAccount
-> ReadPrec [ListDelegatedServicesForAccount]
-> Read ListDelegatedServicesForAccount
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDelegatedServicesForAccount]
$creadListPrec :: ReadPrec [ListDelegatedServicesForAccount]
readPrec :: ReadPrec ListDelegatedServicesForAccount
$creadPrec :: ReadPrec ListDelegatedServicesForAccount
readList :: ReadS [ListDelegatedServicesForAccount]
$creadList :: ReadS [ListDelegatedServicesForAccount]
readsPrec :: Int -> ReadS ListDelegatedServicesForAccount
$creadsPrec :: Int -> ReadS ListDelegatedServicesForAccount
Prelude.Read, Int -> ListDelegatedServicesForAccount -> ShowS
[ListDelegatedServicesForAccount] -> ShowS
ListDelegatedServicesForAccount -> String
(Int -> ListDelegatedServicesForAccount -> ShowS)
-> (ListDelegatedServicesForAccount -> String)
-> ([ListDelegatedServicesForAccount] -> ShowS)
-> Show ListDelegatedServicesForAccount
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDelegatedServicesForAccount] -> ShowS
$cshowList :: [ListDelegatedServicesForAccount] -> ShowS
show :: ListDelegatedServicesForAccount -> String
$cshow :: ListDelegatedServicesForAccount -> String
showsPrec :: Int -> ListDelegatedServicesForAccount -> ShowS
$cshowsPrec :: Int -> ListDelegatedServicesForAccount -> ShowS
Prelude.Show, (forall x.
 ListDelegatedServicesForAccount
 -> Rep ListDelegatedServicesForAccount x)
-> (forall x.
    Rep ListDelegatedServicesForAccount x
    -> ListDelegatedServicesForAccount)
-> Generic ListDelegatedServicesForAccount
forall x.
Rep ListDelegatedServicesForAccount x
-> ListDelegatedServicesForAccount
forall x.
ListDelegatedServicesForAccount
-> Rep ListDelegatedServicesForAccount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListDelegatedServicesForAccount x
-> ListDelegatedServicesForAccount
$cfrom :: forall x.
ListDelegatedServicesForAccount
-> Rep ListDelegatedServicesForAccount x
Prelude.Generic)

-- |
-- Create a value of 'ListDelegatedServicesForAccount' 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', 'listDelegatedServicesForAccount_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', 'listDelegatedServicesForAccount_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.
--
-- 'accountId', 'listDelegatedServicesForAccount_accountId' - The account ID number of a delegated administrator account in the
-- organization.
newListDelegatedServicesForAccount ::
  -- | 'accountId'
  Prelude.Text ->
  ListDelegatedServicesForAccount
newListDelegatedServicesForAccount :: Text -> ListDelegatedServicesForAccount
newListDelegatedServicesForAccount Text
pAccountId_ =
  ListDelegatedServicesForAccount' :: Maybe Text
-> Maybe Natural -> Text -> ListDelegatedServicesForAccount
ListDelegatedServicesForAccount'
    { $sel:nextToken:ListDelegatedServicesForAccount' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListDelegatedServicesForAccount' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:accountId:ListDelegatedServicesForAccount' :: Text
accountId = Text
pAccountId_
    }

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

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

-- | The account ID number of a delegated administrator account in the
-- organization.
listDelegatedServicesForAccount_accountId :: Lens.Lens' ListDelegatedServicesForAccount Prelude.Text
listDelegatedServicesForAccount_accountId :: (Text -> f Text)
-> ListDelegatedServicesForAccount
-> f ListDelegatedServicesForAccount
listDelegatedServicesForAccount_accountId = (ListDelegatedServicesForAccount -> Text)
-> (ListDelegatedServicesForAccount
    -> Text -> ListDelegatedServicesForAccount)
-> Lens
     ListDelegatedServicesForAccount
     ListDelegatedServicesForAccount
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDelegatedServicesForAccount' {Text
accountId :: Text
$sel:accountId:ListDelegatedServicesForAccount' :: ListDelegatedServicesForAccount -> Text
accountId} -> Text
accountId) (\s :: ListDelegatedServicesForAccount
s@ListDelegatedServicesForAccount' {} Text
a -> ListDelegatedServicesForAccount
s {$sel:accountId:ListDelegatedServicesForAccount' :: Text
accountId = Text
a} :: ListDelegatedServicesForAccount)

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

instance
  Prelude.NFData
    ListDelegatedServicesForAccount

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

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

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

-- | /See:/ 'newListDelegatedServicesForAccountResponse' smart constructor.
data ListDelegatedServicesForAccountResponse = ListDelegatedServicesForAccountResponse'
  { -- | The services for which the account is a delegated administrator.
    ListDelegatedServicesForAccountResponse -> Maybe [DelegatedService]
delegatedServices :: Prelude.Maybe [DelegatedService],
    -- | 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@.
    ListDelegatedServicesForAccountResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListDelegatedServicesForAccountResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListDelegatedServicesForAccountResponse
-> ListDelegatedServicesForAccountResponse -> Bool
(ListDelegatedServicesForAccountResponse
 -> ListDelegatedServicesForAccountResponse -> Bool)
-> (ListDelegatedServicesForAccountResponse
    -> ListDelegatedServicesForAccountResponse -> Bool)
-> Eq ListDelegatedServicesForAccountResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDelegatedServicesForAccountResponse
-> ListDelegatedServicesForAccountResponse -> Bool
$c/= :: ListDelegatedServicesForAccountResponse
-> ListDelegatedServicesForAccountResponse -> Bool
== :: ListDelegatedServicesForAccountResponse
-> ListDelegatedServicesForAccountResponse -> Bool
$c== :: ListDelegatedServicesForAccountResponse
-> ListDelegatedServicesForAccountResponse -> Bool
Prelude.Eq, ReadPrec [ListDelegatedServicesForAccountResponse]
ReadPrec ListDelegatedServicesForAccountResponse
Int -> ReadS ListDelegatedServicesForAccountResponse
ReadS [ListDelegatedServicesForAccountResponse]
(Int -> ReadS ListDelegatedServicesForAccountResponse)
-> ReadS [ListDelegatedServicesForAccountResponse]
-> ReadPrec ListDelegatedServicesForAccountResponse
-> ReadPrec [ListDelegatedServicesForAccountResponse]
-> Read ListDelegatedServicesForAccountResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDelegatedServicesForAccountResponse]
$creadListPrec :: ReadPrec [ListDelegatedServicesForAccountResponse]
readPrec :: ReadPrec ListDelegatedServicesForAccountResponse
$creadPrec :: ReadPrec ListDelegatedServicesForAccountResponse
readList :: ReadS [ListDelegatedServicesForAccountResponse]
$creadList :: ReadS [ListDelegatedServicesForAccountResponse]
readsPrec :: Int -> ReadS ListDelegatedServicesForAccountResponse
$creadsPrec :: Int -> ReadS ListDelegatedServicesForAccountResponse
Prelude.Read, Int -> ListDelegatedServicesForAccountResponse -> ShowS
[ListDelegatedServicesForAccountResponse] -> ShowS
ListDelegatedServicesForAccountResponse -> String
(Int -> ListDelegatedServicesForAccountResponse -> ShowS)
-> (ListDelegatedServicesForAccountResponse -> String)
-> ([ListDelegatedServicesForAccountResponse] -> ShowS)
-> Show ListDelegatedServicesForAccountResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDelegatedServicesForAccountResponse] -> ShowS
$cshowList :: [ListDelegatedServicesForAccountResponse] -> ShowS
show :: ListDelegatedServicesForAccountResponse -> String
$cshow :: ListDelegatedServicesForAccountResponse -> String
showsPrec :: Int -> ListDelegatedServicesForAccountResponse -> ShowS
$cshowsPrec :: Int -> ListDelegatedServicesForAccountResponse -> ShowS
Prelude.Show, (forall x.
 ListDelegatedServicesForAccountResponse
 -> Rep ListDelegatedServicesForAccountResponse x)
-> (forall x.
    Rep ListDelegatedServicesForAccountResponse x
    -> ListDelegatedServicesForAccountResponse)
-> Generic ListDelegatedServicesForAccountResponse
forall x.
Rep ListDelegatedServicesForAccountResponse x
-> ListDelegatedServicesForAccountResponse
forall x.
ListDelegatedServicesForAccountResponse
-> Rep ListDelegatedServicesForAccountResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListDelegatedServicesForAccountResponse x
-> ListDelegatedServicesForAccountResponse
$cfrom :: forall x.
ListDelegatedServicesForAccountResponse
-> Rep ListDelegatedServicesForAccountResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListDelegatedServicesForAccountResponse' 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:
--
-- 'delegatedServices', 'listDelegatedServicesForAccountResponse_delegatedServices' - The services for which the account is a delegated administrator.
--
-- 'nextToken', 'listDelegatedServicesForAccountResponse_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', 'listDelegatedServicesForAccountResponse_httpStatus' - The response's http status code.
newListDelegatedServicesForAccountResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListDelegatedServicesForAccountResponse
newListDelegatedServicesForAccountResponse :: Int -> ListDelegatedServicesForAccountResponse
newListDelegatedServicesForAccountResponse
  Int
pHttpStatus_ =
    ListDelegatedServicesForAccountResponse' :: Maybe [DelegatedService]
-> Maybe Text -> Int -> ListDelegatedServicesForAccountResponse
ListDelegatedServicesForAccountResponse'
      { $sel:delegatedServices:ListDelegatedServicesForAccountResponse' :: Maybe [DelegatedService]
delegatedServices =
          Maybe [DelegatedService]
forall a. Maybe a
Prelude.Nothing,
        $sel:nextToken:ListDelegatedServicesForAccountResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:ListDelegatedServicesForAccountResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | The services for which the account is a delegated administrator.
listDelegatedServicesForAccountResponse_delegatedServices :: Lens.Lens' ListDelegatedServicesForAccountResponse (Prelude.Maybe [DelegatedService])
listDelegatedServicesForAccountResponse_delegatedServices :: (Maybe [DelegatedService] -> f (Maybe [DelegatedService]))
-> ListDelegatedServicesForAccountResponse
-> f ListDelegatedServicesForAccountResponse
listDelegatedServicesForAccountResponse_delegatedServices = (ListDelegatedServicesForAccountResponse
 -> Maybe [DelegatedService])
-> (ListDelegatedServicesForAccountResponse
    -> Maybe [DelegatedService]
    -> ListDelegatedServicesForAccountResponse)
-> Lens'
     ListDelegatedServicesForAccountResponse (Maybe [DelegatedService])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDelegatedServicesForAccountResponse' {Maybe [DelegatedService]
delegatedServices :: Maybe [DelegatedService]
$sel:delegatedServices:ListDelegatedServicesForAccountResponse' :: ListDelegatedServicesForAccountResponse -> Maybe [DelegatedService]
delegatedServices} -> Maybe [DelegatedService]
delegatedServices) (\s :: ListDelegatedServicesForAccountResponse
s@ListDelegatedServicesForAccountResponse' {} Maybe [DelegatedService]
a -> ListDelegatedServicesForAccountResponse
s {$sel:delegatedServices:ListDelegatedServicesForAccountResponse' :: Maybe [DelegatedService]
delegatedServices = Maybe [DelegatedService]
a} :: ListDelegatedServicesForAccountResponse) ((Maybe [DelegatedService] -> f (Maybe [DelegatedService]))
 -> ListDelegatedServicesForAccountResponse
 -> f ListDelegatedServicesForAccountResponse)
-> ((Maybe [DelegatedService] -> f (Maybe [DelegatedService]))
    -> Maybe [DelegatedService] -> f (Maybe [DelegatedService]))
-> (Maybe [DelegatedService] -> f (Maybe [DelegatedService]))
-> ListDelegatedServicesForAccountResponse
-> f ListDelegatedServicesForAccountResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [DelegatedService]
  [DelegatedService]
  [DelegatedService]
  [DelegatedService]
-> Iso
     (Maybe [DelegatedService])
     (Maybe [DelegatedService])
     (Maybe [DelegatedService])
     (Maybe [DelegatedService])
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
  [DelegatedService]
  [DelegatedService]
  [DelegatedService]
  [DelegatedService]
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@.
listDelegatedServicesForAccountResponse_nextToken :: Lens.Lens' ListDelegatedServicesForAccountResponse (Prelude.Maybe Prelude.Text)
listDelegatedServicesForAccountResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListDelegatedServicesForAccountResponse
-> f ListDelegatedServicesForAccountResponse
listDelegatedServicesForAccountResponse_nextToken = (ListDelegatedServicesForAccountResponse -> Maybe Text)
-> (ListDelegatedServicesForAccountResponse
    -> Maybe Text -> ListDelegatedServicesForAccountResponse)
-> Lens' ListDelegatedServicesForAccountResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDelegatedServicesForAccountResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDelegatedServicesForAccountResponse' :: ListDelegatedServicesForAccountResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDelegatedServicesForAccountResponse
s@ListDelegatedServicesForAccountResponse' {} Maybe Text
a -> ListDelegatedServicesForAccountResponse
s {$sel:nextToken:ListDelegatedServicesForAccountResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListDelegatedServicesForAccountResponse)

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

instance
  Prelude.NFData
    ListDelegatedServicesForAccountResponse