{-# 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.CostExplorer.Types.SavingsPlansUtilization
-- 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.CostExplorer.Types.SavingsPlansUtilization where

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

-- | The measurement of how well you\'re using your existing Savings Plans.
--
-- /See:/ 'newSavingsPlansUtilization' smart constructor.
data SavingsPlansUtilization = SavingsPlansUtilization'
  { -- | The amount of your Savings Plans commitment that wasn\'t consumed from
    -- Savings Plans eligible usage in a specific period.
    SavingsPlansUtilization -> Maybe Text
unusedCommitment :: Prelude.Maybe Prelude.Text,
    -- | The amount of @UsedCommitment@ divided by the @TotalCommitment@ for your
    -- Savings Plans.
    SavingsPlansUtilization -> Maybe Text
utilizationPercentage :: Prelude.Maybe Prelude.Text,
    -- | The total amount of Savings Plans commitment that\'s been purchased in
    -- an account (or set of accounts).
    SavingsPlansUtilization -> Maybe Text
totalCommitment :: Prelude.Maybe Prelude.Text,
    -- | The amount of your Savings Plans commitment that was consumed from
    -- Savings Plans eligible usage in a specific period.
    SavingsPlansUtilization -> Maybe Text
usedCommitment :: Prelude.Maybe Prelude.Text
  }
  deriving (SavingsPlansUtilization -> SavingsPlansUtilization -> Bool
(SavingsPlansUtilization -> SavingsPlansUtilization -> Bool)
-> (SavingsPlansUtilization -> SavingsPlansUtilization -> Bool)
-> Eq SavingsPlansUtilization
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SavingsPlansUtilization -> SavingsPlansUtilization -> Bool
$c/= :: SavingsPlansUtilization -> SavingsPlansUtilization -> Bool
== :: SavingsPlansUtilization -> SavingsPlansUtilization -> Bool
$c== :: SavingsPlansUtilization -> SavingsPlansUtilization -> Bool
Prelude.Eq, ReadPrec [SavingsPlansUtilization]
ReadPrec SavingsPlansUtilization
Int -> ReadS SavingsPlansUtilization
ReadS [SavingsPlansUtilization]
(Int -> ReadS SavingsPlansUtilization)
-> ReadS [SavingsPlansUtilization]
-> ReadPrec SavingsPlansUtilization
-> ReadPrec [SavingsPlansUtilization]
-> Read SavingsPlansUtilization
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SavingsPlansUtilization]
$creadListPrec :: ReadPrec [SavingsPlansUtilization]
readPrec :: ReadPrec SavingsPlansUtilization
$creadPrec :: ReadPrec SavingsPlansUtilization
readList :: ReadS [SavingsPlansUtilization]
$creadList :: ReadS [SavingsPlansUtilization]
readsPrec :: Int -> ReadS SavingsPlansUtilization
$creadsPrec :: Int -> ReadS SavingsPlansUtilization
Prelude.Read, Int -> SavingsPlansUtilization -> ShowS
[SavingsPlansUtilization] -> ShowS
SavingsPlansUtilization -> String
(Int -> SavingsPlansUtilization -> ShowS)
-> (SavingsPlansUtilization -> String)
-> ([SavingsPlansUtilization] -> ShowS)
-> Show SavingsPlansUtilization
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SavingsPlansUtilization] -> ShowS
$cshowList :: [SavingsPlansUtilization] -> ShowS
show :: SavingsPlansUtilization -> String
$cshow :: SavingsPlansUtilization -> String
showsPrec :: Int -> SavingsPlansUtilization -> ShowS
$cshowsPrec :: Int -> SavingsPlansUtilization -> ShowS
Prelude.Show, (forall x.
 SavingsPlansUtilization -> Rep SavingsPlansUtilization x)
-> (forall x.
    Rep SavingsPlansUtilization x -> SavingsPlansUtilization)
