{-# 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.SavingsPlansUtilizationDetail
-- 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.SavingsPlansUtilizationDetail 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

-- | A single daily or monthly Savings Plans utilization rate, and details
-- for your account. A management account in an organization have access to
-- member accounts. You can use @GetDimensionValues@ to determine the
-- possible dimension values.
--
-- /See:/ 'newSavingsPlansUtilizationDetail' smart constructor.
data SavingsPlansUtilizationDetail = SavingsPlansUtilizationDetail'
  { -- | The total amortized commitment for a Savings Plans. Includes the sum of
    -- the upfront and recurring Savings Plans fees.
    SavingsPlansUtilizationDetail
-> 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.
    SavingsPlansUtilizationDetail -> Maybe SavingsPlansSavings
savings :: Prelude.Maybe SavingsPlansSavings,
    -- | The attribute that applies to a specific @Dimension@.
    SavingsPlansUtilizationDetail -> Maybe (HashMap Text Text)
attributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | A ratio of your effectiveness of using existing Savings Plans to apply
    -- to workloads that are Savings Plans eligible.
    SavingsPlansUtilizationDetail -> Maybe SavingsPlansUtilization
utilization :: Prelude.Maybe SavingsPlansUtilization,
    -- | The unique Amazon Resource Name (ARN) for a particular Savings Plan.
    SavingsPlansUtilizationDetail -> Maybe Text
savingsPlanArn :: Prelude.Maybe Prelude.Text
  }
  deriving (SavingsPlansUtilizationDetail
-> SavingsPlansUtilizationDetail -> Bool
(SavingsPlansUtilizationDetail
 -> SavingsPlansUtilizationDetail -> Bool)
-> (SavingsPlansUtilizationDetail
    -> SavingsPlansUtilizationDetail -> Bool)
-> Eq SavingsPlansUtilizationDetail
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SavingsPlansUtilizationDetail
-> SavingsPlansUtilizationDetail -> Bool
$c/= :: SavingsPlansUtilizationDetail
-> SavingsPlansUtilizationDetail -> Bool
== :: SavingsPlansUtilizationDetail
-> SavingsPlansUtilizationDetail -> Bool
$c== :: SavingsPlansUtilizationDetail
-> SavingsPlansUtilizationDetail -> Bool
Prelude.Eq, ReadPrec [SavingsPlansUtilizationDetail]
ReadPrec SavingsPlansUtilizationDetail
Int -> ReadS SavingsPlansUtilizationDetail
ReadS [SavingsPlansUtilizationDetail]
(Int -> ReadS SavingsPlansUtilizationDetail)
-> ReadS [SavingsPlansUtilizationDetail]
-> ReadPrec SavingsPlansUtilizationDetail
-> ReadPrec [SavingsPlansUtilizationDetail]
-> Read SavingsPlansUtilizationDetail
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SavingsPlansUtilizationDetail]
$creadListPrec :: ReadPrec [SavingsPlansUtilizationDetail]
readPrec :: ReadPrec SavingsPlansUtilizationDetail
$creadPrec :: ReadPrec SavingsPlansUtilizationDetail
readList :: ReadS [SavingsPlansUtilizationDetail]
$creadList :: ReadS [SavingsPlansUtilizationDetail]
readsPrec :: Int -> ReadS SavingsPlansUtilizationDetail
$creadsPrec :: Int -> ReadS SavingsPlansUtilizationDetail
Prelude.Read, Int -> SavingsPlansUtilizationDetail -> ShowS
[SavingsPlansUtilizationDetail] -> ShowS
SavingsPlansUtilizationDetail -> String
(Int -> SavingsPlansUtilizationDetail -> ShowS)
-> (SavingsPlansUtilizationDetail -> String)
-> ([SavingsPlansUtilizationDetail] -> ShowS)
-> Show SavingsPlansUtilizationDetail
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SavingsPlansUtilizationDetail] -> ShowS
$cshowList :: [SavingsPlansUtilizationDetail] -> ShowS
show :: SavingsPlansUtilizationDetail -> String
$cshow :: SavingsPlansUtilizationDetail -> String
showsPrec :: Int -> SavingsPlansUtilizationDetail -> ShowS
$cshowsPrec :: Int -> SavingsPlansUtilizationDetail -> ShowS
Prelude.Show, (forall x.
 SavingsPlansUtilizationDetail
 -> Rep SavingsPlansUtilizationDetail x)
