{-# 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.PredictiveScalingConfiguration
-- 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.PredictiveScalingConfiguration where

import Amazonka.AutoScaling.Types.PredictiveScalingMaxCapacityBreachBehavior
import Amazonka.AutoScaling.Types.PredictiveScalingMetricSpecification
import Amazonka.AutoScaling.Types.PredictiveScalingMode
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents a predictive scaling policy configuration to use with Amazon
-- EC2 Auto Scaling.
--
-- /See:/ 'newPredictiveScalingConfiguration' smart constructor.
data PredictiveScalingConfiguration = PredictiveScalingConfiguration'
  { -- | The amount of time, in seconds, by which the instance launch time can be
    -- advanced. For example, the forecast says to add capacity at 10:00 AM,
    -- and you choose to pre-launch instances by 5 minutes. In that case, the
    -- instances will be launched at 9:55 AM. The intention is to give
    -- resources time to be provisioned. It can take a few minutes to launch an
    -- EC2 instance. The actual amount of time required depends on several
    -- factors, such as the size of the instance and whether there are startup
    -- scripts to complete.
    --
    -- The value must be less than the forecast interval duration of 3600
    -- seconds (60 minutes). Defaults to 300 seconds if not specified.
    PredictiveScalingConfiguration -> Maybe Natural
schedulingBufferTime :: Prelude.Maybe Prelude.Natural,
    -- | The size of the capacity buffer to use when the forecast capacity is
    -- close to or exceeds the maximum capacity. The value is specified as a
    -- percentage relative to the forecast capacity. For example, if the buffer
    -- is 10, this means a 10 percent buffer, such that if the forecast
    -- capacity is 50, and the maximum capacity is 40, then the effective
    -- maximum capacity is 55.
    --
    -- If set to 0, Amazon EC2 Auto Scaling may scale capacity higher than the
    -- maximum capacity to equal but not exceed forecast capacity.
    --
    -- Required if the @MaxCapacityBreachBehavior@ property is set to
    -- @IncreaseMaxCapacity@, and cannot be used otherwise.
    PredictiveScalingConfiguration -> Maybe Natural
maxCapacityBuffer :: Prelude.Maybe Prelude.Natural,
    -- | The predictive scaling mode. Defaults to @ForecastOnly@ if not
    -- specified.
    PredictiveScalingConfiguration -> Maybe PredictiveScalingMode
mode :: Prelude.Maybe PredictiveScalingMode,
    -- | Defines the behavior that should be applied if the forecast capacity
    -- approaches or exceeds the maximum capacity of the Auto Scaling group.
    -- Defaults to @HonorMaxCapacity@ if not specified.
    --
    -- The following are possible values:
    --
    -- -   @HonorMaxCapacity@ - Amazon EC2 Auto Scaling cannot scale out
    --     capacity higher than the maximum capacity. The maximum capacity is
    --     enforced as a hard limit.
    --
    -- -   @IncreaseMaxCapacity@ - Amazon EC2 Auto Scaling can scale out
    --     capacity higher than the maximum capacity when the forecast capacity
    --     is close to or exceeds the maximum capacity. The upper limit is
    --     determined by the forecasted capacity and the value for
    --     @MaxCapacityBuffer@.
    PredictiveScalingConfiguration
-> Maybe PredictiveScalingMaxCapacityBreachBehavior
maxCapacityBreachBehavior :: Prelude.Maybe PredictiveScalingMaxCapacityBreachBehavior,
    -- | This structure includes the metrics and target utilization to use for
    -- predictive scaling.
    --
    -- This is an array, but we currently only support a single metric
    -- specification. That is, you can specify a target value and a single
    -- metric pair, or a target value and one scaling metric and one load
    -- metric.
    PredictiveScalingConfiguration
-> [PredictiveScalingMetricSpecification]
metricSpecifications :: [PredictiveScalingMetricSpecification]
  }
  deriving (PredictiveScalingConfiguration
-> PredictiveScalingConfiguration -> Bool
(PredictiveScalingConfiguration
 -> PredictiveScalingConfiguration -> Bool)
-> (PredictiveScalingConfiguration
    -> PredictiveScalingConfiguration -> Bool)
-> Eq PredictiveScalingConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PredictiveScalingConfiguration
-> PredictiveScalingConfiguration -> Bool
$c/= :: PredictiveScalingConfiguration
-> PredictiveScalingConfiguration -> Bool
== :: PredictiveScalingConfiguration
-> PredictiveScalingConfiguration -> Bool
$c== :: PredictiveScalingConfiguration
-> PredictiveScalingConfiguration -> Bool
Prelude.Eq, ReadPrec [PredictiveScalingConfiguration]
ReadPrec PredictiveScalingConfiguration
Int -> ReadS PredictiveScalingConfiguration
ReadS [PredictiveScalingConfiguration]
(Int -> ReadS PredictiveScalingConfiguration)
-> ReadS [PredictiveScalingConfiguration]
-> ReadPrec PredictiveScalingConfiguration
-> ReadPrec [PredictiveScalingConfiguration]
-> Read PredictiveScalingConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PredictiveScalingConfiguration]
$creadListPrec :: ReadPrec [PredictiveScalingConfiguration]
readPrec :: ReadPrec PredictiveScalingConfiguration
$creadPrec :: ReadPrec PredictiveScalingConfiguration
readList :: ReadS [PredictiveScalingConfiguration]
$creadList :: ReadS [PredictiveScalingConfiguration]
readsPrec :: Int -> ReadS PredictiveScalingConfiguration
$creadsPrec :: Int -> ReadS PredictiveScalingConfiguration
Prelude.Read, Int -> PredictiveScalingConfiguration -> ShowS
[PredictiveScalingConfiguration] -> ShowS
PredictiveScalingConfiguration -> String
(Int -> PredictiveScalingConfiguration -> ShowS)
-> (PredictiveScalingConfiguration -> String)
-> ([PredictiveScalingConfiguration] -> ShowS)
-> Show PredictiveScalingConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PredictiveScalingConfiguration] -> ShowS
$cshowList :: [PredictiveScalingConfiguration] -> ShowS
show :: PredictiveScalingConfiguration -> String
$cshow :: PredictiveScalingConfiguration -> String
showsPrec :: Int -> PredictiveScalingConfiguration -> ShowS
$cshowsPrec :: Int -> PredictiveScalingConfiguration -> ShowS
Prelude.Show, (forall x.
 PredictiveScalingConfiguration
 -> Rep PredictiveScalingConfiguration x)
