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

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

-- | The amount of savings that you\'re accumulating, against the public
-- On-Demand rate of the usage accrued in an account.
--
-- /See:/ 'newSavingsPlansSavings' smart constructor.
data SavingsPlansSavings = SavingsPlansSavings'
  { -- | The savings amount that you\'re accumulating for the usage that\'s
    -- covered by a Savings Plans, when compared to the On-Demand equivalent of
    -- the same usage.
    SavingsPlansSavings -> Maybe Text
netSavings :: Prelude.Maybe Prelude.Text,
    -- | How much the amount that the usage would have cost if it was accrued at
    -- the On-Demand rate.
    SavingsPlansSavings -> Maybe Text
onDemandCostEquivalent :: Prelude.Maybe Prelude.Text
  }
  deriving (SavingsPlansSavings -> SavingsPlansSavings -> Bool
(SavingsPlansSavings -> SavingsPlansSavings -> Bool)
-> (SavingsPlansSavings -> SavingsPlansSavings -> Bool)
-> Eq SavingsPlansSavings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SavingsPlansSavings -> SavingsPlansSavings -> Bool
$c/= :: SavingsPlansSavings -> SavingsPlansSavings -> Bool
== :: SavingsPlansSavings -> SavingsPlansSavings -> Bool
$c== :: SavingsPlansSavings -> SavingsPlansSavings -> Bool
Prelude.Eq, ReadPrec [SavingsPlansSavings]
ReadPrec SavingsPlansSavings
Int -> ReadS SavingsPlansSavings
ReadS [SavingsPlansSavings]
(Int -> ReadS SavingsPlansSavings)
-> ReadS [SavingsPlansSavings]
-> ReadPrec SavingsPlansSavings
-> ReadPrec [SavingsPlansSavings]
-> Read SavingsPlansSavings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SavingsPlansSavings]
$creadListPrec :: ReadPrec [SavingsPlansSavings]
readPrec :: ReadPrec SavingsPlansSavings
$creadPrec :: ReadPrec SavingsPlansSavings
readList :: ReadS [SavingsPlansSavings]
$creadList :: ReadS [SavingsPlansSavings]
readsPrec :: Int -> ReadS SavingsPlansSavings
$creadsPrec :: Int -> ReadS SavingsPlansSavings
Prelude.Read, Int -> SavingsPlansSavings -> ShowS
[SavingsPlansSavings] -> ShowS
SavingsPlansSavings -> String
(Int -> SavingsPlansSavings -> ShowS)
-> (SavingsPlansSavings -> String)
-> ([SavingsPlansSavings] -> ShowS)
-> Show SavingsPlansSavings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SavingsPlansSavings] -> ShowS
$cshowList :: [SavingsPlansSavings] -> ShowS
show :: SavingsPlansSavings -> String
$cshow :: SavingsPlansSavings -> String
showsPrec :: Int -> SavingsPlansSavings -> ShowS
$cshowsPrec :: Int -> SavingsPlansSavings -> ShowS
Prelude.Show, (forall x. SavingsPlansSavings -> Rep SavingsPlansSavings x)
-> (forall x. Rep SavingsPlansSavings x -> SavingsPlansSavings)
-> Generic SavingsPlansSavings
forall x. Rep SavingsPlansSavings x -> SavingsPlansSavings
forall x. SavingsPlansSavings -> Rep SavingsPlansSavings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SavingsPlansSavings x -> SavingsPlansSavings
$cfrom :: forall x. SavingsPlansSavings -> Rep SavingsPlansSavings x
Prelude.Generic)

-- |
-- Create a value of 'SavingsPlansSavings' 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:
--
-- 'netSavings', 'savingsPlansSavings_netSavings' - The savings amount that you\'re accumulating for the usage that\'s
-- covered by a Savings Plans, when compared to the On-Demand equivalent of
-- the same usage.
--
-- 'onDemandCostEquivalent', 'savingsPlansSavings_onDemandCostEquivalent' - How much the amount that the usage would have cost if it was accrued at
-- the On-Demand rate.
newSavingsPlansSavings ::
  SavingsPlansSavings
