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

import qualified Amazonka.Core as Core
import Amazonka.CostExplorer.Types.SavingsPlansAmortizedCommitment
import Amazonka.CostExplorer.Types.SavingsPlansSavings
import Amazonka.CostExplorer.Types.SavingsPlansUtilization
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The aggregated utilization metrics for your Savings Plans usage.
--
-- /See:/ 'newSavingsPlansUtilizationAggregates' smart constructor.
data SavingsPlansUtilizationAggregates = SavingsPlansUtilizationAggregates'
  { -- | The total amortized commitment for a Savings Plans. This includes the
    -- sum of the upfront and recurring Savings Plans fees.
    SavingsPlansUtilizationAggregates
-> Maybe SavingsPlansAmortizedCommitment
amortizedCommitment :: Prelude.Maybe SavingsPlansAmortizedCommitment,
    -- | The amount saved by using existing Savings Plans. Savings returns both
    -- net savings from Savings Plans, as well as the @onDemandCostEquivalent@
    -- of the Savings Plans when considering the utilization rate.
    SavingsPlansUtilizationAggregates -> Maybe SavingsPlansSavings
savings :: Prelude.Maybe SavingsPlansSavings,
    -- | A ratio of your effectiveness of using existing Savings Plans to apply
    -- to workloads that are Savings Plans eligible.
    SavingsPlansUtilizationAggregates -> SavingsPlansUtilization
utilization :: SavingsPlansUtilization
  }
  deriving (SavingsPlansUtilizationAggregates
-> SavingsPlansUtilizationAggregates -> Bool
(SavingsPlansUtilizationAggregates
 -> SavingsPlansUtilizationAggregates -> Bool)
-> (SavingsPlansUtilizationAggregates
    -> SavingsPlansUtilizationAggregates -> Bool)
-> Eq SavingsPlansUtilizationAggregates
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SavingsPlansUtilizationAggregates
-> SavingsPlansUtilizationAggregates -> Bool
$c/= :: SavingsPlansUtilizationAggregates
-> SavingsPlansUtilizationAggregates -> Bool
== :: SavingsPlansUtilizationAggregates
-> SavingsPlansUtilizationAggregates -> Bool
$c== :: SavingsPlansUtilizationAggregates
-> SavingsPlansUtilizationAggregates -> Bool
Prelude.Eq, ReadPrec [SavingsPlansUtilizationAggregates]
ReadPrec SavingsPlansUtilizationAggregates
Int -> ReadS SavingsPlansUtilizationAggregates
ReadS [SavingsPlansUtilizationAggregates]
(Int -> ReadS SavingsPlansUtilizationAggregates)
-> ReadS [SavingsPlansUtilizationAggregates]
-> ReadPrec SavingsPlansUtilizationAggregates
-> ReadPrec [SavingsPlansUtilizationAggregates]
-> Read SavingsPlansUtilizationAggregates
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SavingsPlansUtilizationAggregates]
$creadListPrec :: ReadPrec [SavingsPlansUtilizationAggregates]
readPrec :: ReadPrec SavingsPlansUtilizationAggregates
$creadPrec :: ReadPrec SavingsPlansUtilizationAggregates
readList :: ReadS [SavingsPlansUtilizationAggregates]
$creadList :: ReadS [SavingsPlansUtilizationAggregates]
readsPrec :: Int -> ReadS SavingsPlansUtilizationAggregates
$creadsPrec :: Int -> ReadS SavingsPlansUtilizationAggregates
Prelude.Read, Int -> SavingsPlansUtilizationAggregates -> ShowS
[SavingsPlansUtilizationAggregates] -> ShowS
SavingsPlansUtilizationAggregates -> String
(Int -> SavingsPlansUtilizationAggregates -> ShowS)
-> (SavingsPlansUtilizationAggregates -> String)
-> ([SavingsPlansUtilizationAggregates] -> ShowS)
-> Show SavingsPlansUtilizationAggregates
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SavingsPlansUtilizationAggregates] -> ShowS
$cshowList :: [SavingsPlansUtilizationAggregates] -> ShowS
show :: SavingsPlansUtilizationAggregates -> String
$cshow :: SavingsPlansUtilizationAggregates -> String
showsPrec :: Int -> SavingsPlansUtilizationAggregates -> ShowS
$cshowsPrec :: Int -> SavingsPlansUtilizationAggregates -> ShowS
Prelude.Show, (forall x.
 SavingsPlansUtilizationAggregates
 -> Rep SavingsPlansUtilizationAggregates x)
-> (forall x.
    Rep SavingsPlansUtilizationAggregates x
    -> SavingsPlansUtilizationAggregates)
