{-# 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.AutoScaling.Types.InstancesDistribution
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AutoScaling.Types.InstancesDistribution where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes an instances distribution for an Auto Scaling group with a
-- MixedInstancesPolicy.
--
-- The instances distribution specifies the distribution of On-Demand
-- Instances and Spot Instances, the maximum price to pay for Spot
-- Instances, and how the Auto Scaling group allocates instance types to
-- fulfill On-Demand and Spot capacities.
--
-- When you modify @SpotAllocationStrategy@, @SpotInstancePools@, or
-- @SpotMaxPrice@ in the UpdateAutoScalingGroup API call, this update
-- action does not deploy any changes across the running Amazon EC2
-- instances in the group. Your existing Spot Instances continue to run as
-- long as the maximum price for those instances is higher than the current
-- Spot price. When scale out occurs, Amazon EC2 Auto Scaling launches
-- instances based on the new settings. When scale in occurs, Amazon EC2
-- Auto Scaling terminates instances according to the group\'s termination
-- policies.
--
-- /See:/ 'newInstancesDistribution' smart constructor.
data InstancesDistribution = InstancesDistribution'
  { -- | Indicates how to allocate instances across Spot Instance pools.
    --
    -- If the allocation strategy is @lowest-price@, the Auto Scaling group
    -- launches instances using the Spot pools with the lowest price, and
    -- evenly allocates your instances across the number of Spot pools that you
    -- specify. Defaults to @lowest-price@ if not specified.
    --
    -- If the allocation strategy is @capacity-optimized@ (recommended), the
    -- Auto Scaling group launches instances using Spot pools that are
    -- optimally chosen based on the available Spot capacity. Alternatively,
    -- you can use @capacity-optimized-prioritized@ and set the order of
    -- instance types in the list of launch template overrides from highest to
    -- lowest priority (from first to last in the list). Amazon EC2 Auto
    -- Scaling honors the instance type priorities on a best-effort basis but
    -- optimizes for capacity first.
    InstancesDistribution -> Maybe Text
spotAllocationStrategy :: Prelude.Maybe Prelude.Text,
    -- | The number of Spot Instance pools across which to allocate your Spot
    -- Instances. The Spot pools are determined from the different instance
    -- types in the overrides. Valid only when the Spot allocation strategy is
    -- @lowest-price@. Value must be in the range of 1 to 20. Defaults to 2 if
    -- not specified.
    InstancesDistribution -> Maybe Int
spotInstancePools :: Prelude.Maybe Prelude.Int,
    -- | The maximum price per unit hour that you are willing to pay for a Spot
    -- Instance. If you leave the value at its default (empty), Amazon EC2 Auto
    -- Scaling uses the On-Demand price as the maximum Spot price. To remove a
    -- value that you previously set, include the property but specify an empty
    -- string (\"\") for the value.
    InstancesDistribution -> Maybe Text
spotMaxPrice :: Prelude.Maybe Prelude.Text,
    -- | The minimum amount of the Auto Scaling group\'s capacity that must be
    -- fulfilled by On-Demand Instances. This base portion is provisioned first
    -- as your group scales. Defaults to 0 if not specified. If you specify
    -- weights for the instance types in the overrides, set the value of
    -- @OnDemandBaseCapacity@ in terms of the number of capacity units, and not
    -- the number of instances.
    InstancesDistribution -> Maybe Int
onDemandBaseCapacity :: Prelude.Maybe Prelude.Int,
    -- | Indicates how to allocate instance types to fulfill On-Demand capacity.
    -- The only valid value is @prioritized@, which is also the default value.
    -- This strategy uses the order of instance types in the
    -- @LaunchTemplateOverrides@ to define the launch priority of each instance
    -- type. The first instance type in the array is prioritized higher than
    -- the last. If all your On-Demand capacity cannot be fulfilled using your
    -- highest priority instance, then the Auto Scaling groups launches the
    -- remaining capacity using the second priority instance type, and so on.
    InstancesDistribution -> Maybe Text
onDemandAllocationStrategy :: Prelude.Maybe Prelude.Text,
    -- | Controls the percentages of On-Demand Instances and Spot Instances for
    -- your additional capacity beyond @OnDemandBaseCapacity@. Expressed as a
    -- number (for example, 20 specifies 20% On-Demand Instances, 80% Spot
    -- Instances). Defaults to 100 if not specified. If set to 100, only
    -- On-Demand Instances are provisioned.
    InstancesDistribution -> Maybe Int
onDemandPercentageAboveBaseCapacity :: Prelude.Maybe Prelude.Int
  }
  deriving (InstancesDistribution -> InstancesDistribution -> Bool
(InstancesDistribution -> InstancesDistribution -> Bool)
-> (InstancesDistribution -> InstancesDistribution -> Bool)
-> Eq InstancesDistribution
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstancesDistribution -> InstancesDistribution -> Bool
$c/= :: InstancesDistribution -> InstancesDistribution -> Bool
== :: InstancesDistribution -> InstancesDistribution -> Bool
$c== :: InstancesDistribution -> InstancesDistribution -> Bool
Prelude.Eq, ReadPrec [InstancesDistribution]
ReadPrec InstancesDistribution
Int -> ReadS InstancesDistribution
ReadS [InstancesDistribution]
(Int -> ReadS InstancesDistribution)
-> ReadS [InstancesDistribution]
-> ReadPrec InstancesDistribution
-> ReadPrec [InstancesDistribution]
-> Read InstancesDistribution
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstancesDistribution]
$creadListPrec :: ReadPrec [InstancesDistribution]
readPrec :: ReadPrec InstancesDistribution
$creadPrec :: ReadPrec InstancesDistribution
readList :: ReadS [InstancesDistribution]
$creadList :: ReadS [InstancesDistribution]
readsPrec :: Int -> ReadS InstancesDistribution
$creadsPrec :: Int -> ReadS InstancesDistribution
Prelude.Read, Int -> InstancesDistribution -> ShowS
[InstancesDistribution] -> ShowS
InstancesDistribution -> String
(Int -> InstancesDistribution -> ShowS)
-> (InstancesDistribution -> String)
-> ([InstancesDistribution] -> ShowS)
-> Show InstancesDistribution
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstancesDistribution] -> ShowS
$cshowList :: [InstancesDistribution] -> ShowS
show :: InstancesDistribution -> String
$cshow :: InstancesDistribution -> String
showsPrec :: Int -> InstancesDistribution -> ShowS
$cshowsPrec :: Int -> InstancesDistribution -> ShowS
Prelude.Show, (forall x. InstancesDistribution -> Rep InstancesDistribution x)
-> (forall x. Rep InstancesDistribution x -> InstancesDistribution)
-> Generic InstancesDistribution
forall x. Rep InstancesDistribution x -> InstancesDistribution
forall x. InstancesDistribution -> Rep InstancesDistribution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstancesDistribution x -> InstancesDistribution
$cfrom :: forall x. InstancesDistribution -> Rep InstancesDistribution x
Prelude.Generic)

