{-# 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.LicenseManager.CreateLicense
-- 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)
--
-- Creates a license.
module Amazonka.LicenseManager.CreateLicense
  ( -- * Creating a Request
    CreateLicense (..),
    newCreateLicense,

    -- * Request Lenses
    createLicense_licenseMetadata,
    createLicense_licenseName,
    createLicense_productName,
    createLicense_productSKU,
    createLicense_issuer,
    createLicense_homeRegion,
    createLicense_validity,
    createLicense_entitlements,
    createLicense_beneficiary,
    createLicense_consumptionConfiguration,
    createLicense_clientToken,

    -- * Destructuring the Response
    CreateLicenseResponse (..),
    newCreateLicenseResponse,

    -- * Response Lenses
    createLicenseResponse_status,
    createLicenseResponse_version,
    createLicenseResponse_licenseArn,
    createLicenseResponse_httpStatus,
  )
where

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

-- | /See:/ 'newCreateLicense' smart constructor.
data CreateLicense = CreateLicense'
  { -- | Information about the license.
    CreateLicense -> Maybe [Metadata]
licenseMetadata :: Prelude.Maybe [Metadata],
    -- | License name.
    CreateLicense -> Text
licenseName :: Prelude.Text,
    -- | Product name.
    CreateLicense -> Text
productName :: Prelude.Text,
    -- | Product SKU.
    CreateLicense -> Text
productSKU :: Prelude.Text,
    -- | License issuer.
    CreateLicense -> Issuer
issuer :: Issuer,
    -- | Home Region for the license.
    CreateLicense -> Text
homeRegion :: Prelude.Text,
    -- | Date and time range during which the license is valid, in ISO8601-UTC
    -- format.
    CreateLicense -> DatetimeRange
validity :: DatetimeRange,
    -- | License entitlements.
    CreateLicense -> [Entitlement]
entitlements :: [Entitlement],
    -- | License beneficiary.
    CreateLicense -> Text
beneficiary :: Prelude.Text,
    -- | Configuration for consumption of the license. Choose a provisional
    -- configuration for workloads running with continuous connectivity. Choose
    -- a borrow configuration for workloads with offline usage.
    CreateLicense -> ConsumptionConfiguration
consumptionConfiguration :: ConsumptionConfiguration,
    -- | Unique, case-sensitive identifier that you provide to ensure the
    -- idempotency of the request.
    CreateLicense -> Text
clientToken :: Prelude.Text
  }
  deriving (CreateLicense -> CreateLicense -> Bool
(CreateLicense -> CreateLicense -> Bool)
-> (CreateLicense -> CreateLicense -> Bool) -> Eq CreateLicense
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateLicense -> CreateLicense -> Bool
$c/= :: CreateLicense -> CreateLicense -> Bool
== :: CreateLicense -> CreateLicense -> Bool
$c== :: CreateLicense -> CreateLicense -> Bool
Prelude.Eq, ReadPrec [CreateLicense]
ReadPrec CreateLicense
Int -> ReadS CreateLicense
ReadS [CreateLicense]
(Int -> ReadS CreateLicense)
-> ReadS [CreateLicense]
-> ReadPrec CreateLicense
-> ReadPrec [CreateLicense]
-> Read CreateLicense
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateLicense]
$creadListPrec :: ReadPrec [CreateLicense]
readPrec :: ReadPrec CreateLicense
$creadPrec :: ReadPrec CreateLicense
readList :: ReadS [CreateLicense]
$creadList :: ReadS [CreateLicense]
readsPrec :: Int -> ReadS CreateLicense
$creadsPrec :: Int -> ReadS CreateLicense
Prelude.Read, Int -> CreateLicense -> ShowS
[CreateLicense] -> ShowS
CreateLicense -> String
(Int -> CreateLicense -> ShowS)
-> (CreateLicense -> String)
-> ([CreateLicense] -> ShowS)
-> Show CreateLicense
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateLicense] -> ShowS
$cshowList :: [CreateLicense] -> ShowS
show :: CreateLicense -> String
$cshow :: CreateLicense -> String
showsPrec :: Int -> CreateLicense -> ShowS
$cshowsPrec :: Int -> CreateLicense -> ShowS
Prelude.Show, (forall x. CreateLicense -> Rep CreateLicense x)
-> (forall x. Rep CreateLicense x -> CreateLicense)
-> Generic CreateLicense
forall x. Rep CreateLicense x -> CreateLicense
forall x. CreateLicense -> Rep CreateLicense x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateLicense x -> CreateLicense
$cfrom :: forall x. CreateLicense -> Rep CreateLicense x
Prelude.Generic)

