{-# 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.EntitlementValue
-- 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.EntitlementValue where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The EntitlementValue represents the amount of capacity that the customer
-- is entitled to for the product.
--
-- /See:/ 'newEntitlementValue' smart constructor.
data EntitlementValue = EntitlementValue'
  { -- | The IntegerValue field will be populated with an integer value when the
    -- entitlement is an integer type. Otherwise, the field will not be set.
    EntitlementValue -> Maybe Int
integerValue :: Prelude.Maybe Prelude.Int,
    -- | The DoubleValue field will be populated with a double value when the
    -- entitlement is a double type. Otherwise, the field will not be set.
    EntitlementValue -> Maybe Double
doubleValue :: Prelude.Maybe Prelude.Double,
    -- | The StringValue field will be populated with a string value when the
    -- entitlement is a string type. Otherwise, the field will not be set.
    EntitlementValue -> Maybe Text
stringValue :: Prelude.Maybe Prelude.Text,
    -- | The BooleanValue field will be populated with a boolean value when the
    -- entitlement is a boolean type. Otherwise, the field will not be set.
    EntitlementValue -> Maybe Bool
booleanValue :: Prelude.Maybe Prelude.Bool
  }
  deriving (EntitlementValue -> EntitlementValue -> Bool
(EntitlementValue -> EntitlementValue -> Bool)
-> (EntitlementValue -> EntitlementValue -> Bool)
-> Eq EntitlementValue
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EntitlementValue -> EntitlementValue -> Bool
$c/= :: EntitlementValue -> EntitlementValue -> Bool
== :: EntitlementValue -> EntitlementValue -> Bool
$c== :: EntitlementValue -> EntitlementValue -> Bool
Prelude.Eq, ReadPrec [EntitlementValue]
ReadPrec EntitlementValue
Int -> ReadS EntitlementValue
ReadS [EntitlementValue]
(Int -> ReadS EntitlementValue)
-> ReadS [EntitlementValue]
-> ReadPrec EntitlementValue
-> ReadPrec [EntitlementValue]
-> Read EntitlementValue
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EntitlementValue]
$creadListPrec :: ReadPrec [EntitlementValue]
readPrec :: ReadPrec EntitlementValue
$creadPrec :: ReadPrec EntitlementValue
readList :: ReadS [EntitlementValue]
$creadList :: ReadS [EntitlementValue]
readsPrec :: Int -> ReadS EntitlementValue
$creadsPrec :: Int -> ReadS EntitlementValue
Prelude.Read, Int -> EntitlementValue -> ShowS
[EntitlementValue] -> ShowS
EntitlementValue -> String
(Int -> EntitlementValue -> ShowS)
-> (EntitlementValue -> String)
-> ([EntitlementValue] -> ShowS)
-> Show EntitlementValue
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EntitlementValue] -> ShowS
$cshowList :: [EntitlementValue] -> ShowS
show :: EntitlementValue -> String
$cshow :: EntitlementValue -> String
showsPrec :: Int -> EntitlementValue -> ShowS
$cshowsPrec :: Int -> EntitlementValue -> ShowS
Prelude.Show, (forall x. EntitlementValue -> Rep EntitlementValue x)
-> (forall x. Rep EntitlementValue x -> EntitlementValue)
-> Generic EntitlementValue
forall x. Rep EntitlementValue x -> EntitlementValue
forall x. EntitlementValue -> Rep EntitlementValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EntitlementValue x -> EntitlementValue
$cfrom :: forall x. EntitlementValue -> Rep EntitlementValue x
Prelude.Generic)

-- |
-- Create a value of 'EntitlementValue' 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:
--
-- 'integerValue', 'entitlementValue_integerValue' - The IntegerValue field will be populated with an integer value when the
-- entitlement is an integer type. Otherwise, the field will not be set.
--
-- 'doubleValue', 'entitlementValue_doubleValue' - The DoubleValue field will be populated with a double value when the
-- entitlement is a double type. Otherwise, the field will not be set.
--
-- 'stringValue', 'entitlementValue_stringValue' - The StringValue field will be populated with a string value when the
-- entitlement is a string type. Otherwise, the field will not be set.
--
-- 'booleanValue', 'entitlementValue_booleanValue' - The BooleanValue field will be populated with a boolean value when the
-- entitlement is a boolean type. Otherwise, the field will not be set.
newEntitlementValue ::
  EntitlementValue
newEntitlementValue :: EntitlementValue
newEntitlementValue =
  EntitlementValue' :: Maybe Int
-> Maybe Double -> Maybe Text -> Maybe Bool -> EntitlementValue
EntitlementValue'
    { $sel:integerValue:EntitlementValue' :: Maybe Int
integerValue = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:doubleValue:EntitlementValue' :: Maybe Double
doubleValue = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:stringValue:EntitlementValue' :: Maybe Text
stringValue = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:booleanValue:EntitlementValue' :: Maybe Bool
booleanValue = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The IntegerValue field will be populated with an integer value when the
-- entitlement is an integer type. Otherwise, the field will not be set.
entitlementValue_integerValue :: Lens.Lens' EntitlementValue (Prelude.Maybe Prelude.Int)
entitlementValue_integerValue :: (Maybe Int -> f (Maybe Int))
-> EntitlementValue -> f EntitlementValue
entitlementValue_integerValue = (EntitlementValue -> Maybe Int)
-> (EntitlementValue -> Maybe Int -> EntitlementValue)
-> Lens EntitlementValue EntitlementValue (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntitlementValue' {Maybe Int
integerValue :: Maybe Int
$sel:integerValue:EntitlementValue' :: EntitlementValue -> Maybe Int
integerValue} -> Maybe Int
integerValue) (\s :: EntitlementValue
s@EntitlementValue' {} Maybe Int
a -> EntitlementValue
s {$sel:integerValue:EntitlementValue' :: Maybe Int
integerValue = Maybe Int
a} :: EntitlementValue)

