{-# 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 #-}
module Amazonka.LicenseManager.Types.Entitlement where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.LicenseManager.Types.EntitlementUnit
import qualified Amazonka.Prelude as Prelude
data Entitlement = Entitlement'
{
Entitlement -> Maybe Integer
maxCount :: Prelude.Maybe Prelude.Integer,
Entitlement -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
Entitlement -> Maybe Bool
overage :: Prelude.Maybe Prelude.Bool,
Entitlement -> Maybe Bool
allowCheckIn :: Prelude.Maybe Prelude.Bool,
Entitlement -> Text
name :: Prelude.Text,
Entitlement -> EntitlementUnit
unit :: EntitlementUnit
}
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)
newEntitlement ::
Prelude.Text ->
EntitlementUnit ->
Entitlement
newEntitlement :: Text -> EntitlementUnit -> Entitlement
newEntitlement Text
pName_ EntitlementUnit
pUnit_ =
Entitlement' :: Maybe Integer
-> Maybe Text
-> Maybe Bool
-> Maybe Bool
-> Text
-> EntitlementUnit
-> Entitlement
Entitlement'
{ $sel:maxCount:Entitlement' :: Maybe Integer
maxCount = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
$sel:value:Entitlement' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:overage:Entitlement' :: Maybe Bool
overage = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
$sel:allowCheckIn:Entitlement' :: Maybe Bool
allowCheckIn = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
$sel:name:Entitlement' :: Text
name = Text
pName_,
$sel:unit:Entitlement' :: EntitlementUnit
unit = EntitlementUnit
pUnit_
}
entitlement_maxCount :: Lens.Lens' Entitlement (Prelude.Maybe Prelude.Integer)
entitlement_maxCount :: (Maybe Integer -> f (Maybe Integer))
-> Entitlement -> f Entitlement
entitlement_maxCount = (Entitlement -> Maybe Integer)
-> (Entitlement -> Maybe Integer -> Entitlement)
-> Lens Entitlement Entitlement (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Entitlement' {Maybe Integer
maxCount :: Maybe Integer
$sel:maxCount:Entitlement' :: Entitlement -> Maybe Integer
maxCount} -> Maybe Integer
maxCount) (\s :: Entitlement
s@Entitlement' {} Maybe Integer
a -> Entitlement
s {$sel:maxCount:Entitlement' :: Maybe Integer
maxCount = Maybe Integer
a} :: Entitlement)
entitlement_value :: Lens.Lens' Entitlement (Prelude.Maybe Prelude.Text)
entitlement_value :: (Maybe Text -> f (Maybe Text)) -> Entitlement -> f Entitlement
entitlement_value = (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
value :: Maybe Text
$sel:value:Entitlement' :: Entitlement -> Maybe Text
value} -> Maybe Text
value) (\s :: Entitlement
s@Entitlement' {} Maybe Text
a -> Entitlement
s {$sel:value:Entitlement' :: Maybe Text
value = Maybe Text
a} :: Entitlement)
entitlement_overage :: Lens.Lens' Entitlement (Prelude.Maybe Prelude.Bool)
entitlement_overage :: (Maybe Bool -> f (Maybe Bool)) -> Entitlement -> f Entitlement
entitlement_overage = (Entitlement -> Maybe Bool)
-> (Entitlement -> Maybe Bool -> Entitlement)
-> Lens Entitlement Entitlement (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Entitlement' {Maybe Bool
overage :: Maybe Bool
$sel:overage:Entitlement' :: Entitlement -> Maybe Bool
overage} -> Maybe Bool
overage) (\s :: Entitlement
s@Entitlement' {} Maybe Bool
a -> Entitlement
s {$sel:overage:Entitlement' :: Maybe Bool
overage = Maybe Bool
a} :: Entitlement)
entitlement_allowCheckIn :: Lens.Lens' Entitlement (Prelude.Maybe Prelude.Bool)
entitlement_allowCheckIn :: (Maybe Bool -> f (Maybe Bool)) -> Entitlement -> f Entitlement
entitlement_allowCheckIn = (Entitlement -> Maybe Bool)
-> (Entitlement -> Maybe Bool -> Entitlement)
-> Lens Entitlement Entitlement (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Entitlement' {Maybe Bool
allowCheckIn :: Maybe Bool
$sel:allowCheckIn:Entitlement' :: Entitlement -> Maybe Bool
allowCheckIn} -> Maybe Bool
allowCheckIn) (\s :: Entitlement
s@Entitlement' {} Maybe Bool
a -> Entitlement
s {$sel:allowCheckIn:Entitlement' :: Maybe Bool
allowCheckIn = Maybe Bool
a} :: Entitlement)
entitlement_name :: Lens.Lens' Entitlement Prelude.Text
entitlement_name :: (Text -> f Text) -> Entitlement -> f Entitlement
entitlement_name = (Entitlement -> Text)
-> (Entitlement -> Text -> Entitlement)
-> Lens Entitlement Entitlement Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Entitlement' {Text
name :: Text
$sel:name:Entitlement' :: Entitlement -> Text
name} -> Text
name) (\s :: Entitlement
s@Entitlement' {} Text
a -> Entitlement
s {$sel:name:Entitlement' :: Text
name = Text
a} :: Entitlement)
entitlement_unit :: Lens.Lens' Entitlement EntitlementUnit
entitlement_unit :: (EntitlementUnit -> f EntitlementUnit)
-> Entitlement -> f Entitlement
entitlement_unit = (Entitlement -> EntitlementUnit)
-> (Entitlement -> EntitlementUnit -> Entitlement)
-> Lens Entitlement Entitlement EntitlementUnit EntitlementUnit
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Entitlement' {EntitlementUnit
unit :: EntitlementUnit
$sel:unit:Entitlement' :: Entitlement -> EntitlementUnit
unit} -> EntitlementUnit
unit) (\s :: Entitlement
s@Entitlement' {} EntitlementUnit
a -> Entitlement
s {$sel:unit:Entitlement' :: EntitlementUnit
unit = EntitlementUnit
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 Integer
-> Maybe Text
-> Maybe Bool
-> Maybe Bool
-> Text
-> EntitlementUnit
-> Entitlement
Entitlement'
(Maybe Integer
-> Maybe Text
-> Maybe Bool
-> Maybe Bool
-> Text
-> EntitlementUnit
-> Entitlement)
-> Parser (Maybe Integer)
-> Parser
(Maybe Text
-> Maybe Bool
-> Maybe Bool
-> Text
-> EntitlementUnit
-> Entitlement)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MaxCount")
Parser
(Maybe Text
-> Maybe Bool
-> Maybe Bool
-> Text
-> EntitlementUnit
-> Entitlement)
-> Parser (Maybe Text)
-> Parser
(Maybe Bool
-> Maybe Bool -> Text -> EntitlementUnit -> 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
"Value")
Parser
(Maybe Bool
-> Maybe Bool -> Text -> EntitlementUnit -> Entitlement)
-> Parser (Maybe Bool)
-> Parser (Maybe Bool -> Text -> EntitlementUnit -> Entitlement)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Overage")
Parser (Maybe Bool -> Text -> EntitlementUnit -> Entitlement)
-> Parser (Maybe Bool)
-> Parser (Text -> EntitlementUnit -> Entitlement)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AllowCheckIn")
Parser (Text -> EntitlementUnit -> Entitlement)
-> Parser Text -> Parser (EntitlementUnit -> Entitlement)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Name")
Parser (EntitlementUnit -> Entitlement)
-> Parser EntitlementUnit -> Parser Entitlement
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser EntitlementUnit
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Unit")
)
instance Prelude.Hashable Entitlement
instance Prelude.NFData Entitlement
instance Core.ToJSON Entitlement where
toJSON :: Entitlement -> Value
toJSON Entitlement' {Maybe Bool
Maybe Integer
Maybe Text
Text
EntitlementUnit
unit :: EntitlementUnit
name :: Text
allowCheckIn :: Maybe Bool
overage :: Maybe Bool
value :: Maybe Text
maxCount :: Maybe Integer
$sel:unit:Entitlement' :: Entitlement -> EntitlementUnit
$sel:name:Entitlement' :: Entitlement -> Text
$sel:allowCheckIn:Entitlement' :: Entitlement -> Maybe Bool
$sel:overage:Entitlement' :: Entitlement -> Maybe Bool
$sel:value:Entitlement' :: Entitlement -> Maybe Text
$sel:maxCount:Entitlement' :: Entitlement -> Maybe Integer
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"MaxCount" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Integer -> Pair) -> Maybe Integer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Integer
maxCount,
(Text
"Value" 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
value,
(Text
"Overage" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
overage,
(Text
"AllowCheckIn" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
allowCheckIn,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Unit" Text -> EntitlementUnit -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= EntitlementUnit
unit)
]
)