-- |
-- Create a value of 'CreateLicense' 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:
--
-- 'licenseMetadata', 'createLicense_licenseMetadata' - Information about the license.
--
-- 'licenseName', 'createLicense_licenseName' - License name.
--
-- 'productName', 'createLicense_productName' - Product name.
--
-- 'productSKU', 'createLicense_productSKU' - Product SKU.
--
-- 'issuer', 'createLicense_issuer' - License issuer.
--
-- 'homeRegion', 'createLicense_homeRegion' - Home Region for the license.
--
-- 'validity', 'createLicense_validity' - Date and time range during which the license is valid, in ISO8601-UTC
-- format.
--
-- 'entitlements', 'createLicense_entitlements' - License entitlements.
--
-- 'beneficiary', 'createLicense_beneficiary' - License beneficiary.
--
-- 'consumptionConfiguration', 'createLicense_consumptionConfiguration' - Configuration for consumption of the license. Choose a provisional
-- configuration for workloads running with continuous connectivity. Choose
-- a borrow configuration for workloads with offline usage.
--
-- 'clientToken', 'createLicense_clientToken' - Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request.
newCreateLicense ::
  -- | 'licenseName'
  Prelude.Text ->
  -- | 'productName'
  Prelude.Text ->
  -- | 'productSKU'
  Prelude.Text ->
  -- | 'issuer'
  Issuer ->
  -- | 'homeRegion'
  Prelude.Text ->
  -- | 'validity'
  DatetimeRange ->
  -- | 'beneficiary'
  Prelude.Text ->
  -- | 'consumptionConfiguration'
  ConsumptionConfiguration ->
  -- | 'clientToken'
  Prelude.Text ->
  CreateLicense
newCreateLicense :: Text
-> Text
-> Text
-> Issuer
-> Text
-> DatetimeRange
-> Text
-> ConsumptionConfiguration
-> Text
-> CreateLicense
newCreateLicense
  Text
pLicenseName_
  Text
pProductName_
  Text
pProductSKU_
  Issuer
pIssuer_
  Text
pHomeRegion_
  DatetimeRange
pValidity_
  Text
pBeneficiary_
  ConsumptionConfiguration
pConsumptionConfiguration_
  Text
pClientToken_ =
    CreateLicense' :: Maybe [Metadata]
-> Text
-> Text
-> Text
-> Issuer
-> Text
-> DatetimeRange
-> [Entitlement]
-> Text
-> ConsumptionConfiguration
-> Text
-> CreateLicense
CreateLicense'
      { $sel:licenseMetadata:CreateLicense' :: Maybe [Metadata]
licenseMetadata = Maybe [Metadata]
forall a. Maybe a
Prelude.Nothing,
        $sel:licenseName:CreateLicense' :: Text
licenseName = Text
pLicenseName_,
        $sel:productName:CreateLicense' :: Text
productName = Text
pProductName_,
        $sel:productSKU:CreateLicense' :: Text
productSKU = Text
pProductSKU_,
        $sel:issuer:CreateLicense' :: Issuer
issuer = Issuer
pIssuer_,
        $sel:homeRegion:CreateLicense' :: Text
homeRegion = Text
pHomeRegion_,
        $sel:validity:CreateLicense' :: DatetimeRange
validity = DatetimeRange
pValidity_,
        $sel:entitlements:CreateLicense' :: [Entitlement]
entitlements = [Entitlement]
forall a. Monoid a => a
Prelude.mempty,
        $sel:beneficiary:CreateLicense' :: Text
beneficiary = Text
pBeneficiary_,
        $sel:consumptionConfiguration:CreateLicense' :: ConsumptionConfiguration
consumptionConfiguration =
          ConsumptionConfiguration
pConsumptionConfiguration_,
        $sel:clientToken:CreateLicense' :: Text
clientToken = Text
pClientToken_
      }

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

