{-# 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.ResilienceHub.Types.Cost
-- 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.ResilienceHub.Types.Cost 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
import Amazonka.ResilienceHub.Types.CostFrequency

-- | Defines a cost object.
--
-- /See:/ 'newCost' smart constructor.
data Cost = Cost'
  { -- | The cost amount.
    Cost -> Double
amount :: Prelude.Double,
    -- | The cost currency, for example @USD@.
    Cost -> Text
currency :: Prelude.Text,
    -- | The cost frequency.
    Cost -> CostFrequency
frequency :: CostFrequency
  }
  deriving (Cost -> Cost -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Cost -> Cost -> Bool
$c/= :: Cost -> Cost -> Bool
== :: Cost -> Cost -> Bool
$c== :: Cost -> Cost -> Bool
Prelude.Eq, ReadPrec [Cost]
ReadPrec Cost
Int -> ReadS Cost
ReadS [Cost]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Cost]
$creadListPrec :: ReadPrec [Cost]
readPrec :: ReadPrec Cost
$creadPrec :: ReadPrec Cost
readList :: ReadS [Cost]
$creadList :: ReadS [Cost]
readsPrec :: Int -> ReadS Cost
$creadsPrec :: Int -> ReadS Cost
Prelude.Read, Int -> Cost -> ShowS
[Cost] -> ShowS
Cost -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Cost] -> ShowS
$cshowList :: [Cost] -> ShowS
show :: Cost -> String
$cshow :: Cost -> String
showsPrec :: Int -> Cost -> ShowS
$cshowsPrec :: Int -> Cost -> ShowS
Prelude.Show, forall x. Rep Cost x -> Cost
forall x. Cost -> Rep Cost x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Cost x -> Cost
$cfrom :: forall x. Cost -> Rep Cost x
Prelude.Generic)

-- |
-- Create a value of 'Cost' 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:
--
-- 'amount', 'cost_amount' - The cost amount.
--
-- 'currency', 'cost_currency' - The cost currency, for example @USD@.
--
-- 'frequency', 'cost_frequency' - The cost frequency.
newCost ::
  -- | 'amount'
  Prelude.Double ->
  -- | 'currency'
  Prelude.Text ->
  -- | 'frequency'
  CostFrequency ->
  Cost
newCost :: Double -> Text -> CostFrequency -> Cost
newCost Double
pAmount_ Text
pCurrency_ CostFrequency
pFrequency_ =
  Cost'
    { $sel:amount:Cost' :: Double
amount = Double
pAmount_,
      $sel:currency:Cost' :: Text
currency = Text
pCurrency_,
      $sel:frequency:Cost' :: CostFrequency
frequency = CostFrequency
pFrequency_
    }

-- | The cost amount.
cost_amount :: Lens.Lens' Cost Prelude.Double
cost_amount :: Lens' Cost Double
cost_amount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Cost' {Double
amount :: Double
$sel:amount:Cost' :: Cost -> Double
amount} -> Double
amount) (\s :: Cost
s@Cost' {} Double
a -> Cost
s {$sel:amount:Cost' :: Double
amount = Double
a} :: Cost)

-- | The cost currency, for example @USD@.
cost_currency :: Lens.Lens' Cost Prelude.Text
cost_currency :: Lens' Cost Text
cost_currency = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Cost' {Text
currency :: Text
$sel:currency:Cost' :: Cost -> Text
currency} -> Text
currency) (\s :: Cost
s@Cost' {} Text
a -> Cost
s {$sel:currency:Cost' :: Text
currency = Text
a} :: Cost)

-- | The cost frequency.
cost_frequency :: Lens.Lens' Cost CostFrequency
cost_frequency :: Lens' Cost CostFrequency
cost_frequency = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Cost' {CostFrequency
frequency :: CostFrequency
$sel:frequency:Cost' :: Cost -> CostFrequency
frequency} -> CostFrequency
frequency) (\s :: Cost
s@Cost' {} CostFrequency
a -> Cost
s {$sel:frequency:Cost' :: CostFrequency
frequency = CostFrequency
a} :: Cost)

instance Data.FromJSON Cost where
  parseJSON :: Value -> Parser Cost
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Cost"
      ( \Object
x ->
          Double -> Text -> CostFrequency -> Cost
Cost'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"amount")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser 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 a
Data..: Key
"frequency")
      )

instance Prelude.Hashable Cost where
  hashWithSalt :: Int -> Cost -> Int
hashWithSalt Int
_salt Cost' {Double
Text
CostFrequency
frequency :: CostFrequency
currency :: Text
amount :: Double
$sel:frequency:Cost' :: Cost -> CostFrequency
$sel:currency:Cost' :: Cost -> Text
$sel:amount:Cost' :: Cost -> Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
amount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
currency
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` CostFrequency
frequency

instance Prelude.NFData Cost where
  rnf :: Cost -> ()
rnf Cost' {Double
Text
CostFrequency
frequency :: CostFrequency
currency :: Text
amount :: Double
$sel:frequency:Cost' :: Cost -> CostFrequency
$sel:currency:Cost' :: Cost -> Text
$sel:amount:Cost' :: Cost -> Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Double
amount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
currency
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf CostFrequency
frequency