{-# 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.MarketplaceEntitlement.GetEntitlements
-- 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)
--
-- GetEntitlements retrieves entitlement values for a given product. The
-- results can be filtered based on customer identifier or product
-- dimensions.
--
-- This operation returns paginated results.
module Amazonka.MarketplaceEntitlement.GetEntitlements
  ( -- * Creating a Request
    GetEntitlements (..),
    newGetEntitlements,

    -- * Request Lenses
    getEntitlements_nextToken,
    getEntitlements_filter,
    getEntitlements_maxResults,
    getEntitlements_productCode,

    -- * Destructuring the Response
    GetEntitlementsResponse (..),
    newGetEntitlementsResponse,

    -- * Response Lenses
    getEntitlementsResponse_nextToken,
    getEntitlementsResponse_entitlements,
    getEntitlementsResponse_httpStatus,
  )
where

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

-- | The GetEntitlementsRequest contains parameters for the GetEntitlements
-- operation.
--
-- /See:/ 'newGetEntitlements' smart constructor.
data GetEntitlements = GetEntitlements'
  { -- | For paginated calls to GetEntitlements, pass the NextToken from the
    -- previous GetEntitlementsResult.
    GetEntitlements -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Filter is used to return entitlements for a specific customer or for a
    -- specific dimension. Filters are described as keys mapped to a lists of
    -- values. Filtered requests are /unioned/ for each value in the value
    -- list, and then /intersected/ for each filter key.
    GetEntitlements
-> Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))
filter' :: Prelude.Maybe (Prelude.HashMap GetEntitlementFilterName (Prelude.NonEmpty Prelude.Text)),
    -- | The maximum number of items to retrieve from the GetEntitlements
    -- operation. For pagination, use the NextToken field in subsequent calls
    -- to GetEntitlements.
    GetEntitlements -> Maybe Int
maxResults :: Prelude.Maybe Prelude.Int,
    -- | Product code is used to uniquely identify a product in AWS Marketplace.
    -- The product code will be provided by AWS Marketplace when the product
    -- listing is created.
    GetEntitlements -> Text
productCode :: Prelude.Text
  }
  deriving (GetEntitlements -> GetEntitlements -> Bool
(GetEntitlements -> GetEntitlements -> Bool)
-> (GetEntitlements -> GetEntitlements -> Bool)
-> Eq GetEntitlements
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetEntitlements -> GetEntitlements -> Bool
$c/= :: GetEntitlements -> GetEntitlements -> Bool
== :: GetEntitlements -> GetEntitlements -> Bool
$c== :: GetEntitlements -> GetEntitlements -> Bool
Prelude.Eq, ReadPrec [GetEntitlements]
ReadPrec GetEntitlements
Int -> ReadS GetEntitlements
ReadS [GetEntitlements]
(Int -> ReadS GetEntitlements)
-> ReadS [GetEntitlements]
-> ReadPrec GetEntitlements
-> ReadPrec [GetEntitlements]
-> Read GetEntitlements
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetEntitlements]
$creadListPrec :: ReadPrec [GetEntitlements]
readPrec :: ReadPrec GetEntitlements
$creadPrec :: ReadPrec GetEntitlements
readList :: ReadS [GetEntitlements]
$creadList :: ReadS [GetEntitlements]
readsPrec :: Int -> ReadS GetEntitlements
$creadsPrec :: Int -> ReadS GetEntitlements
Prelude.Read, Int -> GetEntitlements -> ShowS
[GetEntitlements] -> ShowS
GetEntitlements -> String
(Int -> GetEntitlements -> ShowS)
-> (GetEntitlements -> String)
-> ([GetEntitlements] -> ShowS)
-> Show GetEntitlements
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetEntitlements] -> ShowS
$cshowList :: [GetEntitlements] -> ShowS
show :: GetEntitlements -> String
$cshow :: GetEntitlements -> String
showsPrec :: Int -> GetEntitlements -> ShowS
$cshowsPrec :: Int -> GetEntitlements -> ShowS
Prelude.Show, (forall x. GetEntitlements -> Rep GetEntitlements x)
-> (forall x. Rep GetEntitlements x -> GetEntitlements)
-> Generic GetEntitlements
forall x. Rep GetEntitlements x -> GetEntitlements
forall x. GetEntitlements -> Rep GetEntitlements x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetEntitlements x -> GetEntitlements
$cfrom :: forall x. GetEntitlements -> Rep GetEntitlements x
Prelude.Generic)

