{-# 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.LaunchTemplateSpotMarketOptions
-- 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.LaunchTemplateSpotMarketOptions 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.InstanceInterruptionBehavior
import Amazonka.EC2.Types.SpotInstanceType
import qualified Amazonka.Prelude as Prelude

-- | The options for Spot Instances.
--
-- /See:/ 'newLaunchTemplateSpotMarketOptions' smart constructor.
data LaunchTemplateSpotMarketOptions = LaunchTemplateSpotMarketOptions'
  { -- | The required duration for the Spot Instances (also known as Spot
    -- blocks), in minutes. This value must be a multiple of 60 (60, 120, 180,
    -- 240, 300, or 360).
    LaunchTemplateSpotMarketOptions -> Maybe Int
blockDurationMinutes :: Prelude.Maybe Prelude.Int,
    -- | The behavior when a Spot Instance is interrupted.
    LaunchTemplateSpotMarketOptions
-> Maybe InstanceInterruptionBehavior
instanceInterruptionBehavior :: Prelude.Maybe InstanceInterruptionBehavior,
    -- | The maximum hourly price you\'re willing to pay for the Spot Instances.
    -- 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 Spot Instances will be interrupted
    -- more frequently than if you do not specify this parameter.
    LaunchTemplateSpotMarketOptions -> Maybe Text
maxPrice :: Prelude.Maybe Prelude.Text,
    -- | The Spot Instance request type.
    LaunchTemplateSpotMarketOptions -> Maybe SpotInstanceType
spotInstanceType :: Prelude.Maybe SpotInstanceType,
    -- | The end date of the request. For a one-time request, the request remains
    -- active until all instances launch, the request is canceled, or this date
    -- is reached. If the request is persistent, it remains active until it is
    -- canceled or this date and time is reached.
    LaunchTemplateSpotMarketOptions -> Maybe ISO8601
validUntil :: Prelude.Maybe Data.ISO8601
  }
  deriving (LaunchTemplateSpotMarketOptions
-> LaunchTemplateSpotMarketOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LaunchTemplateSpotMarketOptions
-> LaunchTemplateSpotMarketOptions -> Bool
$c/= :: LaunchTemplateSpotMarketOptions
-> LaunchTemplateSpotMarketOptions -> Bool
== :: LaunchTemplateSpotMarketOptions
-> LaunchTemplateSpotMarketOptions -> Bool
$c== :: LaunchTemplateSpotMarketOptions
-> LaunchTemplateSpotMarketOptions -> Bool
Prelude.Eq, ReadPrec [LaunchTemplateSpotMarketOptions]
ReadPrec LaunchTemplateSpotMarketOptions
Int -> ReadS LaunchTemplateSpotMarketOptions
ReadS [LaunchTemplateSpotMarketOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LaunchTemplateSpotMarketOptions]
$creadListPrec :: ReadPrec [LaunchTemplateSpotMarketOptions]
readPrec :: ReadPrec LaunchTemplateSpotMarketOptions
$creadPrec :: ReadPrec LaunchTemplateSpotMarketOptions
readList :: ReadS [LaunchTemplateSpotMarketOptions]
$creadList :: ReadS [LaunchTemplateSpotMarketOptions]
readsPrec :: Int -> ReadS LaunchTemplateSpotMarketOptions
$creadsPrec :: Int -> ReadS LaunchTemplateSpotMarketOptions
Prelude.Read, Int -> LaunchTemplateSpotMarketOptions -> ShowS
[LaunchTemplateSpotMarketOptions] -> ShowS
LaunchTemplateSpotMarketOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LaunchTemplateSpotMarketOptions] -> ShowS
$cshowList :: [LaunchTemplateSpotMarketOptions] -> ShowS
show :: LaunchTemplateSpotMarketOptions -> String
$cshow :: LaunchTemplateSpotMarketOptions -> String
showsPrec :: Int -> LaunchTemplateSpotMarketOptions -> ShowS
$cshowsPrec :: Int -> LaunchTemplateSpotMarketOptions -> ShowS
Prelude.Show, forall x.
Rep LaunchTemplateSpotMarketOptions x
-> LaunchTemplateSpotMarketOptions
forall x.
LaunchTemplateSpotMarketOptions
-> Rep LaunchTemplateSpotMarketOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep LaunchTemplateSpotMarketOptions x
-> LaunchTemplateSpotMarketOptions
$cfrom :: forall x.
LaunchTemplateSpotMarketOptions
-> Rep LaunchTemplateSpotMarketOptions x
Prelude.Generic)

