{-# 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.ListPortfoliosForProduct
-- 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 portfolios that the specified product is associated with.
--
-- This operation returns paginated results.
module Amazonka.ServiceCatalog.ListPortfoliosForProduct
  ( -- * Creating a Request
    ListPortfoliosForProduct (..),
    newListPortfoliosForProduct,

    -- * Request Lenses
    listPortfoliosForProduct_acceptLanguage,
    listPortfoliosForProduct_pageToken,
    listPortfoliosForProduct_pageSize,
    listPortfoliosForProduct_productId,

    -- * Destructuring the Response
    ListPortfoliosForProductResponse (..),
    newListPortfoliosForProductResponse,

    -- * Response Lenses
    listPortfoliosForProductResponse_nextPageToken,
    listPortfoliosForProductResponse_portfolioDetails,
    listPortfoliosForProductResponse_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:/ 'newListPortfoliosForProduct' smart constructor.
data ListPortfoliosForProduct = ListPortfoliosForProduct'
  { -- | The language code.
    --
    -- -   @en@ - English (default)
    --
    -- -   @jp@ - Japanese
    --
    -- -   @zh@ - Chinese
    ListPortfoliosForProduct -> 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.
    ListPortfoliosForProduct -> Maybe Text
pageToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of items to return with this call.
    ListPortfoliosForProduct -> Maybe Natural
pageSize :: Prelude.Maybe Prelude.Natural,
    -- | The product identifier.
    ListPortfoliosForProduct -> Text
productId :: Prelude.Text
  }
  deriving (ListPortfoliosForProduct -> ListPortfoliosForProduct -> Bool
(ListPortfoliosForProduct -> ListPortfoliosForProduct -> Bool)
-> (ListPortfoliosForProduct -> ListPortfoliosForProduct -> Bool)
-> Eq ListPortfoliosForProduct
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPortfoliosForProduct -> ListPortfoliosForProduct -> Bool
$c/= :: ListPortfoliosForProduct -> ListPortfoliosForProduct -> Bool
== :: ListPortfoliosForProduct -> ListPortfoliosForProduct -> Bool
$c== :: ListPortfoliosForProduct -> ListPortfoliosForProduct -> Bool
Prelude.Eq, ReadPrec [ListPortfoliosForProduct]
ReadPrec ListPortfoliosForProduct
Int -> ReadS ListPortfoliosForProduct
ReadS [ListPortfoliosForProduct]
(Int -> ReadS ListPortfoliosForProduct)
-> ReadS [ListPortfoliosForProduct]
-> ReadPrec ListPortfoliosForProduct
-> ReadPrec [ListPortfoliosForProduct]
-> Read ListPortfoliosForProduct
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPortfoliosForProduct]
$creadListPrec :: ReadPrec [ListPortfoliosForProduct]
readPrec :: ReadPrec ListPortfoliosForProduct
$creadPrec :: ReadPrec ListPortfoliosForProduct
readList :: ReadS [ListPortfoliosForProduct]
$creadList :: ReadS [ListPortfoliosForProduct]
readsPrec :: Int -> ReadS ListPortfoliosForProduct
$creadsPrec :: Int -> ReadS ListPortfoliosForProduct
Prelude.Read, Int -> ListPortfoliosForProduct -> ShowS
[ListPortfoliosForProduct] -> ShowS
ListPortfoliosForProduct -> String
(Int -> ListPortfoliosForProduct -> ShowS)
-> (ListPortfoliosForProduct -> String)
-> ([ListPortfoliosForProduct] -> ShowS)
-> Show ListPortfoliosForProduct
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPortfoliosForProduct] -> ShowS
$cshowList :: [ListPortfoliosForProduct] -> ShowS
show :: ListPortfoliosForProduct -> String
$cshow :: ListPortfoliosForProduct -> String
showsPrec :: Int -> ListPortfoliosForProduct -> ShowS
$cshowsPrec :: Int -> ListPortfoliosForProduct -> ShowS
Prelude.Show, (forall x.
 ListPortfoliosForProduct -> Rep ListPortfoliosForProduct x)
-> (forall x.
    Rep ListPortfoliosForProduct x -> ListPortfoliosForProduct)
-> Generic ListPortfoliosForProduct
forall x.
Rep ListPortfoliosForProduct x -> ListPortfoliosForProduct
forall x.
ListPortfoliosForProduct -> Rep ListPortfoliosForProduct x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListPortfoliosForProduct x -> ListPortfoliosForProduct
$cfrom :: forall x.
ListPortfoliosForProduct -> Rep ListPortfoliosForProduct x
Prelude.Generic)