-- |
-- Create a value of 'GetEntitlements' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'nextToken', 'getEntitlements_nextToken' - For paginated calls to GetEntitlements, pass the NextToken from the
-- previous GetEntitlementsResult.
--
-- 'filter'', 'getEntitlements_filter' - Filter is used to return entitlements for a specific customer or for a
-- specific dimension. Filters are described as keys mapped to a lists of
-- values. Filtered requests are /unioned/ for each value in the value
-- list, and then /intersected/ for each filter key.
--
-- 'maxResults', 'getEntitlements_maxResults' - The maximum number of items to retrieve from the GetEntitlements
-- operation. For pagination, use the NextToken field in subsequent calls
-- to GetEntitlements.
--
-- 'productCode', 'getEntitlements_productCode' - Product code is used to uniquely identify a product in AWS Marketplace.
-- The product code will be provided by AWS Marketplace when the product
-- listing is created.
newGetEntitlements ::
  -- | 'productCode'
  Prelude.Text ->
  GetEntitlements
newGetEntitlements :: Text -> GetEntitlements
newGetEntitlements Text
pProductCode_ =
  GetEntitlements' :: Maybe Text
-> Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))
-> Maybe Int
-> Text
-> GetEntitlements
GetEntitlements'
    { $sel:nextToken:GetEntitlements' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:filter':GetEntitlements' :: Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))
filter' = Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:GetEntitlements' :: Maybe Int
maxResults = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:productCode:GetEntitlements' :: Text
productCode = Text
pProductCode_
    }

-- | For paginated calls to GetEntitlements, pass the NextToken from the
-- previous GetEntitlementsResult.
getEntitlements_nextToken :: Lens.Lens' GetEntitlements (Prelude.Maybe Prelude.Text)
getEntitlements_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetEntitlements -> f GetEntitlements
getEntitlements_nextToken = (GetEntitlements -> Maybe Text)
-> (GetEntitlements -> Maybe Text -> GetEntitlements)
-> Lens GetEntitlements GetEntitlements (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEntitlements' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetEntitlements' :: GetEntitlements -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetEntitlements
s@GetEntitlements' {} Maybe Text
a -> GetEntitlements
s {$sel:nextToken:GetEntitlements' :: Maybe Text
nextToken = Maybe Text
a} :: GetEntitlements)

-- | Filter is used to return entitlements for a specific customer or for a
-- specific dimension. Filters are described as keys mapped to a lists of
-- values. Filtered requests are /unioned/ for each value in the value
-- list, and then /intersected/ for each filter key.
getEntitlements_filter :: Lens.Lens' GetEntitlements (Prelude.Maybe (Prelude.HashMap GetEntitlementFilterName (Prelude.NonEmpty Prelude.Text)))
getEntitlements_filter :: (Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))
 -> f (Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))))
-> GetEntitlements -> f GetEntitlements
getEntitlements_filter = (GetEntitlements
 -> Maybe (HashMap GetEntitlementFilterName (NonEmpty Text)))
-> (GetEntitlements
    -> Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))
    -> GetEntitlements)
-> Lens
     GetEntitlements
     GetEntitlements
     (Maybe (HashMap GetEntitlementFilterName (NonEmpty Text)))
     (Maybe (HashMap GetEntitlementFilterName (NonEmpty Text)))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEntitlements' {Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))
filter' :: Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))
$sel:filter':GetEntitlements' :: GetEntitlements
-> Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))
filter'} -> Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))
filter') (\s :: GetEntitlements
s@GetEntitlements' {} Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))
a -> GetEntitlements
s {$sel:filter':GetEntitlements' :: Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))
filter' = Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))
a} :: GetEntitlements) ((Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))
  -> f (Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))))
 -> GetEntitlements -> f GetEntitlements)
