{-# 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.EC2.Types.PriceScheduleSpecification
-- 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.EC2.Types.PriceScheduleSpecification where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import Amazonka.EC2.Types.CurrencyCodeValues
import qualified Amazonka.Prelude as Prelude

-- | Describes the price for a Reserved Instance.
--
-- /See:/ 'newPriceScheduleSpecification' smart constructor.
data PriceScheduleSpecification = PriceScheduleSpecification'
  { -- | The currency for transacting the Reserved Instance resale. At this time,
    -- the only supported currency is @USD@.
    PriceScheduleSpecification -> Maybe CurrencyCodeValues
currencyCode :: Prelude.Maybe CurrencyCodeValues,
    -- | The fixed price for the term.
    PriceScheduleSpecification -> Maybe Double
price :: Prelude.Maybe Prelude.Double,
    -- | The number of months remaining in the reservation. For example, 2 is the
    -- second to the last month before the capacity reservation expires.
    PriceScheduleSpecification -> Maybe Integer
term :: Prelude.Maybe Prelude.Integer
  }
  deriving (PriceScheduleSpecification -> PriceScheduleSpecification -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PriceScheduleSpecification -> PriceScheduleSpecification -> Bool
$c/= :: PriceScheduleSpecification -> PriceScheduleSpecification -> Bool
== :: PriceScheduleSpecification -> PriceScheduleSpecification -> Bool
$c== :: PriceScheduleSpecification -> PriceScheduleSpecification -> Bool
Prelude.Eq, ReadPrec [PriceScheduleSpecification]
ReadPrec PriceScheduleSpecification
Int -> ReadS PriceScheduleSpecification
ReadS [PriceScheduleSpecification]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PriceScheduleSpecification]
$creadListPrec :: ReadPrec [PriceScheduleSpecification]
readPrec :: ReadPrec PriceScheduleSpecification
$creadPrec :: ReadPrec PriceScheduleSpecification
readList :: ReadS [PriceScheduleSpecification]
$creadList :: ReadS [PriceScheduleSpecification]
readsPrec :: Int -> ReadS PriceScheduleSpecification
$creadsPrec :: Int -> ReadS PriceScheduleSpecification
Prelude.Read, Int -> PriceScheduleSpecification -> ShowS
[PriceScheduleSpecification] -> ShowS
PriceScheduleSpecification -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PriceScheduleSpecification] -> ShowS
$cshowList :: [PriceScheduleSpecification] -> ShowS
show :: PriceScheduleSpecification -> String
$cshow :: PriceScheduleSpecification -> String
showsPrec :: Int -> PriceScheduleSpecification -> ShowS
$cshowsPrec :: Int -> PriceScheduleSpecification -> ShowS
Prelude.Show, forall x.
Rep PriceScheduleSpecification x -> PriceScheduleSpecification
forall x.
PriceScheduleSpecification -> Rep PriceScheduleSpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PriceScheduleSpecification x -> PriceScheduleSpecification
$cfrom :: forall x.
PriceScheduleSpecification -> Rep PriceScheduleSpecification x
Prelude.Generic)

-- |
-- Create a value of 'PriceScheduleSpecification' 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:
--
-- 'currencyCode', 'priceScheduleSpecification_currencyCode' - The currency for transacting the Reserved Instance resale. At this time,
-- the only supported currency is @USD@.
--
-- 'price', 'priceScheduleSpecification_price' - The fixed price for the term.
--
-- 'term', 'priceScheduleSpecification_term' - The number of months remaining in the reservation. For example, 2 is the
-- second to the last month before the capacity reservation expires.
newPriceScheduleSpecification ::
  PriceScheduleSpecification
newPriceScheduleSpecification :: PriceScheduleSpecification
newPriceScheduleSpecification =
  PriceScheduleSpecification'
    { $sel:currencyCode:PriceScheduleSpecification' :: Maybe CurrencyCodeValues
currencyCode =
        forall a. Maybe a
Prelude.Nothing,
      $sel:price:PriceScheduleSpecification' :: Maybe Double
price = forall a. Maybe a
Prelude.Nothing,
      $sel:term:PriceScheduleSpecification' :: Maybe Integer
term = forall a. Maybe a
Prelude.Nothing
    }