-- |
-- Create a value of 'InstancesDistribution' 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:
--
-- 'spotAllocationStrategy', 'instancesDistribution_spotAllocationStrategy' - Indicates how to allocate instances across Spot Instance pools.
--
-- If the allocation strategy is @lowest-price@, the Auto Scaling group
-- launches instances using the Spot pools with the lowest price, and
-- evenly allocates your instances across the number of Spot pools that you
-- specify. Defaults to @lowest-price@ if not specified.
--
-- If the allocation strategy is @capacity-optimized@ (recommended), the
-- Auto Scaling group launches instances using Spot pools that are
-- optimally chosen based on the available Spot capacity. Alternatively,
-- you can use @capacity-optimized-prioritized@ and set the order of
-- instance types in the list of launch template overrides from highest to
-- lowest priority (from first to last in the list). Amazon EC2 Auto
-- Scaling honors the instance type priorities on a best-effort basis but
-- optimizes for capacity first.
--
-- 'spotInstancePools', 'instancesDistribution_spotInstancePools' - The number of Spot Instance pools across which to allocate your Spot
-- Instances. The Spot pools are determined from the different instance
-- types in the overrides. Valid only when the Spot allocation strategy is
-- @lowest-price@. Value must be in the range of 1 to 20. Defaults to 2 if
-- not specified.
--
-- 'spotMaxPrice', 'instancesDistribution_spotMaxPrice' - The maximum price per unit hour that you are willing to pay for a Spot
-- Instance. If you leave the value at its default (empty), Amazon EC2 Auto
-- Scaling uses the On-Demand price as the maximum Spot price. To remove a
-- value that you previously set, include the property but specify an empty
-- string (\"\") for the value.
--
-- 'onDemandBaseCapacity', 'instancesDistribution_onDemandBaseCapacity' - The minimum amount of the Auto Scaling group\'s capacity that must be
-- fulfilled by On-Demand Instances. This base portion is provisioned first
-- as your group scales. Defaults to 0 if not specified. If you specify
-- weights for the instance types in the overrides, set the value of
-- @OnDemandBaseCapacity@ in terms of the number of capacity units, and not
-- the number of instances.
--
-- 'onDemandAllocationStrategy', 'instancesDistribution_onDemandAllocationStrategy' - Indicates how to allocate instance types to fulfill On-Demand capacity.
-- The only valid value is @prioritized@, which is also the default value.
-- This strategy uses the order of instance types in the
-- @LaunchTemplateOverrides@ to define the launch priority of each instance
-- type. The first instance type in the array is prioritized higher than
-- the last. If all your On-Demand capacity cannot be fulfilled using your
-- highest priority instance, then the Auto Scaling groups launches the
-- remaining capacity using the second priority instance type, and so on.
--
-- 'onDemandPercentageAboveBaseCapacity', 'instancesDistribution_onDemandPercentageAboveBaseCapacity' - Controls the percentages of On-Demand Instances and Spot Instances for
-- your additional capacity beyond @OnDemandBaseCapacity@. Expressed as a
-- number (for example, 20 specifies 20% On-Demand Instances, 80% Spot
-- Instances). Defaults to 100 if not specified. If set to 100, only
-- On-Demand Instances are provisioned.
newInstancesDistribution ::
  InstancesDistribution
newInstancesDistribution :: InstancesDistribution
newInstancesDistribution =
  InstancesDistribution' :: Maybe Text
-> Maybe Int
-> Maybe Text
-> Maybe Int
-> Maybe Text
-> Maybe Int
-> InstancesDistribution
InstancesDistribution'
    { $sel:spotAllocationStrategy:InstancesDistribution' :: Maybe Text
spotAllocationStrategy =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:spotInstancePools:InstancesDistribution' :: Maybe Int
spotInstancePools = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:spotMaxPrice:InstancesDistribution' :: Maybe Text
spotMaxPrice = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:onDemandBaseCapacity:InstancesDistribution' :: Maybe Int
onDemandBaseCapacity = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:onDemandAllocationStrategy:InstancesDistribution' :: Maybe Text
onDemandAllocationStrategy = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:onDemandPercentageAboveBaseCapacity:InstancesDistribution' :: Maybe Int
onDemandPercentageAboveBaseCapacity =
        Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates how to allocate instances across Spot Instance pools.
--
-- If the allocation strategy is @lowest-price@, the Auto Scaling group
-- launches instances using the Spot pools with the lowest price, and
-- evenly allocates your instances across the number of Spot pools that you
-- specify. Defaults to @lowest-price@ if not specified.
--
-- If the allocation strategy is @capacity-optimized@ (recommended), the
-- Auto Scaling group launches instances using Spot pools that are
-- optimally chosen based on the available Spot capacity. Alternatively,
-- you can use @capacity-optimized-prioritized@ and set the order of
-- instance types in the list of launch template overrides from highest to
-- lowest priority (from first to last in the list). Amazon EC2 Auto
-- Scaling honors the instance type priorities on a best-effort basis but
-- optimizes for capacity first.
instancesDistribution_spotAllocationStrategy :: Lens.Lens' InstancesDistribution (Prelude.Maybe Prelude.Text)
instancesDistribution_spotAllocationStrategy :: (Maybe Text -> f (Maybe Text))
-> InstancesDistribution -> f InstancesDistribution
instancesDistribution_spotAllocationStrategy = (InstancesDistribution -> Maybe Text)
-> (InstancesDistribution -> Maybe Text -> InstancesDistribution)
-> Lens
     InstancesDistribution
     InstancesDistribution
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstancesDistribution' {Maybe Text
spotAllocationStrategy :: Maybe Text
$sel:spotAllocationStrategy:InstancesDistribution' :: InstancesDistribution -> Maybe Text
spotAllocationStrategy} -> Maybe Text
spotAllocationStrategy) (\s :: InstancesDistribution
s@InstancesDistribution' {} Maybe Text
a -> InstancesDistribution
s {$sel:spotAllocationStrategy:InstancesDistribution' :: Maybe Text
spotAllocationStrategy = Maybe Text
a} :: InstancesDistribution)

