{-# 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.EntitlementData where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.LicenseManager.Types.EntitlementDataUnit
import qualified Amazonka.Prelude as Prelude
data EntitlementData = EntitlementData'
{
EntitlementData -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
EntitlementData -> Text
name :: Prelude.Text,
EntitlementData -> EntitlementDataUnit
unit :: EntitlementDataUnit
}
deriving (EntitlementData -> EntitlementData -> Bool
(EntitlementData -> EntitlementData -> Bool)
-> (EntitlementData -> EntitlementData -> Bool)
-> Eq EntitlementData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EntitlementData -> EntitlementData -> Bool
$c/= :: EntitlementData -> EntitlementData -> Bool
== :: EntitlementData -> EntitlementData -> Bool
$c== :: EntitlementData -> EntitlementData -> Bool
Prelude.Eq, ReadPrec [EntitlementData]
ReadPrec EntitlementData
Int -> ReadS EntitlementData
ReadS [EntitlementData]
(Int -> ReadS EntitlementData)
-> ReadS [EntitlementData]
-> ReadPrec EntitlementData
-> ReadPrec [EntitlementData]
-> Read EntitlementData
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EntitlementData]
$creadListPrec :: ReadPrec [EntitlementData]
readPrec :: ReadPrec EntitlementData
$creadPrec :: ReadPrec EntitlementData
readList :: ReadS [EntitlementData]
$creadList :: ReadS [EntitlementData]
readsPrec :: Int -> ReadS EntitlementData
$creadsPrec :: Int -> ReadS EntitlementData
Prelude.Read, Int -> EntitlementData -> ShowS
[EntitlementData] -> ShowS
EntitlementData -> String
(Int -> EntitlementData -> ShowS)
-> (EntitlementData -> String)
-> ([EntitlementData] -> ShowS)
-> Show EntitlementData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EntitlementData] -> ShowS
$cshowList :: [EntitlementData] -> ShowS
show :: EntitlementData -> String
$cshow :: EntitlementData -> String
showsPrec :: Int -> EntitlementData -> ShowS
$cshowsPrec :: Int -> EntitlementData -> ShowS
Prelude.Show, (forall x. EntitlementData -> Rep EntitlementData x)
-> (forall x. Rep EntitlementData x -> EntitlementData)
-> Generic EntitlementData
forall x. Rep EntitlementData x -> EntitlementData
forall x. EntitlementData -> Rep EntitlementData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EntitlementData x -> EntitlementData
$cfrom :: forall x. EntitlementData -> Rep EntitlementData x
Prelude.Generic)
newEntitlementData ::
Prelude.Text ->
EntitlementDataUnit ->
EntitlementData
newEntitlementData :: Text -> EntitlementDataUnit -> EntitlementData
newEntitlementData Text
pName_ EntitlementDataUnit
pUnit_ =
EntitlementData' :: Maybe Text -> Text -> EntitlementDataUnit -> EntitlementData
EntitlementData'
{ $sel:value:EntitlementData' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:name:EntitlementData' :: Text
name = Text
pName_,
$sel:unit:EntitlementData' :: EntitlementDataUnit
unit = EntitlementDataUnit
pUnit_
}
entitlementData_value :: Lens.Lens' EntitlementData (Prelude.Maybe Prelude.Text)
entitlementData_value :: (Maybe Text -> f (Maybe Text))
-> EntitlementData -> f EntitlementData
entitlementData_value = (EntitlementData -> Maybe Text)
-> (EntitlementData -> Maybe Text -> EntitlementData)
-> Lens EntitlementData EntitlementData (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntitlementData' {Maybe Text
value :: Maybe Text
$sel:value:EntitlementData' :: EntitlementData -> Maybe Text
value} -> Maybe Text
value) (\s :: EntitlementData
s@EntitlementData' {} Maybe Text
a -> EntitlementData
s {$sel:value:EntitlementData' :: Maybe Text
value = Maybe Text
a} :: EntitlementData)
entitlementData_name :: Lens.Lens' EntitlementData Prelude.Text
entitlementData_name :: (Text -> f Text) -> EntitlementData -> f EntitlementData
entitlementData_name = (EntitlementData -> Text)
-> (EntitlementData -> Text -> EntitlementData)
-> Lens EntitlementData EntitlementData Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntitlementData' {Text
name :: Text
$sel:name:EntitlementData' :: EntitlementData -> Text
name} -> Text
name) (\s :: EntitlementData
s@EntitlementData' {} Text
a -> EntitlementData
s {$sel:name:EntitlementData' :: Text
name = Text
a} :: EntitlementData)
entitlementData_unit :: Lens.Lens' EntitlementData EntitlementDataUnit
entitlementData_unit :: (EntitlementDataUnit -> f EntitlementDataUnit)
-> EntitlementData -> f EntitlementData
entitlementData_unit = (EntitlementData -> EntitlementDataUnit)
-> (EntitlementData -> EntitlementDataUnit -> EntitlementData)
-> Lens
EntitlementData
EntitlementData
EntitlementDataUnit
EntitlementDataUnit
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntitlementData' {EntitlementDataUnit
unit :: EntitlementDataUnit
$sel:unit:EntitlementData' :: EntitlementData -> EntitlementDataUnit
unit} -> EntitlementDataUnit
unit) (\s :: EntitlementData
s@EntitlementData' {} EntitlementDataUnit
a -> EntitlementData
s {$sel:unit:EntitlementData' :: EntitlementDataUnit
unit = EntitlementDataUnit
a} :: EntitlementData)
instance Core.FromJSON EntitlementData where
parseJSON :: Value -> Parser EntitlementData
parseJSON =
String
-> (Object -> Parser EntitlementData)
-> Value
-> Parser EntitlementData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"EntitlementData"
( \Object
x ->
Maybe Text -> Text -> EntitlementDataUnit -> EntitlementData
EntitlementData'
(Maybe Text -> Text -> EntitlementDataUnit -> EntitlementData)
-> Parser (Maybe Text)
-> Parser (Text -> EntitlementDataUnit -> EntitlementData)
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
"Value")
Parser (Text -> EntitlementDataUnit -> EntitlementData)
-> Parser Text -> Parser (EntitlementDataUnit -> EntitlementData)
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 (EntitlementDataUnit -> EntitlementData)
-> Parser EntitlementDataUnit -> Parser EntitlementData
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser EntitlementDataUnit
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Unit")
)
instance Prelude.Hashable EntitlementData
instance Prelude.NFData EntitlementData
instance Core.ToJSON EntitlementData where
toJSON :: EntitlementData -> Value
toJSON EntitlementData' {Maybe Text
Text
EntitlementDataUnit
unit :: EntitlementDataUnit
name :: Text
value :: Maybe Text
$sel:unit:EntitlementData' :: EntitlementData -> EntitlementDataUnit
$sel:name:EntitlementData' :: EntitlementData -> Text
$sel:value:EntitlementData' :: EntitlementData -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (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,
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 -> EntitlementDataUnit -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= EntitlementDataUnit
unit)
]
)