{-# 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.LicenseManager.Types.EntitlementUsage
-- 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.LicenseManager.Types.EntitlementUsage where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.LicenseManager.Types.EntitlementDataUnit
import qualified Amazonka.Prelude as Prelude

-- | Usage associated with an entitlement resource.
--
-- /See:/ 'newEntitlementUsage' smart constructor.
data EntitlementUsage = EntitlementUsage'
  { -- | Maximum entitlement usage count.
    EntitlementUsage -> Maybe Text
maxCount :: Prelude.Maybe Prelude.Text,
    -- | Entitlement usage name.
    EntitlementUsage -> Text
name :: Prelude.Text,
    -- | Resource usage consumed.
    EntitlementUsage -> Text
consumedValue :: Prelude.Text,
    -- | Entitlement usage unit.
    EntitlementUsage -> EntitlementDataUnit
unit :: EntitlementDataUnit
  }
  deriving (EntitlementUsage -> EntitlementUsage -> Bool
(EntitlementUsage -> EntitlementUsage -> Bool)
-> (EntitlementUsage -> EntitlementUsage -> Bool)
-> Eq EntitlementUsage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EntitlementUsage -> EntitlementUsage -> Bool
$c/= :: EntitlementUsage -> EntitlementUsage -> Bool
== :: EntitlementUsage -> EntitlementUsage -> Bool
$c== :: EntitlementUsage -> EntitlementUsage -> Bool
Prelude.Eq, ReadPrec [EntitlementUsage]
ReadPrec EntitlementUsage
Int -> ReadS EntitlementUsage
ReadS [EntitlementUsage]
(Int -> ReadS EntitlementUsage)
-> ReadS [EntitlementUsage]
-> ReadPrec EntitlementUsage
-> ReadPrec [EntitlementUsage]
-> Read EntitlementUsage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EntitlementUsage]
$creadListPrec :: ReadPrec [EntitlementUsage]
readPrec :: ReadPrec EntitlementUsage
$creadPrec :: ReadPrec EntitlementUsage
readList :: ReadS [EntitlementUsage]
$creadList :: ReadS [EntitlementUsage]
readsPrec :: Int -> ReadS EntitlementUsage
$creadsPrec :: Int -> ReadS EntitlementUsage
Prelude.Read, Int -> EntitlementUsage -> ShowS
[EntitlementUsage] -> ShowS
EntitlementUsage -> String
(Int -> EntitlementUsage -> ShowS)
-> (EntitlementUsage -> String)
-> ([EntitlementUsage] -> ShowS)
-> Show EntitlementUsage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EntitlementUsage] -> ShowS
$cshowList :: [EntitlementUsage] -> ShowS
show :: EntitlementUsage -> String
$cshow :: EntitlementUsage -> String
showsPrec :: Int -> EntitlementUsage -> ShowS
$cshowsPrec :: Int -> EntitlementUsage -> ShowS
Prelude.Show, (forall x. EntitlementUsage -> Rep EntitlementUsage x)
-> (forall x. Rep EntitlementUsage x -> EntitlementUsage)
-> Generic EntitlementUsage
forall x. Rep EntitlementUsage x -> EntitlementUsage
forall x. EntitlementUsage -> Rep EntitlementUsage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EntitlementUsage x -> EntitlementUsage
$cfrom :: forall x. EntitlementUsage -> Rep EntitlementUsage x
Prelude.Generic)

-- |
-- Create a value of 'EntitlementUsage' 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:
--
-- 'maxCount', 'entitlementUsage_maxCount' - Maximum entitlement usage count.
--
-- 'name', 'entitlementUsage_name' - Entitlement usage name.
--
-- 'consumedValue', 'entitlementUsage_consumedValue' - Resource usage consumed.
--
-- 'unit', 'entitlementUsage_unit' - Entitlement usage unit.
newEntitlementUsage ::
  -- | 'name'
  Prelude.Text ->
  -- | 'consumedValue'
  Prelude.Text ->
  -- | 'unit'
  EntitlementDataUnit ->
  EntitlementUsage
newEntitlementUsage :: Text -> Text -> EntitlementDataUnit -> EntitlementUsage
newEntitlementUsage Text
pName_ Text
pConsumedValue_ EntitlementDataUnit
pUnit_ =
  EntitlementUsage' :: Maybe Text
-> Text -> Text -> EntitlementDataUnit -> EntitlementUsage
EntitlementUsage'
    { $sel:maxCount:EntitlementUsage' :: Maybe Text
maxCount = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:EntitlementUsage' :: Text
name = Text
pName_,
      $sel:consumedValue:EntitlementUsage' :: Text
consumedValue = Text
pConsumedValue_,
      $sel:unit:EntitlementUsage' :: EntitlementDataUnit
unit = EntitlementDataUnit
pUnit_
    }