-- | The number of Spot Instance pools across which to allocate your Spot
-- Instances. The Spot pools are determined from the different instance
-- types in the overrides. Valid only when the Spot allocation strategy is
-- @lowest-price@. Value must be in the range of 1 to 20. Defaults to 2 if
-- not specified.
instancesDistribution_spotInstancePools :: Lens.Lens' InstancesDistribution (Prelude.Maybe Prelude.Int)
instancesDistribution_spotInstancePools :: (Maybe Int -> f (Maybe Int))
-> InstancesDistribution -> f InstancesDistribution
instancesDistribution_spotInstancePools = (InstancesDistribution -> Maybe Int)
-> (InstancesDistribution -> Maybe Int -> InstancesDistribution)
-> Lens
     InstancesDistribution InstancesDistribution (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstancesDistribution' {Maybe Int
spotInstancePools :: Maybe Int
$sel:spotInstancePools:InstancesDistribution' :: InstancesDistribution -> Maybe Int
spotInstancePools} -> Maybe Int
spotInstancePools) (\s :: InstancesDistribution
s@InstancesDistribution' {} Maybe Int
a -> InstancesDistribution
s {$sel:spotInstancePools:InstancesDistribution' :: Maybe Int
spotInstancePools = Maybe Int
a} :: InstancesDistribution)

