{-# 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.ListOrganizationPortfolioAccess
-- 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 organization nodes that have access to the specified
-- portfolio. This API can only be called by the management account in the
-- organization or by a delegated admin.
--
-- If a delegated admin is de-registered, they can no longer perform this
-- operation.
--
-- This operation returns paginated results.
module Amazonka.ServiceCatalog.ListOrganizationPortfolioAccess
  ( -- * Creating a Request
    ListOrganizationPortfolioAccess (..),
    newListOrganizationPortfolioAccess,

    -- * Request Lenses
    listOrganizationPortfolioAccess_acceptLanguage,
    listOrganizationPortfolioAccess_pageToken,
    listOrganizationPortfolioAccess_pageSize,
    listOrganizationPortfolioAccess_portfolioId,
    listOrganizationPortfolioAccess_organizationNodeType,

    -- * Destructuring the Response
    ListOrganizationPortfolioAccessResponse (..),
    newListOrganizationPortfolioAccessResponse,

    -- * Response Lenses
    listOrganizationPortfolioAccessResponse_nextPageToken,
    listOrganizationPortfolioAccessResponse_organizationNodes,
    listOrganizationPortfolioAccessResponse_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:/ 'newListOrganizationPortfolioAccess' smart constructor.
data ListOrganizationPortfolioAccess = ListOrganizationPortfolioAccess'
  { -- | The language code.
    --
    -- -   @en@ - English (default)
    --
    -- -   @jp@ - Japanese
    --
    -- -   @zh@ - Chinese
    ListOrganizationPortfolioAccess -> 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.
    ListOrganizationPortfolioAccess -> Maybe Text
pageToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of items to return with this call.
    ListOrganizationPortfolioAccess -> Maybe Natural
pageSize :: Prelude.Maybe Prelude.Natural,
    -- | The portfolio identifier. For example, @port-2abcdext3y5fk@.
    ListOrganizationPortfolioAccess -> Text
portfolioId :: Prelude.Text,
    -- | The organization node type that will be returned in the output.
    --
    -- -   @ORGANIZATION@ - Organization that has access to the portfolio.
    --
    -- -   @ORGANIZATIONAL_UNIT@ - Organizational unit that has access to the
    --     portfolio within your organization.
    --
    -- -   @ACCOUNT@ - Account that has access to the portfolio within your
    --     organization.
    ListOrganizationPortfolioAccess -> OrganizationNodeType
organizationNodeType :: OrganizationNodeType
  }
  deriving (ListOrganizationPortfolioAccess
-> ListOrganizationPortfolioAccess -> Bool
(ListOrganizationPortfolioAccess
 -> ListOrganizationPortfolioAccess -> Bool)
-> (ListOrganizationPortfolioAccess
    -> ListOrganizationPortfolioAccess -> Bool)
-> Eq ListOrganizationPortfolioAccess
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListOrganizationPortfolioAccess
-> ListOrganizationPortfolioAccess -> Bool
$c/= :: ListOrganizationPortfolioAccess
-> ListOrganizationPortfolioAccess -> Bool
== :: ListOrganizationPortfolioAccess
-> ListOrganizationPortfolioAccess -> Bool
$c== :: ListOrganizationPortfolioAccess
-> ListOrganizationPortfolioAccess -> Bool
Prelude.Eq, ReadPrec [ListOrganizationPortfolioAccess]
ReadPrec ListOrganizationPortfolioAccess
Int -> ReadS ListOrganizationPortfolioAccess
ReadS [ListOrganizationPortfolioAccess]
(Int -> ReadS ListOrganizationPortfolioAccess)
-> ReadS [ListOrganizationPortfolioAccess]
-> ReadPrec ListOrganizationPortfolioAccess
-> ReadPrec [ListOrganizationPortfolioAccess]
-> Read ListOrganizationPortfolioAccess
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListOrganizationPortfolioAccess]
$creadListPrec :: ReadPrec [ListOrganizationPortfolioAccess]
readPrec :: ReadPrec ListOrganizationPortfolioAccess
$creadPrec :: ReadPrec ListOrganizationPortfolioAccess
readList :: ReadS [ListOrganizationPortfolioAccess]
$creadList :: ReadS [ListOrganizationPortfolioAccess]
readsPrec :: Int -> ReadS ListOrganizationPortfolioAccess
$creadsPrec :: Int -> ReadS ListOrganizationPortfolioAccess
Prelude.Read, Int -> ListOrganizationPortfolioAccess -> ShowS
[ListOrganizationPortfolioAccess] -> ShowS
ListOrganizationPortfolioAccess -> String
(Int -> ListOrganizationPortfolioAccess -> ShowS)
-> (ListOrganizationPortfolioAccess -> String)
-> ([ListOrganizationPortfolioAccess] -> ShowS)
-> Show ListOrganizationPortfolioAccess
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListOrganizationPortfolioAccess] -> ShowS
$cshowList :: [ListOrganizationPortfolioAccess] -> ShowS
show :: ListOrganizationPortfolioAccess -> String
$cshow :: ListOrganizationPortfolioAccess -> String
showsPrec :: Int -> ListOrganizationPortfolioAccess -> ShowS
$cshowsPrec :: Int -> ListOrganizationPortfolioAccess -> ShowS
Prelude.Show, (forall x.
 ListOrganizationPortfolioAccess
 -> Rep ListOrganizationPortfolioAccess x)
-> (forall x.
    Rep ListOrganizationPortfolioAccess x
    -> ListOrganizationPortfolioAccess)
-> Generic ListOrganizationPortfolioAccess
forall x.
Rep ListOrganizationPortfolioAccess x
-> ListOrganizationPortfolioAccess
forall x.
ListOrganizationPortfolioAccess
-> Rep ListOrganizationPortfolioAccess x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListOrganizationPortfolioAccess x
-> ListOrganizationPortfolioAccess
$cfrom :: forall x.
ListOrganizationPortfolioAccess
-> Rep ListOrganizationPortfolioAccess x
Prelude.Generic)

