{-# 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-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)
module Amazonka.MarketplaceEntitlement.Types.Entitlement where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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 EntitlementValue represents the amount of capacity that the customer
    -- is entitled to for the product.
    Entitlement -> Maybe EntitlementValue
value :: Prelude.Maybe EntitlementValue,
    -- | 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 Core.POSIX,
    -- | 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 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
  }
  deriving (Entitlement -> Entitlement -> Bool
(Entitlement -> Entitlement -> Bool)
-> (Entitlement -> Entitlement -> Bool) -> Eq Entitlement
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]
(Int -> ReadS Entitlement)
-> ReadS [Entitlement]
-> ReadPrec Entitlement
-> ReadPrec [Entitlement]
-> Read 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
(Int -> Entitlement -> ShowS)
-> (Entitlement -> String)
-> ([Entitlement] -> ShowS)
-> Show Entitlement
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. Entitlement -> Rep Entitlement x)
-> (forall x. Rep Entitlement x -> Entitlement)
-> Generic Entitlement
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:
--
-- '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.
--
-- 'value', 'entitlement_value' - The EntitlementValue represents the amount of capacity that the customer
-- is entitled to for the product.
--
-- '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.
--
-- '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.
--
-- '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.
newEntitlement ::
  Entitlement
newEntitlement :: Entitlement
newEntitlement =
  Entitlement' :: Maybe Text
-> Maybe EntitlementValue
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Entitlement
Entitlement'
    { $sel:dimension:Entitlement' :: Maybe Text
dimension = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:value:Entitlement' :: Maybe EntitlementValue
value = Maybe EntitlementValue
forall a. Maybe a
Prelude.Nothing,
      $sel:expirationDate:Entitlement' :: Maybe POSIX
expirationDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:customerIdentifier:Entitlement' :: Maybe Text
customerIdentifier = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:productCode:Entitlement' :: Maybe Text
productCode = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> Entitlement -> f Entitlement
entitlement_dimension = (Entitlement -> Maybe Text)
-> (Entitlement -> Maybe Text -> Entitlement)
-> Lens Entitlement Entitlement (Maybe Text) (Maybe Text)
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 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 :: (Maybe EntitlementValue -> f (Maybe EntitlementValue))
-> Entitlement -> f Entitlement
entitlement_value = (Entitlement -> Maybe EntitlementValue)
-> (Entitlement -> Maybe EntitlementValue -> Entitlement)
-> Lens
     Entitlement
     Entitlement
     (Maybe EntitlementValue)
     (Maybe EntitlementValue)
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)

-- | 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 :: (Maybe UTCTime -> f (Maybe UTCTime))
-> Entitlement -> f Entitlement
entitlement_expirationDate = (Entitlement -> Maybe POSIX)
-> (Entitlement -> Maybe POSIX -> Entitlement)
-> Lens Entitlement Entitlement (Maybe POSIX) (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX)) -> Entitlement -> f Entitlement)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Entitlement
-> f Entitlement
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> Entitlement -> f Entitlement
entitlement_customerIdentifier = (Entitlement -> Maybe Text)
-> (Entitlement -> Maybe Text -> Entitlement)
-> Lens Entitlement Entitlement (Maybe Text) (Maybe Text)
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 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 :: (Maybe Text -> f (Maybe Text)) -> Entitlement -> f Entitlement
entitlement_productCode = (Entitlement -> Maybe Text)
-> (Entitlement -> Maybe Text -> Entitlement)
-> Lens Entitlement Entitlement (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable Entitlement

instance Prelude.NFData Entitlement