-> Generic SavingsPlansUtilizationAggregates
forall x.
Rep SavingsPlansUtilizationAggregates x
-> SavingsPlansUtilizationAggregates
forall x.
SavingsPlansUtilizationAggregates
-> Rep SavingsPlansUtilizationAggregates x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SavingsPlansUtilizationAggregates x
-> SavingsPlansUtilizationAggregates
$cfrom :: forall x.
SavingsPlansUtilizationAggregates
-> Rep SavingsPlansUtilizationAggregates x
Prelude.Generic)

-- |
-- Create a value of 'SavingsPlansUtilizationAggregates' 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:
--
-- 'amortizedCommitment', 'savingsPlansUtilizationAggregates_amortizedCommitment' - The total amortized commitment for a Savings Plans. This includes the
-- sum of the upfront and recurring Savings Plans fees.
--
-- 'savings', 'savingsPlansUtilizationAggregates_savings' - The amount saved by using existing Savings Plans. Savings returns both
-- net savings from Savings Plans, as well as the @onDemandCostEquivalent@
-- of the Savings Plans when considering the utilization rate.
--
-- 'utilization', 'savingsPlansUtilizationAggregates_utilization' - A ratio of your effectiveness of using existing Savings Plans to apply
-- to workloads that are Savings Plans eligible.
newSavingsPlansUtilizationAggregates ::
  -- | 'utilization'
  SavingsPlansUtilization ->
  SavingsPlansUtilizationAggregates
newSavingsPlansUtilizationAggregates :: SavingsPlansUtilization -> SavingsPlansUtilizationAggregates
newSavingsPlansUtilizationAggregates SavingsPlansUtilization
pUtilization_ =
  SavingsPlansUtilizationAggregates' :: Maybe SavingsPlansAmortizedCommitment
-> Maybe SavingsPlansSavings
-> SavingsPlansUtilization
-> SavingsPlansUtilizationAggregates
SavingsPlansUtilizationAggregates'
    { $sel:amortizedCommitment:SavingsPlansUtilizationAggregates' :: Maybe SavingsPlansAmortizedCommitment
amortizedCommitment =
        Maybe SavingsPlansAmortizedCommitment
forall a. Maybe a
Prelude.Nothing,
      $sel:savings:SavingsPlansUtilizationAggregates' :: Maybe SavingsPlansSavings
savings = Maybe SavingsPlansSavings
forall a. Maybe a
Prelude.Nothing,
      $sel:utilization:SavingsPlansUtilizationAggregates' :: SavingsPlansUtilization
utilization = SavingsPlansUtilization
pUtilization_
    }

-- | The total amortized commitment for a Savings Plans. This includes the
-- sum of the upfront and recurring Savings Plans fees.
savingsPlansUtilizationAggregates_amortizedCommitment :: Lens.Lens' SavingsPlansUtilizationAggregates (Prelude.Maybe SavingsPlansAmortizedCommitment)
savingsPlansUtilizationAggregates_amortizedCommitment :: (Maybe SavingsPlansAmortizedCommitment
 -> f (Maybe SavingsPlansAmortizedCommitment))
-> SavingsPlansUtilizationAggregates
-> f SavingsPlansUtilizationAggregates
savingsPlansUtilizationAggregates_amortizedCommitment = (SavingsPlansUtilizationAggregates
 -> Maybe SavingsPlansAmortizedCommitment)
-> (SavingsPlansUtilizationAggregates
    -> Maybe SavingsPlansAmortizedCommitment
    -> SavingsPlansUtilizationAggregates)
-> Lens
     SavingsPlansUtilizationAggregates
     SavingsPlansUtilizationAggregates
     (Maybe SavingsPlansAmortizedCommitment)
     (Maybe SavingsPlansAmortizedCommitment)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SavingsPlansUtilizationAggregates' {Maybe SavingsPlansAmortizedCommitment
amortizedCommitment :: Maybe SavingsPlansAmortizedCommitment
$sel:amortizedCommitment:SavingsPlansUtilizationAggregates' :: SavingsPlansUtilizationAggregates
-> Maybe SavingsPlansAmortizedCommitment
amortizedCommitment} -> Maybe SavingsPlansAmortizedCommitment
amortizedCommitment) (\s :: SavingsPlansUtilizationAggregates
s@SavingsPlansUtilizationAggregates' {} Maybe SavingsPlansAmortizedCommitment
a -> SavingsPlansUtilizationAggregates
s {$sel:amortizedCommitment:SavingsPlansUtilizationAggregates' :: Maybe SavingsPlansAmortizedCommitment
amortizedCommitment = Maybe SavingsPlansAmortizedCommitment
a} :: SavingsPlansUtilizationAggregates)