-> (forall x.
    Rep PredictiveScalingConfiguration x
    -> PredictiveScalingConfiguration)
-> Generic PredictiveScalingConfiguration
forall x.
Rep PredictiveScalingConfiguration x
-> PredictiveScalingConfiguration
forall x.
PredictiveScalingConfiguration
-> Rep PredictiveScalingConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PredictiveScalingConfiguration x
-> PredictiveScalingConfiguration
$cfrom :: forall x.
PredictiveScalingConfiguration
-> Rep PredictiveScalingConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'PredictiveScalingConfiguration' 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:
--
-- 'schedulingBufferTime', 'predictiveScalingConfiguration_schedulingBufferTime' - The amount of time, in seconds, by which the instance launch time can be
-- advanced. For example, the forecast says to add capacity at 10:00 AM,
-- and you choose to pre-launch instances by 5 minutes. In that case, the
-- instances will be launched at 9:55 AM. The intention is to give
-- resources time to be provisioned. It can take a few minutes to launch an
-- EC2 instance. The actual amount of time required depends on several
-- factors, such as the size of the instance and whether there are startup
-- scripts to complete.
--
-- The value must be less than the forecast interval duration of 3600
-- seconds (60 minutes). Defaults to 300 seconds if not specified.
--
-- 'maxCapacityBuffer', 'predictiveScalingConfiguration_maxCapacityBuffer' - The size of the capacity buffer to use when the forecast capacity is
-- close to or exceeds the maximum capacity. The value is specified as a
-- percentage relative to the forecast capacity. For example, if the buffer
-- is 10, this means a 10 percent buffer, such that if the forecast
-- capacity is 50, and the maximum capacity is 40, then the effective
-- maximum capacity is 55.
--
-- If set to 0, Amazon EC2 Auto Scaling may scale capacity higher than the
-- maximum capacity to equal but not exceed forecast capacity.
--
-- Required if the @MaxCapacityBreachBehavior@ property is set to
-- @IncreaseMaxCapacity@, and cannot be used otherwise.
--
-- 'mode', 'predictiveScalingConfiguration_mode' - The predictive scaling mode. Defaults to @ForecastOnly@ if not
-- specified.
--
-- 'maxCapacityBreachBehavior', 'predictiveScalingConfiguration_maxCapacityBreachBehavior' - Defines the behavior that should be applied if the forecast capacity
-- approaches or exceeds the maximum capacity of the Auto Scaling group.
-- Defaults to @HonorMaxCapacity@ if not specified.
--
-- The following are possible values:
--
-- -   @HonorMaxCapacity@ - Amazon EC2 Auto Scaling cannot scale out
--     capacity higher than the maximum capacity. The maximum capacity is
--     enforced as a hard limit.
--
-- -   @IncreaseMaxCapacity@ - Amazon EC2 Auto Scaling can scale out
--     capacity higher than the maximum capacity when the forecast capacity
--     is close to or exceeds the maximum capacity. The upper limit is
--     determined by the forecasted capacity and the value for
--     @MaxCapacityBuffer@.
--
-- 'metricSpecifications', 'predictiveScalingConfiguration_metricSpecifications' - This structure includes the metrics and target utilization to use for
-- predictive scaling.
--
-- This is an array, but we currently only support a single metric
-- specification. That is, you can specify a target value and a single
-- metric pair, or a target value and one scaling metric and one load
-- metric.
newPredictiveScalingConfiguration ::
  PredictiveScalingConfiguration