-- |
-- Create a value of 'LaunchTemplateSpotMarketOptions' 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:
--
-- 'blockDurationMinutes', 'launchTemplateSpotMarketOptions_blockDurationMinutes' - The required duration for the Spot Instances (also known as Spot
-- blocks), in minutes. This value must be a multiple of 60 (60, 120, 180,
-- 240, 300, or 360).
--
-- 'instanceInterruptionBehavior', 'launchTemplateSpotMarketOptions_instanceInterruptionBehavior' - The behavior when a Spot Instance is interrupted.
--
-- 'maxPrice', 'launchTemplateSpotMarketOptions_maxPrice' - The maximum hourly price you\'re willing to pay for the Spot Instances.
-- 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 Spot Instances will be interrupted
-- more frequently than if you do not specify this parameter.
--
-- 'spotInstanceType', 'launchTemplateSpotMarketOptions_spotInstanceType' - The Spot Instance request type.
--
-- 'validUntil', 'launchTemplateSpotMarketOptions_validUntil' - The end date of the request. For a one-time request, the request remains
-- active until all instances launch, the request is canceled, or this date
-- is reached. If the request is persistent, it remains active until it is
-- canceled or this date and time is reached.
newLaunchTemplateSpotMarketOptions ::
  LaunchTemplateSpotMarketOptions
newLaunchTemplateSpotMarketOptions :: LaunchTemplateSpotMarketOptions
newLaunchTemplateSpotMarketOptions =
  LaunchTemplateSpotMarketOptions'
    { $sel:blockDurationMinutes:LaunchTemplateSpotMarketOptions' :: Maybe Int
blockDurationMinutes =
        forall a. Maybe a
Prelude.Nothing,
      $sel:instanceInterruptionBehavior:LaunchTemplateSpotMarketOptions' :: Maybe InstanceInterruptionBehavior
instanceInterruptionBehavior =
        forall a. Maybe a
Prelude.Nothing,
      $sel:maxPrice:LaunchTemplateSpotMarketOptions' :: Maybe Text
maxPrice = forall a. Maybe a
Prelude.Nothing,
      $sel:spotInstanceType:LaunchTemplateSpotMarketOptions' :: Maybe SpotInstanceType
spotInstanceType = forall a. Maybe a
Prelude.Nothing,
      $sel:validUntil:LaunchTemplateSpotMarketOptions' :: Maybe ISO8601
validUntil = forall a. Maybe a
Prelude.Nothing
    }

-- | The required duration for the Spot Instances (also known as Spot
-- blocks), in minutes. This value must be a multiple of 60 (60, 120, 180,
-- 240, 300, or 360).
launchTemplateSpotMarketOptions_blockDurationMinutes :: Lens.Lens' LaunchTemplateSpotMarketOptions (Prelude.Maybe Prelude.Int)
launchTemplateSpotMarketOptions_blockDurationMinutes :: Lens' LaunchTemplateSpotMarketOptions (Maybe Int)
launchTemplateSpotMarketOptions_blockDurationMinutes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LaunchTemplateSpotMarketOptions' {Maybe Int
blockDurationMinutes :: Maybe Int
$sel:blockDurationMinutes:LaunchTemplateSpotMarketOptions' :: LaunchTemplateSpotMarketOptions -> Maybe Int
blockDurationMinutes} -> Maybe Int
blockDurationMinutes) (\s :: LaunchTemplateSpotMarketOptions
s@LaunchTemplateSpotMarketOptions' {} Maybe Int
a -> LaunchTemplateSpotMarketOptions
s {$sel:blockDurationMinutes:LaunchTemplateSpotMarketOptions' :: Maybe Int
blockDurationMinutes = Maybe Int
a} :: LaunchTemplateSpotMarketOptions)

-- | The behavior when a Spot Instance is interrupted.
launchTemplateSpotMarketOptions_instanceInterruptionBehavior :: Lens.Lens' LaunchTemplateSpotMarketOptions (Prelude.Maybe InstanceInterruptionBehavior)
launchTemplateSpotMarketOptions_instanceInterruptionBehavior :: Lens'
  LaunchTemplateSpotMarketOptions
  (Maybe InstanceInterruptionBehavior)
