{-# 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.ServiceCatalog.ListPrincipalsForPortfolio
-- 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 all principal ARNs associated with the specified portfolio.
--
-- This operation returns paginated results.
module Amazonka.ServiceCatalog.ListPrincipalsForPortfolio
  ( -- * Creating a Request
    ListPrincipalsForPortfolio (..),
    newListPrincipalsForPortfolio,

    -- * Request Lenses
    listPrincipalsForPortfolio_acceptLanguage,
    listPrincipalsForPortfolio_pageToken,
    listPrincipalsForPortfolio_pageSize,
    listPrincipalsForPortfolio_portfolioId,

    -- * Destructuring the Response
    ListPrincipalsForPortfolioResponse (..),
    newListPrincipalsForPortfolioResponse,

    -- * Response Lenses
    listPrincipalsForPortfolioResponse_nextPageToken,
    listPrincipalsForPortfolioResponse_principals,
    listPrincipalsForPortfolioResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.ServiceCatalog.Types

-- | /See:/ 'newListPrincipalsForPortfolio' smart constructor.
data ListPrincipalsForPortfolio = ListPrincipalsForPortfolio'
  { -- | The language code.
    --
    -- -   @en@ - English (default)
    --
    -- -   @jp@ - Japanese
    --
    -- -   @zh@ - Chinese
    ListPrincipalsForPortfolio -> Maybe Text
acceptLanguage :: Prelude.Maybe Prelude.Text,
    -- | The page token for the next set of results. To retrieve the first set of
    -- results, use null.
    ListPrincipalsForPortfolio -> Maybe Text
pageToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of items to return with this call.
    ListPrincipalsForPortfolio -> Maybe Natural
pageSize :: Prelude.Maybe Prelude.Natural,
    -- | The portfolio identifier.
    ListPrincipalsForPortfolio -> Text
portfolioId :: Prelude.Text
  }
  deriving (ListPrincipalsForPortfolio -> ListPrincipalsForPortfolio -> Bool
(ListPrincipalsForPortfolio -> ListPrincipalsForPortfolio -> Bool)
-> (ListPrincipalsForPortfolio
    -> ListPrincipalsForPortfolio -> Bool)
-> Eq ListPrincipalsForPortfolio
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPrincipalsForPortfolio -> ListPrincipalsForPortfolio -> Bool
$c/= :: ListPrincipalsForPortfolio -> ListPrincipalsForPortfolio -> Bool
== :: ListPrincipalsForPortfolio -> ListPrincipalsForPortfolio -> Bool
$c== :: ListPrincipalsForPortfolio -> ListPrincipalsForPortfolio -> Bool
Prelude.Eq, ReadPrec [ListPrincipalsForPortfolio]
ReadPrec ListPrincipalsForPortfolio
Int -> ReadS ListPrincipalsForPortfolio
ReadS [ListPrincipalsForPortfolio]
(Int -> ReadS ListPrincipalsForPortfolio)
-> ReadS [ListPrincipalsForPortfolio]
-> ReadPrec ListPrincipalsForPortfolio
-> ReadPrec [ListPrincipalsForPortfolio]
-> Read ListPrincipalsForPortfolio
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPrincipalsForPortfolio]
$creadListPrec :: ReadPrec [ListPrincipalsForPortfolio]
readPrec :: ReadPrec ListPrincipalsForPortfolio
$creadPrec :: ReadPrec ListPrincipalsForPortfolio
readList :: ReadS [ListPrincipalsForPortfolio]
$creadList :: ReadS [ListPrincipalsForPortfolio]
readsPrec :: Int -> ReadS ListPrincipalsForPortfolio
$creadsPrec :: Int -> ReadS ListPrincipalsForPortfolio
Prelude.Read, Int -> ListPrincipalsForPortfolio -> ShowS
[ListPrincipalsForPortfolio] -> ShowS
ListPrincipalsForPortfolio -> String
(Int -> ListPrincipalsForPortfolio -> ShowS)
-> (ListPrincipalsForPortfolio -> String)
-> ([ListPrincipalsForPortfolio] -> ShowS)
-> Show ListPrincipalsForPortfolio
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPrincipalsForPortfolio] -> ShowS
$cshowList :: [ListPrincipalsForPortfolio] -> ShowS
show :: ListPrincipalsForPortfolio -> String
$cshow :: ListPrincipalsForPortfolio -> String
showsPrec :: Int -> ListPrincipalsForPortfolio -> ShowS
$cshowsPrec :: Int -> ListPrincipalsForPortfolio -> ShowS
Prelude.Show, (forall x.
 ListPrincipalsForPortfolio -> Rep ListPrincipalsForPortfolio x)
-> (forall x.
    Rep ListPrincipalsForPortfolio x -> ListPrincipalsForPortfolio)
-> Generic ListPrincipalsForPortfolio
forall x.
Rep ListPrincipalsForPortfolio x -> ListPrincipalsForPortfolio
forall x.
ListPrincipalsForPortfolio -> Rep ListPrincipalsForPortfolio x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListPrincipalsForPortfolio x -> ListPrincipalsForPortfolio
$cfrom :: forall x.
ListPrincipalsForPortfolio -> Rep ListPrincipalsForPortfolio x
Prelude.Generic)