-- | The currency for transacting the Reserved Instance resale. At this time,
-- the only supported currency is @USD@.
priceScheduleSpecification_currencyCode :: Lens.Lens' PriceScheduleSpecification (Prelude.Maybe CurrencyCodeValues)
priceScheduleSpecification_currencyCode :: Lens' PriceScheduleSpecification (Maybe CurrencyCodeValues)
priceScheduleSpecification_currencyCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PriceScheduleSpecification' {Maybe CurrencyCodeValues
currencyCode :: Maybe CurrencyCodeValues
$sel:currencyCode:PriceScheduleSpecification' :: PriceScheduleSpecification -> Maybe CurrencyCodeValues
currencyCode} -> Maybe CurrencyCodeValues
currencyCode) (\s :: PriceScheduleSpecification
s@PriceScheduleSpecification' {} Maybe CurrencyCodeValues
a -> PriceScheduleSpecification
s {$sel:currencyCode:PriceScheduleSpecification' :: Maybe CurrencyCodeValues
currencyCode = Maybe CurrencyCodeValues
a} :: PriceScheduleSpecification)

-- | The fixed price for the term.
priceScheduleSpecification_price :: Lens.Lens' PriceScheduleSpecification (Prelude.Maybe Prelude.Double)
priceScheduleSpecification_price :: Lens' PriceScheduleSpecification (Maybe Double)
priceScheduleSpecification_price = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PriceScheduleSpecification' {Maybe Double
price :: Maybe Double
$sel:price:PriceScheduleSpecification' :: PriceScheduleSpecification -> Maybe Double
price} -> Maybe Double
price) (\s :: PriceScheduleSpecification
s@PriceScheduleSpecification' {} Maybe Double
a -> PriceScheduleSpecification
s {$sel:price:PriceScheduleSpecification' :: Maybe Double
price = Maybe Double
a} :: PriceScheduleSpecification)

-- | The number of months remaining in the reservation. For example, 2 is the
-- second to the last month before the capacity reservation expires.
priceScheduleSpecification_term :: Lens.Lens' PriceScheduleSpecification (Prelude.Maybe Prelude.Integer)
priceScheduleSpecification_term :: Lens' PriceScheduleSpecification (Maybe Integer)
priceScheduleSpecification_term = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PriceScheduleSpecification' {Maybe Integer
term :: Maybe Integer
$sel:term:PriceScheduleSpecification' :: PriceScheduleSpecification -> Maybe Integer
term} -> Maybe Integer
term) (\s :: PriceScheduleSpecification
s@PriceScheduleSpecification' {} Maybe Integer
a -> PriceScheduleSpecification
s {$sel:term:PriceScheduleSpecification' :: Maybe Integer
term = Maybe Integer
a} :: PriceScheduleSpecification)

instance Prelude.Hashable PriceScheduleSpecification where
  hashWithSalt :: Int -> PriceScheduleSpecification -> Int
hashWithSalt Int
_salt PriceScheduleSpecification' {Maybe Double
Maybe Integer
Maybe CurrencyCodeValues
term :: Maybe Integer
price :: Maybe Double
currencyCode :: Maybe CurrencyCodeValues
$sel:term:PriceScheduleSpecification' :: PriceScheduleSpecification -> Maybe Integer
$sel:price:PriceScheduleSpecification' :: PriceScheduleSpecification -> Maybe Double
$sel:currencyCode:PriceScheduleSpecification' :: PriceScheduleSpecification -> Maybe CurrencyCodeValues
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CurrencyCodeValues
currencyCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
price
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
term

instance Prelude.NFData PriceScheduleSpecification where
  rnf :: PriceScheduleSpecification -> ()
rnf PriceScheduleSpecification' {Maybe Double
Maybe Integer
Maybe CurrencyCodeValues
term :: Maybe Integer
price :: Maybe Double
currencyCode :: Maybe CurrencyCodeValues
$sel:term:PriceScheduleSpecification' :: PriceScheduleSpecification -> Maybe Integer
$sel:price:PriceScheduleSpecification' :: PriceScheduleSpecification -> Maybe Double
$sel:currencyCode:PriceScheduleSpecification' :: PriceScheduleSpecification -> Maybe CurrencyCodeValues
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe CurrencyCodeValues
currencyCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
price
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
term

instance Data.ToQuery PriceScheduleSpecification where
  toQuery :: PriceScheduleSpecification -> QueryString
toQuery PriceScheduleSpecification' {Maybe Double
Maybe Integer
Maybe CurrencyCodeValues
term :: Maybe Integer
price :: Maybe Double
currencyCode :: Maybe CurrencyCodeValues
$sel:term:PriceScheduleSpecification' :: PriceScheduleSpecification -> Maybe Integer
$sel:price:PriceScheduleSpecification' :: PriceScheduleSpecification -> Maybe Double
$sel:currencyCode:PriceScheduleSpecification' :: PriceScheduleSpecification -> Maybe CurrencyCodeValues
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"CurrencyCode" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe CurrencyCodeValues
currencyCode,
        ByteString
"Price" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Double
price,
        ByteString
"Term" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Integer
term
      ]