launchTemplateSpotMarketOptions_instanceInterruptionBehavior = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LaunchTemplateSpotMarketOptions' {Maybe InstanceInterruptionBehavior
instanceInterruptionBehavior :: Maybe InstanceInterruptionBehavior
$sel:instanceInterruptionBehavior:LaunchTemplateSpotMarketOptions' :: LaunchTemplateSpotMarketOptions
-> Maybe InstanceInterruptionBehavior
instanceInterruptionBehavior} -> Maybe InstanceInterruptionBehavior
instanceInterruptionBehavior) (\s :: LaunchTemplateSpotMarketOptions
s@LaunchTemplateSpotMarketOptions' {} Maybe InstanceInterruptionBehavior
a -> LaunchTemplateSpotMarketOptions
s {$sel:instanceInterruptionBehavior:LaunchTemplateSpotMarketOptions' :: Maybe InstanceInterruptionBehavior
instanceInterruptionBehavior = Maybe InstanceInterruptionBehavior
a} :: LaunchTemplateSpotMarketOptions)

-- | The maximum hourly price you\'re willing to pay for the Spot Instances.
-- 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 Spot Instances will be interrupted
-- more frequently than if you do not specify this parameter.
launchTemplateSpotMarketOptions_maxPrice :: Lens.Lens' LaunchTemplateSpotMarketOptions (Prelude.Maybe Prelude.Text)
launchTemplateSpotMarketOptions_maxPrice :: Lens' LaunchTemplateSpotMarketOptions (Maybe Text)
launchTemplateSpotMarketOptions_maxPrice = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LaunchTemplateSpotMarketOptions' {Maybe Text
maxPrice :: Maybe Text
$sel:maxPrice:LaunchTemplateSpotMarketOptions' :: LaunchTemplateSpotMarketOptions -> Maybe Text
maxPrice} -> Maybe Text
maxPrice) (\s :: LaunchTemplateSpotMarketOptions
s@LaunchTemplateSpotMarketOptions' {} Maybe Text
a -> LaunchTemplateSpotMarketOptions
s {$sel:maxPrice:LaunchTemplateSpotMarketOptions' :: Maybe Text
maxPrice = Maybe Text
a} :: LaunchTemplateSpotMarketOptions)

-- | The Spot Instance request type.
launchTemplateSpotMarketOptions_spotInstanceType :: Lens.Lens' LaunchTemplateSpotMarketOptions (Prelude.Maybe SpotInstanceType)
launchTemplateSpotMarketOptions_spotInstanceType :: Lens' LaunchTemplateSpotMarketOptions (Maybe SpotInstanceType)
launchTemplateSpotMarketOptions_spotInstanceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LaunchTemplateSpotMarketOptions' {Maybe SpotInstanceType
spotInstanceType :: Maybe SpotInstanceType
$sel:spotInstanceType:LaunchTemplateSpotMarketOptions' :: LaunchTemplateSpotMarketOptions -> Maybe SpotInstanceType
spotInstanceType} -> Maybe SpotInstanceType
spotInstanceType) (\s :: LaunchTemplateSpotMarketOptions
s@LaunchTemplateSpotMarketOptions' {} Maybe SpotInstanceType
a -> LaunchTemplateSpotMarketOptions
s {$sel:spotInstanceType:LaunchTemplateSpotMarketOptions' :: Maybe SpotInstanceType
spotInstanceType = Maybe SpotInstanceType
a} :: LaunchTemplateSpotMarketOptions)

-- | The end date of the request. For a one-time request, the request remains
-- active until all instances launch, the request is canceled, or this date
-- is reached. If the request is persistent, it remains active until it is
-- canceled or this date and time is reached.
launchTemplateSpotMarketOptions_validUntil :: Lens.Lens' LaunchTemplateSpotMarketOptions (Prelude.Maybe Prelude.UTCTime)
launchTemplateSpotMarketOptions_validUntil :: Lens' LaunchTemplateSpotMarketOptions (Maybe UTCTime)
launchTemplateSpotMarketOptions_validUntil = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LaunchTemplateSpotMarketOptions' {Maybe ISO8601
validUntil :: Maybe ISO8601
$sel:validUntil:LaunchTemplateSpotMarketOptions' :: LaunchTemplateSpotMarketOptions -> Maybe ISO8601
validUntil} -> Maybe ISO8601
validUntil) (\s :: LaunchTemplateSpotMarketOptions
s@LaunchTemplateSpotMarketOptions' {} Maybe ISO8601
a -> LaunchTemplateSpotMarketOptions
s {$sel:validUntil:LaunchTemplateSpotMarketOptions' :: Maybe ISO8601
validUntil = Maybe ISO8601
a} :: LaunchTemplateSpotMarketOptions) 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 LaunchTemplateSpotMarketOptions where
  parseXML :: [Node] -> Either String LaunchTemplateSpotMarketOptions