newPredictiveScalingConfiguration :: PredictiveScalingConfiguration
newPredictiveScalingConfiguration =
  PredictiveScalingConfiguration' :: Maybe Natural
-> Maybe Natural
-> Maybe PredictiveScalingMode
-> Maybe PredictiveScalingMaxCapacityBreachBehavior
-> [PredictiveScalingMetricSpecification]
-> PredictiveScalingConfiguration
PredictiveScalingConfiguration'
    { $sel:schedulingBufferTime:PredictiveScalingConfiguration' :: Maybe Natural
schedulingBufferTime =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:maxCapacityBuffer:PredictiveScalingConfiguration' :: Maybe Natural
maxCapacityBuffer = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:mode:PredictiveScalingConfiguration' :: Maybe PredictiveScalingMode
mode = Maybe PredictiveScalingMode
forall a. Maybe a
Prelude.Nothing,
      $sel:maxCapacityBreachBehavior:PredictiveScalingConfiguration' :: Maybe PredictiveScalingMaxCapacityBreachBehavior
maxCapacityBreachBehavior = Maybe PredictiveScalingMaxCapacityBreachBehavior
forall a. Maybe a
Prelude.Nothing,
      $sel:metricSpecifications:PredictiveScalingConfiguration' :: [PredictiveScalingMetricSpecification]
metricSpecifications = [PredictiveScalingMetricSpecification]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The amount of time, in seconds, by which the instance launch time can be
-- advanced. For example, the forecast says to add capacity at 10:00 AM,
-- and you choose to pre-launch instances by 5 minutes. In that case, the
-- instances will be launched at 9:55 AM. The intention is to give
-- resources time to be provisioned. It can take a few minutes to launch an
-- EC2 instance. The actual amount of time required depends on several
-- factors, such as the size of the instance and whether there are startup
-- scripts to complete.
--
-- The value must be less than the forecast interval duration of 3600
-- seconds (60 minutes). Defaults to 300 seconds if not specified.
predictiveScalingConfiguration_schedulingBufferTime :: Lens.Lens' PredictiveScalingConfiguration (Prelude.Maybe Prelude.Natural)
predictiveScalingConfiguration_schedulingBufferTime :: (Maybe Natural -> f (Maybe Natural))
-> PredictiveScalingConfiguration
-> f PredictiveScalingConfiguration
predictiveScalingConfiguration_schedulingBufferTime = (PredictiveScalingConfiguration -> Maybe Natural)
-> (PredictiveScalingConfiguration
    -> Maybe Natural -> PredictiveScalingConfiguration)
-> Lens
     PredictiveScalingConfiguration
     PredictiveScalingConfiguration
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PredictiveScalingConfiguration' {Maybe Natural
schedulingBufferTime :: Maybe Natural
$sel:schedulingBufferTime:PredictiveScalingConfiguration' :: PredictiveScalingConfiguration -> Maybe Natural
schedulingBufferTime} -> Maybe Natural
schedulingBufferTime) (\s :: PredictiveScalingConfiguration
s@PredictiveScalingConfiguration' {} Maybe Natural
a -> PredictiveScalingConfiguration
s {$sel:schedulingBufferTime:PredictiveScalingConfiguration' :: Maybe Natural
schedulingBufferTime = Maybe Natural
a} :: PredictiveScalingConfiguration)

