{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.Entitlement
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MarketplaceEntitlement.Types.Entitlement where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MarketplaceEntitlement.Types.EntitlementValue
import qualified Amazonka.Prelude as Prelude

-- | An entitlement represents capacity in a product owned by the customer.
-- For example, a customer might own some number of users or seats in an
-- SaaS application or some amount of data capacity in a multi-tenant
-- database.
--
-- /See:/ 'newEntitlement' smart constructor.
data Entitlement = Entitlement'
  { -- | The customer identifier is a handle to each unique customer in an
    -- application. Customer identifiers are obtained through the
    -- ResolveCustomer operation in AWS Marketplace Metering Service.
    Entitlement -> Maybe Text
customerIdentifier :: Prelude.Maybe Prelude.Text,
    -- | The dimension for which the given entitlement applies. Dimensions
    -- represent categories of capacity in a product and are specified when the
    -- product is listed in AWS Marketplace.
    Entitlement -> Maybe Text
dimension :: Prelude.Maybe Prelude.Text,
    -- | The expiration date represents the minimum date through which this
    -- entitlement is expected to remain valid. For contractual products listed
    -- on AWS Marketplace, the expiration date is the date at which the
    -- customer will renew or cancel their contract. Customers who are opting
    -- to renew their contract will still have entitlements with an expiration
    -- date.
    Entitlement -> Maybe POSIX
expirationDate :: Prelude.Maybe Data.POSIX,
    -- | The product code for which the given entitlement applies. Product codes
    -- are provided by AWS Marketplace when the product listing is created.
    Entitlement -> Maybe Text
productCode :: Prelude.Maybe Prelude.Text,
    -- | The EntitlementValue represents the amount of capacity that the customer
    -- is entitled to for the product.
    Entitlement -> Maybe EntitlementValue
value :: Prelude.Maybe EntitlementValue
  }
  deriving (Entitlement -> Entitlement -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Entitlement -> Entitlement -> Bool
$c/= :: Entitlement -> Entitlement -> Bool
== :: Entitlement -> Entitlement -> Bool
$c== :: Entitlement -> Entitlement -> Bool
Prelude.Eq, ReadPrec [Entitlement]
ReadPrec Entitlement
Int -> ReadS Entitlement
ReadS [Entitlement]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Entitlement]
$creadListPrec :: ReadPrec [Entitlement]
readPrec :: ReadPrec Entitlement
$creadPrec :: ReadPrec Entitlement
readList :: ReadS [Entitlement]
$creadList :: ReadS [Entitlement]
readsPrec :: Int -> ReadS Entitlement
$creadsPrec :: Int -> ReadS Entitlement
Prelude.Read, Int -> Entitlement -> ShowS
[Entitlement] -> ShowS
Entitlement -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Entitlement] -> ShowS
$cshowList :: [Entitlement] -> ShowS
show :: Entitlement -> String
$cshow :: Entitlement -> String
showsPrec :: Int -> Entitlement -> ShowS
$cshowsPrec :: Int -> Entitlement -> ShowS
Prelude.Show, forall x. Rep Entitlement x -> Entitlement
forall x. Entitlement -> Rep Entitlement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Entitlement x -> Entitlement
$cfrom :: forall x. Entitlement -> Rep Entitlement x
Prelude.Generic)

-- |
-- Create a value of 'Entitlement' 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:
--
-- 'customerIdentifier', 'entitlement_customerIdentifier' - The customer identifier is a handle to each unique customer in an
-- application. Customer identifiers are obtained through the
-- ResolveCustomer operation in AWS Marketplace Metering Service.
--
-- 'dimension', 'entitlement_dimension' - The dimension for which the given entitlement applies. Dimensions
-- represent categories of capacity in a product and are specified when the
-- product is listed in AWS Marketplace.
--
-- 'expirationDate', 'entitlement_expirationDate' - The expiration date represents the minimum date through which this
-- entitlement is expected to remain valid. For contractual products listed
-- on AWS Marketplace, the expiration date is the date at which the
-- customer will renew or cancel their contract. Customers who are opting
-- to renew their contract will still have entitlements with an expiration
-- date.
--
-- 'productCode', 'entitlement_productCode' - The product code for which the given entitlement applies. Product codes
-- are provided by AWS Marketplace when the product listing is created.
--
-- 'value', 'entitlement_value' - The EntitlementValue represents the amount of capacity that the customer
-- is entitled to for the product.
newEntitlement ::
  Entitlement
newEntitlement :: Entitlement
newEntitlement =
  Entitlement'
    { $sel:customerIdentifier:Entitlement' :: Maybe Text
customerIdentifier = forall a. Maybe a
Prelude.Nothing,
      $sel:dimension:Entitlement' :: Maybe Text
dimension = forall a. Maybe a
Prelude.Nothing,
      $sel:expirationDate:Entitlement' :: Maybe POSIX
expirationDate = forall a. Maybe a
Prelude.Nothing,
      $sel:productCode:Entitlement' :: Maybe Text
productCode = forall a. Maybe a
Prelude.Nothing,
      $sel:value:Entitlement' :: Maybe EntitlementValue
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The customer identifier is a handle to each unique customer in an
-- application. Customer identifiers are obtained through the
-- ResolveCustomer operation in AWS Marketplace Metering Service.
entitlement_customerIdentifier :: Lens.Lens' Entitlement (Prelude.Maybe Prelude.Text)
entitlement_customerIdentifier :: Lens' Entitlement (Maybe Text)
entitlement_customerIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Entitlement' {Maybe Text
customerIdentifier :: Maybe Text
$sel:customerIdentifier:Entitlement' :: Entitlement -> Maybe Text
customerIdentifier} -> Maybe Text
customerIdentifier) (\s :: Entitlement
s@Entitlement' {} Maybe Text
a -> Entitlement
s {$sel:customerIdentifier:Entitlement' :: Maybe Text
customerIdentifier = Maybe Text
a} :: Entitlement)

