{-# 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.SavingsPlans.Types.SavingsPlanRate
-- 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.SavingsPlans.Types.SavingsPlanRate 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.SavingsPlans.Types.CurrencyCode
import Amazonka.SavingsPlans.Types.SavingsPlanProductType
import Amazonka.SavingsPlans.Types.SavingsPlanRateProperty
import Amazonka.SavingsPlans.Types.SavingsPlanRateServiceCode
import Amazonka.SavingsPlans.Types.SavingsPlanRateUnit

-- | Information about a Savings Plan rate.
--
-- /See:/ 'newSavingsPlanRate' smart constructor.
data SavingsPlanRate = SavingsPlanRate'
  { -- | The currency.
    SavingsPlanRate -> Maybe CurrencyCode
currency :: Prelude.Maybe CurrencyCode,
    -- | The specific AWS operation for the line item in the billing report.
    SavingsPlanRate -> Maybe Text
operation :: Prelude.Maybe Prelude.Text,
    -- | The product type.
    SavingsPlanRate -> Maybe SavingsPlanProductType
productType :: Prelude.Maybe SavingsPlanProductType,
    -- | The properties.
    SavingsPlanRate -> Maybe [SavingsPlanRateProperty]
properties :: Prelude.Maybe [SavingsPlanRateProperty],
    -- | The rate.
    SavingsPlanRate -> Maybe Text
rate :: Prelude.Maybe Prelude.Text,
    -- | The service.
    SavingsPlanRate -> Maybe SavingsPlanRateServiceCode
serviceCode :: Prelude.Maybe SavingsPlanRateServiceCode,
    -- | The unit.
    SavingsPlanRate -> Maybe SavingsPlanRateUnit
unit :: Prelude.Maybe SavingsPlanRateUnit,
    -- | The usage details of the line item in the billing report.
    SavingsPlanRate -> Maybe Text
usageType :: Prelude.Maybe Prelude.Text
  }
  deriving (SavingsPlanRate -> SavingsPlanRate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SavingsPlanRate -> SavingsPlanRate -> Bool
$c/= :: SavingsPlanRate -> SavingsPlanRate -> Bool
== :: SavingsPlanRate -> SavingsPlanRate -> Bool
$c== :: SavingsPlanRate -> SavingsPlanRate -> Bool
Prelude.Eq, ReadPrec [SavingsPlanRate]
ReadPrec SavingsPlanRate
Int -> ReadS SavingsPlanRate
ReadS [SavingsPlanRate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SavingsPlanRate]
$creadListPrec :: ReadPrec [SavingsPlanRate]
readPrec :: ReadPrec SavingsPlanRate
$creadPrec :: ReadPrec SavingsPlanRate
readList :: ReadS [SavingsPlanRate]
$creadList :: ReadS [SavingsPlanRate]
readsPrec :: Int -> ReadS SavingsPlanRate
$creadsPrec :: Int -> ReadS SavingsPlanRate
Prelude.Read, Int -> SavingsPlanRate -> ShowS
[SavingsPlanRate] -> ShowS
SavingsPlanRate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SavingsPlanRate] -> ShowS
$cshowList :: [SavingsPlanRate] -> ShowS
show :: SavingsPlanRate -> String
$cshow :: SavingsPlanRate -> String
showsPrec :: Int -> SavingsPlanRate -> ShowS
$cshowsPrec :: Int -> SavingsPlanRate -> ShowS
Prelude.Show, forall x. Rep SavingsPlanRate x -> SavingsPlanRate
forall x. SavingsPlanRate -> Rep SavingsPlanRate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SavingsPlanRate x -> SavingsPlanRate
$cfrom :: forall x. SavingsPlanRate -> Rep SavingsPlanRate x
Prelude.Generic)

-- |
-- Create a value of 'SavingsPlanRate' 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', 'savingsPlanRate_currency' - The currency.
--
-- 'operation', 'savingsPlanRate_operation' - The specific AWS operation for the line item in the billing report.
--
-- 'productType', 'savingsPlanRate_productType' - The product type.
--
-- 'properties', 'savingsPlanRate_properties' - The properties.
--
-- 'rate', 'savingsPlanRate_rate' - The rate.
--
-- 'serviceCode', 'savingsPlanRate_serviceCode' - The service.
--
-- 'unit', 'savingsPlanRate_unit' - The unit.
--
-- 'usageType', 'savingsPlanRate_usageType' - The usage details of the line item in the billing report.
newSavingsPlanRate ::
  SavingsPlanRate