-- |
-- Create a value of 'ListPortfoliosForProduct' 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', 'listPortfoliosForProduct_acceptLanguage' - The language code.
--
-- -   @en@ - English (default)
--
-- -   @jp@ - Japanese
--
-- -   @zh@ - Chinese
--
-- 'pageToken', 'listPortfoliosForProduct_pageToken' - The page token for the next set of results. To retrieve the first set of
-- results, use null.
--
-- 'pageSize', 'listPortfoliosForProduct_pageSize' - The maximum number of items to return with this call.
--
-- 'productId', 'listPortfoliosForProduct_productId' - The product identifier.
newListPortfoliosForProduct ::
  -- | 'productId'
  Prelude.Text ->
  ListPortfoliosForProduct
newListPortfoliosForProduct :: Text -> ListPortfoliosForProduct
newListPortfoliosForProduct Text
pProductId_ =
  ListPortfoliosForProduct' :: Maybe Text
-> Maybe Text -> Maybe Natural -> Text -> ListPortfoliosForProduct
ListPortfoliosForProduct'
    { $sel:acceptLanguage:ListPortfoliosForProduct' :: Maybe Text
acceptLanguage =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:pageToken:ListPortfoliosForProduct' :: Maybe Text
pageToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:pageSize:ListPortfoliosForProduct' :: Maybe Natural
pageSize = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:productId:ListPortfoliosForProduct' :: Text
productId = Text
pProductId_
    }

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

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

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

-- | The product identifier.
listPortfoliosForProduct_productId :: Lens.Lens' ListPortfoliosForProduct Prelude.Text
listPortfoliosForProduct_productId :: (Text -> f Text)
-> ListPortfoliosForProduct -> f ListPortfoliosForProduct
listPortfoliosForProduct_productId = (ListPortfoliosForProduct -> Text)
-> (ListPortfoliosForProduct -> Text -> ListPortfoliosForProduct)
-> Lens ListPortfoliosForProduct ListPortfoliosForProduct Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPortfoliosForProduct' {Text
productId :: Text
$sel:productId:ListPortfoliosForProduct' :: ListPortfoliosForProduct -> Text
productId} -> Text
productId) (\s :: ListPortfoliosForProduct
s@ListPortfoliosForProduct' {} Text
a -> ListPortfoliosForProduct
s {$sel:productId:ListPortfoliosForProduct' :: Text
productId = Text
a} :: ListPortfoliosForProduct)

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

instance Prelude.NFData ListPortfoliosForProduct

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

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

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

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

-- |
-- Create a value of 'ListPortfoliosForProductResponse' 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', 'listPortfoliosForProductResponse_nextPageToken' - The page token to use to retrieve the next set of results. If there are
-- no additional results, this value is null.
--
-- 'portfolioDetails', 'listPortfoliosForProductResponse_portfolioDetails' - Information about the portfolios.
--
-- 'httpStatus', 'listPortfoliosForProductResponse_httpStatus' - The response's http status code.
newListPortfoliosForProductResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListPortfoliosForProductResponse
newListPortfoliosForProductResponse :: Int -> ListPortfoliosForProductResponse
newListPortfoliosForProductResponse Int
pHttpStatus_ =
  ListPortfoliosForProductResponse' :: Maybe Text