-- | The size of the capacity buffer to use when the forecast capacity is
-- close to or exceeds the maximum capacity. The value is specified as a
-- percentage relative to the forecast capacity. For example, if the buffer
-- is 10, this means a 10 percent buffer, such that if the forecast
-- capacity is 50, and the maximum capacity is 40, then the effective
-- maximum capacity is 55.
--
-- If set to 0, Amazon EC2 Auto Scaling may scale capacity higher than the
-- maximum capacity to equal but not exceed forecast capacity.
--
-- Required if the @MaxCapacityBreachBehavior@ property is set to
-- @IncreaseMaxCapacity@, and cannot be used otherwise.
predictiveScalingConfiguration_maxCapacityBuffer :: Lens.Lens' PredictiveScalingConfiguration (Prelude.Maybe Prelude.Natural)
predictiveScalingConfiguration_maxCapacityBuffer :: (Maybe Natural -> f (Maybe Natural))
-> PredictiveScalingConfiguration
-> f PredictiveScalingConfiguration
predictiveScalingConfiguration_maxCapacityBuffer = (PredictiveScalingConfiguration -> Maybe Natural)
-> (PredictiveScalingConfiguration
    -> Maybe Natural -> PredictiveScalingConfiguration)
-> Lens
     PredictiveScalingConfiguration
     PredictiveScalingConfiguration
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PredictiveScalingConfiguration' {Maybe Natural
maxCapacityBuffer :: Maybe Natural
$sel:maxCapacityBuffer:PredictiveScalingConfiguration' :: PredictiveScalingConfiguration -> Maybe Natural
maxCapacityBuffer} -> Maybe Natural
maxCapacityBuffer) (\s :: PredictiveScalingConfiguration
s@PredictiveScalingConfiguration' {} Maybe Natural
a -> PredictiveScalingConfiguration
s {$sel:maxCapacityBuffer:PredictiveScalingConfiguration' :: Maybe Natural
maxCapacityBuffer = Maybe Natural
a} :: PredictiveScalingConfiguration)

-- | The predictive scaling mode. Defaults to @ForecastOnly@ if not
-- specified.
predictiveScalingConfiguration_mode :: Lens.Lens' PredictiveScalingConfiguration (Prelude.Maybe PredictiveScalingMode)
predictiveScalingConfiguration_mode :: (Maybe PredictiveScalingMode -> f (Maybe PredictiveScalingMode))
-> PredictiveScalingConfiguration
-> f PredictiveScalingConfiguration
predictiveScalingConfiguration_mode = (PredictiveScalingConfiguration -> Maybe PredictiveScalingMode)
-> (PredictiveScalingConfiguration
    -> Maybe PredictiveScalingMode -> PredictiveScalingConfiguration)