-- |
-- Create a value of 'ListOrganizationPortfolioAccess' 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', 'listOrganizationPortfolioAccess_acceptLanguage' - The language code.
--
-- -   @en@ - English (default)
--
-- -   @jp@ - Japanese
--
-- -   @zh@ - Chinese
--
-- 'pageToken', 'listOrganizationPortfolioAccess_pageToken' - The page token for the next set of results. To retrieve the first set of
-- results, use null.
--
-- 'pageSize', 'listOrganizationPortfolioAccess_pageSize' - The maximum number of items to return with this call.
--
-- 'portfolioId', 'listOrganizationPortfolioAccess_portfolioId' - The portfolio identifier. For example, @port-2abcdext3y5fk@.
--
-- 'organizationNodeType', 'listOrganizationPortfolioAccess_organizationNodeType' - The organization node type that will be returned in the output.
--
-- -   @ORGANIZATION@ - Organization that has access to the portfolio.
--
-- -   @ORGANIZATIONAL_UNIT@ - Organizational unit that has access to the
--     portfolio within your organization.
--
-- -   @ACCOUNT@ - Account that has access to the portfolio within your
--     organization.
newListOrganizationPortfolioAccess ::
  -- | 'portfolioId'
  Prelude.Text ->
  -- | 'organizationNodeType'
  OrganizationNodeType ->
  ListOrganizationPortfolioAccess
newListOrganizationPortfolioAccess :: Text -> OrganizationNodeType -> ListOrganizationPortfolioAccess
newListOrganizationPortfolioAccess
  Text
pPortfolioId_
  OrganizationNodeType
pOrganizationNodeType_ =
    ListOrganizationPortfolioAccess' :: Maybe Text
-> Maybe Text
-> Maybe Natural
-> Text
-> OrganizationNodeType
-> ListOrganizationPortfolioAccess
ListOrganizationPortfolioAccess'
      { $sel:acceptLanguage:ListOrganizationPortfolioAccess' :: Maybe Text
acceptLanguage =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:pageToken:ListOrganizationPortfolioAccess' :: Maybe Text
pageToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:pageSize:ListOrganizationPortfolioAccess' :: Maybe Natural
pageSize = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
        $sel:portfolioId:ListOrganizationPortfolioAccess' :: Text
portfolioId = Text
pPortfolioId_,
        $sel:organizationNodeType:ListOrganizationPortfolioAccess' :: OrganizationNodeType
organizationNodeType =
          OrganizationNodeType
pOrganizationNodeType_
      }

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

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

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

-- | The portfolio identifier. For example, @port-2abcdext3y5fk@.
listOrganizationPortfolioAccess_portfolioId :: Lens.Lens' ListOrganizationPortfolioAccess Prelude.Text
listOrganizationPortfolioAccess_portfolioId :: (Text -> f Text)
-> ListOrganizationPortfolioAccess
-> f ListOrganizationPortfolioAccess
listOrganizationPortfolioAccess_portfolioId = (ListOrganizationPortfolioAccess -> Text)
-> (ListOrganizationPortfolioAccess
    -> Text -> ListOrganizationPortfolioAccess)