-- |
-- Create a value of 'ListPrincipalsForPortfolio' 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:
--
-- 'acceptLanguage', 'listPrincipalsForPortfolio_acceptLanguage' - The language code.
--
-- -   @en@ - English (default)
--
-- -   @jp@ - Japanese
--
-- -   @zh@ - Chinese
--
-- 'pageToken', 'listPrincipalsForPortfolio_pageToken' - The page token for the next set of results. To retrieve the first set of
-- results, use null.
--
-- 'pageSize', 'listPrincipalsForPortfolio_pageSize' - The maximum number of items to return with this call.
--
-- 'portfolioId', 'listPrincipalsForPortfolio_portfolioId' - The portfolio identifier.
newListPrincipalsForPortfolio ::
  -- | 'portfolioId'
  Prelude.Text ->
  ListPrincipalsForPortfolio
newListPrincipalsForPortfolio :: Text -> ListPrincipalsForPortfolio
newListPrincipalsForPortfolio Text
pPortfolioId_ =
  ListPrincipalsForPortfolio' :: Maybe Text
-> Maybe Text
-> Maybe Natural
-> Text
-> ListPrincipalsForPortfolio
ListPrincipalsForPortfolio'
    { $sel:acceptLanguage:ListPrincipalsForPortfolio' :: Maybe Text
acceptLanguage =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:pageToken:ListPrincipalsForPortfolio' :: Maybe Text
pageToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:pageSize:ListPrincipalsForPortfolio' :: Maybe Natural
pageSize = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:portfolioId:ListPrincipalsForPortfolio' :: Text
portfolioId = Text
pPortfolioId_
    }

-- | The language code.
--
-- -   @en@ - English (default)
--
-- -   @jp@ - Japanese
--
-- -   @zh@ - Chinese
listPrincipalsForPortfolio_acceptLanguage :: Lens.Lens' ListPrincipalsForPortfolio (Prelude.Maybe Prelude.Text)
listPrincipalsForPortfolio_acceptLanguage :: (Maybe Text -> f (Maybe Text))
-> ListPrincipalsForPortfolio -> f ListPrincipalsForPortfolio
listPrincipalsForPortfolio_acceptLanguage = (ListPrincipalsForPortfolio -> Maybe Text)
-> (ListPrincipalsForPortfolio
    -> Maybe Text -> ListPrincipalsForPortfolio)
-> Lens
     ListPrincipalsForPortfolio
     ListPrincipalsForPortfolio
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPrincipalsForPortfolio' {Maybe Text
acceptLanguage :: Maybe Text
$sel:acceptLanguage:ListPrincipalsForPortfolio' :: ListPrincipalsForPortfolio -> Maybe Text
acceptLanguage} -> Maybe Text
acceptLanguage) (\s :: ListPrincipalsForPortfolio
s@ListPrincipalsForPortfolio' {} Maybe Text
a -> ListPrincipalsForPortfolio
s {$sel:acceptLanguage:ListPrincipalsForPortfolio' :: Maybe Text
acceptLanguage = Maybe Text
a} :: ListPrincipalsForPortfolio)

-- | The page token for the next set of results. To retrieve the first set of
-- results, use null.
listPrincipalsForPortfolio_pageToken :: Lens.Lens' ListPrincipalsForPortfolio (Prelude.Maybe Prelude.Text)
listPrincipalsForPortfolio_pageToken :: (Maybe Text -> f (Maybe Text))
-> ListPrincipalsForPortfolio -> f ListPrincipalsForPortfolio
listPrincipalsForPortfolio_pageToken = (ListPrincipalsForPortfolio -> Maybe Text)
-> (ListPrincipalsForPortfolio
    -> Maybe Text -> ListPrincipalsForPortfolio)