-> Lens
     PredictiveScalingConfiguration
     PredictiveScalingConfiguration
     (Maybe PredictiveScalingMode)
     (Maybe PredictiveScalingMode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PredictiveScalingConfiguration' {Maybe PredictiveScalingMode
mode :: Maybe PredictiveScalingMode
$sel:mode:PredictiveScalingConfiguration' :: PredictiveScalingConfiguration -> Maybe PredictiveScalingMode
mode} -> Maybe PredictiveScalingMode
mode) (\s :: PredictiveScalingConfiguration
s@PredictiveScalingConfiguration' {} Maybe PredictiveScalingMode
a -> PredictiveScalingConfiguration
s {$sel:mode:PredictiveScalingConfiguration' :: Maybe PredictiveScalingMode
mode = Maybe PredictiveScalingMode
a} :: PredictiveScalingConfiguration)

-- | Defines the behavior that should be applied if the forecast capacity
-- approaches or exceeds the maximum capacity of the Auto Scaling group.
-- Defaults to @HonorMaxCapacity@ if not specified.
--
-- The following are possible values:
--
-- -   @HonorMaxCapacity@ - Amazon EC2 Auto Scaling cannot scale out
--     capacity higher than the maximum capacity. The maximum capacity is
--     enforced as a hard limit.
--
-- -   @IncreaseMaxCapacity@ - Amazon EC2 Auto Scaling can scale out
--     capacity higher than the maximum capacity when the forecast capacity
--     is close to or exceeds the maximum capacity. The upper limit is
--     determined by the forecasted capacity and the value for
--     @MaxCapacityBuffer@.
predictiveScalingConfiguration_maxCapacityBreachBehavior :: Lens.Lens' PredictiveScalingConfiguration (Prelude.Maybe PredictiveScalingMaxCapacityBreachBehavior)
predictiveScalingConfiguration_maxCapacityBreachBehavior :: (Maybe PredictiveScalingMaxCapacityBreachBehavior
 -> f (Maybe PredictiveScalingMaxCapacityBreachBehavior))
-> PredictiveScalingConfiguration
-> f PredictiveScalingConfiguration
predictiveScalingConfiguration_maxCapacityBreachBehavior = (PredictiveScalingConfiguration
 -> Maybe PredictiveScalingMaxCapacityBreachBehavior)
-> (PredictiveScalingConfiguration
    -> Maybe PredictiveScalingMaxCapacityBreachBehavior
    -> PredictiveScalingConfiguration)
-> Lens
     PredictiveScalingConfiguration
     PredictiveScalingConfiguration
     (Maybe PredictiveScalingMaxCapacityBreachBehavior)
     (Maybe PredictiveScalingMaxCapacityBreachBehavior)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PredictiveScalingConfiguration' {Maybe PredictiveScalingMaxCapacityBreachBehavior
maxCapacityBreachBehavior :: Maybe PredictiveScalingMaxCapacityBreachBehavior
$sel:maxCapacityBreachBehavior:PredictiveScalingConfiguration' :: PredictiveScalingConfiguration
-> Maybe PredictiveScalingMaxCapacityBreachBehavior
maxCapacityBreachBehavior} -> Maybe PredictiveScalingMaxCapacityBreachBehavior
maxCapacityBreachBehavior) (\s :: PredictiveScalingConfiguration
s@PredictiveScalingConfiguration' {} Maybe PredictiveScalingMaxCapacityBreachBehavior
a -> PredictiveScalingConfiguration
s {$sel:maxCapacityBreachBehavior:PredictiveScalingConfiguration' :: Maybe PredictiveScalingMaxCapacityBreachBehavior
maxCapacityBreachBehavior = Maybe PredictiveScalingMaxCapacityBreachBehavior
a} :: PredictiveScalingConfiguration)

