{-# 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.PricingDetail
-- 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.PricingDetail 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

-- | Describes a Reserved Instance offering.
--
-- /See:/ 'newPricingDetail' smart constructor.
data PricingDetail = PricingDetail'
  { -- | The number of reservations available for the price.
    PricingDetail -> Maybe Int
count :: Prelude.Maybe Prelude.Int,
    -- | The price per instance.
    PricingDetail -> Maybe Double
price :: Prelude.Maybe Prelude.Double
  }
  deriving (PricingDetail -> PricingDetail -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PricingDetail -> PricingDetail -> Bool
$c/= :: PricingDetail -> PricingDetail -> Bool
== :: PricingDetail -> PricingDetail -> Bool
$c== :: PricingDetail -> PricingDetail -> Bool
Prelude.Eq, ReadPrec [PricingDetail]
ReadPrec PricingDetail
Int -> ReadS PricingDetail
ReadS [PricingDetail]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PricingDetail]
$creadListPrec :: ReadPrec [PricingDetail]
readPrec :: ReadPrec PricingDetail
$creadPrec :: ReadPrec PricingDetail
readList :: ReadS [PricingDetail]
$creadList :: ReadS [PricingDetail]
readsPrec :: Int -> ReadS PricingDetail
$creadsPrec :: Int -> ReadS PricingDetail
Prelude.Read, Int -> PricingDetail -> ShowS
[PricingDetail] -> ShowS
PricingDetail -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PricingDetail] -> ShowS
$cshowList :: [PricingDetail] -> ShowS
show :: PricingDetail -> String
$cshow :: PricingDetail -> String
showsPrec :: Int -> PricingDetail -> ShowS
$cshowsPrec :: Int -> PricingDetail -> ShowS
Prelude.Show, forall x. Rep PricingDetail x -> PricingDetail
forall x. PricingDetail -> Rep PricingDetail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PricingDetail x -> PricingDetail
$cfrom :: forall x. PricingDetail -> Rep PricingDetail x
Prelude.Generic)

-- |
-- Create a value of 'PricingDetail' 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:
--
-- 'count', 'pricingDetail_count' - The number of reservations available for the price.
--
-- 'price', 'pricingDetail_price' - The price per instance.
newPricingDetail ::
  PricingDetail
newPricingDetail :: PricingDetail
newPricingDetail =
  PricingDetail'
    { $sel:count:PricingDetail' :: Maybe Int
count = forall a. Maybe a
Prelude.Nothing,
      $sel:price:PricingDetail' :: Maybe Double
price = forall a. Maybe a
Prelude.Nothing
    }

-- | The number of reservations available for the price.
pricingDetail_count :: Lens.Lens' PricingDetail (Prelude.Maybe Prelude.Int)
pricingDetail_count :: Lens' PricingDetail (Maybe Int)
pricingDetail_count = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PricingDetail' {Maybe Int
count :: Maybe Int
$sel:count:PricingDetail' :: PricingDetail -> Maybe Int
count} -> Maybe Int
count) (\s :: PricingDetail
s@PricingDetail' {} Maybe Int
a -> PricingDetail
s {$sel:count:PricingDetail' :: Maybe Int
count = Maybe Int
a} :: PricingDetail)

-- | The price per instance.
pricingDetail_price :: Lens.Lens' PricingDetail (Prelude.Maybe Prelude.Double)
pricingDetail_price :: Lens' PricingDetail (Maybe Double)
pricingDetail_price = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PricingDetail' {Maybe Double
price :: Maybe Double
$sel:price:PricingDetail' :: PricingDetail -> Maybe Double
price} -> Maybe Double
price) (\s :: PricingDetail
s@PricingDetail' {} Maybe Double
a -> PricingDetail
s {$sel:price:PricingDetail' :: Maybe Double
price = Maybe Double
a} :: PricingDetail)

instance Data.FromXML PricingDetail where
  parseXML :: [Node] -> Either String PricingDetail
parseXML [Node]
x =
    Maybe Int -> Maybe Double -> PricingDetail
PricingDetail'
      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
"count")
      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")

instance Prelude.Hashable PricingDetail where
  hashWithSalt :: Int -> PricingDetail -> Int
hashWithSalt Int
_salt PricingDetail' {Maybe Double
Maybe Int
price :: Maybe Double
count :: Maybe Int
$sel:price:PricingDetail' :: PricingDetail -> Maybe Double
$sel:count:PricingDetail' :: PricingDetail -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
count
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
price

instance Prelude.NFData PricingDetail where
  rnf :: PricingDetail -> ()
rnf PricingDetail' {Maybe Double
Maybe Int
price :: Maybe Double
count :: Maybe Int
$sel:price:PricingDetail' :: PricingDetail -> Maybe Double
$sel:count:PricingDetail' :: PricingDetail -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
count seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
price