-- | The DoubleValue field will be populated with a double value when the
-- entitlement is a double type. Otherwise, the field will not be set.
entitlementValue_doubleValue :: Lens.Lens' EntitlementValue (Prelude.Maybe Prelude.Double)
entitlementValue_doubleValue :: (Maybe Double -> f (Maybe Double))
-> EntitlementValue -> f EntitlementValue
entitlementValue_doubleValue = (EntitlementValue -> Maybe Double)
-> (EntitlementValue -> Maybe Double -> EntitlementValue)
-> Lens
     EntitlementValue EntitlementValue (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntitlementValue' {Maybe Double
doubleValue :: Maybe Double
$sel:doubleValue:EntitlementValue' :: EntitlementValue -> Maybe Double
doubleValue} -> Maybe Double
doubleValue) (\s :: EntitlementValue
s@EntitlementValue' {} Maybe Double
a -> EntitlementValue
s {$sel:doubleValue:EntitlementValue' :: Maybe Double
doubleValue = Maybe Double
a} :: EntitlementValue)

-- | The StringValue field will be populated with a string value when the
-- entitlement is a string type. Otherwise, the field will not be set.
entitlementValue_stringValue :: Lens.Lens' EntitlementValue (Prelude.Maybe Prelude.Text)
entitlementValue_stringValue :: (Maybe Text -> f (Maybe Text))
-> EntitlementValue -> f EntitlementValue
entitlementValue_stringValue = (EntitlementValue -> Maybe Text)
-> (EntitlementValue -> Maybe Text -> EntitlementValue)
-> Lens EntitlementValue EntitlementValue (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntitlementValue' {Maybe Text
stringValue :: Maybe Text
$sel:stringValue:EntitlementValue' :: EntitlementValue -> Maybe Text
stringValue} -> Maybe Text
stringValue) (\s :: EntitlementValue
s@EntitlementValue' {} Maybe Text
a -> EntitlementValue
s {$sel:stringValue:EntitlementValue' :: Maybe Text
stringValue = Maybe Text
a} :: EntitlementValue)

-- | The BooleanValue field will be populated with a boolean value when the
-- entitlement is a boolean type. Otherwise, the field will not be set.
entitlementValue_booleanValue :: Lens.Lens' EntitlementValue (Prelude.Maybe Prelude.Bool)
entitlementValue_booleanValue :: (Maybe Bool -> f (Maybe Bool))
-> EntitlementValue -> f EntitlementValue
entitlementValue_booleanValue = (EntitlementValue -> Maybe Bool)
-> (EntitlementValue -> Maybe Bool -> EntitlementValue)
-> Lens EntitlementValue EntitlementValue (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntitlementValue' {Maybe Bool
booleanValue :: Maybe Bool
$sel:booleanValue:EntitlementValue' :: EntitlementValue -> Maybe Bool
booleanValue} -> Maybe Bool
booleanValue) (\s :: EntitlementValue
s@EntitlementValue' {} Maybe Bool
a -> EntitlementValue
s {$sel:booleanValue:EntitlementValue' :: Maybe Bool
booleanValue = Maybe Bool
a} :: EntitlementValue)

instance Core.FromJSON EntitlementValue where
  parseJSON :: Value -> Parser EntitlementValue
parseJSON =
    String
-> (Object -> Parser EntitlementValue)
-> Value
-> Parser EntitlementValue
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EntitlementValue"
      ( \Object
x ->
          Maybe Int
-> Maybe Double -> Maybe Text -> Maybe Bool -> EntitlementValue
EntitlementValue'
            (Maybe Int
 -> Maybe Double -> Maybe Text -> Maybe Bool -> EntitlementValue)
-> Parser (Maybe Int)
-> Parser
     (Maybe Double -> Maybe Text -> Maybe Bool -> EntitlementValue)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IntegerValue")
            Parser
  (Maybe Double -> Maybe Text -> Maybe Bool -> EntitlementValue)
-> Parser (Maybe Double)
-> Parser (Maybe Text -> Maybe Bool -> EntitlementValue)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DoubleValue")
            Parser (Maybe Text -> Maybe Bool -> EntitlementValue)
-> Parser (Maybe Text) -> Parser (Maybe Bool -> EntitlementValue)
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
"StringValue")
            Parser (Maybe Bool -> EntitlementValue)
-> Parser (Maybe Bool) -> Parser EntitlementValue
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
"BooleanValue")
      )

instance Prelude.Hashable EntitlementValue

instance Prelude.NFData EntitlementValue