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

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

-- | A @GetPredictiveScalingForecast@ call returns the load forecast for a
-- predictive scaling policy. This structure includes the data points for
-- that load forecast, along with the timestamps of those data points and
-- the metric specification.
--
-- /See:/ 'newLoadForecast' smart constructor.
data LoadForecast = LoadForecast'
  { -- | The time stamps for the data points, in UTC format.
    LoadForecast -> [ISO8601]
timestamps :: [Core.ISO8601],
    -- | The values of the data points.
    LoadForecast -> [Double]
values :: [Prelude.Double],
    -- | The metric specification for the load forecast.
    LoadForecast -> PredictiveScalingMetricSpecification
metricSpecification :: PredictiveScalingMetricSpecification
  }
  deriving (LoadForecast -> LoadForecast -> Bool
(LoadForecast -> LoadForecast -> Bool)
-> (LoadForecast -> LoadForecast -> Bool) -> Eq LoadForecast
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LoadForecast -> LoadForecast -> Bool
$c/= :: LoadForecast -> LoadForecast -> Bool
== :: LoadForecast -> LoadForecast -> Bool
$c== :: LoadForecast -> LoadForecast -> Bool
Prelude.Eq, ReadPrec [LoadForecast]
ReadPrec LoadForecast
Int -> ReadS LoadForecast
ReadS [LoadForecast]
(Int -> ReadS LoadForecast)
-> ReadS [LoadForecast]
-> ReadPrec LoadForecast
-> ReadPrec [LoadForecast]
-> Read LoadForecast
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LoadForecast]
$creadListPrec :: ReadPrec [LoadForecast]
readPrec :: ReadPrec LoadForecast
$creadPrec :: ReadPrec LoadForecast
readList :: ReadS [LoadForecast]
$creadList :: ReadS [LoadForecast]
readsPrec :: Int -> ReadS LoadForecast
$creadsPrec :: Int -> ReadS LoadForecast
Prelude.Read, Int -> LoadForecast -> ShowS
[LoadForecast] -> ShowS
LoadForecast -> String
(Int -> LoadForecast -> ShowS)
-> (LoadForecast -> String)
-> ([LoadForecast] -> ShowS)
-> Show LoadForecast
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LoadForecast] -> ShowS
$cshowList :: [LoadForecast] -> ShowS
show :: LoadForecast -> String
$cshow :: LoadForecast -> String
showsPrec :: Int -> LoadForecast -> ShowS
$cshowsPrec :: Int -> LoadForecast -> ShowS
Prelude.Show, (forall x. LoadForecast -> Rep LoadForecast x)
-> (forall x. Rep LoadForecast x -> LoadForecast)
-> Generic LoadForecast
forall x. Rep LoadForecast x -> LoadForecast
forall x. LoadForecast -> Rep LoadForecast x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LoadForecast x -> LoadForecast
$cfrom :: forall x. LoadForecast -> Rep LoadForecast x
Prelude.Generic)

-- |
-- Create a value of 'LoadForecast' 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:
--
-- 'timestamps', 'loadForecast_timestamps' - The time stamps for the data points, in UTC format.
--
-- 'values', 'loadForecast_values' - The values of the data points.
--
-- 'metricSpecification', 'loadForecast_metricSpecification' - The metric specification for the load forecast.
newLoadForecast ::
  -- | 'metricSpecification'
  PredictiveScalingMetricSpecification ->
  LoadForecast
newLoadForecast :: PredictiveScalingMetricSpecification -> LoadForecast
newLoadForecast PredictiveScalingMetricSpecification
pMetricSpecification_ =
  LoadForecast' :: [ISO8601]
-> [Double] -> PredictiveScalingMetricSpecification -> LoadForecast
LoadForecast'
    { $sel:timestamps:LoadForecast' :: [ISO8601]
timestamps = [ISO8601]
forall a. Monoid a => a
Prelude.mempty,
      $sel:values:LoadForecast' :: [Double]
values = [Double]
forall a. Monoid a => a
Prelude.mempty,
      $sel:metricSpecification:LoadForecast' :: PredictiveScalingMetricSpecification
metricSpecification = PredictiveScalingMetricSpecification
pMetricSpecification_
    }