-- | The maximum price per unit hour that you are willing to pay for a Spot
-- Instance. If you leave the value at its default (empty), Amazon EC2 Auto
-- Scaling uses the On-Demand price as the maximum Spot price. To remove a
-- value that you previously set, include the property but specify an empty
-- string (\"\") for the value.
instancesDistribution_spotMaxPrice :: Lens.Lens' InstancesDistribution (Prelude.Maybe Prelude.Text)
instancesDistribution_spotMaxPrice :: (Maybe Text -> f (Maybe Text))
-> InstancesDistribution -> f InstancesDistribution
instancesDistribution_spotMaxPrice = (InstancesDistribution -> Maybe Text)
-> (InstancesDistribution -> Maybe Text -> InstancesDistribution)
-> Lens
     InstancesDistribution
     InstancesDistribution
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstancesDistribution' {Maybe Text
spotMaxPrice :: Maybe Text
$sel:spotMaxPrice:InstancesDistribution' :: InstancesDistribution -> Maybe Text
spotMaxPrice} -> Maybe Text
spotMaxPrice) (\s :: InstancesDistribution
s@InstancesDistribution' {} Maybe Text
a -> InstancesDistribution
s {$sel:spotMaxPrice:InstancesDistribution' :: Maybe Text
spotMaxPrice = Maybe Text
a} :: InstancesDistribution)