-> Lens
     ListPrincipalsForPortfolio
     ListPrincipalsForPortfolio
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPrincipalsForPortfolio' {Maybe Text
pageToken :: Maybe Text
$sel:pageToken:ListPrincipalsForPortfolio' :: ListPrincipalsForPortfolio -> Maybe Text
pageToken} -> Maybe Text
pageToken) (\s :: ListPrincipalsForPortfolio
s@ListPrincipalsForPortfolio' {} Maybe Text
a -> ListPrincipalsForPortfolio
s {$sel:pageToken:ListPrincipalsForPortfolio' :: Maybe Text
pageToken = Maybe Text
a} :: ListPrincipalsForPortfolio)

-- | The maximum number of items to return with this call.
listPrincipalsForPortfolio_pageSize :: Lens.Lens' ListPrincipalsForPortfolio (Prelude.Maybe Prelude.Natural)
listPrincipalsForPortfolio_pageSize :: (Maybe Natural -> f (Maybe Natural))
-> ListPrincipalsForPortfolio -> f ListPrincipalsForPortfolio
listPrincipalsForPortfolio_pageSize = (ListPrincipalsForPortfolio -> Maybe Natural)
-> (ListPrincipalsForPortfolio
    -> Maybe Natural -> ListPrincipalsForPortfolio)
-> Lens
     ListPrincipalsForPortfolio
     ListPrincipalsForPortfolio
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPrincipalsForPortfolio' {Maybe Natural
pageSize :: Maybe Natural
$sel:pageSize:ListPrincipalsForPortfolio' :: ListPrincipalsForPortfolio -> Maybe Natural
pageSize} -> Maybe Natural
pageSize) (\s :: ListPrincipalsForPortfolio
s@ListPrincipalsForPortfolio' {} Maybe Natural
a -> ListPrincipalsForPortfolio
s {$sel:pageSize:ListPrincipalsForPortfolio' :: Maybe Natural
pageSize = Maybe Natural
a} :: ListPrincipalsForPortfolio)

-- | The portfolio identifier.
listPrincipalsForPortfolio_portfolioId :: Lens.Lens' ListPrincipalsForPortfolio Prelude.Text
listPrincipalsForPortfolio_portfolioId :: (Text -> f Text)
-> ListPrincipalsForPortfolio -> f ListPrincipalsForPortfolio
listPrincipalsForPortfolio_portfolioId = (ListPrincipalsForPortfolio -> Text)
-> (ListPrincipalsForPortfolio
    -> Text -> ListPrincipalsForPortfolio)
-> Lens
     ListPrincipalsForPortfolio ListPrincipalsForPortfolio Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPrincipalsForPortfolio' {Text
portfolioId :: Text
$sel:portfolioId:ListPrincipalsForPortfolio' :: ListPrincipalsForPortfolio -> Text
portfolioId} -> Text
portfolioId) (\s :: ListPrincipalsForPortfolio
s@ListPrincipalsForPortfolio' {} Text
a -> ListPrincipalsForPortfolio
s {$sel:portfolioId:ListPrincipalsForPortfolio' :: Text
portfolioId = Text
a} :: ListPrincipalsForPortfolio)

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

instance Prelude.NFData ListPrincipalsForPortfolio

instance Core.ToHeaders ListPrincipalsForPortfolio where
  toHeaders :: ListPrincipalsForPortfolio -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListPrincipalsForPortfolio -> 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
"AWS242ServiceCatalogService.ListPrincipalsForPortfolio" ::
                          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 ListPrincipalsForPortfolio where
  toJSON :: ListPrincipalsForPortfolio -> Value
toJSON ListPrincipalsForPortfolio' {Maybe Natural
Maybe Text
Text
portfolioId :: Text
pageSize :: Maybe Natural
pageToken :: Maybe Text
acceptLanguage :: Maybe Text
$sel:portfolioId:ListPrincipalsForPortfolio' :: ListPrincipalsForPortfolio -> Text
$sel:pageSize:ListPrincipalsForPortfolio' :: ListPrincipalsForPortfolio -> Maybe Natural
$sel:pageToken:ListPrincipalsForPortfolio' :: ListPrincipalsForPortfolio -> Maybe Text
$sel:acceptLanguage:ListPrincipalsForPortfolio' :: ListPrincipalsForPortfolio -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AcceptLanguage" 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
acceptLanguage,
            (Text
"PageToken" 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
pageToken,
            (Text
"PageSize" 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
pageSize,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"PortfolioId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
portfolioId)
          ]
      )

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

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