-- | The time stamps for the data points, in UTC format.
loadForecast_timestamps :: Lens.Lens' LoadForecast [Prelude.UTCTime]
loadForecast_timestamps :: ([UTCTime] -> f [UTCTime]) -> LoadForecast -> f LoadForecast
loadForecast_timestamps = (LoadForecast -> [ISO8601])
-> (LoadForecast -> [ISO8601] -> LoadForecast)
-> Lens LoadForecast LoadForecast [ISO8601] [ISO8601]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoadForecast' {[ISO8601]
timestamps :: [ISO8601]
$sel:timestamps:LoadForecast' :: LoadForecast -> [ISO8601]
timestamps} -> [ISO8601]
timestamps) (\s :: LoadForecast
s@LoadForecast' {} [ISO8601]
a -> LoadForecast
s {$sel:timestamps:LoadForecast' :: [ISO8601]
timestamps = [ISO8601]
a} :: LoadForecast) (([ISO8601] -> f [ISO8601]) -> LoadForecast -> f LoadForecast)
-> (([UTCTime] -> f [UTCTime]) -> [ISO8601] -> f [ISO8601])
-> ([UTCTime] -> f [UTCTime])
-> LoadForecast
-> f LoadForecast
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([UTCTime] -> f [UTCTime]) -> [ISO8601] -> f [ISO8601]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The values of the data points.
loadForecast_values :: Lens.Lens' LoadForecast [Prelude.Double]
loadForecast_values :: ([Double] -> f [Double]) -> LoadForecast -> f LoadForecast
loadForecast_values = (LoadForecast -> [Double])
-> (LoadForecast -> [Double] -> LoadForecast)
-> Lens LoadForecast LoadForecast [Double] [Double]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoadForecast' {[Double]
values :: [Double]
$sel:values:LoadForecast' :: LoadForecast -> [Double]
values} -> [Double]
values) (\s :: LoadForecast
s@LoadForecast' {} [Double]
a -> LoadForecast
s {$sel:values:LoadForecast' :: [Double]
values = [Double]
a} :: LoadForecast) (([Double] -> f [Double]) -> LoadForecast -> f LoadForecast)
-> (([Double] -> f [Double]) -> [Double] -> f [Double])
-> ([Double] -> f [Double])
-> LoadForecast
-> f LoadForecast
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Double] -> f [Double]) -> [Double] -> f [Double]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The metric specification for the load forecast.
loadForecast_metricSpecification :: Lens.Lens' LoadForecast PredictiveScalingMetricSpecification
loadForecast_metricSpecification :: (PredictiveScalingMetricSpecification
 -> f PredictiveScalingMetricSpecification)
-> LoadForecast -> f LoadForecast
loadForecast_metricSpecification = (LoadForecast -> PredictiveScalingMetricSpecification)
-> (LoadForecast
    -> PredictiveScalingMetricSpecification -> LoadForecast)
-> Lens
     LoadForecast
     LoadForecast
     PredictiveScalingMetricSpecification
     PredictiveScalingMetricSpecification
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoadForecast' {PredictiveScalingMetricSpecification
metricSpecification :: PredictiveScalingMetricSpecification
$sel:metricSpecification:LoadForecast' :: LoadForecast -> PredictiveScalingMetricSpecification
metricSpecification} -> PredictiveScalingMetricSpecification
metricSpecification) (\s :: LoadForecast
s@LoadForecast' {} PredictiveScalingMetricSpecification
a -> LoadForecast
s {$sel:metricSpecification:LoadForecast' :: PredictiveScalingMetricSpecification
metricSpecification = PredictiveScalingMetricSpecification
a} :: LoadForecast)

instance Core.FromXML LoadForecast where
  parseXML :: [Node] -> Either String LoadForecast
parseXML [Node]
x =
    [ISO8601]
-> [Double] -> PredictiveScalingMetricSpecification -> LoadForecast
LoadForecast'
      ([ISO8601]
 -> [Double]
 -> PredictiveScalingMetricSpecification
 -> LoadForecast)
-> Either String [ISO8601]
-> Either
     String
     ([Double] -> PredictiveScalingMetricSpecification -> LoadForecast)
forall (f :: * -> *) a b. Functor 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
"Timestamps" 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 [ISO8601]) -> Either String [ISO8601]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= Text -> [Node] -> Either String [ISO8601]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member"
                  )
      Either
  String
  ([Double] -> PredictiveScalingMetricSpecification -> LoadForecast)
-> Either String [Double]
-> Either
     String (PredictiveScalingMetricSpecification -> LoadForecast)
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
"Values" 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 [Double]) -> Either String [Double]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= Text -> [Node] -> Either String [Double]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member"
                  )
      Either
  String (PredictiveScalingMetricSpecification -> LoadForecast)
-> Either String PredictiveScalingMetricSpecification
-> Either String LoadForecast
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node]
-> Text -> Either String PredictiveScalingMetricSpecification
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"MetricSpecification")

instance Prelude.Hashable LoadForecast

instance Prelude.NFData LoadForecast