-> Lens
     ListOrganizationPortfolioAccess
     ListOrganizationPortfolioAccess
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListOrganizationPortfolioAccess' {Text
portfolioId :: Text
$sel:portfolioId:ListOrganizationPortfolioAccess' :: ListOrganizationPortfolioAccess -> Text
portfolioId} -> Text
portfolioId) (\s :: ListOrganizationPortfolioAccess
s@ListOrganizationPortfolioAccess' {} Text
a -> ListOrganizationPortfolioAccess
s {$sel:portfolioId:ListOrganizationPortfolioAccess' :: Text
portfolioId = Text
a} :: ListOrganizationPortfolioAccess)

-- | The organization node type that will be returned in the output.
--
-- -   @ORGANIZATION@ - Organization that has access to the portfolio.
--
-- -   @ORGANIZATIONAL_UNIT@ - Organizational unit that has access to the
--     portfolio within your organization.
--
-- -   @ACCOUNT@ - Account that has access to the portfolio within your
--     organization.
listOrganizationPortfolioAccess_organizationNodeType :: Lens.Lens' ListOrganizationPortfolioAccess OrganizationNodeType
listOrganizationPortfolioAccess_organizationNodeType :: (OrganizationNodeType -> f OrganizationNodeType)
-> ListOrganizationPortfolioAccess
-> f ListOrganizationPortfolioAccess
listOrganizationPortfolioAccess_organizationNodeType = (ListOrganizationPortfolioAccess -> OrganizationNodeType)
-> (ListOrganizationPortfolioAccess
    -> OrganizationNodeType -> ListOrganizationPortfolioAccess)
-> Lens
     ListOrganizationPortfolioAccess
     ListOrganizationPortfolioAccess
     OrganizationNodeType
     OrganizationNodeType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListOrganizationPortfolioAccess' {OrganizationNodeType
organizationNodeType :: OrganizationNodeType
$sel:organizationNodeType:ListOrganizationPortfolioAccess' :: ListOrganizationPortfolioAccess -> OrganizationNodeType
organizationNodeType} -> OrganizationNodeType
organizationNodeType) (\s :: ListOrganizationPortfolioAccess
s@ListOrganizationPortfolioAccess' {} OrganizationNodeType
a -> ListOrganizationPortfolioAccess
s {$sel:organizationNodeType:ListOrganizationPortfolioAccess' :: OrganizationNodeType
organizationNodeType = OrganizationNodeType
a} :: ListOrganizationPortfolioAccess)

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

instance
  Prelude.NFData
    ListOrganizationPortfolioAccess

instance
  Core.ToHeaders
    ListOrganizationPortfolioAccess
  where
  toHeaders :: ListOrganizationPortfolioAccess -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> ListOrganizationPortfolioAccess -> 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.ListOrganizationPortfolioAccess" ::
                          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 ListOrganizationPortfolioAccess where
  toJSON :: ListOrganizationPortfolioAccess -> Value
toJSON ListOrganizationPortfolioAccess' {Maybe Natural
Maybe Text
Text
OrganizationNodeType
organizationNodeType :: OrganizationNodeType
portfolioId :: Text
pageSize :: Maybe Natural
pageToken :: Maybe Text
acceptLanguage :: Maybe Text
$sel:organizationNodeType:ListOrganizationPortfolioAccess' :: ListOrganizationPortfolioAccess -> OrganizationNodeType
$sel:portfolioId:ListOrganizationPortfolioAccess' :: ListOrganizationPortfolioAccess -> Text
$sel:pageSize:ListOrganizationPortfolioAccess' :: ListOrganizationPortfolioAccess -> Maybe Natural
$sel:pageToken:ListOrganizationPortfolioAccess' :: ListOrganizationPortfolioAccess -> Maybe Text
$sel:acceptLanguage:ListOrganizationPortfolioAccess' :: ListOrganizationPortfolioAccess -> 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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"OrganizationNodeType"
                  Text -> OrganizationNodeType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= OrganizationNodeType
organizationNodeType
              )
          ]
      )

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

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

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

-- |
-- Create a value of 'ListOrganizationPortfolioAccessResponse' 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', 'listOrganizationPortfolioAccessResponse_nextPageToken' - The page token to use to retrieve the next set of results. If there are
-- no additional results, this value is null.
--
-- 'organizationNodes', 'listOrganizationPortfolioAccessResponse_organizationNodes' - Displays information about the organization nodes.
--
-- 'httpStatus', 'listOrganizationPortfolioAccessResponse_httpStatus' - The response's http status code.
newListOrganizationPortfolioAccessResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListOrganizationPortfolioAccessResponse
newListOrganizationPortfolioAccessResponse :: Int -> ListOrganizationPortfolioAccessResponse
newListOrganizationPortfolioAccessResponse
  Int
pHttpStatus_ =
    ListOrganizationPortfolioAccessResponse' :: Maybe Text