-- | /See:/ 'newListPrincipalsForPortfolioResponse' smart constructor.
data ListPrincipalsForPortfolioResponse = ListPrincipalsForPortfolioResponse'
  { -- | The page token to use to retrieve the next set of results. If there are
    -- no additional results, this value is null.
    ListPrincipalsForPortfolioResponse -> Maybe Text
nextPageToken :: Prelude.Maybe Prelude.Text,
    -- | The IAM principals (users or roles) associated with the portfolio.
    ListPrincipalsForPortfolioResponse -> Maybe [Principal]
principals :: Prelude.Maybe [Principal],
    -- | The response's http status code.
    ListPrincipalsForPortfolioResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListPrincipalsForPortfolioResponse
-> ListPrincipalsForPortfolioResponse -> Bool
(ListPrincipalsForPortfolioResponse
 -> ListPrincipalsForPortfolioResponse -> Bool)
-> (ListPrincipalsForPortfolioResponse
    -> ListPrincipalsForPortfolioResponse -> Bool)
-> Eq ListPrincipalsForPortfolioResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPrincipalsForPortfolioResponse
-> ListPrincipalsForPortfolioResponse -> Bool
$c/= :: ListPrincipalsForPortfolioResponse
-> ListPrincipalsForPortfolioResponse -> Bool
== :: ListPrincipalsForPortfolioResponse
-> ListPrincipalsForPortfolioResponse -> Bool
$c== :: ListPrincipalsForPortfolioResponse
-> ListPrincipalsForPortfolioResponse -> Bool
Prelude.Eq, ReadPrec [ListPrincipalsForPortfolioResponse]
ReadPrec ListPrincipalsForPortfolioResponse
Int -> ReadS ListPrincipalsForPortfolioResponse
ReadS [ListPrincipalsForPortfolioResponse]
(Int -> ReadS ListPrincipalsForPortfolioResponse)
-> ReadS [ListPrincipalsForPortfolioResponse]
-> ReadPrec ListPrincipalsForPortfolioResponse
-> ReadPrec [ListPrincipalsForPortfolioResponse]
-> Read ListPrincipalsForPortfolioResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPrincipalsForPortfolioResponse]
$creadListPrec :: ReadPrec [ListPrincipalsForPortfolioResponse]
readPrec :: ReadPrec ListPrincipalsForPortfolioResponse
$creadPrec :: ReadPrec ListPrincipalsForPortfolioResponse
readList :: ReadS [ListPrincipalsForPortfolioResponse]
$creadList :: ReadS [ListPrincipalsForPortfolioResponse]
readsPrec :: Int -> ReadS ListPrincipalsForPortfolioResponse
$creadsPrec :: Int -> ReadS ListPrincipalsForPortfolioResponse
Prelude.Read, Int -> ListPrincipalsForPortfolioResponse -> ShowS
[ListPrincipalsForPortfolioResponse] -> ShowS
ListPrincipalsForPortfolioResponse -> String
(Int -> ListPrincipalsForPortfolioResponse -> ShowS)
-> (ListPrincipalsForPortfolioResponse -> String)
-> ([ListPrincipalsForPortfolioResponse] -> ShowS)
-> Show ListPrincipalsForPortfolioResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPrincipalsForPortfolioResponse] -> ShowS
$cshowList :: [ListPrincipalsForPortfolioResponse] -> ShowS
show :: ListPrincipalsForPortfolioResponse -> String
$cshow :: ListPrincipalsForPortfolioResponse -> String
showsPrec :: Int -> ListPrincipalsForPortfolioResponse -> ShowS
$cshowsPrec :: Int -> ListPrincipalsForPortfolioResponse -> ShowS
Prelude.Show, (forall x.
 ListPrincipalsForPortfolioResponse
 -> Rep ListPrincipalsForPortfolioResponse x)
-> (forall x.
    Rep ListPrincipalsForPortfolioResponse x
    -> ListPrincipalsForPortfolioResponse)
-> Generic ListPrincipalsForPortfolioResponse
forall x.
Rep ListPrincipalsForPortfolioResponse x
-> ListPrincipalsForPortfolioResponse
forall x.
ListPrincipalsForPortfolioResponse
-> Rep ListPrincipalsForPortfolioResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListPrincipalsForPortfolioResponse x
-> ListPrincipalsForPortfolioResponse
$cfrom :: forall x.
ListPrincipalsForPortfolioResponse
-> Rep ListPrincipalsForPortfolioResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListPrincipalsForPortfolioResponse' 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:
--
-- 'nextPageToken', 'listPrincipalsForPortfolioResponse_nextPageToken' - The page token to use to retrieve the next set of results. If there are
-- no additional results, this value is null.
--
-- 'principals', 'listPrincipalsForPortfolioResponse_principals' - The IAM principals (users or roles) associated with the portfolio.
--
-- 'httpStatus', 'listPrincipalsForPortfolioResponse_httpStatus' - The response's http status code.
newListPrincipalsForPortfolioResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListPrincipalsForPortfolioResponse
newListPrincipalsForPortfolioResponse :: Int -> ListPrincipalsForPortfolioResponse
newListPrincipalsForPortfolioResponse Int
pHttpStatus_ =
  ListPrincipalsForPortfolioResponse' :: Maybe Text
