{-# 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.PriceSchedule
-- 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.PriceSchedule 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:/ 'newPriceSchedule' smart constructor.
data PriceSchedule = PriceSchedule'
  { -- | The current price schedule, as determined by the term remaining for the
    -- Reserved Instance in the listing.
    --
    -- A specific price schedule is always in effect, but only one price
    -- schedule can be active at any time. Take, for example, a Reserved
    -- Instance listing that has five months remaining in its term. When you
    -- specify price schedules for five months and two months, this means that
    -- schedule 1, covering the first three months of the remaining term, will
    -- be active during months 5, 4, and 3. Then schedule 2, covering the last
    -- two months of the term, will be active for months 2 and 1.
    PriceSchedule -> Maybe Bool
active :: Prelude.Maybe Prelude.Bool,
    -- | The currency for transacting the Reserved Instance resale. At this time,
    -- the only supported currency is @USD@.
    PriceSchedule -> Maybe CurrencyCodeValues
currencyCode :: Prelude.Maybe CurrencyCodeValues,
    -- | The fixed price for the term.
    PriceSchedule -> 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.
    PriceSchedule -> Maybe Integer
term :: Prelude.Maybe Prelude.Integer
  }
  deriving (PriceSchedule -> PriceSchedule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PriceSchedule -> PriceSchedule -> Bool
$c/= :: PriceSchedule -> PriceSchedule -> Bool
== :: PriceSchedule -> PriceSchedule -> Bool
$c== :: PriceSchedule -> PriceSchedule -> Bool
Prelude.Eq, ReadPrec [PriceSchedule]
ReadPrec PriceSchedule
Int -> ReadS PriceSchedule
ReadS [PriceSchedule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PriceSchedule]
$creadListPrec :: ReadPrec [PriceSchedule]
readPrec :: ReadPrec PriceSchedule
$creadPrec :: ReadPrec PriceSchedule
readList :: ReadS [PriceSchedule]
$creadList :: ReadS [PriceSchedule]
readsPrec :: Int -> ReadS PriceSchedule
$creadsPrec :: Int -> ReadS PriceSchedule
Prelude.Read, Int -> PriceSchedule -> ShowS
[PriceSchedule] -> ShowS
PriceSchedule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PriceSchedule] -> ShowS
$cshowList :: [PriceSchedule] -> ShowS
show :: PriceSchedule -> String
$cshow :: PriceSchedule -> String
showsPrec :: Int -> PriceSchedule -> ShowS
$cshowsPrec :: Int -> PriceSchedule -> ShowS
Prelude.Show, forall x. Rep PriceSchedule x -> PriceSchedule
forall x. PriceSchedule -> Rep PriceSchedule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PriceSchedule x -> PriceSchedule
$cfrom :: forall x. PriceSchedule -> Rep PriceSchedule x
Prelude.Generic)

-- |
-- Create a value of 'PriceSchedule' 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:
--
-- 'active', 'priceSchedule_active' - The current price schedule, as determined by the term remaining for the
-- Reserved Instance in the listing.
--
-- A specific price schedule is always in effect, but only one price
-- schedule can be active at any time. Take, for example, a Reserved
-- Instance listing that has five months remaining in its term. When you
-- specify price schedules for five months and two months, this means that
-- schedule 1, covering the first three months of the remaining term, will
-- be active during months 5, 4, and 3. Then schedule 2, covering the last
-- two months of the term, will be active for months 2 and 1.
--
-- 'currencyCode', 'priceSchedule_currencyCode' - The currency for transacting the Reserved Instance resale. At this time,
-- the only supported currency is @USD@.
--
-- 'price', 'priceSchedule_price' - The fixed price for the term.
--
-- 'term', 'priceSchedule_term' - The number of months remaining in the reservation. For example, 2 is the
-- second to the last month before the capacity reservation expires.
newPriceSchedule ::
  PriceSchedule
newPriceSchedule :: PriceSchedule
newPriceSchedule =
  PriceSchedule'
    { $sel:active:PriceSchedule' :: Maybe Bool
active = forall a. Maybe a
Prelude.Nothing,
      $sel:currencyCode:PriceSchedule' :: Maybe CurrencyCodeValues
currencyCode = forall a. Maybe a
Prelude.Nothing,
      $sel:price:PriceSchedule' :: Maybe Double
price = forall a. Maybe a
Prelude.Nothing,
      $sel:term:PriceSchedule' :: Maybe Integer
term = forall a. Maybe a
Prelude.Nothing
    }

-- | The current price schedule, as determined by the term remaining for the
-- Reserved Instance in the listing.
--
-- A specific price schedule is always in effect, but only one price
-- schedule can be active at any time. Take, for example, a Reserved
-- Instance listing that has five months remaining in its term. When you
-- specify price schedules for five months and two months, this means that
-- schedule 1, covering the first three months of the remaining term, will
-- be active during months 5, 4, and 3. Then schedule 2, covering the last
-- two months of the term, will be active for months 2 and 1.
priceSchedule_active :: Lens.Lens' PriceSchedule (Prelude.Maybe Prelude.Bool)
priceSchedule_active :: Lens' PriceSchedule (Maybe Bool)
priceSchedule_active = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PriceSchedule' {Maybe Bool
active :: Maybe Bool
$sel:active:PriceSchedule' :: PriceSchedule -> Maybe Bool
active} -> Maybe Bool
active) (\s :: PriceSchedule
s@PriceSchedule' {} Maybe Bool
a -> PriceSchedule
s {$sel:active:PriceSchedule' :: Maybe Bool
active = Maybe Bool
a} :: PriceSchedule)

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

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

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

instance Data.FromXML PriceSchedule where
  parseXML :: [Node] -> Either String PriceSchedule
parseXML [Node]
x =
    Maybe Bool
-> Maybe CurrencyCodeValues
-> Maybe Double
-> Maybe Integer
-> PriceSchedule
PriceSchedule'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"active")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"currencyCode")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"price")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"term")

instance Prelude.Hashable PriceSchedule where
  hashWithSalt :: Int -> PriceSchedule -> Int
hashWithSalt Int
_salt PriceSchedule' {Maybe Bool
Maybe Double
Maybe Integer
Maybe CurrencyCodeValues
term :: Maybe Integer
price :: Maybe Double
currencyCode :: Maybe CurrencyCodeValues
active :: Maybe Bool
$sel:term:PriceSchedule' :: PriceSchedule -> Maybe Integer
$sel:price:PriceSchedule' :: PriceSchedule -> Maybe Double
$sel:currencyCode:PriceSchedule' :: PriceSchedule -> Maybe CurrencyCodeValues
$sel:active:PriceSchedule' :: PriceSchedule -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
active
      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 PriceSchedule where
  rnf :: PriceSchedule -> ()
rnf PriceSchedule' {Maybe Bool
Maybe Double
Maybe Integer
Maybe CurrencyCodeValues
term :: Maybe Integer
price :: Maybe Double
currencyCode :: Maybe CurrencyCodeValues
active :: Maybe Bool
$sel:term:PriceSchedule' :: PriceSchedule -> Maybe Integer
$sel:price:PriceSchedule' :: PriceSchedule -> Maybe Double
$sel:currencyCode:PriceSchedule' :: PriceSchedule -> Maybe CurrencyCodeValues
$sel:active:PriceSchedule' :: PriceSchedule -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
active
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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