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

import qualified Amazonka.Core as Core
import Amazonka.CostExplorer.Types.DateInterval
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 amount of Savings Plans utilization, in hours.
--
-- /See:/ 'newSavingsPlansUtilizationByTime' smart constructor.
data SavingsPlansUtilizationByTime = SavingsPlansUtilizationByTime'
  { -- | The total amortized commitment for a Savings Plans. This includes the
    -- sum of the upfront and recurring Savings Plans fees.
    SavingsPlansUtilizationByTime
-> 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.
    SavingsPlansUtilizationByTime -> Maybe SavingsPlansSavings
savings :: Prelude.Maybe SavingsPlansSavings,
    SavingsPlansUtilizationByTime -> DateInterval
timePeriod :: DateInterval,
    -- | A ratio of your effectiveness of using existing Savings Plans to apply
    -- to workloads that are Savings Plans eligible.
    SavingsPlansUtilizationByTime -> SavingsPlansUtilization
utilization :: SavingsPlansUtilization
  }
  deriving (SavingsPlansUtilizationByTime
-> SavingsPlansUtilizationByTime -> Bool
(SavingsPlansUtilizationByTime
 -> SavingsPlansUtilizationByTime -> Bool)
-> (SavingsPlansUtilizationByTime
    -> SavingsPlansUtilizationByTime -> Bool)
-> Eq SavingsPlansUtilizationByTime
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SavingsPlansUtilizationByTime
-> SavingsPlansUtilizationByTime -> Bool
$c/= :: SavingsPlansUtilizationByTime
-> SavingsPlansUtilizationByTime -> Bool
== :: SavingsPlansUtilizationByTime
-> SavingsPlansUtilizationByTime -> Bool
$c== :: SavingsPlansUtilizationByTime
-> SavingsPlansUtilizationByTime -> Bool
Prelude.Eq, ReadPrec [SavingsPlansUtilizationByTime]
ReadPrec SavingsPlansUtilizationByTime
Int -> ReadS SavingsPlansUtilizationByTime
ReadS [SavingsPlansUtilizationByTime]
(Int -> ReadS SavingsPlansUtilizationByTime)
-> ReadS [SavingsPlansUtilizationByTime]
-> ReadPrec SavingsPlansUtilizationByTime
-> ReadPrec [SavingsPlansUtilizationByTime]
-> Read SavingsPlansUtilizationByTime
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SavingsPlansUtilizationByTime]
$creadListPrec :: ReadPrec [SavingsPlansUtilizationByTime]
readPrec :: ReadPrec SavingsPlansUtilizationByTime
$creadPrec :: ReadPrec SavingsPlansUtilizationByTime
readList :: ReadS [SavingsPlansUtilizationByTime]
$creadList :: ReadS [SavingsPlansUtilizationByTime]
readsPrec :: Int -> ReadS SavingsPlansUtilizationByTime
$creadsPrec :: Int -> ReadS SavingsPlansUtilizationByTime
Prelude.Read, Int -> SavingsPlansUtilizationByTime -> ShowS
[SavingsPlansUtilizationByTime] -> ShowS
SavingsPlansUtilizationByTime -> String
(Int -> SavingsPlansUtilizationByTime -> ShowS)
-> (SavingsPlansUtilizationByTime -> String)
-> ([SavingsPlansUtilizationByTime] -> ShowS)
-> Show SavingsPlansUtilizationByTime
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SavingsPlansUtilizationByTime] -> ShowS
$cshowList :: [SavingsPlansUtilizationByTime] -> ShowS
show :: SavingsPlansUtilizationByTime -> String
$cshow :: SavingsPlansUtilizationByTime -> String
showsPrec :: Int -> SavingsPlansUtilizationByTime -> ShowS
$cshowsPrec :: Int -> SavingsPlansUtilizationByTime -> ShowS
Prelude.Show, (forall x.
 SavingsPlansUtilizationByTime
 -> Rep SavingsPlansUtilizationByTime x)