newSavingsPlansSavings :: SavingsPlansSavings
newSavingsPlansSavings =
  SavingsPlansSavings' :: Maybe Text -> Maybe Text -> SavingsPlansSavings
SavingsPlansSavings'
    { $sel:netSavings:SavingsPlansSavings' :: Maybe Text
netSavings = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:onDemandCostEquivalent:SavingsPlansSavings' :: Maybe Text
onDemandCostEquivalent = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The savings amount that you\'re accumulating for the usage that\'s
-- covered by a Savings Plans, when compared to the On-Demand equivalent of
-- the same usage.
savingsPlansSavings_netSavings :: Lens.Lens' SavingsPlansSavings (Prelude.Maybe Prelude.Text)
savingsPlansSavings_netSavings :: (Maybe Text -> f (Maybe Text))
-> SavingsPlansSavings -> f SavingsPlansSavings
savingsPlansSavings_netSavings = (SavingsPlansSavings -> Maybe Text)
-> (SavingsPlansSavings -> Maybe Text -> SavingsPlansSavings)
-> Lens
     SavingsPlansSavings SavingsPlansSavings (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SavingsPlansSavings' {Maybe Text
netSavings :: Maybe Text
$sel:netSavings:SavingsPlansSavings' :: SavingsPlansSavings -> Maybe Text
netSavings} -> Maybe Text
netSavings) (\s :: SavingsPlansSavings
s@SavingsPlansSavings' {} Maybe Text
a -> SavingsPlansSavings
s {$sel:netSavings:SavingsPlansSavings' :: Maybe Text
netSavings = Maybe Text
a} :: SavingsPlansSavings)

-- | How much the amount that the usage would have cost if it was accrued at
-- the On-Demand rate.
savingsPlansSavings_onDemandCostEquivalent :: Lens.Lens' SavingsPlansSavings (Prelude.Maybe Prelude.Text)
savingsPlansSavings_onDemandCostEquivalent :: (Maybe Text -> f (Maybe Text))
-> SavingsPlansSavings -> f SavingsPlansSavings
savingsPlansSavings_onDemandCostEquivalent = (SavingsPlansSavings -> Maybe Text)
-> (SavingsPlansSavings -> Maybe Text -> SavingsPlansSavings)
-> Lens
     SavingsPlansSavings SavingsPlansSavings (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SavingsPlansSavings' {Maybe Text
onDemandCostEquivalent :: Maybe Text
$sel:onDemandCostEquivalent:SavingsPlansSavings' :: SavingsPlansSavings -> Maybe Text
onDemandCostEquivalent} -> Maybe Text
onDemandCostEquivalent) (\s :: SavingsPlansSavings
s@SavingsPlansSavings' {} Maybe Text
a -> SavingsPlansSavings
s {$sel:onDemandCostEquivalent:SavingsPlansSavings' :: Maybe Text
onDemandCostEquivalent = Maybe Text
a} :: SavingsPlansSavings)

instance Core.FromJSON SavingsPlansSavings where
  parseJSON :: Value -> Parser SavingsPlansSavings
parseJSON =
    String
-> (Object -> Parser SavingsPlansSavings)
-> Value
-> Parser SavingsPlansSavings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SavingsPlansSavings"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> SavingsPlansSavings
SavingsPlansSavings'
            (Maybe Text -> Maybe Text -> SavingsPlansSavings)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> SavingsPlansSavings)
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
"NetSavings")
            Parser (Maybe Text -> SavingsPlansSavings)
-> Parser (Maybe Text) -> Parser SavingsPlansSavings
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
"OnDemandCostEquivalent")
      )

instance Prelude.Hashable SavingsPlansSavings

instance Prelude.NFData SavingsPlansSavings