-- | License name.
createLicense_licenseName :: Lens.Lens' CreateLicense Prelude.Text
createLicense_licenseName :: (Text -> f Text) -> CreateLicense -> f CreateLicense
createLicense_licenseName = (CreateLicense -> Text)
-> (CreateLicense -> Text -> CreateLicense)
-> Lens CreateLicense CreateLicense Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLicense' {Text
licenseName :: Text
$sel:licenseName:CreateLicense' :: CreateLicense -> Text
licenseName} -> Text
licenseName) (\s :: CreateLicense
s@CreateLicense' {} Text
a -> CreateLicense
s {$sel:licenseName:CreateLicense' :: Text
licenseName = Text
a} :: CreateLicense)

-- | Product name.
createLicense_productName :: Lens.Lens' CreateLicense Prelude.Text
createLicense_productName :: (Text -> f Text) -> CreateLicense -> f CreateLicense
createLicense_productName = (CreateLicense -> Text)
-> (CreateLicense -> Text -> CreateLicense)
-> Lens CreateLicense CreateLicense Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLicense' {Text
productName :: Text
$sel:productName:CreateLicense' :: CreateLicense -> Text
productName} -> Text
productName) (\s :: CreateLicense
s@CreateLicense' {} Text
a -> CreateLicense
s {$sel:productName:CreateLicense' :: Text
productName = Text
a} :: CreateLicense)

-- | Product SKU.
createLicense_productSKU :: Lens.Lens' CreateLicense Prelude.Text
createLicense_productSKU :: (Text -> f Text) -> CreateLicense -> f CreateLicense
createLicense_productSKU = (CreateLicense -> Text)
-> (CreateLicense -> Text -> CreateLicense)
-> Lens CreateLicense CreateLicense Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLicense' {Text
productSKU :: Text
$sel:productSKU:CreateLicense' :: CreateLicense -> Text
productSKU} -> Text
productSKU) (\s :: CreateLicense
s@CreateLicense' {} Text
a -> CreateLicense
s {$sel:productSKU:CreateLicense' :: Text
productSKU = Text
a} :: CreateLicense)

-- | License issuer.
createLicense_issuer :: Lens.Lens' CreateLicense Issuer
createLicense_issuer :: (Issuer -> f Issuer) -> CreateLicense -> f CreateLicense
createLicense_issuer = (CreateLicense -> Issuer)
-> (CreateLicense -> Issuer -> CreateLicense)
-> Lens CreateLicense CreateLicense Issuer Issuer
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLicense' {Issuer
issuer :: Issuer
$sel:issuer:CreateLicense' :: CreateLicense -> Issuer
issuer} -> Issuer
issuer) (\s :: CreateLicense
s@CreateLicense' {} Issuer
a -> CreateLicense
s {$sel:issuer:CreateLicense' :: Issuer
issuer = Issuer
a} :: CreateLicense)

-- | Home Region for the license.
createLicense_homeRegion :: Lens.Lens' CreateLicense Prelude.Text
createLicense_homeRegion :: (Text -> f Text) -> CreateLicense -> f CreateLicense
createLicense_homeRegion = (CreateLicense -> Text)
-> (CreateLicense -> Text -> CreateLicense)
-> Lens CreateLicense CreateLicense Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLicense' {Text
homeRegion :: Text
$sel:homeRegion:CreateLicense' :: CreateLicense -> Text
homeRegion} -> Text
homeRegion) (\s :: CreateLicense
s@CreateLicense' {} Text
a -> CreateLicense
s {$sel:homeRegion:CreateLicense' :: Text
homeRegion = Text
a} :: CreateLicense)