-> Maybe [Principal] -> Int -> ListPrincipalsForPortfolioResponse
ListPrincipalsForPortfolioResponse'
    { $sel:nextPageToken:ListPrincipalsForPortfolioResponse' :: Maybe Text
nextPageToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:principals:ListPrincipalsForPortfolioResponse' :: Maybe [Principal]
principals = Maybe [Principal]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListPrincipalsForPortfolioResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The page token to use to retrieve the next set of results. If there are
-- no additional results, this value is null.
listPrincipalsForPortfolioResponse_nextPageToken :: Lens.Lens' ListPrincipalsForPortfolioResponse (Prelude.Maybe Prelude.Text)
listPrincipalsForPortfolioResponse_nextPageToken :: (Maybe Text -> f (Maybe Text))
-> ListPrincipalsForPortfolioResponse
-> f ListPrincipalsForPortfolioResponse
listPrincipalsForPortfolioResponse_nextPageToken = (ListPrincipalsForPortfolioResponse -> Maybe Text)
-> (ListPrincipalsForPortfolioResponse
    -> Maybe Text -> ListPrincipalsForPortfolioResponse)
-> Lens' ListPrincipalsForPortfolioResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPrincipalsForPortfolioResponse' {Maybe Text
nextPageToken :: Maybe Text
$sel:nextPageToken:ListPrincipalsForPortfolioResponse' :: ListPrincipalsForPortfolioResponse -> Maybe Text
nextPageToken} -> Maybe Text
nextPageToken) (\s :: ListPrincipalsForPortfolioResponse
s@ListPrincipalsForPortfolioResponse' {} Maybe Text
a -> ListPrincipalsForPortfolioResponse
s {$sel:nextPageToken:ListPrincipalsForPortfolioResponse' :: Maybe Text
nextPageToken = Maybe Text
a} :: ListPrincipalsForPortfolioResponse)

-- | The IAM principals (users or roles) associated with the portfolio.
listPrincipalsForPortfolioResponse_principals :: Lens.Lens' ListPrincipalsForPortfolioResponse (Prelude.Maybe [Principal])
listPrincipalsForPortfolioResponse_principals :: (Maybe [Principal] -> f (Maybe [Principal]))
-> ListPrincipalsForPortfolioResponse
-> f ListPrincipalsForPortfolioResponse
listPrincipalsForPortfolioResponse_principals = (ListPrincipalsForPortfolioResponse -> Maybe [Principal])
-> (ListPrincipalsForPortfolioResponse
    -> Maybe [Principal] -> ListPrincipalsForPortfolioResponse)
-> Lens' ListPrincipalsForPortfolioResponse (Maybe [Principal])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPrincipalsForPortfolioResponse' {Maybe [Principal]
principals :: Maybe [Principal]
$sel:principals:ListPrincipalsForPortfolioResponse' :: ListPrincipalsForPortfolioResponse -> Maybe [Principal]
principals} -> Maybe [Principal]
principals) (\s :: ListPrincipalsForPortfolioResponse
s@ListPrincipalsForPortfolioResponse' {} Maybe [Principal]
a -> ListPrincipalsForPortfolioResponse
s {$sel:principals:ListPrincipalsForPortfolioResponse' :: Maybe [Principal]
principals = Maybe [Principal]
a} :: ListPrincipalsForPortfolioResponse) ((Maybe [Principal] -> f (Maybe [Principal]))
 -> ListPrincipalsForPortfolioResponse
 -> f ListPrincipalsForPortfolioResponse)
-> ((Maybe [Principal] -> f (Maybe [Principal]))
    -> Maybe [Principal] -> f (Maybe [Principal]))
-> (Maybe [Principal] -> f (Maybe [Principal]))
-> ListPrincipalsForPortfolioResponse
-> f ListPrincipalsForPortfolioResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Principal] [Principal] [Principal] [Principal]
-> Iso
     (Maybe [Principal])
     (Maybe [Principal])
     (Maybe [Principal])
     (Maybe [Principal])
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 [Principal] [Principal] [Principal] [Principal]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    ListPrincipalsForPortfolioResponse