newSavingsPlanRate :: SavingsPlanRate
newSavingsPlanRate =
  SavingsPlanRate'
    { $sel:currency:SavingsPlanRate' :: Maybe CurrencyCode
currency = forall a. Maybe a
Prelude.Nothing,
      $sel:operation:SavingsPlanRate' :: Maybe Text
operation = forall a. Maybe a
Prelude.Nothing,
      $sel:productType:SavingsPlanRate' :: Maybe SavingsPlanProductType
productType = forall a. Maybe a
Prelude.Nothing,
      $sel:properties:SavingsPlanRate' :: Maybe [SavingsPlanRateProperty]
properties = forall a. Maybe a
Prelude.Nothing,
      $sel:rate:SavingsPlanRate' :: Maybe Text
rate = forall a. Maybe a
Prelude.Nothing,
      $sel:serviceCode:SavingsPlanRate' :: Maybe SavingsPlanRateServiceCode
serviceCode = forall a. Maybe a
Prelude.Nothing,
      $sel:unit:SavingsPlanRate' :: Maybe SavingsPlanRateUnit
unit = forall a. Maybe a
Prelude.Nothing,
      $sel:usageType:SavingsPlanRate' :: Maybe Text
usageType = forall a. Maybe a
Prelude.Nothing
    }

-- | The currency.
savingsPlanRate_currency :: Lens.Lens' SavingsPlanRate (Prelude.Maybe CurrencyCode)
savingsPlanRate_currency :: Lens' SavingsPlanRate (Maybe CurrencyCode)
savingsPlanRate_currency = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SavingsPlanRate' {Maybe CurrencyCode
currency :: Maybe CurrencyCode
$sel:currency:SavingsPlanRate' :: SavingsPlanRate -> Maybe CurrencyCode
currency} -> Maybe CurrencyCode
currency) (\s :: SavingsPlanRate
s@SavingsPlanRate' {} Maybe CurrencyCode
a -> SavingsPlanRate
s {$sel:currency:SavingsPlanRate' :: Maybe CurrencyCode
currency = Maybe CurrencyCode
a} :: SavingsPlanRate)

-- | The specific AWS operation for the line item in the billing report.
savingsPlanRate_operation :: Lens.Lens' SavingsPlanRate (Prelude.Maybe Prelude.Text)
savingsPlanRate_operation :: Lens' SavingsPlanRate (Maybe Text)
savingsPlanRate_operation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SavingsPlanRate' {Maybe Text
operation :: Maybe Text
$sel:operation:SavingsPlanRate' :: SavingsPlanRate -> Maybe Text
operation} -> Maybe Text
operation) (\s :: SavingsPlanRate
s@SavingsPlanRate' {} Maybe Text
a -> SavingsPlanRate
s {$sel:operation:SavingsPlanRate' :: Maybe Text
operation = Maybe Text
a} :: SavingsPlanRate)

-- | The product type.
savingsPlanRate_productType :: Lens.Lens' SavingsPlanRate (Prelude.Maybe SavingsPlanProductType)
savingsPlanRate_productType :: Lens' SavingsPlanRate (Maybe SavingsPlanProductType)
savingsPlanRate_productType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SavingsPlanRate' {Maybe SavingsPlanProductType
productType :: Maybe SavingsPlanProductType
$sel:productType:SavingsPlanRate' :: SavingsPlanRate -> Maybe SavingsPlanProductType
productType} -> Maybe SavingsPlanProductType
productType) (\s :: SavingsPlanRate
s@SavingsPlanRate' {} Maybe SavingsPlanProductType
a -> SavingsPlanRate
s {$sel:productType:SavingsPlanRate' :: Maybe SavingsPlanProductType
productType = Maybe SavingsPlanProductType
a} :: SavingsPlanRate)