-- | The amount saved by using existing Savings Plans. Savings returns both
-- net savings from Savings Plans, as well as the @onDemandCostEquivalent@
-- of the Savings Plans when considering the utilization rate.
savingsPlansUtilizationAggregates_savings :: Lens.Lens' SavingsPlansUtilizationAggregates (Prelude.Maybe SavingsPlansSavings)
savingsPlansUtilizationAggregates_savings :: (Maybe SavingsPlansSavings -> f (Maybe SavingsPlansSavings))
-> SavingsPlansUtilizationAggregates
-> f SavingsPlansUtilizationAggregates
savingsPlansUtilizationAggregates_savings = (SavingsPlansUtilizationAggregates -> Maybe SavingsPlansSavings)
-> (SavingsPlansUtilizationAggregates
    -> Maybe SavingsPlansSavings -> SavingsPlansUtilizationAggregates)
-> Lens
     SavingsPlansUtilizationAggregates
     SavingsPlansUtilizationAggregates
     (Maybe SavingsPlansSavings)
     (Maybe SavingsPlansSavings)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SavingsPlansUtilizationAggregates' {Maybe SavingsPlansSavings
savings :: Maybe SavingsPlansSavings
$sel:savings:SavingsPlansUtilizationAggregates' :: SavingsPlansUtilizationAggregates -> Maybe SavingsPlansSavings
savings} -> Maybe SavingsPlansSavings
savings) (\s :: SavingsPlansUtilizationAggregates
s@SavingsPlansUtilizationAggregates' {} Maybe SavingsPlansSavings
a -> SavingsPlansUtilizationAggregates
s {$sel:savings:SavingsPlansUtilizationAggregates' :: Maybe SavingsPlansSavings
savings = Maybe SavingsPlansSavings
a} :: SavingsPlansUtilizationAggregates)

-- | A ratio of your effectiveness of using existing Savings Plans to apply
-- to workloads that are Savings Plans eligible.
savingsPlansUtilizationAggregates_utilization :: Lens.Lens' SavingsPlansUtilizationAggregates SavingsPlansUtilization
savingsPlansUtilizationAggregates_utilization :: (SavingsPlansUtilization -> f SavingsPlansUtilization)
-> SavingsPlansUtilizationAggregates
-> f SavingsPlansUtilizationAggregates
savingsPlansUtilizationAggregates_utilization = (SavingsPlansUtilizationAggregates -> SavingsPlansUtilization)
-> (SavingsPlansUtilizationAggregates
    -> SavingsPlansUtilization -> SavingsPlansUtilizationAggregates)
-> Lens
     SavingsPlansUtilizationAggregates
     SavingsPlansUtilizationAggregates
     SavingsPlansUtilization
     SavingsPlansUtilization
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SavingsPlansUtilizationAggregates' {SavingsPlansUtilization
utilization :: SavingsPlansUtilization
$sel:utilization:SavingsPlansUtilizationAggregates' :: SavingsPlansUtilizationAggregates -> SavingsPlansUtilization
utilization} -> SavingsPlansUtilization
utilization) (\s :: SavingsPlansUtilizationAggregates
s@SavingsPlansUtilizationAggregates' {} SavingsPlansUtilization
a -> SavingsPlansUtilizationAggregates
s {$sel:utilization:SavingsPlansUtilizationAggregates' :: SavingsPlansUtilization
utilization = SavingsPlansUtilization
a} :: SavingsPlansUtilizationAggregates)

instance
  Core.FromJSON
    SavingsPlansUtilizationAggregates
  where
  parseJSON :: Value -> Parser SavingsPlansUtilizationAggregates
parseJSON =
    String
-> (Object -> Parser SavingsPlansUtilizationAggregates)
-> Value
-> Parser SavingsPlansUtilizationAggregates
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SavingsPlansUtilizationAggregates"
      ( \Object
x ->
          Maybe SavingsPlansAmortizedCommitment
-> Maybe SavingsPlansSavings
-> SavingsPlansUtilization
-> SavingsPlansUtilizationAggregates
SavingsPlansUtilizationAggregates'
            (Maybe SavingsPlansAmortizedCommitment
 -> Maybe SavingsPlansSavings
 -> SavingsPlansUtilization
 -> SavingsPlansUtilizationAggregates)
-> Parser (Maybe SavingsPlansAmortizedCommitment)
-> Parser
     (Maybe SavingsPlansSavings
      -> SavingsPlansUtilization -> SavingsPlansUtilizationAggregates)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe SavingsPlansAmortizedCommitment)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AmortizedCommitment")
            Parser
  (Maybe SavingsPlansSavings
   -> SavingsPlansUtilization -> SavingsPlansUtilizationAggregates)
-> Parser (Maybe SavingsPlansSavings)
-> Parser
     (SavingsPlansUtilization -> SavingsPlansUtilizationAggregates)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SavingsPlansSavings)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Savings")
            Parser
  (SavingsPlansUtilization -> SavingsPlansUtilizationAggregates)
-> Parser SavingsPlansUtilization
-> Parser SavingsPlansUtilizationAggregates
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser SavingsPlansUtilization
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Utilization")
      )

instance
  Prelude.Hashable
    SavingsPlansUtilizationAggregates

instance
  Prelude.NFData
    SavingsPlansUtilizationAggregates