{-# 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.OnDemandOptions
-- 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.OnDemandOptions 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.CapacityReservationOptions
import Amazonka.EC2.Types.FleetOnDemandAllocationStrategy
import qualified Amazonka.Prelude as Prelude

-- | Describes the configuration of On-Demand Instances in an EC2 Fleet.
--
-- /See:/ 'newOnDemandOptions' smart constructor.
data OnDemandOptions = OnDemandOptions'
  { -- | The strategy that determines the order of the launch template overrides
    -- to use in fulfilling On-Demand capacity.
    --
    -- @lowest-price@ - EC2 Fleet uses price to determine the order, launching
    -- the lowest price first.
    --
    -- @prioritized@ - EC2 Fleet uses the priority that you assigned to each
    -- launch template override, launching the highest priority first.
    --
    -- Default: @lowest-price@
    OnDemandOptions -> Maybe FleetOnDemandAllocationStrategy
allocationStrategy :: Prelude.Maybe FleetOnDemandAllocationStrategy,
    -- | The strategy for using unused Capacity Reservations for fulfilling
    -- On-Demand capacity.
    --
    -- Supported only for fleets of type @instant@.
    OnDemandOptions -> Maybe CapacityReservationOptions
capacityReservationOptions :: Prelude.Maybe CapacityReservationOptions,
    -- | The maximum amount per hour for On-Demand Instances that you\'re willing
    -- to pay.
    OnDemandOptions -> Maybe Text
maxTotalPrice :: Prelude.Maybe Prelude.Text,
    -- | The minimum target capacity for On-Demand Instances in the fleet. If the
    -- minimum target capacity is not reached, the fleet launches no instances.
    --
    -- Supported only for fleets of type @instant@.
    --
    -- At least one of the following must be specified:
    -- @SingleAvailabilityZone@ | @SingleInstanceType@
    OnDemandOptions -> Maybe Int
minTargetCapacity :: Prelude.Maybe Prelude.Int,
    -- | Indicates that the fleet launches all On-Demand Instances into a single
    -- Availability Zone.
    --
    -- Supported only for fleets of type @instant@.
    OnDemandOptions -> Maybe Bool
singleAvailabilityZone :: Prelude.Maybe Prelude.Bool,
    -- | Indicates that the fleet uses a single instance type to launch all
    -- On-Demand Instances in the fleet.
    --
    -- Supported only for fleets of type @instant@.
    OnDemandOptions -> Maybe Bool
singleInstanceType :: Prelude.Maybe Prelude.Bool
  }
  deriving (OnDemandOptions -> OnDemandOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OnDemandOptions -> OnDemandOptions -> Bool
$c/= :: OnDemandOptions -> OnDemandOptions -> Bool
== :: OnDemandOptions -> OnDemandOptions -> Bool
$c== :: OnDemandOptions -> OnDemandOptions -> Bool
Prelude.Eq, ReadPrec [OnDemandOptions]
ReadPrec OnDemandOptions
Int -> ReadS OnDemandOptions
ReadS [OnDemandOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OnDemandOptions]
$creadListPrec :: ReadPrec [OnDemandOptions]
readPrec :: ReadPrec OnDemandOptions
$creadPrec :: ReadPrec OnDemandOptions
readList :: ReadS [OnDemandOptions]
$creadList :: ReadS [OnDemandOptions]
readsPrec :: Int -> ReadS OnDemandOptions
$creadsPrec :: Int -> ReadS OnDemandOptions
Prelude.Read, Int -> OnDemandOptions -> ShowS
[OnDemandOptions] -> ShowS
OnDemandOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OnDemandOptions] -> ShowS
$cshowList :: [OnDemandOptions] -> ShowS
show :: OnDemandOptions -> String
$cshow :: OnDemandOptions -> String
showsPrec :: Int -> OnDemandOptions -> ShowS
$cshowsPrec :: Int -> OnDemandOptions -> ShowS
Prelude.Show, forall x. Rep OnDemandOptions x -> OnDemandOptions
forall x. OnDemandOptions -> Rep OnDemandOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OnDemandOptions x -> OnDemandOptions
$cfrom :: forall x. OnDemandOptions -> Rep OnDemandOptions x
Prelude.Generic)