-- | This structure includes the metrics and target utilization to use for
-- predictive scaling.
--
-- This is an array, but we currently only support a single metric
-- specification. That is, you can specify a target value and a single
-- metric pair, or a target value and one scaling metric and one load
-- metric.
predictiveScalingConfiguration_metricSpecifications :: Lens.Lens' PredictiveScalingConfiguration [PredictiveScalingMetricSpecification]
predictiveScalingConfiguration_metricSpecifications :: ([PredictiveScalingMetricSpecification]
 -> f [PredictiveScalingMetricSpecification])
-> PredictiveScalingConfiguration
-> f PredictiveScalingConfiguration
predictiveScalingConfiguration_metricSpecifications = (PredictiveScalingConfiguration
 -> [PredictiveScalingMetricSpecification])
-> (PredictiveScalingConfiguration
    -> [PredictiveScalingMetricSpecification]
    -> PredictiveScalingConfiguration)
-> Lens
     PredictiveScalingConfiguration
     PredictiveScalingConfiguration
     [PredictiveScalingMetricSpecification]
     [PredictiveScalingMetricSpecification]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PredictiveScalingConfiguration' {[PredictiveScalingMetricSpecification]
metricSpecifications :: [PredictiveScalingMetricSpecification]
$sel:metricSpecifications:PredictiveScalingConfiguration' :: PredictiveScalingConfiguration
-> [PredictiveScalingMetricSpecification]
metricSpecifications} -> [PredictiveScalingMetricSpecification]
metricSpecifications) (\s :: PredictiveScalingConfiguration
s@PredictiveScalingConfiguration' {} [PredictiveScalingMetricSpecification]
a -> PredictiveScalingConfiguration
s {$sel:metricSpecifications:PredictiveScalingConfiguration' :: [PredictiveScalingMetricSpecification]
metricSpecifications = [PredictiveScalingMetricSpecification]
a} :: PredictiveScalingConfiguration) (([PredictiveScalingMetricSpecification]
  -> f [PredictiveScalingMetricSpecification])
 -> PredictiveScalingConfiguration
 -> f PredictiveScalingConfiguration)
-> (([PredictiveScalingMetricSpecification]
     -> f [PredictiveScalingMetricSpecification])
    -> [PredictiveScalingMetricSpecification]
    -> f [PredictiveScalingMetricSpecification])
-> ([PredictiveScalingMetricSpecification]
    -> f [PredictiveScalingMetricSpecification])
-> PredictiveScalingConfiguration
-> f PredictiveScalingConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([PredictiveScalingMetricSpecification]
 -> f [PredictiveScalingMetricSpecification])
-> [PredictiveScalingMetricSpecification]
-> f [PredictiveScalingMetricSpecification]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromXML PredictiveScalingConfiguration where
  parseXML :: [Node] -> Either String PredictiveScalingConfiguration
parseXML [Node]
x =
    Maybe Natural
-> Maybe Natural
-> Maybe PredictiveScalingMode
-> Maybe PredictiveScalingMaxCapacityBreachBehavior
-> [PredictiveScalingMetricSpecification]
-> PredictiveScalingConfiguration
PredictiveScalingConfiguration'
      (Maybe Natural
 -> Maybe Natural
 -> Maybe PredictiveScalingMode
 -> Maybe PredictiveScalingMaxCapacityBreachBehavior
 -> [PredictiveScalingMetricSpecification]
 -> PredictiveScalingConfiguration)
-> Either String (Maybe Natural)
-> Either
     String
     (Maybe Natural
      -> Maybe PredictiveScalingMode
      -> Maybe PredictiveScalingMaxCapacityBreachBehavior
      -> [PredictiveScalingMetricSpecification]
      -> PredictiveScalingConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Natural)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SchedulingBufferTime")
      Either
  String
  (Maybe Natural
   -> Maybe PredictiveScalingMode
   -> Maybe PredictiveScalingMaxCapacityBreachBehavior
   -> [PredictiveScalingMetricSpecification]
   -> PredictiveScalingConfiguration)