-> (forall x.
    Rep SavingsPlansUtilizationByTime x
    -> SavingsPlansUtilizationByTime)
-> Generic SavingsPlansUtilizationByTime
forall x.
Rep SavingsPlansUtilizationByTime x
-> SavingsPlansUtilizationByTime
forall x.
SavingsPlansUtilizationByTime
-> Rep SavingsPlansUtilizationByTime x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SavingsPlansUtilizationByTime x
-> SavingsPlansUtilizationByTime
$cfrom :: forall x.
SavingsPlansUtilizationByTime
-> Rep SavingsPlansUtilizationByTime x
Prelude.Generic)

-- |
-- Create a value of 'SavingsPlansUtilizationByTime' 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', 'savingsPlansUtilizationByTime_amortizedCommitment' - The total amortized commitment for a Savings Plans. This includes the
-- sum of the upfront and recurring Savings Plans fees.
--
-- 'savings', 'savingsPlansUtilizationByTime_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.
--
-- 'timePeriod', 'savingsPlansUtilizationByTime_timePeriod' - Undocumented member.
--
-- 'utilization', 'savingsPlansUtilizationByTime_utilization' - A ratio of your effectiveness of using existing Savings Plans to apply
-- to workloads that are Savings Plans eligible.
newSavingsPlansUtilizationByTime ::
  -- | 'timePeriod'
  DateInterval ->
  -- | 'utilization'
  SavingsPlansUtilization ->
  SavingsPlansUtilizationByTime
newSavingsPlansUtilizationByTime :: DateInterval
-> SavingsPlansUtilization -> SavingsPlansUtilizationByTime
newSavingsPlansUtilizationByTime
  DateInterval
pTimePeriod_
  SavingsPlansUtilization
pUtilization_ =
    SavingsPlansUtilizationByTime' :: Maybe SavingsPlansAmortizedCommitment
-> Maybe SavingsPlansSavings
-> DateInterval
-> SavingsPlansUtilization
-> SavingsPlansUtilizationByTime
SavingsPlansUtilizationByTime'
      { $sel:amortizedCommitment:SavingsPlansUtilizationByTime' :: Maybe SavingsPlansAmortizedCommitment
amortizedCommitment =
          Maybe SavingsPlansAmortizedCommitment
forall a. Maybe a
Prelude.Nothing,
        $sel:savings:SavingsPlansUtilizationByTime' :: Maybe SavingsPlansSavings
savings = Maybe SavingsPlansSavings
forall a. Maybe a
Prelude.Nothing,
        $sel:timePeriod:SavingsPlansUtilizationByTime' :: DateInterval
timePeriod = DateInterval
pTimePeriod_,
        $sel:utilization:SavingsPlansUtilizationByTime' :: SavingsPlansUtilization
utilization = SavingsPlansUtilization
pUtilization_
      }

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

-- | 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.
savingsPlansUtilizationByTime_savings :: Lens.Lens' SavingsPlansUtilizationByTime (Prelude.Maybe SavingsPlansSavings)
savingsPlansUtilizationByTime_savings :: (Maybe SavingsPlansSavings -> f (Maybe SavingsPlansSavings))
-> SavingsPlansUtilizationByTime -> f SavingsPlansUtilizationByTime
savingsPlansUtilizationByTime_savings = (SavingsPlansUtilizationByTime -> Maybe SavingsPlansSavings)
-> (SavingsPlansUtilizationByTime
    -> Maybe SavingsPlansSavings -> SavingsPlansUtilizationByTime)
-> Lens
     SavingsPlansUtilizationByTime
     SavingsPlansUtilizationByTime
     (Maybe SavingsPlansSavings)
     (Maybe SavingsPlansSavings)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SavingsPlansUtilizationByTime' {Maybe SavingsPlansSavings