-- |
-- Create a value of 'OnDemandOptions' 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:
--
-- 'allocationStrategy', 'onDemandOptions_allocationStrategy' - The strategy that determines the order of the launch template overrides
-- to use in fulfilling On-Demand capacity.
--
-- @lowest-price@ - EC2 Fleet uses price to determine the order, launching
-- the lowest price first.
--
-- @prioritized@ - EC2 Fleet uses the priority that you assigned to each
-- launch template override, launching the highest priority first.
--
-- Default: @lowest-price@
--
-- 'capacityReservationOptions', 'onDemandOptions_capacityReservationOptions' - The strategy for using unused Capacity Reservations for fulfilling
-- On-Demand capacity.
--
-- Supported only for fleets of type @instant@.
--
-- 'maxTotalPrice', 'onDemandOptions_maxTotalPrice' - The maximum amount per hour for On-Demand Instances that you\'re willing
-- to pay.
--
-- 'minTargetCapacity', 'onDemandOptions_minTargetCapacity' - The minimum target capacity for On-Demand Instances in the fleet. If the
-- minimum target capacity is not reached, the fleet launches no instances.
--
-- Supported only for fleets of type @instant@.
--
-- At least one of the following must be specified:
-- @SingleAvailabilityZone@ | @SingleInstanceType@
--
-- 'singleAvailabilityZone', 'onDemandOptions_singleAvailabilityZone' - Indicates that the fleet launches all On-Demand Instances into a single
-- Availability Zone.
--
-- Supported only for fleets of type @instant@.
--
-- 'singleInstanceType', 'onDemandOptions_singleInstanceType' - Indicates that the fleet uses a single instance type to launch all
-- On-Demand Instances in the fleet.
--
-- Supported only for fleets of type @instant@.
newOnDemandOptions ::
  OnDemandOptions
newOnDemandOptions :: OnDemandOptions
newOnDemandOptions =
  OnDemandOptions'
    { $sel:allocationStrategy:OnDemandOptions' :: Maybe FleetOnDemandAllocationStrategy
allocationStrategy =
        forall a. Maybe a
Prelude.Nothing,
      $sel:capacityReservationOptions:OnDemandOptions' :: Maybe CapacityReservationOptions
capacityReservationOptions = forall a. Maybe a
Prelude.Nothing,
      $sel:maxTotalPrice:OnDemandOptions' :: Maybe Text
maxTotalPrice = forall a. Maybe a
Prelude.Nothing,
      $sel:minTargetCapacity:OnDemandOptions' :: Maybe Int
minTargetCapacity = forall a. Maybe a
Prelude.Nothing,
      $sel:singleAvailabilityZone:OnDemandOptions' :: Maybe Bool
singleAvailabilityZone = forall a. Maybe a
Prelude.Nothing,
      $sel:singleInstanceType:OnDemandOptions' :: Maybe Bool
singleInstanceType = forall a. Maybe a
Prelude.Nothing
    }

-- | The strategy that determines the order of the launch template overrides
-- to use in fulfilling On-Demand capacity.
--
-- @lowest-price@ - EC2 Fleet uses price to determine the order, launching
-- the lowest price first.
--
-- @prioritized@ - EC2 Fleet uses the priority that you assigned to each
-- launch template override, launching the highest priority first.
--
-- Default: @lowest-price@
onDemandOptions_allocationStrategy :: Lens.Lens' OnDemandOptions (Prelude.Maybe FleetOnDemandAllocationStrategy)
onDemandOptions_allocationStrategy :: Lens' OnDemandOptions (Maybe FleetOnDemandAllocationStrategy)
onDemandOptions_allocationStrategy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OnDemandOptions' {Maybe FleetOnDemandAllocationStrategy
allocationStrategy :: Maybe FleetOnDemandAllocationStrategy
$sel:allocationStrategy:OnDemandOptions' :: OnDemandOptions -> Maybe FleetOnDemandAllocationStrategy
allocationStrategy} -> Maybe FleetOnDemandAllocationStrategy
allocationStrategy) (\s :: OnDemandOptions
s@OnDemandOptions' {} Maybe FleetOnDemandAllocationStrategy
a -> OnDemandOptions
s {$sel:allocationStrategy:OnDemandOptions' :: Maybe FleetOnDemandAllocationStrategy
allocationStrategy = Maybe FleetOnDemandAllocationStrategy
a} :: OnDemandOptions)