-> Maybe [OrganizationNode]
-> Int
-> ListOrganizationPortfolioAccessResponse
ListOrganizationPortfolioAccessResponse'
      { $sel:nextPageToken:ListOrganizationPortfolioAccessResponse' :: Maybe Text
nextPageToken =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:organizationNodes:ListOrganizationPortfolioAccessResponse' :: Maybe [OrganizationNode]
organizationNodes =
          Maybe [OrganizationNode]
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:ListOrganizationPortfolioAccessResponse' :: 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.
listOrganizationPortfolioAccessResponse_nextPageToken :: Lens.Lens' ListOrganizationPortfolioAccessResponse (Prelude.Maybe Prelude.Text)
listOrganizationPortfolioAccessResponse_nextPageToken :: (Maybe Text -> f (Maybe Text))
-> ListOrganizationPortfolioAccessResponse
-> f ListOrganizationPortfolioAccessResponse
listOrganizationPortfolioAccessResponse_nextPageToken = (ListOrganizationPortfolioAccessResponse -> Maybe Text)
-> (ListOrganizationPortfolioAccessResponse
    -> Maybe Text -> ListOrganizationPortfolioAccessResponse)
-> Lens' ListOrganizationPortfolioAccessResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListOrganizationPortfolioAccessResponse' {Maybe Text
nextPageToken :: Maybe Text
$sel:nextPageToken:ListOrganizationPortfolioAccessResponse' :: ListOrganizationPortfolioAccessResponse -> Maybe Text
nextPageToken} -> Maybe Text
nextPageToken) (\s :: ListOrganizationPortfolioAccessResponse
s@ListOrganizationPortfolioAccessResponse' {} Maybe Text
a -> ListOrganizationPortfolioAccessResponse
s {$sel:nextPageToken:ListOrganizationPortfolioAccessResponse' :: Maybe Text
nextPageToken = Maybe Text
a} :: ListOrganizationPortfolioAccessResponse)

-- | Displays information about the organization nodes.
listOrganizationPortfolioAccessResponse_organizationNodes :: Lens.Lens' ListOrganizationPortfolioAccessResponse (Prelude.Maybe [OrganizationNode])
listOrganizationPortfolioAccessResponse_organizationNodes :: (Maybe [OrganizationNode] -> f (Maybe [OrganizationNode]))
-> ListOrganizationPortfolioAccessResponse
-> f ListOrganizationPortfolioAccessResponse
listOrganizationPortfolioAccessResponse_organizationNodes = (ListOrganizationPortfolioAccessResponse
 -> Maybe [OrganizationNode])
-> (ListOrganizationPortfolioAccessResponse
    -> Maybe [OrganizationNode]
    -> ListOrganizationPortfolioAccessResponse)
-> Lens'
     ListOrganizationPortfolioAccessResponse (Maybe [OrganizationNode])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListOrganizationPortfolioAccessResponse' {Maybe [OrganizationNode]
organizationNodes :: Maybe [OrganizationNode]
$sel:organizationNodes:ListOrganizationPortfolioAccessResponse' :: ListOrganizationPortfolioAccessResponse -> Maybe [OrganizationNode]
organizationNodes} -> Maybe [OrganizationNode]
organizationNodes) (\s :: ListOrganizationPortfolioAccessResponse
s@ListOrganizationPortfolioAccessResponse' {} Maybe [OrganizationNode]
a -> ListOrganizationPortfolioAccessResponse
s {$sel:organizationNodes:ListOrganizationPortfolioAccessResponse' :: Maybe [OrganizationNode]
organizationNodes = Maybe [OrganizationNode]
a} :: ListOrganizationPortfolioAccessResponse) ((Maybe [OrganizationNode] -> f (Maybe [OrganizationNode]))
 -> ListOrganizationPortfolioAccessResponse
 -> f ListOrganizationPortfolioAccessResponse)
-> ((Maybe [OrganizationNode] -> f (Maybe [OrganizationNode]))
    -> Maybe [OrganizationNode] -> f (Maybe [OrganizationNode]))
-> (Maybe [OrganizationNode] -> f (Maybe [OrganizationNode]))
-> ListOrganizationPortfolioAccessResponse
-> f ListOrganizationPortfolioAccessResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [OrganizationNode]
  [OrganizationNode]
  [OrganizationNode]
  [OrganizationNode]
-> Iso
     (Maybe [OrganizationNode])
     (Maybe [OrganizationNode])
     (Maybe [OrganizationNode])
     (Maybe [OrganizationNode])
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
  [OrganizationNode]
  [OrganizationNode]
  [OrganizationNode]
  [OrganizationNode]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    ListOrganizationPortfolioAccessResponse