-> (forall x.
    Rep SavingsPlansUtilizationDetail x
    -> SavingsPlansUtilizationDetail)
-> Generic SavingsPlansUtilizationDetail
forall x.
Rep SavingsPlansUtilizationDetail x
-> SavingsPlansUtilizationDetail
forall x.
SavingsPlansUtilizationDetail
-> Rep SavingsPlansUtilizationDetail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SavingsPlansUtilizationDetail x
-> SavingsPlansUtilizationDetail
$cfrom :: forall x.
SavingsPlansUtilizationDetail
-> Rep SavingsPlansUtilizationDetail x
Prelude.Generic)

-- |
-- Create a value of 'SavingsPlansUtilizationDetail' 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', 'savingsPlansUtilizationDetail_amortizedCommitment' - The total amortized commitment for a Savings Plans. Includes the sum of
-- the upfront and recurring Savings Plans fees.
--
-- 'savings', 'savingsPlansUtilizationDetail_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.
--
-- 'attributes', 'savingsPlansUtilizationDetail_attributes' - The attribute that applies to a specific @Dimension@.
--
-- 'utilization', 'savingsPlansUtilizationDetail_utilization' - A ratio of your effectiveness of using existing Savings Plans to apply
-- to workloads that are Savings Plans eligible.
--
-- 'savingsPlanArn', 'savingsPlansUtilizationDetail_savingsPlanArn' - The unique Amazon Resource Name (ARN) for a particular Savings Plan.
newSavingsPlansUtilizationDetail ::
  SavingsPlansUtilizationDetail
newSavingsPlansUtilizationDetail :: SavingsPlansUtilizationDetail
newSavingsPlansUtilizationDetail =
  SavingsPlansUtilizationDetail' :: Maybe SavingsPlansAmortizedCommitment
-> Maybe SavingsPlansSavings
-> Maybe (HashMap Text Text)
-> Maybe SavingsPlansUtilization
-> Maybe Text
-> SavingsPlansUtilizationDetail
SavingsPlansUtilizationDetail'
    { $sel:amortizedCommitment:SavingsPlansUtilizationDetail' :: Maybe SavingsPlansAmortizedCommitment
amortizedCommitment =
        Maybe SavingsPlansAmortizedCommitment
forall a. Maybe a
Prelude.Nothing,
      $sel:savings:SavingsPlansUtilizationDetail' :: Maybe SavingsPlansSavings
savings = Maybe SavingsPlansSavings
forall a. Maybe a
Prelude.Nothing,
      $sel:attributes:SavingsPlansUtilizationDetail' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:utilization:SavingsPlansUtilizationDetail' :: Maybe SavingsPlansUtilization
utilization = Maybe SavingsPlansUtilization
forall a. Maybe a
Prelude.Nothing,
      $sel:savingsPlanArn:SavingsPlansUtilizationDetail' :: Maybe Text
savingsPlanArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

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

-- | The attribute that applies to a specific @Dimension@.
savingsPlansUtilizationDetail_attributes :: Lens.Lens' SavingsPlansUtilizationDetail (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
savingsPlansUtilizationDetail_attributes :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> SavingsPlansUtilizationDetail -> f SavingsPlansUtilizationDetail
savingsPlansUtilizationDetail_attributes = (SavingsPlansUtilizationDetail -> Maybe (HashMap Text Text))
-> (SavingsPlansUtilizationDetail
    -> Maybe (HashMap Text Text) -> SavingsPlansUtilizationDetail)
-> Lens
     SavingsPlansUtilizationDetail
     SavingsPlansUtilizationDetail
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SavingsPlansUtilizationDetail' {Maybe (HashMap Text Text)
attributes :: Maybe (HashMap Text Text)
$sel:attributes:SavingsPlansUtilizationDetail' :: SavingsPlansUtilizationDetail -> Maybe (HashMap Text Text)
attributes} -> Maybe (HashMap Text Text)
attributes) (\s :: SavingsPlansUtilizationDetail
s@SavingsPlansUtilizationDetail' {} Maybe (HashMap Text Text)
a -> SavingsPlansUtilizationDetail
s {$sel:attributes:SavingsPlansUtilizationDetail' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
a} :: SavingsPlansUtilizationDetail) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> SavingsPlansUtilizationDetail
 -> f SavingsPlansUtilizationDetail)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> SavingsPlansUtilizationDetail