-- | The strategy for using unused Capacity Reservations for fulfilling
-- On-Demand capacity.
--
-- Supported only for fleets of type @instant@.
onDemandOptions_capacityReservationOptions :: Lens.Lens' OnDemandOptions (Prelude.Maybe CapacityReservationOptions)
onDemandOptions_capacityReservationOptions :: Lens' OnDemandOptions (Maybe CapacityReservationOptions)
onDemandOptions_capacityReservationOptions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OnDemandOptions' {Maybe CapacityReservationOptions
capacityReservationOptions :: Maybe CapacityReservationOptions
$sel:capacityReservationOptions:OnDemandOptions' :: OnDemandOptions -> Maybe CapacityReservationOptions
capacityReservationOptions} -> Maybe CapacityReservationOptions
capacityReservationOptions) (\s :: OnDemandOptions
s@OnDemandOptions' {} Maybe CapacityReservationOptions
a -> OnDemandOptions
s {$sel:capacityReservationOptions:OnDemandOptions' :: Maybe CapacityReservationOptions
capacityReservationOptions = Maybe CapacityReservationOptions
a} :: OnDemandOptions)

-- | The maximum amount per hour for On-Demand Instances that you\'re willing
-- to pay.
onDemandOptions_maxTotalPrice :: Lens.Lens' OnDemandOptions (Prelude.Maybe Prelude.Text)
onDemandOptions_maxTotalPrice :: Lens' OnDemandOptions (Maybe Text)
onDemandOptions_maxTotalPrice = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OnDemandOptions' {Maybe Text
maxTotalPrice :: Maybe Text
$sel:maxTotalPrice:OnDemandOptions' :: OnDemandOptions -> Maybe Text
maxTotalPrice} -> Maybe Text
maxTotalPrice) (\s :: OnDemandOptions
s@OnDemandOptions' {} Maybe Text
a -> OnDemandOptions
s {$sel:maxTotalPrice:OnDemandOptions' :: Maybe Text
maxTotalPrice = Maybe Text
a} :: OnDemandOptions)

-- | The minimum target capacity for On-Demand Instances in the fleet. If the
-- minimum target capacity is not reached, the fleet launches no instances.
--
-- Supported only for fleets of type @instant@.
--
-- At least one of the following must be specified:
-- @SingleAvailabilityZone@ | @SingleInstanceType@
onDemandOptions_minTargetCapacity :: Lens.Lens' OnDemandOptions (Prelude.Maybe Prelude.Int)
onDemandOptions_minTargetCapacity :: Lens' OnDemandOptions (Maybe Int)
onDemandOptions_minTargetCapacity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OnDemandOptions' {Maybe Int
minTargetCapacity :: Maybe Int
$sel:minTargetCapacity:OnDemandOptions' :: OnDemandOptions -> Maybe Int
minTargetCapacity} -> Maybe Int
minTargetCapacity) (\s :: OnDemandOptions
s@OnDemandOptions' {} Maybe Int
a -> OnDemandOptions
s {$sel:minTargetCapacity:OnDemandOptions' :: Maybe Int
minTargetCapacity = Maybe Int
a} :: OnDemandOptions)

-- | Indicates that the fleet launches all On-Demand Instances into a single
-- Availability Zone.
--
-- Supported only for fleets of type @instant@.
onDemandOptions_singleAvailabilityZone :: Lens.Lens' OnDemandOptions (Prelude.Maybe Prelude.Bool)
onDemandOptions_singleAvailabilityZone :: Lens' OnDemandOptions (Maybe Bool)
onDemandOptions_singleAvailabilityZone = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OnDemandOptions' {Maybe Bool
singleAvailabilityZone :: Maybe Bool
$sel:singleAvailabilityZone:OnDemandOptions' :: OnDemandOptions -> Maybe Bool
singleAvailabilityZone} -> Maybe Bool
singleAvailabilityZone) (\s :: OnDemandOptions
s@OnDemandOptions' {} Maybe Bool
a -> OnDemandOptions
s {$sel:singleAvailabilityZone:OnDemandOptions' :: Maybe Bool
singleAvailabilityZone = Maybe Bool
a} :: OnDemandOptions)