-> Either String (Maybe Natural)
-> Either
     String
     (Maybe PredictiveScalingMode
      -> Maybe PredictiveScalingMaxCapacityBreachBehavior
      -> [PredictiveScalingMetricSpecification]
      -> PredictiveScalingConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Natural)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"MaxCapacityBuffer")
      Either
  String
  (Maybe PredictiveScalingMode
   -> Maybe PredictiveScalingMaxCapacityBreachBehavior
   -> [PredictiveScalingMetricSpecification]
   -> PredictiveScalingConfiguration)
-> Either String (Maybe PredictiveScalingMode)
-> Either
     String
     (Maybe PredictiveScalingMaxCapacityBreachBehavior
      -> [PredictiveScalingMetricSpecification]
      -> PredictiveScalingConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe PredictiveScalingMode)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Mode")
      Either
  String
  (Maybe PredictiveScalingMaxCapacityBreachBehavior
   -> [PredictiveScalingMetricSpecification]
   -> PredictiveScalingConfiguration)
-> Either String (Maybe PredictiveScalingMaxCapacityBreachBehavior)
-> Either
     String
     ([PredictiveScalingMetricSpecification]
      -> PredictiveScalingConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node]
-> Text
-> Either String (Maybe PredictiveScalingMaxCapacityBreachBehavior)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"MaxCapacityBreachBehavior")
      Either
  String
  ([PredictiveScalingMetricSpecification]
   -> PredictiveScalingConfiguration)
-> Either String [PredictiveScalingMetricSpecification]
-> Either String PredictiveScalingConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"MetricSpecifications"
                      Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String [PredictiveScalingMetricSpecification])
-> Either String [PredictiveScalingMetricSpecification]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= Text
-> [Node] -> Either String [PredictiveScalingMetricSpecification]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member"
                  )

instance
  Prelude.Hashable
    PredictiveScalingConfiguration

instance
  Prelude.NFData
    PredictiveScalingConfiguration

instance Core.ToQuery PredictiveScalingConfiguration where
  toQuery :: PredictiveScalingConfiguration -> QueryString
toQuery PredictiveScalingConfiguration' {[PredictiveScalingMetricSpecification]
Maybe Natural
Maybe PredictiveScalingMaxCapacityBreachBehavior
Maybe PredictiveScalingMode
metricSpecifications :: [PredictiveScalingMetricSpecification]
maxCapacityBreachBehavior :: Maybe PredictiveScalingMaxCapacityBreachBehavior
mode :: Maybe PredictiveScalingMode
maxCapacityBuffer :: Maybe Natural
schedulingBufferTime :: Maybe Natural
$sel:metricSpecifications:PredictiveScalingConfiguration' :: PredictiveScalingConfiguration
-> [PredictiveScalingMetricSpecification]
$sel:maxCapacityBreachBehavior:PredictiveScalingConfiguration' :: PredictiveScalingConfiguration
-> Maybe PredictiveScalingMaxCapacityBreachBehavior
$sel:mode:PredictiveScalingConfiguration' :: PredictiveScalingConfiguration -> Maybe PredictiveScalingMode
$sel:maxCapacityBuffer:PredictiveScalingConfiguration' :: PredictiveScalingConfiguration -> Maybe Natural
$sel:schedulingBufferTime:PredictiveScalingConfiguration' :: PredictiveScalingConfiguration -> Maybe Natural
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"SchedulingBufferTime" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
schedulingBufferTime,
        ByteString
"MaxCapacityBuffer" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
maxCapacityBuffer,
        ByteString
"Mode" ByteString -> Maybe PredictiveScalingMode -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe PredictiveScalingMode
mode,
        ByteString
"MaxCapacityBreachBehavior"
          ByteString
-> Maybe PredictiveScalingMaxCapacityBreachBehavior -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe PredictiveScalingMaxCapacityBreachBehavior
maxCapacityBreachBehavior,
        ByteString
"MetricSpecifications"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ByteString -> [PredictiveScalingMetricSpecification] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" [PredictiveScalingMetricSpecification]
metricSpecifications
      ]