{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CostExplorer.Types.SavingsPlansUtilization where

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

-- | 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 :: Lens' SavingsPlansUtilization (Maybe Text)
savingsPlansUtilization_totalCommitment = 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 wasn\'t consumed from
-- Savings Plans eligible usage in a specific period.
savingsPlansUtilization_unusedCommitment :: Lens.Lens' SavingsPlansUtilization (Prelude.Maybe Prelude.Text)
savingsPlansUtilization_unusedCommitment :: Lens' SavingsPlansUtilization (Maybe Text)
savingsPlansUtilization_unusedCommitment = 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 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 :: Lens' SavingsPlansUtilization (Maybe Text)
savingsPlansUtilization_usedCommitment = 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)

-- | The amount of @UsedCommitment@ divided by the @TotalCommitment@ for your
-- Savings Plans.
savingsPlansUtilization_utilizationPercentage :: Lens.Lens' SavingsPlansUtilization (Prelude.Maybe Prelude.Text)
savingsPlansUtilization_utilizationPercentage :: Lens' SavingsPlansUtilization (Maybe Text)
savingsPlansUtilization_utilizationPercentage = 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)

instance Data.FromJSON SavingsPlansUtilization where
  parseJSON :: Value -> Parser SavingsPlansUtilization
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SavingsPlansUtilization"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> SavingsPlansUtilization
SavingsPlansUtilization'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"TotalCommitment")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"UnusedCommitment")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"UsedCommitment")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"UtilizationPercentage")
      )

instance Prelude.Hashable SavingsPlansUtilization where
  hashWithSalt :: Int -> SavingsPlansUtilization -> Int
hashWithSalt Int
_salt SavingsPlansUtilization' {Maybe Text
utilizationPercentage :: Maybe Text
usedCommitment :: Maybe Text
unusedCommitment :: Maybe Text
totalCommitment :: Maybe Text
$sel:utilizationPercentage:SavingsPlansUtilization' :: SavingsPlansUtilization -> Maybe Text
$sel:usedCommitment:SavingsPlansUtilization' :: SavingsPlansUtilization -> Maybe Text
$sel:unusedCommitment:SavingsPlansUtilization' :: SavingsPlansUtilization -> Maybe Text
$sel:totalCommitment:SavingsPlansUtilization' :: SavingsPlansUtilization -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
totalCommitment
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
unusedCommitment
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
usedCommitment
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
utilizationPercentage

instance Prelude.NFData SavingsPlansUtilization where
  rnf :: SavingsPlansUtilization -> ()
rnf SavingsPlansUtilization' {Maybe Text
utilizationPercentage :: Maybe Text
usedCommitment :: Maybe Text
unusedCommitment :: Maybe Text
totalCommitment :: Maybe Text
$sel:utilizationPercentage:SavingsPlansUtilization' :: SavingsPlansUtilization -> Maybe Text
$sel:usedCommitment:SavingsPlansUtilization' :: SavingsPlansUtilization -> Maybe Text
$sel:unusedCommitment:SavingsPlansUtilization' :: SavingsPlansUtilization -> Maybe Text
$sel:totalCommitment:SavingsPlansUtilization' :: SavingsPlansUtilization -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
totalCommitment
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
unusedCommitment
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
usedCommitment
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
utilizationPercentage