savings :: Maybe SavingsPlansSavings
$sel:savings:SavingsPlansUtilizationByTime' :: SavingsPlansUtilizationByTime -> Maybe SavingsPlansSavings
savings} -> Maybe SavingsPlansSavings
savings) (\s :: SavingsPlansUtilizationByTime
s@SavingsPlansUtilizationByTime' {} Maybe SavingsPlansSavings
a -> SavingsPlansUtilizationByTime
s {$sel:savings:SavingsPlansUtilizationByTime' :: Maybe SavingsPlansSavings
savings = Maybe SavingsPlansSavings
a} :: SavingsPlansUtilizationByTime)

-- | Undocumented member.
savingsPlansUtilizationByTime_timePeriod :: Lens.Lens' SavingsPlansUtilizationByTime DateInterval
savingsPlansUtilizationByTime_timePeriod :: (DateInterval -> f DateInterval)
-> SavingsPlansUtilizationByTime -> f SavingsPlansUtilizationByTime
savingsPlansUtilizationByTime_timePeriod = (SavingsPlansUtilizationByTime -> DateInterval)
-> (SavingsPlansUtilizationByTime
    -> DateInterval -> SavingsPlansUtilizationByTime)
-> Lens
     SavingsPlansUtilizationByTime
     SavingsPlansUtilizationByTime
     DateInterval
     DateInterval
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SavingsPlansUtilizationByTime' {DateInterval
timePeriod :: DateInterval
$sel:timePeriod:SavingsPlansUtilizationByTime' :: SavingsPlansUtilizationByTime -> DateInterval
timePeriod} -> DateInterval
timePeriod) (\s :: SavingsPlansUtilizationByTime
s@SavingsPlansUtilizationByTime' {} DateInterval
a -> SavingsPlansUtilizationByTime
s {$sel:timePeriod:SavingsPlansUtilizationByTime' :: DateInterval
timePeriod = DateInterval
a} :: SavingsPlansUtilizationByTime)

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

instance Core.FromJSON SavingsPlansUtilizationByTime where
  parseJSON :: Value -> Parser SavingsPlansUtilizationByTime
parseJSON =
    String
-> (Object -> Parser SavingsPlansUtilizationByTime)
-> Value
-> Parser SavingsPlansUtilizationByTime
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SavingsPlansUtilizationByTime"
      ( \Object
x ->
          Maybe SavingsPlansAmortizedCommitment
-> Maybe SavingsPlansSavings
-> DateInterval
-> SavingsPlansUtilization
-> SavingsPlansUtilizationByTime
SavingsPlansUtilizationByTime'
            (Maybe SavingsPlansAmortizedCommitment
 -> Maybe SavingsPlansSavings
 -> DateInterval
 -> SavingsPlansUtilization
 -> SavingsPlansUtilizationByTime)
-> Parser (Maybe SavingsPlansAmortizedCommitment)
-> Parser
     (Maybe SavingsPlansSavings
      -> DateInterval
      -> SavingsPlansUtilization
      -> SavingsPlansUtilizationByTime)
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
   -> DateInterval
   -> SavingsPlansUtilization
   -> SavingsPlansUtilizationByTime)
-> Parser (Maybe SavingsPlansSavings)
-> Parser
     (DateInterval
      -> SavingsPlansUtilization -> SavingsPlansUtilizationByTime)
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
  (DateInterval
   -> SavingsPlansUtilization -> SavingsPlansUtilizationByTime)
-> Parser DateInterval
-> Parser
     (SavingsPlansUtilization -> SavingsPlansUtilizationByTime)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser DateInterval
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"TimePeriod")
            Parser (SavingsPlansUtilization -> SavingsPlansUtilizationByTime)
-> Parser SavingsPlansUtilization
-> Parser SavingsPlansUtilizationByTime
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
    SavingsPlansUtilizationByTime

instance Prelude.NFData SavingsPlansUtilizationByTime