{-# 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.SpotPrice
-- 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.SpotPrice 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.InstanceType
import Amazonka.EC2.Types.RIProductDescription
import qualified Amazonka.Prelude as Prelude

-- | The maximum price per unit hour that you are willing to pay for a Spot
-- Instance. We do not recommend using this parameter because it can lead
-- to increased interruptions. If you do not specify this parameter, you
-- will pay the current Spot price.
--
-- If you specify a maximum price, your instances will be interrupted more
-- frequently than if you do not specify this parameter.
--
-- /See:/ 'newSpotPrice' smart constructor.
data SpotPrice = SpotPrice'
  { -- | The Availability Zone.
    SpotPrice -> Maybe Text
availabilityZone :: Prelude.Maybe Prelude.Text,
    -- | The instance type.
    SpotPrice -> Maybe InstanceType
instanceType :: Prelude.Maybe InstanceType,
    -- | A general description of the AMI.
    SpotPrice -> Maybe RIProductDescription
productDescription :: Prelude.Maybe RIProductDescription,
    -- | The maximum price per unit hour that you are willing to pay for a Spot
    -- Instance. We do not recommend using this parameter because it can lead
    -- to increased interruptions. If you do not specify this parameter, you
    -- will pay the current Spot price.
    --
    -- If you specify a maximum price, your instances will be interrupted more
    -- frequently than if you do not specify this parameter.
    SpotPrice -> Maybe Text
spotPrice :: Prelude.Maybe Prelude.Text,
    -- | The date and time the request was created, in UTC format (for example,
    -- /YYYY/-/MM/-/DD/T/HH/:/MM/:/SS/Z).
    SpotPrice -> Maybe ISO8601
timestamp :: Prelude.Maybe Data.ISO8601
  }
  deriving (SpotPrice -> SpotPrice -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SpotPrice -> SpotPrice -> Bool
$c/= :: SpotPrice -> SpotPrice -> Bool
== :: SpotPrice -> SpotPrice -> Bool
$c== :: SpotPrice -> SpotPrice -> Bool
Prelude.Eq, ReadPrec [SpotPrice]
ReadPrec SpotPrice
Int -> ReadS SpotPrice
ReadS [SpotPrice]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SpotPrice]
$creadListPrec :: ReadPrec [SpotPrice]
readPrec :: ReadPrec SpotPrice
$creadPrec :: ReadPrec SpotPrice
readList :: ReadS [SpotPrice]
$creadList :: ReadS [SpotPrice]
readsPrec :: Int -> ReadS SpotPrice
$creadsPrec :: Int -> ReadS SpotPrice
Prelude.Read, Int -> SpotPrice -> ShowS
[SpotPrice] -> ShowS
SpotPrice -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SpotPrice] -> ShowS
$cshowList :: [SpotPrice] -> ShowS
show :: SpotPrice -> String
$cshow :: SpotPrice -> String
showsPrec :: Int -> SpotPrice -> ShowS
$cshowsPrec :: Int -> SpotPrice -> ShowS
Prelude.Show, forall x. Rep SpotPrice x -> SpotPrice
forall x. SpotPrice -> Rep SpotPrice x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SpotPrice x -> SpotPrice
$cfrom :: forall x. SpotPrice -> Rep SpotPrice x
Prelude.Generic)

-- |
-- Create a value of 'SpotPrice' 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:
--
-- 'availabilityZone', 'spotPrice_availabilityZone' - The Availability Zone.
--
-- 'instanceType', 'spotPrice_instanceType' - The instance type.
--
-- 'productDescription', 'spotPrice_productDescription' - A general description of the AMI.
--
-- 'spotPrice', 'spotPrice_spotPrice' - The maximum price per unit hour that you are willing to pay for a Spot
-- Instance. We do not recommend using this parameter because it can lead
-- to increased interruptions. If you do not specify this parameter, you
-- will pay the current Spot price.
--
-- If you specify a maximum price, your instances will be interrupted more
-- frequently than if you do not specify this parameter.
--
-- 'timestamp', 'spotPrice_timestamp' - The date and time the request was created, in UTC format (for example,
-- /YYYY/-/MM/-/DD/T/HH/:/MM/:/SS/Z).
newSpotPrice ::
  SpotPrice
newSpotPrice :: SpotPrice
newSpotPrice =
  SpotPrice'
    { $sel:availabilityZone:SpotPrice' :: Maybe Text
availabilityZone = forall a. Maybe a
Prelude.Nothing,
      $sel:instanceType:SpotPrice' :: Maybe InstanceType
instanceType = forall a. Maybe a
Prelude.Nothing,
      $sel:productDescription:SpotPrice' :: Maybe RIProductDescription
productDescription = forall a. Maybe a
Prelude.Nothing,
      $sel:spotPrice:SpotPrice' :: Maybe Text
spotPrice = forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:SpotPrice' :: Maybe ISO8601
timestamp = forall a. Maybe a
Prelude.Nothing
    }

-- | The Availability Zone.
spotPrice_availabilityZone :: Lens.Lens' SpotPrice (Prelude.Maybe Prelude.Text)
spotPrice_availabilityZone :: Lens' SpotPrice (Maybe Text)
spotPrice_availabilityZone = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SpotPrice' {Maybe Text
availabilityZone :: Maybe Text
$sel:availabilityZone:SpotPrice' :: SpotPrice -> Maybe Text
availabilityZone} -> Maybe Text
availabilityZone) (\s :: SpotPrice
s@SpotPrice' {} Maybe Text
a -> SpotPrice
s {$sel:availabilityZone:SpotPrice' :: Maybe Text
availabilityZone = Maybe Text
a} :: SpotPrice)