-> ((Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))
     -> f (Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))))
    -> Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))
    -> f (Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))))
-> (Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))
    -> f (Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))))
-> GetEntitlements
-> f GetEntitlements
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap GetEntitlementFilterName (NonEmpty Text))
  (HashMap GetEntitlementFilterName (NonEmpty Text))
  (HashMap GetEntitlementFilterName (NonEmpty Text))
  (HashMap GetEntitlementFilterName (NonEmpty Text))
-> Iso
     (Maybe (HashMap GetEntitlementFilterName (NonEmpty Text)))
     (Maybe (HashMap GetEntitlementFilterName (NonEmpty Text)))
     (Maybe (HashMap GetEntitlementFilterName (NonEmpty Text)))
     (Maybe (HashMap GetEntitlementFilterName (NonEmpty Text)))
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
  (HashMap GetEntitlementFilterName (NonEmpty Text))
  (HashMap GetEntitlementFilterName (NonEmpty Text))
  (HashMap GetEntitlementFilterName (NonEmpty Text))
  (HashMap GetEntitlementFilterName (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The maximum number of items to retrieve from the GetEntitlements
-- operation. For pagination, use the NextToken field in subsequent calls
-- to GetEntitlements.
getEntitlements_maxResults :: Lens.Lens' GetEntitlements (Prelude.Maybe Prelude.Int)
getEntitlements_maxResults :: (Maybe Int -> f (Maybe Int))
-> GetEntitlements -> f GetEntitlements
getEntitlements_maxResults = (GetEntitlements -> Maybe Int)
-> (GetEntitlements -> Maybe Int -> GetEntitlements)
-> Lens GetEntitlements GetEntitlements (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEntitlements' {Maybe Int
maxResults :: Maybe Int
$sel:maxResults:GetEntitlements' :: GetEntitlements -> Maybe Int
maxResults} -> Maybe Int
maxResults) (\s :: GetEntitlements
s@GetEntitlements' {} Maybe Int
a -> GetEntitlements
s {$sel:maxResults:GetEntitlements' :: Maybe Int
maxResults = Maybe Int
a} :: GetEntitlements)

-- | Product code is used to uniquely identify a product in AWS Marketplace.
-- The product code will be provided by AWS Marketplace when the product
-- listing is created.
getEntitlements_productCode :: Lens.Lens' GetEntitlements Prelude.Text
getEntitlements_productCode :: (Text -> f Text) -> GetEntitlements -> f GetEntitlements
getEntitlements_productCode = (GetEntitlements -> Text)
-> (GetEntitlements -> Text -> GetEntitlements)
-> Lens GetEntitlements GetEntitlements Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEntitlements' {Text
productCode :: Text
$sel:productCode:GetEntitlements' :: GetEntitlements -> Text
productCode} -> Text
productCode) (\s :: GetEntitlements
s@GetEntitlements' {} Text
a -> GetEntitlements
s {$sel:productCode:GetEntitlements' :: Text
productCode = Text
a} :: GetEntitlements)

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

instance Prelude.NFData GetEntitlements

instance Core.ToHeaders GetEntitlements where
  toHeaders :: GetEntitlements -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetEntitlements -> 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
"AWSMPEntitlementService.GetEntitlements" ::
                          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 GetEntitlements where
  toJSON :: GetEntitlements -> Value
toJSON GetEntitlements' {Maybe Int
Maybe Text
Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))
Text
productCode :: Text
maxResults :: Maybe Int
filter' :: Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))
nextToken :: Maybe Text
$sel:productCode:GetEntitlements' :: GetEntitlements -> Text
$sel:maxResults:GetEntitlements' :: GetEntitlements -> Maybe Int
$sel:filter':GetEntitlements' :: GetEntitlements
-> Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))
$sel:nextToken:GetEntitlements' :: GetEntitlements -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"NextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"Filter" Text -> HashMap GetEntitlementFilterName (NonEmpty Text) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap GetEntitlementFilterName (NonEmpty Text) -> Pair)
-> Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))
-> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap GetEntitlementFilterName (NonEmpty Text))
filter',
            (Text
"MaxResults" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
maxResults,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ProductCode" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
productCode)
          ]
      )

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

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