-- | The minimum amount of the Auto Scaling group\'s capacity that must be
-- fulfilled by On-Demand Instances. This base portion is provisioned first
-- as your group scales. Defaults to 0 if not specified. If you specify
-- weights for the instance types in the overrides, set the value of
-- @OnDemandBaseCapacity@ in terms of the number of capacity units, and not
-- the number of instances.
instancesDistribution_onDemandBaseCapacity :: Lens.Lens' InstancesDistribution (Prelude.Maybe Prelude.Int)
instancesDistribution_onDemandBaseCapacity :: (Maybe Int -> f (Maybe Int))
-> InstancesDistribution -> f InstancesDistribution
instancesDistribution_onDemandBaseCapacity = (InstancesDistribution -> Maybe Int)
-> (InstancesDistribution -> Maybe Int -> InstancesDistribution)
-> Lens
     InstancesDistribution InstancesDistribution (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstancesDistribution' {Maybe Int
onDemandBaseCapacity :: Maybe Int
$sel:onDemandBaseCapacity:InstancesDistribution' :: InstancesDistribution -> Maybe Int
onDemandBaseCapacity} -> Maybe Int
onDemandBaseCapacity) (\s :: InstancesDistribution
s@InstancesDistribution' {} Maybe Int
a -> InstancesDistribution
s {$sel:onDemandBaseCapacity:InstancesDistribution' :: Maybe Int
onDemandBaseCapacity = Maybe Int
a} :: InstancesDistribution)

-- | Indicates how to allocate instance types to fulfill On-Demand capacity.
-- The only valid value is @prioritized@, which is also the default value.
-- This strategy uses the order of instance types in the
-- @LaunchTemplateOverrides@ to define the launch priority of each instance
-- type. The first instance type in the array is prioritized higher than
-- the last. If all your On-Demand capacity cannot be fulfilled using your
-- highest priority instance, then the Auto Scaling groups launches the
-- remaining capacity using the second priority instance type, and so on.
instancesDistribution_onDemandAllocationStrategy :: Lens.Lens' InstancesDistribution (Prelude.Maybe Prelude.Text)
instancesDistribution_onDemandAllocationStrategy :: (Maybe Text -> f (Maybe Text))
-> InstancesDistribution -> f InstancesDistribution
instancesDistribution_onDemandAllocationStrategy = (InstancesDistribution -> Maybe Text)
-> (InstancesDistribution -> Maybe Text -> InstancesDistribution)
-> Lens
     InstancesDistribution
     InstancesDistribution
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstancesDistribution' {Maybe Text
onDemandAllocationStrategy :: Maybe Text
$sel:onDemandAllocationStrategy:InstancesDistribution' :: InstancesDistribution -> Maybe Text
onDemandAllocationStrategy} -> Maybe Text
onDemandAllocationStrategy) (\s :: InstancesDistribution
s@InstancesDistribution' {} Maybe Text
a -> InstancesDistribution
s {$sel:onDemandAllocationStrategy:InstancesDistribution' :: Maybe Text
onDemandAllocationStrategy = Maybe Text
a} :: InstancesDistribution)

-- | Controls the percentages of On-Demand Instances and Spot Instances for
-- your additional capacity beyond @OnDemandBaseCapacity@. Expressed as a
-- number (for example, 20 specifies 20% On-Demand Instances, 80% Spot
-- Instances). Defaults to 100 if not specified. If set to 100, only
-- On-Demand Instances are provisioned.
instancesDistribution_onDemandPercentageAboveBaseCapacity :: Lens.Lens' InstancesDistribution (Prelude.Maybe Prelude.Int)
instancesDistribution_onDemandPercentageAboveBaseCapacity :: (Maybe Int -> f (Maybe Int))
-> InstancesDistribution -> f InstancesDistribution
instancesDistribution_onDemandPercentageAboveBaseCapacity = (InstancesDistribution -> Maybe Int)
-> (InstancesDistribution -> Maybe Int -> InstancesDistribution)
-> Lens
     InstancesDistribution InstancesDistribution (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstancesDistribution' {Maybe Int
onDemandPercentageAboveBaseCapacity :: Maybe Int
$sel:onDemandPercentageAboveBaseCapacity:InstancesDistribution' :: InstancesDistribution -> Maybe Int
onDemandPercentageAboveBaseCapacity} -> Maybe Int
onDemandPercentageAboveBaseCapacity) (\s :: InstancesDistribution
s@InstancesDistribution' {} Maybe Int
a -> InstancesDistribution
s {$sel:onDemandPercentageAboveBaseCapacity:InstancesDistribution' :: Maybe Int
onDemandPercentageAboveBaseCapacity = Maybe Int
a} :: InstancesDistribution)