-> f SavingsPlansUtilizationDetail
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

-- | The unique Amazon Resource Name (ARN) for a particular Savings Plan.
savingsPlansUtilizationDetail_savingsPlanArn :: Lens.Lens' SavingsPlansUtilizationDetail (Prelude.Maybe Prelude.Text)
savingsPlansUtilizationDetail_savingsPlanArn :: (Maybe Text -> f (Maybe Text))
-> SavingsPlansUtilizationDetail -> f SavingsPlansUtilizationDetail
savingsPlansUtilizationDetail_savingsPlanArn = (SavingsPlansUtilizationDetail -> Maybe Text)
-> (SavingsPlansUtilizationDetail
    -> Maybe Text -> SavingsPlansUtilizationDetail)
-> Lens
     SavingsPlansUtilizationDetail
     SavingsPlansUtilizationDetail
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SavingsPlansUtilizationDetail' {Maybe Text
savingsPlanArn :: Maybe Text
$sel:savingsPlanArn:SavingsPlansUtilizationDetail' :: SavingsPlansUtilizationDetail -> Maybe Text
savingsPlanArn} -> Maybe Text
savingsPlanArn) (\s :: SavingsPlansUtilizationDetail
s@SavingsPlansUtilizationDetail' {} Maybe Text
a -> SavingsPlansUtilizationDetail
s {$sel:savingsPlanArn:SavingsPlansUtilizationDetail' :: Maybe Text
savingsPlanArn = Maybe Text
a} :: SavingsPlansUtilizationDetail)

instance Core.FromJSON SavingsPlansUtilizationDetail where
  parseJSON :: Value -> Parser SavingsPlansUtilizationDetail
parseJSON =
    String
-> (Object -> Parser SavingsPlansUtilizationDetail)
-> Value
-> Parser SavingsPlansUtilizationDetail
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SavingsPlansUtilizationDetail"
      ( \Object
x ->
          Maybe SavingsPlansAmortizedCommitment
-> Maybe SavingsPlansSavings
-> Maybe (HashMap Text Text)
-> Maybe SavingsPlansUtilization
-> Maybe Text
-> SavingsPlansUtilizationDetail
SavingsPlansUtilizationDetail'
            (Maybe SavingsPlansAmortizedCommitment
 -> Maybe SavingsPlansSavings
 -> Maybe (HashMap Text Text)
 -> Maybe SavingsPlansUtilization
 -> Maybe Text
 -> SavingsPlansUtilizationDetail)
-> Parser (Maybe SavingsPlansAmortizedCommitment)
-> Parser
     (Maybe SavingsPlansSavings
      -> Maybe (HashMap Text Text)
      -> Maybe SavingsPlansUtilization
      -> Maybe Text
      -> SavingsPlansUtilizationDetail)
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
   -> Maybe (HashMap Text Text)
   -> Maybe SavingsPlansUtilization
   -> Maybe Text
   -> SavingsPlansUtilizationDetail)
-> Parser (Maybe SavingsPlansSavings)
-> Parser
     (Maybe (HashMap Text Text)
      -> Maybe SavingsPlansUtilization
      -> Maybe Text
      -> SavingsPlansUtilizationDetail)
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
  (Maybe (HashMap Text Text)
   -> Maybe SavingsPlansUtilization
   -> Maybe Text
   -> SavingsPlansUtilizationDetail)
-> Parser (Maybe (HashMap Text Text))
-> Parser
     (Maybe SavingsPlansUtilization
      -> Maybe Text -> SavingsPlansUtilizationDetail)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Attributes" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe SavingsPlansUtilization
   -> Maybe Text -> SavingsPlansUtilizationDetail)
-> Parser (Maybe SavingsPlansUtilization)
-> Parser (Maybe Text -> SavingsPlansUtilizationDetail)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SavingsPlansUtilization)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Utilization")
            Parser (Maybe Text -> SavingsPlansUtilizationDetail)
-> Parser (Maybe Text) -> Parser SavingsPlansUtilizationDetail
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
"SavingsPlanArn")
      )

instance
  Prelude.Hashable
    SavingsPlansUtilizationDetail

instance Prelude.NFData SavingsPlansUtilizationDetail