{-# 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-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.SavingsPlansSavings 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 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
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]
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
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. 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'
    { $sel:netSavings:SavingsPlansSavings' :: Maybe Text
netSavings = forall a. Maybe a
Prelude.Nothing,
      $sel:onDemandCostEquivalent:SavingsPlansSavings' :: Maybe Text
onDemandCostEquivalent = 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 :: Lens' SavingsPlansSavings (Maybe Text)
savingsPlansSavings_netSavings = 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 :: Lens' SavingsPlansSavings (Maybe Text)
savingsPlansSavings_onDemandCostEquivalent = 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 Data.FromJSON SavingsPlansSavings where
  parseJSON :: Value -> Parser SavingsPlansSavings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SavingsPlansSavings"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> SavingsPlansSavings
SavingsPlansSavings'
            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
"NetSavings")
            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
"OnDemandCostEquivalent")
      )

instance Prelude.Hashable SavingsPlansSavings where
  hashWithSalt :: Int -> SavingsPlansSavings -> Int
hashWithSalt Int
_salt SavingsPlansSavings' {Maybe Text
onDemandCostEquivalent :: Maybe Text
netSavings :: Maybe Text
$sel:onDemandCostEquivalent:SavingsPlansSavings' :: SavingsPlansSavings -> Maybe Text
$sel:netSavings:SavingsPlansSavings' :: SavingsPlansSavings -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
netSavings
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
onDemandCostEquivalent

instance Prelude.NFData SavingsPlansSavings where
  rnf :: SavingsPlansSavings -> ()
rnf SavingsPlansSavings' {Maybe Text
onDemandCostEquivalent :: Maybe Text
netSavings :: Maybe Text
$sel:onDemandCostEquivalent:SavingsPlansSavings' :: SavingsPlansSavings -> Maybe Text
$sel:netSavings:SavingsPlansSavings' :: SavingsPlansSavings -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
netSavings
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
onDemandCostEquivalent