{-# 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.ComputeOptimizer.Types.EstimatedMonthlySavings
-- 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.ComputeOptimizer.Types.EstimatedMonthlySavings where

import Amazonka.ComputeOptimizer.Types.Currency
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

-- | Describes the estimated monthly savings amount possible, based on
-- On-Demand instance pricing, by adopting Compute Optimizer
-- recommendations for a given resource.
--
-- For more information, see
-- <https://docs.aws.amazon.com/compute-optimizer/latest/ug/view-ec2-recommendations.html#ec2-savings-calculation Estimated monthly savings and savings opportunities>
-- in the /Compute Optimizer User Guide/.
--
-- /See:/ 'newEstimatedMonthlySavings' smart constructor.
data EstimatedMonthlySavings = EstimatedMonthlySavings'
  { -- | The currency of the estimated monthly savings.
    EstimatedMonthlySavings -> Maybe Currency
currency :: Prelude.Maybe Currency,
    -- | The value of the estimated monthly savings.
    EstimatedMonthlySavings -> Maybe Double
value :: Prelude.Maybe Prelude.Double
  }
  deriving (EstimatedMonthlySavings -> EstimatedMonthlySavings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EstimatedMonthlySavings -> EstimatedMonthlySavings -> Bool
$c/= :: EstimatedMonthlySavings -> EstimatedMonthlySavings -> Bool
== :: EstimatedMonthlySavings -> EstimatedMonthlySavings -> Bool
$c== :: EstimatedMonthlySavings -> EstimatedMonthlySavings -> Bool
Prelude.Eq, ReadPrec [EstimatedMonthlySavings]
ReadPrec EstimatedMonthlySavings
Int -> ReadS EstimatedMonthlySavings
ReadS [EstimatedMonthlySavings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EstimatedMonthlySavings]
$creadListPrec :: ReadPrec [EstimatedMonthlySavings]
readPrec :: ReadPrec EstimatedMonthlySavings
$creadPrec :: ReadPrec EstimatedMonthlySavings
readList :: ReadS [EstimatedMonthlySavings]
$creadList :: ReadS [EstimatedMonthlySavings]
readsPrec :: Int -> ReadS EstimatedMonthlySavings
$creadsPrec :: Int -> ReadS EstimatedMonthlySavings
Prelude.Read, Int -> EstimatedMonthlySavings -> ShowS
[EstimatedMonthlySavings] -> ShowS
EstimatedMonthlySavings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EstimatedMonthlySavings] -> ShowS
$cshowList :: [EstimatedMonthlySavings] -> ShowS
show :: EstimatedMonthlySavings -> String
$cshow :: EstimatedMonthlySavings -> String
showsPrec :: Int -> EstimatedMonthlySavings -> ShowS
$cshowsPrec :: Int -> EstimatedMonthlySavings -> ShowS
Prelude.Show, forall x. Rep EstimatedMonthlySavings x -> EstimatedMonthlySavings
forall x. EstimatedMonthlySavings -> Rep EstimatedMonthlySavings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EstimatedMonthlySavings x -> EstimatedMonthlySavings
$cfrom :: forall x. EstimatedMonthlySavings -> Rep EstimatedMonthlySavings x
Prelude.Generic)

-- |
-- Create a value of 'EstimatedMonthlySavings' 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:
--
-- 'currency', 'estimatedMonthlySavings_currency' - The currency of the estimated monthly savings.
--
-- 'value', 'estimatedMonthlySavings_value' - The value of the estimated monthly savings.
newEstimatedMonthlySavings ::
  EstimatedMonthlySavings
newEstimatedMonthlySavings :: EstimatedMonthlySavings
newEstimatedMonthlySavings =
  EstimatedMonthlySavings'
    { $sel:currency:EstimatedMonthlySavings' :: Maybe Currency
currency =
        forall a. Maybe a
Prelude.Nothing,
      $sel:value:EstimatedMonthlySavings' :: Maybe Double
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The currency of the estimated monthly savings.
estimatedMonthlySavings_currency :: Lens.Lens' EstimatedMonthlySavings (Prelude.Maybe Currency)
estimatedMonthlySavings_currency :: Lens' EstimatedMonthlySavings (Maybe Currency)
estimatedMonthlySavings_currency = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EstimatedMonthlySavings' {Maybe Currency
currency :: Maybe Currency
$sel:currency:EstimatedMonthlySavings' :: EstimatedMonthlySavings -> Maybe Currency
currency} -> Maybe Currency
currency) (\s :: EstimatedMonthlySavings
s@EstimatedMonthlySavings' {} Maybe Currency
a -> EstimatedMonthlySavings
s {$sel:currency:EstimatedMonthlySavings' :: Maybe Currency
currency = Maybe Currency
a} :: EstimatedMonthlySavings)

-- | The value of the estimated monthly savings.
estimatedMonthlySavings_value :: Lens.Lens' EstimatedMonthlySavings (Prelude.Maybe Prelude.Double)
estimatedMonthlySavings_value :: Lens' EstimatedMonthlySavings (Maybe Double)
estimatedMonthlySavings_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EstimatedMonthlySavings' {Maybe Double
value :: Maybe Double
$sel:value:EstimatedMonthlySavings' :: EstimatedMonthlySavings -> Maybe Double
value} -> Maybe Double
value) (\s :: EstimatedMonthlySavings
s@EstimatedMonthlySavings' {} Maybe Double
a -> EstimatedMonthlySavings
s {$sel:value:EstimatedMonthlySavings' :: Maybe Double
value = Maybe Double
a} :: EstimatedMonthlySavings)

instance Data.FromJSON EstimatedMonthlySavings where
  parseJSON :: Value -> Parser EstimatedMonthlySavings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EstimatedMonthlySavings"
      ( \Object
x ->
          Maybe Currency -> Maybe Double -> EstimatedMonthlySavings
EstimatedMonthlySavings'
            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
"currency")
            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
"value")
      )

instance Prelude.Hashable EstimatedMonthlySavings where
  hashWithSalt :: Int -> EstimatedMonthlySavings -> Int
hashWithSalt Int
_salt EstimatedMonthlySavings' {Maybe Double
Maybe Currency
value :: Maybe Double
currency :: Maybe Currency
$sel:value:EstimatedMonthlySavings' :: EstimatedMonthlySavings -> Maybe Double
$sel:currency:EstimatedMonthlySavings' :: EstimatedMonthlySavings -> Maybe Currency
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Currency
currency
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
value

instance Prelude.NFData EstimatedMonthlySavings where
  rnf :: EstimatedMonthlySavings -> ()
rnf EstimatedMonthlySavings' {Maybe Double
Maybe Currency
value :: Maybe Double
currency :: Maybe Currency
$sel:value:EstimatedMonthlySavings' :: EstimatedMonthlySavings -> Maybe Double
$sel:currency:EstimatedMonthlySavings' :: EstimatedMonthlySavings -> Maybe Currency
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Currency
currency
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
value