-- | The dimension for which the given entitlement applies. Dimensions
-- represent categories of capacity in a product and are specified when the
-- product is listed in AWS Marketplace.
entitlement_dimension :: Lens.Lens' Entitlement (Prelude.Maybe Prelude.Text)
entitlement_dimension :: Lens' Entitlement (Maybe Text)
entitlement_dimension = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Entitlement' {Maybe Text
dimension :: Maybe Text
$sel:dimension:Entitlement' :: Entitlement -> Maybe Text
dimension} -> Maybe Text
dimension) (\s :: Entitlement
s@Entitlement' {} Maybe Text
a -> Entitlement
s {$sel:dimension:Entitlement' :: Maybe Text
dimension = Maybe Text
a} :: Entitlement)

-- | The expiration date represents the minimum date through which this
-- entitlement is expected to remain valid. For contractual products listed
-- on AWS Marketplace, the expiration date is the date at which the
-- customer will renew or cancel their contract. Customers who are opting
-- to renew their contract will still have entitlements with an expiration
-- date.
entitlement_expirationDate :: Lens.Lens' Entitlement (Prelude.Maybe Prelude.UTCTime)
entitlement_expirationDate :: Lens' Entitlement (Maybe UTCTime)
entitlement_expirationDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Entitlement' {Maybe POSIX
expirationDate :: Maybe POSIX
$sel:expirationDate:Entitlement' :: Entitlement -> Maybe POSIX
expirationDate} -> Maybe POSIX
expirationDate) (\s :: Entitlement
s@Entitlement' {} Maybe POSIX
a -> Entitlement
s {$sel:expirationDate:Entitlement' :: Maybe POSIX
expirationDate = Maybe POSIX
a} :: Entitlement) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The product code for which the given entitlement applies. Product codes
-- are provided by AWS Marketplace when the product listing is created.
entitlement_productCode :: Lens.Lens' Entitlement (Prelude.Maybe Prelude.Text)
entitlement_productCode :: Lens' Entitlement (Maybe Text)
entitlement_productCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Entitlement' {Maybe Text
productCode :: Maybe Text
$sel:productCode:Entitlement' :: Entitlement -> Maybe Text
productCode} -> Maybe Text
productCode) (\s :: Entitlement
s@Entitlement' {} Maybe Text
a -> Entitlement
s {$sel:productCode:Entitlement' :: Maybe Text
productCode = Maybe Text
a} :: Entitlement)

-- | The EntitlementValue represents the amount of capacity that the customer
-- is entitled to for the product.
entitlement_value :: Lens.Lens' Entitlement (Prelude.Maybe EntitlementValue)
entitlement_value :: Lens' Entitlement (Maybe EntitlementValue)
entitlement_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Entitlement' {Maybe EntitlementValue
value :: Maybe EntitlementValue
$sel:value:Entitlement' :: Entitlement -> Maybe EntitlementValue
value} -> Maybe EntitlementValue
value) (\s :: Entitlement
s@Entitlement' {} Maybe EntitlementValue
a -> Entitlement
s {$sel:value:Entitlement' :: Maybe EntitlementValue
value = Maybe EntitlementValue
a} :: Entitlement)

instance Data.FromJSON Entitlement where
  parseJSON :: Value -> Parser Entitlement
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Entitlement"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe EntitlementValue
-> Entitlement
Entitlement'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CustomerIdentifier")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Dimension")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ExpirationDate")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ProductCode")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Value")
      )

instance Prelude.Hashable Entitlement where
  hashWithSalt :: Int -> Entitlement -> Int
hashWithSalt Int
_salt Entitlement' {Maybe Text
Maybe POSIX
Maybe EntitlementValue
value :: Maybe EntitlementValue
productCode :: Maybe Text
expirationDate :: Maybe POSIX
dimension :: Maybe Text
customerIdentifier :: Maybe Text
$sel:value:Entitlement' :: Entitlement -> Maybe EntitlementValue
$sel:productCode:Entitlement' :: Entitlement -> Maybe Text
$sel:expirationDate:Entitlement' :: Entitlement -> Maybe POSIX
$sel:dimension:Entitlement' :: Entitlement -> Maybe Text
$sel:customerIdentifier:Entitlement' :: Entitlement -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
customerIdentifier
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
dimension
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
expirationDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
productCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EntitlementValue
value

instance Prelude.NFData Entitlement where
  rnf :: Entitlement -> ()
rnf Entitlement' {Maybe Text
Maybe POSIX
Maybe EntitlementValue
value :: Maybe EntitlementValue
productCode :: Maybe Text
expirationDate :: Maybe POSIX
dimension :: Maybe Text
customerIdentifier :: Maybe Text
$sel:value:Entitlement' :: Entitlement -> Maybe EntitlementValue
$sel:productCode:Entitlement' :: Entitlement -> Maybe Text
$sel:expirationDate:Entitlement' :: Entitlement -> Maybe POSIX
$sel:dimension:Entitlement' :: Entitlement -> Maybe Text
$sel:customerIdentifier:Entitlement' :: Entitlement -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
customerIdentifier
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
dimension
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
expirationDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
productCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe EntitlementValue
value