{-# 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.ReservationValue
-- 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.ReservationValue 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 qualified Amazonka.Prelude as Prelude

-- | The cost associated with the Reserved Instance.
--
-- /See:/ 'newReservationValue' smart constructor.
data ReservationValue = ReservationValue'
  { -- | The hourly rate of the reservation.
    ReservationValue -> Maybe Text
hourlyPrice :: Prelude.Maybe Prelude.Text,
    -- | The balance of the total value (the sum of remainingUpfrontValue +
    -- hourlyPrice * number of hours remaining).
    ReservationValue -> Maybe Text
remainingTotalValue :: Prelude.Maybe Prelude.Text,
    -- | The remaining upfront cost of the reservation.
    ReservationValue -> Maybe Text
remainingUpfrontValue :: Prelude.Maybe Prelude.Text
  }
  deriving (ReservationValue -> ReservationValue -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReservationValue -> ReservationValue -> Bool
$c/= :: ReservationValue -> ReservationValue -> Bool
== :: ReservationValue -> ReservationValue -> Bool
$c== :: ReservationValue -> ReservationValue -> Bool
Prelude.Eq, ReadPrec [ReservationValue]
ReadPrec ReservationValue
Int -> ReadS ReservationValue
ReadS [ReservationValue]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReservationValue]
$creadListPrec :: ReadPrec [ReservationValue]
readPrec :: ReadPrec ReservationValue
$creadPrec :: ReadPrec ReservationValue
readList :: ReadS [ReservationValue]
$creadList :: ReadS [ReservationValue]
readsPrec :: Int -> ReadS ReservationValue
$creadsPrec :: Int -> ReadS ReservationValue
Prelude.Read, Int -> ReservationValue -> ShowS
[ReservationValue] -> ShowS
ReservationValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReservationValue] -> ShowS
$cshowList :: [ReservationValue] -> ShowS
show :: ReservationValue -> String
$cshow :: ReservationValue -> String
showsPrec :: Int -> ReservationValue -> ShowS
$cshowsPrec :: Int -> ReservationValue -> ShowS
Prelude.Show, forall x. Rep ReservationValue x -> ReservationValue
forall x. ReservationValue -> Rep ReservationValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReservationValue x -> ReservationValue
$cfrom :: forall x. ReservationValue -> Rep ReservationValue x
Prelude.Generic)

-- |
-- Create a value of 'ReservationValue' 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:
--
-- 'hourlyPrice', 'reservationValue_hourlyPrice' - The hourly rate of the reservation.
--
-- 'remainingTotalValue', 'reservationValue_remainingTotalValue' - The balance of the total value (the sum of remainingUpfrontValue +
-- hourlyPrice * number of hours remaining).
--
-- 'remainingUpfrontValue', 'reservationValue_remainingUpfrontValue' - The remaining upfront cost of the reservation.
newReservationValue ::
  ReservationValue
newReservationValue :: ReservationValue
newReservationValue =
  ReservationValue'
    { $sel:hourlyPrice:ReservationValue' :: Maybe Text
hourlyPrice = forall a. Maybe a
Prelude.Nothing,
      $sel:remainingTotalValue:ReservationValue' :: Maybe Text
remainingTotalValue = forall a. Maybe a
Prelude.Nothing,
      $sel:remainingUpfrontValue:ReservationValue' :: Maybe Text
remainingUpfrontValue = forall a. Maybe a
Prelude.Nothing
    }

-- | The hourly rate of the reservation.
reservationValue_hourlyPrice :: Lens.Lens' ReservationValue (Prelude.Maybe Prelude.Text)
reservationValue_hourlyPrice :: Lens' ReservationValue (Maybe Text)
reservationValue_hourlyPrice = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReservationValue' {Maybe Text
hourlyPrice :: Maybe Text
$sel:hourlyPrice:ReservationValue' :: ReservationValue -> Maybe Text
hourlyPrice} -> Maybe Text
hourlyPrice) (\s :: ReservationValue
s@ReservationValue' {} Maybe Text
a -> ReservationValue
s {$sel:hourlyPrice:ReservationValue' :: Maybe Text
hourlyPrice = Maybe Text
a} :: ReservationValue)

-- | The balance of the total value (the sum of remainingUpfrontValue +
-- hourlyPrice * number of hours remaining).
reservationValue_remainingTotalValue :: Lens.Lens' ReservationValue (Prelude.Maybe Prelude.Text)
reservationValue_remainingTotalValue :: Lens' ReservationValue (Maybe Text)
reservationValue_remainingTotalValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReservationValue' {Maybe Text
remainingTotalValue :: Maybe Text
$sel:remainingTotalValue:ReservationValue' :: ReservationValue -> Maybe Text
remainingTotalValue} -> Maybe Text
remainingTotalValue) (\s :: ReservationValue
s@ReservationValue' {} Maybe Text
a -> ReservationValue
s {$sel:remainingTotalValue:ReservationValue' :: Maybe Text
remainingTotalValue = Maybe Text
a} :: ReservationValue)

-- | The remaining upfront cost of the reservation.
reservationValue_remainingUpfrontValue :: Lens.Lens' ReservationValue (Prelude.Maybe Prelude.Text)
reservationValue_remainingUpfrontValue :: Lens' ReservationValue (Maybe Text)
reservationValue_remainingUpfrontValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReservationValue' {Maybe Text
remainingUpfrontValue :: Maybe Text
$sel:remainingUpfrontValue:ReservationValue' :: ReservationValue -> Maybe Text
remainingUpfrontValue} -> Maybe Text
remainingUpfrontValue) (\s :: ReservationValue
s@ReservationValue' {} Maybe Text
a -> ReservationValue
s {$sel:remainingUpfrontValue:ReservationValue' :: Maybe Text
remainingUpfrontValue = Maybe Text
a} :: ReservationValue)

instance Data.FromXML ReservationValue where
  parseXML :: [Node] -> Either String ReservationValue
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> Maybe Text -> ReservationValue
ReservationValue'
      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
"hourlyPrice")
      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
"remainingTotalValue")
      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
"remainingUpfrontValue")

instance Prelude.Hashable ReservationValue where
  hashWithSalt :: Int -> ReservationValue -> Int
hashWithSalt Int
_salt ReservationValue' {Maybe Text
remainingUpfrontValue :: Maybe Text
remainingTotalValue :: Maybe Text
hourlyPrice :: Maybe Text
$sel:remainingUpfrontValue:ReservationValue' :: ReservationValue -> Maybe Text
$sel:remainingTotalValue:ReservationValue' :: ReservationValue -> Maybe Text
$sel:hourlyPrice:ReservationValue' :: ReservationValue -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
hourlyPrice
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
remainingTotalValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
remainingUpfrontValue

instance Prelude.NFData ReservationValue where
  rnf :: ReservationValue -> ()
rnf ReservationValue' {Maybe Text
remainingUpfrontValue :: Maybe Text
remainingTotalValue :: Maybe Text
hourlyPrice :: Maybe Text
$sel:remainingUpfrontValue:ReservationValue' :: ReservationValue -> Maybe Text
$sel:remainingTotalValue:ReservationValue' :: ReservationValue -> Maybe Text
$sel:hourlyPrice:ReservationValue' :: ReservationValue -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
hourlyPrice
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
remainingTotalValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
remainingUpfrontValue