-- | Date and time range during which the license is valid, in ISO8601-UTC
-- format.
createLicense_validity :: Lens.Lens' CreateLicense DatetimeRange
createLicense_validity :: (DatetimeRange -> f DatetimeRange)
-> CreateLicense -> f CreateLicense
createLicense_validity = (CreateLicense -> DatetimeRange)
-> (CreateLicense -> DatetimeRange -> CreateLicense)
-> Lens CreateLicense CreateLicense DatetimeRange DatetimeRange
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLicense' {DatetimeRange
validity :: DatetimeRange
$sel:validity:CreateLicense' :: CreateLicense -> DatetimeRange
validity} -> DatetimeRange
validity) (\s :: CreateLicense
s@CreateLicense' {} DatetimeRange
a -> CreateLicense
s {$sel:validity:CreateLicense' :: DatetimeRange
validity = DatetimeRange
a} :: CreateLicense)

-- | License entitlements.
createLicense_entitlements :: Lens.Lens' CreateLicense [Entitlement]
createLicense_entitlements :: ([Entitlement] -> f [Entitlement])
-> CreateLicense -> f CreateLicense
createLicense_entitlements = (CreateLicense -> [Entitlement])
-> (CreateLicense -> [Entitlement] -> CreateLicense)
-> Lens CreateLicense CreateLicense [Entitlement] [Entitlement]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLicense' {[Entitlement]
entitlements :: [Entitlement]
$sel:entitlements:CreateLicense' :: CreateLicense -> [Entitlement]
entitlements} -> [Entitlement]
entitlements) (\s :: CreateLicense
s@CreateLicense' {} [Entitlement]
a -> CreateLicense
s {$sel:entitlements:CreateLicense' :: [Entitlement]
entitlements = [Entitlement]
a} :: CreateLicense) (([Entitlement] -> f [Entitlement])
 -> CreateLicense -> f CreateLicense)
-> (([Entitlement] -> f [Entitlement])
    -> [Entitlement] -> f [Entitlement])
-> ([Entitlement] -> f [Entitlement])
-> CreateLicense
-> f CreateLicense
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Entitlement] -> f [Entitlement])
-> [Entitlement] -> f [Entitlement]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | License beneficiary.
createLicense_beneficiary :: Lens.Lens' CreateLicense Prelude.Text
createLicense_beneficiary :: (Text -> f Text) -> CreateLicense -> f CreateLicense
createLicense_beneficiary = (CreateLicense -> Text)
-> (CreateLicense -> Text -> CreateLicense)
-> Lens CreateLicense CreateLicense Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLicense' {Text
beneficiary :: Text
$sel:beneficiary:CreateLicense' :: CreateLicense -> Text
beneficiary} -> Text
beneficiary) (\s :: CreateLicense
s@CreateLicense' {} Text
a -> CreateLicense
s {$sel:beneficiary:CreateLicense' :: Text
beneficiary = Text
a} :: CreateLicense)

-- | Configuration for consumption of the license. Choose a provisional
-- configuration for workloads running with continuous connectivity. Choose
-- a borrow configuration for workloads with offline usage.
createLicense_consumptionConfiguration :: Lens.Lens' CreateLicense ConsumptionConfiguration
createLicense_consumptionConfiguration :: (ConsumptionConfiguration -> f ConsumptionConfiguration)
-> CreateLicense -> f CreateLicense
createLicense_consumptionConfiguration = (CreateLicense -> ConsumptionConfiguration)
-> (CreateLicense -> ConsumptionConfiguration -> CreateLicense)
-> Lens
     CreateLicense
     CreateLicense
     ConsumptionConfiguration
     ConsumptionConfiguration
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLicense' {ConsumptionConfiguration
consumptionConfiguration :: ConsumptionConfiguration
$sel:consumptionConfiguration:CreateLicense' :: CreateLicense -> ConsumptionConfiguration
consumptionConfiguration} -> ConsumptionConfiguration
consumptionConfiguration) (\s :: CreateLicense
s@CreateLicense' {} ConsumptionConfiguration
a -> CreateLicense
s {$sel:consumptionConfiguration:CreateLicense' :: ConsumptionConfiguration
consumptionConfiguration = ConsumptionConfiguration
a} :: CreateLicense)

-- | Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request.
createLicense_clientToken :: Lens.Lens' CreateLicense Prelude.Text
createLicense_clientToken :: (Text -> f Text) -> CreateLicense -> f CreateLicense
createLicense_clientToken = (CreateLicense -> Text)
-> (CreateLicense -> Text -> CreateLicense)
-> Lens CreateLicense CreateLicense Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLicense' {Text
clientToken :: Text
$sel:clientToken:CreateLicense' :: CreateLicense -> Text
clientToken} -> Text
clientToken) (\s :: CreateLicense
s@CreateLicense' {} Text
a -> CreateLicense
s {$sel:clientToken:CreateLicense' :: Text
clientToken = Text
a} :: CreateLicense)

instance Core.AWSRequest CreateLicense where
  type
    AWSResponse CreateLicense =
      CreateLicenseResponse
  request :: CreateLicense -> Request CreateLicense
request = Service -> CreateLicense -> Request CreateLicense
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateLicense
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateLicense)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateLicense))
-> Logger
-> Service
-> Proxy CreateLicense
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateLicense)))
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 LicenseStatus
-> Maybe Text -> Maybe Text -> Int -> CreateLicenseResponse
CreateLicenseResponse'
            (Maybe LicenseStatus
 -> Maybe Text -> Maybe Text -> Int -> CreateLicenseResponse)
-> Either String (Maybe LicenseStatus)
-> Either
     String (Maybe Text -> Maybe Text -> Int -> CreateLicenseResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe LicenseStatus)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Status")
            Either
  String (Maybe Text -> Maybe Text -> Int -> CreateLicenseResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> CreateLicenseResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Version")
            Either String (Maybe Text -> Int -> CreateLicenseResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateLicenseResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"LicenseArn")
            Either String (Int -> CreateLicenseResponse)
-> Either String Int -> Either String CreateLicenseResponse
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 CreateLicense

instance Prelude.NFData CreateLicense

instance Core.ToHeaders CreateLicense where
  toHeaders :: CreateLicense -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateLicense -> 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
"AWSLicenseManager.CreateLicense" ::
                          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 CreateLicense where
  toJSON :: CreateLicense -> Value
toJSON CreateLicense' {[Entitlement]
Maybe [Metadata]
Text
DatetimeRange
Issuer
ConsumptionConfiguration
clientToken :: Text
consumptionConfiguration :: ConsumptionConfiguration
beneficiary :: Text
entitlements :: [Entitlement]
validity :: DatetimeRange
homeRegion :: Text
issuer :: Issuer
productSKU :: Text
productName :: Text
licenseName :: Text
licenseMetadata :: Maybe [Metadata]
$sel:clientToken:CreateLicense' :: CreateLicense -> Text
$sel:consumptionConfiguration:CreateLicense' :: CreateLicense -> ConsumptionConfiguration
$sel:beneficiary:CreateLicense' :: CreateLicense -> Text
$sel:entitlements:CreateLicense' :: CreateLicense -> [Entitlement]
$sel:validity:CreateLicense' :: CreateLicense -> DatetimeRange
$sel:homeRegion:CreateLicense' :: CreateLicense -> Text
$sel:issuer:CreateLicense' :: CreateLicense -> Issuer
$sel:productSKU:CreateLicense' :: CreateLicense -> Text
$sel:productName:CreateLicense' :: CreateLicense -> Text
$sel:licenseName:CreateLicense' :: CreateLicense -> Text
$sel:licenseMetadata:CreateLicense' :: CreateLicense -> Maybe [Metadata]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"LicenseMetadata" Text -> [Metadata] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([Metadata] -> Pair) -> Maybe [Metadata] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Metadata]
licenseMetadata,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"LicenseName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
licenseName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ProductName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
productName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ProductSKU" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
productSKU),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Issuer" Text -> Issuer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Issuer
issuer),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"HomeRegion" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
homeRegion),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Validity" Text -> DatetimeRange -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= DatetimeRange
validity),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Entitlements" Text -> [Entitlement] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Entitlement]
entitlements),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Beneficiary" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
beneficiary),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"ConsumptionConfiguration"
                  Text -> ConsumptionConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ConsumptionConfiguration
consumptionConfiguration
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ClientToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
clientToken)
          ]
      )

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

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

-- | /See:/ 'newCreateLicenseResponse' smart constructor.
data CreateLicenseResponse = CreateLicenseResponse'
  { -- | License status.
    CreateLicenseResponse -> Maybe LicenseStatus
status :: Prelude.Maybe LicenseStatus,
    -- | License version.
    CreateLicenseResponse -> Maybe Text
version :: Prelude.Maybe Prelude.Text,
    -- | Amazon Resource Name (ARN) of the license.
    CreateLicenseResponse -> Maybe Text
licenseArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateLicenseResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateLicenseResponse -> CreateLicenseResponse -> Bool
(CreateLicenseResponse -> CreateLicenseResponse -> Bool)
-> (CreateLicenseResponse -> CreateLicenseResponse -> Bool)
-> Eq CreateLicenseResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateLicenseResponse -> CreateLicenseResponse -> Bool
$c/= :: CreateLicenseResponse -> CreateLicenseResponse -> Bool
== :: CreateLicenseResponse -> CreateLicenseResponse -> Bool
$c== :: CreateLicenseResponse -> CreateLicenseResponse -> Bool
Prelude.Eq, ReadPrec [CreateLicenseResponse]
ReadPrec CreateLicenseResponse
Int -> ReadS CreateLicenseResponse
ReadS [CreateLicenseResponse]
(Int -> ReadS CreateLicenseResponse)
-> ReadS [CreateLicenseResponse]
-> ReadPrec CreateLicenseResponse
-> ReadPrec [CreateLicenseResponse]
-> Read CreateLicenseResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateLicenseResponse]
$creadListPrec :: ReadPrec [CreateLicenseResponse]
readPrec :: ReadPrec CreateLicenseResponse
$creadPrec :: ReadPrec CreateLicenseResponse
readList :: ReadS [CreateLicenseResponse]
$creadList :: ReadS [CreateLicenseResponse]
readsPrec :: Int -> ReadS CreateLicenseResponse
$creadsPrec :: Int -> ReadS CreateLicenseResponse
Prelude.Read, Int -> CreateLicenseResponse -> ShowS
[CreateLicenseResponse] -> ShowS
CreateLicenseResponse -> String
(Int -> CreateLicenseResponse -> ShowS)
-> (CreateLicenseResponse -> String)
-> ([CreateLicenseResponse] -> ShowS)
-> Show CreateLicenseResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateLicenseResponse] -> ShowS
$cshowList :: [CreateLicenseResponse] -> ShowS
show :: CreateLicenseResponse -> String
$cshow :: CreateLicenseResponse -> String
showsPrec :: Int -> CreateLicenseResponse -> ShowS
$cshowsPrec :: Int -> CreateLicenseResponse -> ShowS
Prelude.Show, (forall x. CreateLicenseResponse -> Rep CreateLicenseResponse x)
-> (forall x. Rep CreateLicenseResponse x -> CreateLicenseResponse)
-> Generic CreateLicenseResponse
forall x. Rep CreateLicenseResponse x -> CreateLicenseResponse
forall x. CreateLicenseResponse -> Rep CreateLicenseResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateLicenseResponse x -> CreateLicenseResponse
$cfrom :: forall x. CreateLicenseResponse -> Rep CreateLicenseResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateLicenseResponse' 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:
--
-- 'status', 'createLicenseResponse_status' - License status.
--
-- 'version', 'createLicenseResponse_version' - License version.
--
-- 'licenseArn', 'createLicenseResponse_licenseArn' - Amazon Resource Name (ARN) of the license.
--
-- 'httpStatus', 'createLicenseResponse_httpStatus' - The response's http status code.
newCreateLicenseResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateLicenseResponse
newCreateLicenseResponse :: Int -> CreateLicenseResponse
newCreateLicenseResponse Int
pHttpStatus_ =
  CreateLicenseResponse' :: Maybe LicenseStatus