-- | Maximum entitlement usage count.
entitlementUsage_maxCount :: Lens.Lens' EntitlementUsage (Prelude.Maybe Prelude.Text)
entitlementUsage_maxCount :: (Maybe Text -> f (Maybe Text))
-> EntitlementUsage -> f EntitlementUsage
entitlementUsage_maxCount = (EntitlementUsage -> Maybe Text)
-> (EntitlementUsage -> Maybe Text -> EntitlementUsage)
-> Lens EntitlementUsage EntitlementUsage (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntitlementUsage' {Maybe Text
maxCount :: Maybe Text
$sel:maxCount:EntitlementUsage' :: EntitlementUsage -> Maybe Text
maxCount} -> Maybe Text
maxCount) (\s :: EntitlementUsage
s@EntitlementUsage' {} Maybe Text
a -> EntitlementUsage
s {$sel:maxCount:EntitlementUsage' :: Maybe Text
maxCount = Maybe Text
a} :: EntitlementUsage)

-- | Entitlement usage name.
entitlementUsage_name :: Lens.Lens' EntitlementUsage Prelude.Text
entitlementUsage_name :: (Text -> f Text) -> EntitlementUsage -> f EntitlementUsage
entitlementUsage_name = (EntitlementUsage -> Text)
-> (EntitlementUsage -> Text -> EntitlementUsage)
-> Lens EntitlementUsage EntitlementUsage Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntitlementUsage' {Text
name :: Text
$sel:name:EntitlementUsage' :: EntitlementUsage -> Text
name} -> Text
name) (\s :: EntitlementUsage
s@EntitlementUsage' {} Text
a -> EntitlementUsage
s {$sel:name:EntitlementUsage' :: Text
name = Text
a} :: EntitlementUsage)

-- | Resource usage consumed.
entitlementUsage_consumedValue :: Lens.Lens' EntitlementUsage Prelude.Text
entitlementUsage_consumedValue :: (Text -> f Text) -> EntitlementUsage -> f EntitlementUsage
entitlementUsage_consumedValue = (EntitlementUsage -> Text)
-> (EntitlementUsage -> Text -> EntitlementUsage)
-> Lens EntitlementUsage EntitlementUsage Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntitlementUsage' {Text
consumedValue :: Text
$sel:consumedValue:EntitlementUsage' :: EntitlementUsage -> Text
consumedValue} -> Text
consumedValue) (\s :: EntitlementUsage
s@EntitlementUsage' {} Text
a -> EntitlementUsage
s {$sel:consumedValue:EntitlementUsage' :: Text
consumedValue = Text
a} :: EntitlementUsage)

-- | Entitlement usage unit.
entitlementUsage_unit :: Lens.Lens' EntitlementUsage EntitlementDataUnit
entitlementUsage_unit :: (EntitlementDataUnit -> f EntitlementDataUnit)
-> EntitlementUsage -> f EntitlementUsage
entitlementUsage_unit = (EntitlementUsage -> EntitlementDataUnit)
-> (EntitlementUsage -> EntitlementDataUnit -> EntitlementUsage)
-> Lens
     EntitlementUsage
     EntitlementUsage
     EntitlementDataUnit
     EntitlementDataUnit
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntitlementUsage' {EntitlementDataUnit
unit :: EntitlementDataUnit
$sel:unit:EntitlementUsage' :: EntitlementUsage -> EntitlementDataUnit
unit} -> EntitlementDataUnit
unit) (\s :: EntitlementUsage
s@EntitlementUsage' {} EntitlementDataUnit
a -> EntitlementUsage
s {$sel:unit:EntitlementUsage' :: EntitlementDataUnit
unit = EntitlementDataUnit
a} :: EntitlementUsage)

instance Core.FromJSON EntitlementUsage where
  parseJSON :: Value -> Parser EntitlementUsage
parseJSON =
    String
-> (Object -> Parser EntitlementUsage)
-> Value
-> Parser EntitlementUsage
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EntitlementUsage"
      ( \Object
x ->
          Maybe Text
-> Text -> Text -> EntitlementDataUnit -> EntitlementUsage
EntitlementUsage'
            (Maybe Text
 -> Text -> Text -> EntitlementDataUnit -> EntitlementUsage)
-> Parser (Maybe Text)
-> Parser (Text -> Text -> EntitlementDataUnit -> EntitlementUsage)
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
"MaxCount")
            Parser (Text -> Text -> EntitlementDataUnit -> EntitlementUsage)
-> Parser Text
-> Parser (Text -> EntitlementDataUnit -> EntitlementUsage)
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 (Text -> EntitlementDataUnit -> EntitlementUsage)
-> Parser Text -> Parser (EntitlementDataUnit -> EntitlementUsage)
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
"ConsumedValue")
            Parser (EntitlementDataUnit -> EntitlementUsage)
-> Parser EntitlementDataUnit -> Parser EntitlementUsage
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 EntitlementUsage

instance Prelude.NFData EntitlementUsage