-- | Indicates that the fleet uses a single instance type to launch all
-- On-Demand Instances in the fleet.
--
-- Supported only for fleets of type @instant@.
onDemandOptions_singleInstanceType :: Lens.Lens' OnDemandOptions (Prelude.Maybe Prelude.Bool)
onDemandOptions_singleInstanceType :: Lens' OnDemandOptions (Maybe Bool)
onDemandOptions_singleInstanceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OnDemandOptions' {Maybe Bool
singleInstanceType :: Maybe Bool
$sel:singleInstanceType:OnDemandOptions' :: OnDemandOptions -> Maybe Bool
singleInstanceType} -> Maybe Bool
singleInstanceType) (\s :: OnDemandOptions
s@OnDemandOptions' {} Maybe Bool
a -> OnDemandOptions
s {$sel:singleInstanceType:OnDemandOptions' :: Maybe Bool
singleInstanceType = Maybe Bool
a} :: OnDemandOptions)

instance Data.FromXML OnDemandOptions where
  parseXML :: [Node] -> Either String OnDemandOptions
parseXML [Node]
x =
    Maybe FleetOnDemandAllocationStrategy
-> Maybe CapacityReservationOptions
-> Maybe Text
-> Maybe Int
-> Maybe Bool
-> Maybe Bool
-> OnDemandOptions
OnDemandOptions'
      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
"allocationStrategy")
      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
"capacityReservationOptions")
      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
"maxTotalPrice")
      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
"minTargetCapacity")
      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
"singleAvailabilityZone")
      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
"singleInstanceType")

instance Prelude.Hashable OnDemandOptions where
  hashWithSalt :: Int -> OnDemandOptions -> Int
hashWithSalt Int
_salt OnDemandOptions' {Maybe Bool
Maybe Int
Maybe Text
Maybe CapacityReservationOptions
Maybe FleetOnDemandAllocationStrategy
singleInstanceType :: Maybe Bool
singleAvailabilityZone :: Maybe Bool
minTargetCapacity :: Maybe Int
maxTotalPrice :: Maybe Text
capacityReservationOptions :: Maybe CapacityReservationOptions
allocationStrategy :: Maybe FleetOnDemandAllocationStrategy
$sel:singleInstanceType:OnDemandOptions' :: OnDemandOptions -> Maybe Bool
$sel:singleAvailabilityZone:OnDemandOptions' :: OnDemandOptions -> Maybe Bool
$sel:minTargetCapacity:OnDemandOptions' :: OnDemandOptions -> Maybe Int
$sel:maxTotalPrice:OnDemandOptions' :: OnDemandOptions -> Maybe Text
$sel:capacityReservationOptions:OnDemandOptions' :: OnDemandOptions -> Maybe CapacityReservationOptions
$sel:allocationStrategy:OnDemandOptions' :: OnDemandOptions -> Maybe FleetOnDemandAllocationStrategy
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FleetOnDemandAllocationStrategy
allocationStrategy
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CapacityReservationOptions
capacityReservationOptions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
maxTotalPrice
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
minTargetCapacity
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
singleAvailabilityZone
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
singleInstanceType

instance Prelude.NFData OnDemandOptions where
  rnf :: OnDemandOptions -> ()
rnf OnDemandOptions' {Maybe Bool
Maybe Int
Maybe Text
Maybe CapacityReservationOptions
Maybe FleetOnDemandAllocationStrategy
singleInstanceType :: Maybe Bool
singleAvailabilityZone :: Maybe Bool
minTargetCapacity :: Maybe Int
maxTotalPrice :: Maybe Text
capacityReservationOptions :: Maybe CapacityReservationOptions
allocationStrategy :: Maybe FleetOnDemandAllocationStrategy
$sel:singleInstanceType:OnDemandOptions' :: OnDemandOptions -> Maybe Bool
$sel:singleAvailabilityZone:OnDemandOptions' :: OnDemandOptions -> Maybe Bool
$sel:minTargetCapacity:OnDemandOptions' :: OnDemandOptions -> Maybe Int
$sel:maxTotalPrice:OnDemandOptions' :: OnDemandOptions -> Maybe Text
$sel:capacityReservationOptions:OnDemandOptions' :: OnDemandOptions -> Maybe CapacityReservationOptions
$sel:allocationStrategy:OnDemandOptions' :: OnDemandOptions -> Maybe FleetOnDemandAllocationStrategy
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe FleetOnDemandAllocationStrategy
allocationStrategy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe CapacityReservationOptions
capacityReservationOptions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
maxTotalPrice
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
minTargetCapacity
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
singleAvailabilityZone
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
singleInstanceType