-- | The instance type.
spotPrice_instanceType :: Lens.Lens' SpotPrice (Prelude.Maybe InstanceType)
spotPrice_instanceType :: Lens' SpotPrice (Maybe InstanceType)
spotPrice_instanceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SpotPrice' {Maybe InstanceType
instanceType :: Maybe InstanceType
$sel:instanceType:SpotPrice' :: SpotPrice -> Maybe InstanceType
instanceType} -> Maybe InstanceType
instanceType) (\s :: SpotPrice
s@SpotPrice' {} Maybe InstanceType
a -> SpotPrice
s {$sel:instanceType:SpotPrice' :: Maybe InstanceType
instanceType = Maybe InstanceType
a} :: SpotPrice)

-- | A general description of the AMI.
spotPrice_productDescription :: Lens.Lens' SpotPrice (Prelude.Maybe RIProductDescription)
spotPrice_productDescription :: Lens' SpotPrice (Maybe RIProductDescription)
spotPrice_productDescription = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SpotPrice' {Maybe RIProductDescription
productDescription :: Maybe RIProductDescription
$sel:productDescription:SpotPrice' :: SpotPrice -> Maybe RIProductDescription
productDescription} -> Maybe RIProductDescription
productDescription) (\s :: SpotPrice
s@SpotPrice' {} Maybe RIProductDescription
a -> SpotPrice
s {$sel:productDescription:SpotPrice' :: Maybe RIProductDescription
productDescription = Maybe RIProductDescription
a} :: SpotPrice)

-- | The maximum price per unit hour that you are willing to pay for a Spot
-- Instance. We do not recommend using this parameter because it can lead
-- to increased interruptions. If you do not specify this parameter, you
-- will pay the current Spot price.
--
-- If you specify a maximum price, your instances will be interrupted more
-- frequently than if you do not specify this parameter.
spotPrice_spotPrice :: Lens.Lens' SpotPrice (Prelude.Maybe Prelude.Text)
spotPrice_spotPrice :: Lens' SpotPrice (Maybe Text)
spotPrice_spotPrice = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SpotPrice' {Maybe Text
spotPrice :: Maybe Text
$sel:spotPrice:SpotPrice' :: SpotPrice -> Maybe Text
spotPrice} -> Maybe Text
spotPrice) (\s :: SpotPrice
s@SpotPrice' {} Maybe Text
a -> SpotPrice
s {$sel:spotPrice:SpotPrice' :: Maybe Text
spotPrice = Maybe Text
a} :: SpotPrice)

-- | The date and time the request was created, in UTC format (for example,
-- /YYYY/-/MM/-/DD/T/HH/:/MM/:/SS/Z).
spotPrice_timestamp :: Lens.Lens' SpotPrice (Prelude.Maybe Prelude.UTCTime)
spotPrice_timestamp :: Lens' SpotPrice (Maybe UTCTime)
spotPrice_timestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SpotPrice' {Maybe ISO8601
timestamp :: Maybe ISO8601
$sel:timestamp:SpotPrice' :: SpotPrice -> Maybe ISO8601
timestamp} -> Maybe ISO8601
timestamp) (\s :: SpotPrice
s@SpotPrice' {} Maybe ISO8601
a -> SpotPrice
s {$sel:timestamp:SpotPrice' :: Maybe ISO8601
timestamp = Maybe ISO8601
a} :: SpotPrice) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Data.FromXML SpotPrice where
  parseXML :: [Node] -> Either String SpotPrice
parseXML [Node]
x =
    Maybe Text
-> Maybe InstanceType
-> Maybe RIProductDescription
-> Maybe Text
-> Maybe ISO8601
-> SpotPrice
SpotPrice'
      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
"availabilityZone")
      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
"instanceType")
      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
"productDescription")
      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
"spotPrice")
      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
"timestamp")

instance Prelude.Hashable SpotPrice where
  hashWithSalt :: Int -> SpotPrice -> Int
hashWithSalt Int
_salt SpotPrice' {Maybe Text
Maybe ISO8601
Maybe InstanceType
Maybe RIProductDescription
timestamp :: Maybe ISO8601
spotPrice :: Maybe Text
productDescription :: Maybe RIProductDescription
instanceType :: Maybe InstanceType
availabilityZone :: Maybe Text
$sel:timestamp:SpotPrice' :: SpotPrice -> Maybe ISO8601
$sel:spotPrice:SpotPrice' :: SpotPrice -> Maybe Text
$sel:productDescription:SpotPrice' :: SpotPrice -> Maybe RIProductDescription
$sel:instanceType:SpotPrice' :: SpotPrice -> Maybe InstanceType
$sel:availabilityZone:SpotPrice' :: SpotPrice -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
availabilityZone
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InstanceType
instanceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RIProductDescription
productDescription
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
spotPrice
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
timestamp

instance Prelude.NFData SpotPrice where
  rnf :: SpotPrice -> ()
rnf SpotPrice' {Maybe Text
Maybe ISO8601
Maybe InstanceType
Maybe RIProductDescription
timestamp :: Maybe ISO8601
spotPrice :: Maybe Text
productDescription :: Maybe RIProductDescription
instanceType :: Maybe InstanceType
availabilityZone :: Maybe Text
$sel:timestamp:SpotPrice' :: SpotPrice -> Maybe ISO8601
$sel:spotPrice:SpotPrice' :: SpotPrice -> Maybe Text
$sel:productDescription:SpotPrice' :: SpotPrice -> Maybe RIProductDescription
$sel:instanceType:SpotPrice' :: SpotPrice -> Maybe InstanceType
$sel:availabilityZone:SpotPrice' :: SpotPrice -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
availabilityZone
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe InstanceType
instanceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RIProductDescription
productDescription
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
spotPrice
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
timestamp