-> Generic SavingsPlansUtilization
forall x. Rep SavingsPlansUtilization x -> SavingsPlansUtilization
forall x. SavingsPlansUtilization -> Rep SavingsPlansUtilization x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SavingsPlansUtilization x -> SavingsPlansUtilization
$cfrom :: forall x. SavingsPlansUtilization -> Rep SavingsPlansUtilization x
Prelude.Generic)

-- |
-- Create a value of 'SavingsPlansUtilization' 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:
--
-- 'unusedCommitment', 'savingsPlansUtilization_unusedCommitment' - The amount of your Savings Plans commitment that wasn\'t consumed from
-- Savings Plans eligible usage in a specific period.
--
-- 'utilizationPercentage', 'savingsPlansUtilization_utilizationPercentage' - The amount of @UsedCommitment@ divided by the @TotalCommitment@ for your
-- Savings Plans.
--
-- 'totalCommitment', 'savingsPlansUtilization_totalCommitment' - The total amount of Savings Plans commitment that\'s been purchased in
-- an account (or set of accounts).
--
-- 'usedCommitment', 'savingsPlansUtilization_usedCommitment' - The amount of your Savings Plans commitment that was consumed from
-- Savings Plans eligible usage in a specific period.
newSavingsPlansUtilization ::
  SavingsPlansUtilization
newSavingsPlansUtilization :: SavingsPlansUtilization
newSavingsPlansUtilization =
  SavingsPlansUtilization' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> SavingsPlansUtilization
SavingsPlansUtilization'
    { $sel:unusedCommitment:SavingsPlansUtilization' :: Maybe Text
unusedCommitment =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:utilizationPercentage:SavingsPlansUtilization' :: Maybe Text
utilizationPercentage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:totalCommitment:SavingsPlansUtilization' :: Maybe Text
totalCommitment = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:usedCommitment:SavingsPlansUtilization' :: Maybe Text
usedCommitment = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The amount of your Savings Plans commitment that wasn\'t consumed from
-- Savings Plans eligible usage in a specific period.
savingsPlansUtilization_unusedCommitment :: Lens.Lens' SavingsPlansUtilization (Prelude.Maybe Prelude.Text)
savingsPlansUtilization_unusedCommitment :: (Maybe Text -> f (Maybe Text))
-> SavingsPlansUtilization -> f SavingsPlansUtilization
savingsPlansUtilization_unusedCommitment = (SavingsPlansUtilization -> Maybe Text)
-> (SavingsPlansUtilization
    -> Maybe Text -> SavingsPlansUtilization)
-> Lens
     SavingsPlansUtilization
     SavingsPlansUtilization
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SavingsPlansUtilization' {Maybe Text
unusedCommitment :: Maybe Text
$sel:unusedCommitment:SavingsPlansUtilization' :: SavingsPlansUtilization -> Maybe Text
unusedCommitment} -> Maybe Text
unusedCommitment) (\s :: SavingsPlansUtilization
s@SavingsPlansUtilization' {} Maybe Text
a -> SavingsPlansUtilization
s {$sel:unusedCommitment:SavingsPlansUtilization' :: Maybe Text
unusedCommitment = Maybe Text
a} :: SavingsPlansUtilization)

-- | The amount of @UsedCommitment@ divided by the @TotalCommitment@ for your
-- Savings Plans.
savingsPlansUtilization_utilizationPercentage :: Lens.Lens' SavingsPlansUtilization (Prelude.Maybe Prelude.Text)
savingsPlansUtilization_utilizationPercentage :: (Maybe Text -> f (Maybe Text))
-> SavingsPlansUtilization -> f SavingsPlansUtilization
savingsPlansUtilization_utilizationPercentage = (SavingsPlansUtilization -> Maybe Text)
-> (SavingsPlansUtilization
    -> Maybe Text -> SavingsPlansUtilization)