-- | The GetEntitlementsRequest contains results from the GetEntitlements
-- operation.
--
-- /See:/ 'newGetEntitlementsResponse' smart constructor.
data GetEntitlementsResponse = GetEntitlementsResponse'
  { -- | For paginated results, use NextToken in subsequent calls to
    -- GetEntitlements. If the result contains an empty set of entitlements,
    -- NextToken might still be present and should be used.
    GetEntitlementsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The set of entitlements found through the GetEntitlements operation. If
    -- the result contains an empty set of entitlements, NextToken might still
    -- be present and should be used.
    GetEntitlementsResponse -> Maybe [Entitlement]
entitlements :: Prelude.Maybe [Entitlement],
    -- | The response's http status code.
    GetEntitlementsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetEntitlementsResponse -> GetEntitlementsResponse -> Bool
(GetEntitlementsResponse -> GetEntitlementsResponse -> Bool)
-> (GetEntitlementsResponse -> GetEntitlementsResponse -> Bool)
-> Eq GetEntitlementsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetEntitlementsResponse -> GetEntitlementsResponse -> Bool
$c/= :: GetEntitlementsResponse -> GetEntitlementsResponse -> Bool
== :: GetEntitlementsResponse -> GetEntitlementsResponse -> Bool
$c== :: GetEntitlementsResponse -> GetEntitlementsResponse -> Bool
Prelude.Eq, ReadPrec [GetEntitlementsResponse]
ReadPrec GetEntitlementsResponse
Int -> ReadS GetEntitlementsResponse
ReadS [GetEntitlementsResponse]
(Int -> ReadS GetEntitlementsResponse)
-> ReadS [GetEntitlementsResponse]
-> ReadPrec GetEntitlementsResponse
-> ReadPrec [GetEntitlementsResponse]
-> Read GetEntitlementsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetEntitlementsResponse]
$creadListPrec :: ReadPrec [GetEntitlementsResponse]
readPrec :: ReadPrec GetEntitlementsResponse
$creadPrec :: ReadPrec GetEntitlementsResponse
readList :: ReadS [GetEntitlementsResponse]
$creadList :: ReadS [GetEntitlementsResponse]
readsPrec :: Int -> ReadS GetEntitlementsResponse
$creadsPrec :: Int -> ReadS GetEntitlementsResponse
Prelude.Read, Int -> GetEntitlementsResponse -> ShowS
[GetEntitlementsResponse] -> ShowS
GetEntitlementsResponse -> String
(Int -> GetEntitlementsResponse -> ShowS)
-> (GetEntitlementsResponse -> String)
-> ([GetEntitlementsResponse] -> ShowS)
-> Show GetEntitlementsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetEntitlementsResponse] -> ShowS
$cshowList :: [GetEntitlementsResponse] -> ShowS
show :: GetEntitlementsResponse -> String
$cshow :: GetEntitlementsResponse -> String
showsPrec :: Int -> GetEntitlementsResponse -> ShowS
$cshowsPrec :: Int -> GetEntitlementsResponse -> ShowS
Prelude.Show, (forall x.
 GetEntitlementsResponse -> Rep GetEntitlementsResponse x)
-> (forall x.
    Rep GetEntitlementsResponse x -> GetEntitlementsResponse)