-- | The properties.
savingsPlanRate_properties :: Lens.Lens' SavingsPlanRate (Prelude.Maybe [SavingsPlanRateProperty])
savingsPlanRate_properties :: Lens' SavingsPlanRate (Maybe [SavingsPlanRateProperty])
savingsPlanRate_properties = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SavingsPlanRate' {Maybe [SavingsPlanRateProperty]
properties :: Maybe [SavingsPlanRateProperty]
$sel:properties:SavingsPlanRate' :: SavingsPlanRate -> Maybe [SavingsPlanRateProperty]
properties} -> Maybe [SavingsPlanRateProperty]
properties) (\s :: SavingsPlanRate
s@SavingsPlanRate' {} Maybe [SavingsPlanRateProperty]
a -> SavingsPlanRate
s {$sel:properties:SavingsPlanRate' :: Maybe [SavingsPlanRateProperty]
properties = Maybe [SavingsPlanRateProperty]
a} :: SavingsPlanRate) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The rate.
savingsPlanRate_rate :: Lens.Lens' SavingsPlanRate (Prelude.Maybe Prelude.Text)
savingsPlanRate_rate :: Lens' SavingsPlanRate (Maybe Text)
savingsPlanRate_rate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SavingsPlanRate' {Maybe Text
rate :: Maybe Text
$sel:rate:SavingsPlanRate' :: SavingsPlanRate -> Maybe Text
rate} -> Maybe Text
rate) (\s :: SavingsPlanRate
s@SavingsPlanRate' {} Maybe Text
a -> SavingsPlanRate
s {$sel:rate:SavingsPlanRate' :: Maybe Text
rate = Maybe Text
a} :: SavingsPlanRate)

-- | The service.
savingsPlanRate_serviceCode :: Lens.Lens' SavingsPlanRate (Prelude.Maybe SavingsPlanRateServiceCode)
savingsPlanRate_serviceCode :: Lens' SavingsPlanRate (Maybe SavingsPlanRateServiceCode)
savingsPlanRate_serviceCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SavingsPlanRate' {Maybe SavingsPlanRateServiceCode
serviceCode :: Maybe SavingsPlanRateServiceCode
$sel:serviceCode:SavingsPlanRate' :: SavingsPlanRate -> Maybe SavingsPlanRateServiceCode
serviceCode} -> Maybe SavingsPlanRateServiceCode
serviceCode) (\s :: SavingsPlanRate
s@SavingsPlanRate' {} Maybe SavingsPlanRateServiceCode
a -> SavingsPlanRate
s {$sel:serviceCode:SavingsPlanRate' :: Maybe SavingsPlanRateServiceCode
serviceCode = Maybe SavingsPlanRateServiceCode
a} :: SavingsPlanRate)

-- | The unit.
savingsPlanRate_unit :: Lens.Lens' SavingsPlanRate (Prelude.Maybe SavingsPlanRateUnit)
savingsPlanRate_unit :: Lens' SavingsPlanRate (Maybe SavingsPlanRateUnit)
savingsPlanRate_unit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SavingsPlanRate' {Maybe SavingsPlanRateUnit
unit :: Maybe SavingsPlanRateUnit
$sel:unit:SavingsPlanRate' :: SavingsPlanRate -> Maybe SavingsPlanRateUnit
unit} -> Maybe SavingsPlanRateUnit
unit) (\s :: SavingsPlanRate
s@SavingsPlanRate' {} Maybe SavingsPlanRateUnit
a -> SavingsPlanRate
s {$sel:unit:SavingsPlanRate' :: Maybe SavingsPlanRateUnit
unit = Maybe SavingsPlanRateUnit
a} :: SavingsPlanRate)

-- | The usage details of the line item in the billing report.
savingsPlanRate_usageType :: Lens.Lens' SavingsPlanRate (Prelude.Maybe Prelude.Text)
savingsPlanRate_usageType :: Lens' SavingsPlanRate (Maybe Text)
savingsPlanRate_usageType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SavingsPlanRate' {Maybe Text
usageType :: Maybe Text
$sel:usageType:SavingsPlanRate' :: SavingsPlanRate -> Maybe Text
usageType} -> Maybe Text
usageType) (\s :: SavingsPlanRate
s@SavingsPlanRate' {} Maybe Text
a -> SavingsPlanRate
s {$sel:usageType:SavingsPlanRate' :: Maybe Text
usageType = Maybe Text
a} :: SavingsPlanRate)