-> Maybe [PortfolioDetail]
-> Int
-> ListPortfoliosForProductResponse
ListPortfoliosForProductResponse'
    { $sel:nextPageToken:ListPortfoliosForProductResponse' :: Maybe Text
nextPageToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:portfolioDetails:ListPortfoliosForProductResponse' :: Maybe [PortfolioDetail]
portfolioDetails = Maybe [PortfolioDetail]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListPortfoliosForProductResponse' :: 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.
listPortfoliosForProductResponse_nextPageToken :: Lens.Lens' ListPortfoliosForProductResponse (Prelude.Maybe Prelude.Text)
listPortfoliosForProductResponse_nextPageToken :: (Maybe Text -> f (Maybe Text))
-> ListPortfoliosForProductResponse
-> f ListPortfoliosForProductResponse
listPortfoliosForProductResponse_nextPageToken = (ListPortfoliosForProductResponse -> Maybe Text)
-> (ListPortfoliosForProductResponse
    -> Maybe Text -> ListPortfoliosForProductResponse)
-> Lens' ListPortfoliosForProductResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPortfoliosForProductResponse' {Maybe Text
nextPageToken :: Maybe Text
$sel:nextPageToken:ListPortfoliosForProductResponse' :: ListPortfoliosForProductResponse -> Maybe Text
nextPageToken} -> Maybe Text
nextPageToken) (\s :: ListPortfoliosForProductResponse
s@ListPortfoliosForProductResponse' {} Maybe Text
a -> ListPortfoliosForProductResponse
s {$sel:nextPageToken:ListPortfoliosForProductResponse' :: Maybe Text
nextPageToken = Maybe Text
a} :: ListPortfoliosForProductResponse)

-- | Information about the portfolios.
listPortfoliosForProductResponse_portfolioDetails :: Lens.Lens' ListPortfoliosForProductResponse (Prelude.Maybe [PortfolioDetail])
listPortfoliosForProductResponse_portfolioDetails :: (Maybe [PortfolioDetail] -> f (Maybe [PortfolioDetail]))
-> ListPortfoliosForProductResponse
-> f ListPortfoliosForProductResponse
listPortfoliosForProductResponse_portfolioDetails = (ListPortfoliosForProductResponse -> Maybe [PortfolioDetail])
-> (ListPortfoliosForProductResponse
    -> Maybe [PortfolioDetail] -> ListPortfoliosForProductResponse)
-> Lens' ListPortfoliosForProductResponse (Maybe [PortfolioDetail])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPortfoliosForProductResponse' {Maybe [PortfolioDetail]
portfolioDetails :: Maybe [PortfolioDetail]
$sel:portfolioDetails:ListPortfoliosForProductResponse' :: ListPortfoliosForProductResponse -> Maybe [PortfolioDetail]
portfolioDetails} -> Maybe [PortfolioDetail]
portfolioDetails) (\s :: ListPortfoliosForProductResponse
s@ListPortfoliosForProductResponse' {} Maybe [PortfolioDetail]
a -> ListPortfoliosForProductResponse
s {$sel:portfolioDetails:ListPortfoliosForProductResponse' :: Maybe [PortfolioDetail]
portfolioDetails = Maybe [PortfolioDetail]
a} :: ListPortfoliosForProductResponse) ((Maybe [PortfolioDetail] -> f (Maybe [PortfolioDetail]))
 -> ListPortfoliosForProductResponse
 -> f ListPortfoliosForProductResponse)
-> ((Maybe [PortfolioDetail] -> f (Maybe [PortfolioDetail]))
    -> Maybe [PortfolioDetail] -> f (Maybe [PortfolioDetail]))
-> (Maybe [PortfolioDetail] -> f (Maybe [PortfolioDetail]))
-> ListPortfoliosForProductResponse
-> f ListPortfoliosForProductResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PortfolioDetail]
  [PortfolioDetail]
  [PortfolioDetail]
  [PortfolioDetail]
-> Iso
     (Maybe [PortfolioDetail])
     (Maybe [PortfolioDetail])
     (Maybe [PortfolioDetail])
     (Maybe [PortfolioDetail])
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
  [PortfolioDetail]
  [PortfolioDetail]
  [PortfolioDetail]
  [PortfolioDetail]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    ListPortfoliosForProductResponse