-> Maybe Text -> Maybe Text -> Int -> CreateLicenseResponse
CreateLicenseResponse'
    { $sel:status:CreateLicenseResponse' :: Maybe LicenseStatus
status = Maybe LicenseStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:version:CreateLicenseResponse' :: Maybe Text
version = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:licenseArn:CreateLicenseResponse' :: Maybe Text
licenseArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateLicenseResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | License status.
createLicenseResponse_status :: Lens.Lens' CreateLicenseResponse (Prelude.Maybe LicenseStatus)
createLicenseResponse_status :: (Maybe LicenseStatus -> f (Maybe LicenseStatus))
-> CreateLicenseResponse -> f CreateLicenseResponse
createLicenseResponse_status = (CreateLicenseResponse -> Maybe LicenseStatus)
-> (CreateLicenseResponse
    -> Maybe LicenseStatus -> CreateLicenseResponse)
-> Lens
     CreateLicenseResponse
     CreateLicenseResponse
     (Maybe LicenseStatus)
     (Maybe LicenseStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLicenseResponse' {Maybe LicenseStatus
status :: Maybe LicenseStatus
$sel:status:CreateLicenseResponse' :: CreateLicenseResponse -> Maybe LicenseStatus
status} -> Maybe LicenseStatus
status) (\s :: CreateLicenseResponse
s@CreateLicenseResponse' {} Maybe LicenseStatus
a -> CreateLicenseResponse
s {$sel:status:CreateLicenseResponse' :: Maybe LicenseStatus
status = Maybe LicenseStatus
a} :: CreateLicenseResponse)

-- | License version.
createLicenseResponse_version :: Lens.Lens' CreateLicenseResponse (Prelude.Maybe Prelude.Text)
createLicenseResponse_version :: (Maybe Text -> f (Maybe Text))
-> CreateLicenseResponse -> f CreateLicenseResponse
createLicenseResponse_version = (CreateLicenseResponse -> Maybe Text)
-> (CreateLicenseResponse -> Maybe Text -> CreateLicenseResponse)
-> Lens
     CreateLicenseResponse
     CreateLicenseResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLicenseResponse' {Maybe Text
version :: Maybe Text
$sel:version:CreateLicenseResponse' :: CreateLicenseResponse -> Maybe Text
version} -> Maybe Text
version) (\s :: CreateLicenseResponse
s@CreateLicenseResponse' {} Maybe Text
a -> CreateLicenseResponse
s {$sel:version:CreateLicenseResponse' :: Maybe Text
version = Maybe Text
a} :: CreateLicenseResponse)

-- | Amazon Resource Name (ARN) of the license.
createLicenseResponse_licenseArn :: Lens.Lens' CreateLicenseResponse (Prelude.Maybe Prelude.Text)
createLicenseResponse_licenseArn :: (Maybe Text -> f (Maybe Text))
-> CreateLicenseResponse -> f CreateLicenseResponse
createLicenseResponse_licenseArn = (CreateLicenseResponse -> Maybe Text)
-> (CreateLicenseResponse -> Maybe Text -> CreateLicenseResponse)
-> Lens
     CreateLicenseResponse
     CreateLicenseResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLicenseResponse' {Maybe Text
licenseArn :: Maybe Text
$sel:licenseArn:CreateLicenseResponse' :: CreateLicenseResponse -> Maybe Text
licenseArn} -> Maybe Text
licenseArn) (\s :: CreateLicenseResponse
s@CreateLicenseResponse' {} Maybe Text
a -> CreateLicenseResponse
s {$sel:licenseArn:CreateLicenseResponse' :: Maybe Text
licenseArn = Maybe Text
a} :: CreateLicenseResponse)

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

instance Prelude.NFData CreateLicenseResponse