-> Lens
     SavingsPlansUtilization
     SavingsPlansUtilization
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SavingsPlansUtilization' {Maybe Text
utilizationPercentage :: Maybe Text
$sel:utilizationPercentage:SavingsPlansUtilization' :: SavingsPlansUtilization -> Maybe Text
utilizationPercentage} -> Maybe Text
utilizationPercentage) (\s :: SavingsPlansUtilization
s@SavingsPlansUtilization' {} Maybe Text
a -> SavingsPlansUtilization
s {$sel:utilizationPercentage:SavingsPlansUtilization' :: Maybe Text
utilizationPercentage = Maybe Text
a} :: SavingsPlansUtilization)

-- | The total amount of Savings Plans commitment that\'s been purchased in
-- an account (or set of accounts).
savingsPlansUtilization_totalCommitment :: Lens.Lens' SavingsPlansUtilization (Prelude.Maybe Prelude.Text)
savingsPlansUtilization_totalCommitment :: (Maybe Text -> f (Maybe Text))
-> SavingsPlansUtilization -> f SavingsPlansUtilization
savingsPlansUtilization_totalCommitment = (SavingsPlansUtilization -> Maybe Text)
-> (SavingsPlansUtilization
    -> Maybe Text -> SavingsPlansUtilization)
-> Lens
     SavingsPlansUtilization
     SavingsPlansUtilization
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SavingsPlansUtilization' {Maybe Text
totalCommitment :: Maybe Text
$sel:totalCommitment:SavingsPlansUtilization' :: SavingsPlansUtilization -> Maybe Text
totalCommitment} -> Maybe Text
totalCommitment) (\s :: SavingsPlansUtilization
s@SavingsPlansUtilization' {} Maybe Text
a -> SavingsPlansUtilization
s {$sel:totalCommitment:SavingsPlansUtilization' :: Maybe Text
totalCommitment = Maybe Text
a} :: SavingsPlansUtilization)

-- | The amount of your Savings Plans commitment that was consumed from
-- Savings Plans eligible usage in a specific period.
savingsPlansUtilization_usedCommitment :: Lens.Lens' SavingsPlansUtilization (Prelude.Maybe Prelude.Text)
savingsPlansUtilization_usedCommitment :: (Maybe Text -> f (Maybe Text))
-> SavingsPlansUtilization -> f SavingsPlansUtilization
savingsPlansUtilization_usedCommitment = (SavingsPlansUtilization -> Maybe Text)
-> (SavingsPlansUtilization
    -> Maybe Text -> SavingsPlansUtilization)
-> Lens
     SavingsPlansUtilization
     SavingsPlansUtilization
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SavingsPlansUtilization' {Maybe Text
usedCommitment :: Maybe Text
$sel:usedCommitment:SavingsPlansUtilization' :: SavingsPlansUtilization -> Maybe Text
usedCommitment} -> Maybe Text
usedCommitment) (\s :: SavingsPlansUtilization
s@SavingsPlansUtilization' {} Maybe Text
a -> SavingsPlansUtilization
s {$sel:usedCommitment:SavingsPlansUtilization' :: Maybe Text
usedCommitment = Maybe Text
a} :: SavingsPlansUtilization)

instance Core.FromJSON SavingsPlansUtilization where
  parseJSON :: Value -> Parser SavingsPlansUtilization
parseJSON =
    String
-> (Object -> Parser SavingsPlansUtilization)
-> Value
-> Parser SavingsPlansUtilization
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SavingsPlansUtilization"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> SavingsPlansUtilization
SavingsPlansUtilization'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> SavingsPlansUtilization)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> SavingsPlansUtilization)
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
"UnusedCommitment")
            Parser
  (Maybe Text -> Maybe Text -> Maybe Text -> SavingsPlansUtilization)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> SavingsPlansUtilization)
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
"UtilizationPercentage")
            Parser (Maybe Text -> Maybe Text -> SavingsPlansUtilization)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> SavingsPlansUtilization)
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
"TotalCommitment")
            Parser (Maybe Text -> SavingsPlansUtilization)
-> Parser (Maybe Text) -> Parser SavingsPlansUtilization
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
"UsedCommitment")
      )

instance Prelude.Hashable SavingsPlansUtilization

instance Prelude.NFData SavingsPlansUtilization