instance Core.FromXML InstancesDistribution where
  parseXML :: [Node] -> Either String InstancesDistribution
parseXML [Node]
x =
    Maybe Text
-> Maybe Int
-> Maybe Text
-> Maybe Int
-> Maybe Text
-> Maybe Int
-> InstancesDistribution
InstancesDistribution'
      (Maybe Text
 -> Maybe Int
 -> Maybe Text
 -> Maybe Int
 -> Maybe Text
 -> Maybe Int
 -> InstancesDistribution)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Int
      -> Maybe Text
      -> Maybe Int
      -> Maybe Text
      -> Maybe Int
      -> InstancesDistribution)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SpotAllocationStrategy")
      Either
  String
  (Maybe Int
   -> Maybe Text
   -> Maybe Int
   -> Maybe Text
   -> Maybe Int
   -> InstancesDistribution)
-> Either String (Maybe Int)
-> Either
     String
     (Maybe Text
      -> Maybe Int -> Maybe Text -> Maybe Int -> InstancesDistribution)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Int)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SpotInstancePools")
      Either
  String
  (Maybe Text
   -> Maybe Int -> Maybe Text -> Maybe Int -> InstancesDistribution)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Int -> Maybe Text -> Maybe Int -> InstancesDistribution)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SpotMaxPrice")
      Either
  String
  (Maybe Int -> Maybe Text -> Maybe Int -> InstancesDistribution)
-> Either String (Maybe Int)
-> Either String (Maybe Text -> Maybe Int -> InstancesDistribution)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Int)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"OnDemandBaseCapacity")
      Either String (Maybe Text -> Maybe Int -> InstancesDistribution)
-> Either String (Maybe Text)
-> Either String (Maybe Int -> InstancesDistribution)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"OnDemandAllocationStrategy")
      Either String (Maybe Int -> InstancesDistribution)
-> Either String (Maybe Int) -> Either String InstancesDistribution
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Int)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"OnDemandPercentageAboveBaseCapacity")

instance Prelude.Hashable InstancesDistribution

instance Prelude.NFData InstancesDistribution

instance Core.ToQuery InstancesDistribution where
  toQuery :: InstancesDistribution -> QueryString
toQuery InstancesDistribution' {Maybe Int
Maybe Text
onDemandPercentageAboveBaseCapacity :: Maybe Int
onDemandAllocationStrategy :: Maybe Text
onDemandBaseCapacity :: Maybe Int
spotMaxPrice :: Maybe Text
spotInstancePools :: Maybe Int
spotAllocationStrategy :: Maybe Text
$sel:onDemandPercentageAboveBaseCapacity:InstancesDistribution' :: InstancesDistribution -> Maybe Int
$sel:onDemandAllocationStrategy:InstancesDistribution' :: InstancesDistribution -> Maybe Text
$sel:onDemandBaseCapacity:InstancesDistribution' :: InstancesDistribution -> Maybe Int
$sel:spotMaxPrice:InstancesDistribution' :: InstancesDistribution -> Maybe Text
$sel:spotInstancePools:InstancesDistribution' :: InstancesDistribution -> Maybe Int
$sel:spotAllocationStrategy:InstancesDistribution' :: InstancesDistribution -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"SpotAllocationStrategy"
          ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
spotAllocationStrategy,
        ByteString
"SpotInstancePools" ByteString -> Maybe Int -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Int
spotInstancePools,
        ByteString
"SpotMaxPrice" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
spotMaxPrice,
        ByteString
"OnDemandBaseCapacity" ByteString -> Maybe Int -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Int
onDemandBaseCapacity,
        ByteString
"OnDemandAllocationStrategy"
          ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
onDemandAllocationStrategy,
        ByteString
"OnDemandPercentageAboveBaseCapacity"
          ByteString -> Maybe Int -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Int
onDemandPercentageAboveBaseCapacity
      ]