instance Data.FromJSON SavingsPlanRate where
  parseJSON :: Value -> Parser SavingsPlanRate
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SavingsPlanRate"
      ( \Object
x ->
          Maybe CurrencyCode
-> Maybe Text
-> Maybe SavingsPlanProductType
-> Maybe [SavingsPlanRateProperty]
-> Maybe Text
-> Maybe SavingsPlanRateServiceCode
-> Maybe SavingsPlanRateUnit
-> Maybe Text
-> SavingsPlanRate
SavingsPlanRate'
            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
"operation")
            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
"productType")
            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
"properties" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"rate")
            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
"serviceCode")
            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
"unit")
            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
"usageType")
      )

instance Prelude.Hashable SavingsPlanRate where
  hashWithSalt :: Int -> SavingsPlanRate -> Int
hashWithSalt Int
_salt SavingsPlanRate' {Maybe [SavingsPlanRateProperty]
Maybe Text
Maybe CurrencyCode
Maybe SavingsPlanProductType
Maybe SavingsPlanRateServiceCode
Maybe SavingsPlanRateUnit
usageType :: Maybe Text
unit :: Maybe SavingsPlanRateUnit
serviceCode :: Maybe SavingsPlanRateServiceCode
rate :: Maybe Text
properties :: Maybe [SavingsPlanRateProperty]
productType :: Maybe SavingsPlanProductType
operation :: Maybe Text
currency :: Maybe CurrencyCode
$sel:usageType:SavingsPlanRate' :: SavingsPlanRate -> Maybe Text
$sel:unit:SavingsPlanRate' :: SavingsPlanRate -> Maybe SavingsPlanRateUnit
$sel:serviceCode:SavingsPlanRate' :: SavingsPlanRate -> Maybe SavingsPlanRateServiceCode
$sel:rate:SavingsPlanRate' :: SavingsPlanRate -> Maybe Text
$sel:properties:SavingsPlanRate' :: SavingsPlanRate -> Maybe [SavingsPlanRateProperty]
$sel:productType:SavingsPlanRate' :: SavingsPlanRate -> Maybe SavingsPlanProductType
$sel:operation:SavingsPlanRate' :: SavingsPlanRate -> Maybe Text
$sel:currency:SavingsPlanRate' :: SavingsPlanRate -> Maybe CurrencyCode
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CurrencyCode
currency
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
operation
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SavingsPlanProductType
productType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [SavingsPlanRateProperty]
properties
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
rate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SavingsPlanRateServiceCode
serviceCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SavingsPlanRateUnit
unit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
usageType

instance Prelude.NFData SavingsPlanRate where
  rnf :: SavingsPlanRate -> ()
rnf SavingsPlanRate' {Maybe [SavingsPlanRateProperty]
Maybe Text
Maybe CurrencyCode
Maybe SavingsPlanProductType
Maybe SavingsPlanRateServiceCode
Maybe SavingsPlanRateUnit
usageType :: Maybe Text
unit :: Maybe SavingsPlanRateUnit
serviceCode :: Maybe SavingsPlanRateServiceCode
rate :: Maybe Text
properties :: Maybe [SavingsPlanRateProperty]
productType :: Maybe SavingsPlanProductType
operation :: Maybe Text
currency :: Maybe CurrencyCode
$sel:usageType:SavingsPlanRate' :: SavingsPlanRate -> Maybe Text
$sel:unit:SavingsPlanRate' :: SavingsPlanRate -> Maybe SavingsPlanRateUnit
$sel:serviceCode:SavingsPlanRate' :: SavingsPlanRate -> Maybe SavingsPlanRateServiceCode
$sel:rate:SavingsPlanRate' :: SavingsPlanRate -> Maybe Text
$sel:properties:SavingsPlanRate' :: SavingsPlanRate -> Maybe [SavingsPlanRateProperty]
$sel:productType:SavingsPlanRate' :: SavingsPlanRate -> Maybe SavingsPlanProductType
$sel:operation:SavingsPlanRate' :: SavingsPlanRate -> Maybe Text
$sel:currency:SavingsPlanRate' :: SavingsPlanRate -> Maybe CurrencyCode
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe CurrencyCode
currency
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
operation
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SavingsPlanProductType
productType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [SavingsPlanRateProperty]
properties
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
rate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SavingsPlanRateServiceCode
serviceCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SavingsPlanRateUnit
unit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
usageType