parseXML [Node]
x =
    Maybe Int
-> Maybe InstanceInterruptionBehavior
-> Maybe Text
-> Maybe SpotInstanceType
-> Maybe ISO8601
-> LaunchTemplateSpotMarketOptions
LaunchTemplateSpotMarketOptions'
      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
"blockDurationMinutes")
      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
"instanceInterruptionBehavior")
      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
"maxPrice")
      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
"spotInstanceType")
      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
"validUntil")

instance
  Prelude.Hashable
    LaunchTemplateSpotMarketOptions
  where
  hashWithSalt :: Int -> LaunchTemplateSpotMarketOptions -> Int
hashWithSalt
    Int
_salt
    LaunchTemplateSpotMarketOptions' {Maybe Int
Maybe Text
Maybe ISO8601
Maybe InstanceInterruptionBehavior
Maybe SpotInstanceType
validUntil :: Maybe ISO8601
spotInstanceType :: Maybe SpotInstanceType
maxPrice :: Maybe Text
instanceInterruptionBehavior :: Maybe InstanceInterruptionBehavior
blockDurationMinutes :: Maybe Int
$sel:validUntil:LaunchTemplateSpotMarketOptions' :: LaunchTemplateSpotMarketOptions -> Maybe ISO8601
$sel:spotInstanceType:LaunchTemplateSpotMarketOptions' :: LaunchTemplateSpotMarketOptions -> Maybe SpotInstanceType
$sel:maxPrice:LaunchTemplateSpotMarketOptions' :: LaunchTemplateSpotMarketOptions -> Maybe Text
$sel:instanceInterruptionBehavior:LaunchTemplateSpotMarketOptions' :: LaunchTemplateSpotMarketOptions
-> Maybe InstanceInterruptionBehavior
$sel:blockDurationMinutes:LaunchTemplateSpotMarketOptions' :: LaunchTemplateSpotMarketOptions -> Maybe Int
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
blockDurationMinutes
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InstanceInterruptionBehavior
instanceInterruptionBehavior
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
maxPrice
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SpotInstanceType
spotInstanceType
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
validUntil

instance
  Prelude.NFData
    LaunchTemplateSpotMarketOptions
  where
  rnf :: LaunchTemplateSpotMarketOptions -> ()
rnf LaunchTemplateSpotMarketOptions' {Maybe Int
Maybe Text
Maybe ISO8601
Maybe InstanceInterruptionBehavior
Maybe SpotInstanceType
validUntil :: Maybe ISO8601
spotInstanceType :: Maybe SpotInstanceType
maxPrice :: Maybe Text
instanceInterruptionBehavior :: Maybe InstanceInterruptionBehavior
blockDurationMinutes :: Maybe Int
$sel:validUntil:LaunchTemplateSpotMarketOptions' :: LaunchTemplateSpotMarketOptions -> Maybe ISO8601
$sel:spotInstanceType:LaunchTemplateSpotMarketOptions' :: LaunchTemplateSpotMarketOptions -> Maybe SpotInstanceType
$sel:maxPrice:LaunchTemplateSpotMarketOptions' :: LaunchTemplateSpotMarketOptions -> Maybe Text
$sel:instanceInterruptionBehavior:LaunchTemplateSpotMarketOptions' :: LaunchTemplateSpotMarketOptions
-> Maybe InstanceInterruptionBehavior
$sel:blockDurationMinutes:LaunchTemplateSpotMarketOptions' :: LaunchTemplateSpotMarketOptions -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
blockDurationMinutes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe InstanceInterruptionBehavior
instanceInterruptionBehavior
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
maxPrice
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SpotInstanceType
spotInstanceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
validUntil