-> Generic GetEntitlementsResponse
forall x. Rep GetEntitlementsResponse x -> GetEntitlementsResponse
forall x. GetEntitlementsResponse -> Rep GetEntitlementsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetEntitlementsResponse x -> GetEntitlementsResponse
$cfrom :: forall x. GetEntitlementsResponse -> Rep GetEntitlementsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetEntitlementsResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'nextToken', 'getEntitlementsResponse_nextToken' - For paginated results, use NextToken in subsequent calls to
-- GetEntitlements. If the result contains an empty set of entitlements,
-- NextToken might still be present and should be used.
--
-- 'entitlements', 'getEntitlementsResponse_entitlements' - The set of entitlements found through the GetEntitlements operation. If
-- the result contains an empty set of entitlements, NextToken might still
-- be present and should be used.
--
-- 'httpStatus', 'getEntitlementsResponse_httpStatus' - The response's http status code.
newGetEntitlementsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetEntitlementsResponse
newGetEntitlementsResponse :: Int -> GetEntitlementsResponse
newGetEntitlementsResponse Int
pHttpStatus_ =
  GetEntitlementsResponse' :: Maybe Text -> Maybe [Entitlement] -> Int -> GetEntitlementsResponse
GetEntitlementsResponse'
    { $sel:nextToken:GetEntitlementsResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:entitlements:GetEntitlementsResponse' :: Maybe [Entitlement]
entitlements = Maybe [Entitlement]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetEntitlementsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | For paginated results, use NextToken in subsequent calls to
-- GetEntitlements. If the result contains an empty set of entitlements,
-- NextToken might still be present and should be used.
getEntitlementsResponse_nextToken :: Lens.Lens' GetEntitlementsResponse (Prelude.Maybe Prelude.Text)
getEntitlementsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetEntitlementsResponse -> f GetEntitlementsResponse
getEntitlementsResponse_nextToken = (GetEntitlementsResponse -> Maybe Text)
-> (GetEntitlementsResponse
    -> Maybe Text -> GetEntitlementsResponse)
-> Lens' GetEntitlementsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEntitlementsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetEntitlementsResponse' :: GetEntitlementsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetEntitlementsResponse
s@GetEntitlementsResponse' {} Maybe Text
a -> GetEntitlementsResponse
s {$sel:nextToken:GetEntitlementsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetEntitlementsResponse)

-- | The set of entitlements found through the GetEntitlements operation. If
-- the result contains an empty set of entitlements, NextToken might still
-- be present and should be used.
getEntitlementsResponse_entitlements :: Lens.Lens' GetEntitlementsResponse (Prelude.Maybe [Entitlement])
getEntitlementsResponse_entitlements :: (Maybe [Entitlement] -> f (Maybe [Entitlement]))
-> GetEntitlementsResponse -> f GetEntitlementsResponse
getEntitlementsResponse_entitlements = (GetEntitlementsResponse -> Maybe [Entitlement])
-> (GetEntitlementsResponse
    -> Maybe [Entitlement] -> GetEntitlementsResponse)
-> Lens' GetEntitlementsResponse (Maybe [Entitlement])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEntitlementsResponse' {Maybe [Entitlement]
entitlements :: Maybe [Entitlement]
$sel:entitlements:GetEntitlementsResponse' :: GetEntitlementsResponse -> Maybe [Entitlement]
entitlements} -> Maybe [Entitlement]
entitlements) (\s :: GetEntitlementsResponse
s@GetEntitlementsResponse' {} Maybe [Entitlement]
a -> GetEntitlementsResponse
s {$sel:entitlements:GetEntitlementsResponse' :: Maybe [Entitlement]
entitlements = Maybe [Entitlement]
a} :: GetEntitlementsResponse) ((Maybe [Entitlement] -> f (Maybe [Entitlement]))
 -> GetEntitlementsResponse -> f GetEntitlementsResponse)
-> ((Maybe [Entitlement] -> f (Maybe [Entitlement]))
    -> Maybe [Entitlement] -> f (Maybe [Entitlement]))
-> (Maybe [Entitlement] -> f (Maybe [Entitlement]))
-> GetEntitlementsResponse
-> f GetEntitlementsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Entitlement] [Entitlement] [Entitlement] [Entitlement]
-> Iso
     (Maybe [Entitlement])
     (Maybe [Entitlement])
     (Maybe [Entitlement])
     (Maybe [Entitlement])
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 [Entitlement] [Entitlement] [Entitlement] [Entitlement]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData GetEntitlementsResponse