{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 timestamps for the data points, in UTC format.
    LoadForecast -> [ISO8601]
timestamps :: [Data.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
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]
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
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. 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 timestamps 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'
    { $sel:timestamps:LoadForecast' :: [ISO8601]
timestamps = forall a. Monoid a => a
Prelude.mempty,
      $sel:values:LoadForecast' :: [Double]
values = forall a. Monoid a => a
Prelude.mempty,
      $sel:metricSpecification:LoadForecast' :: PredictiveScalingMetricSpecification
metricSpecification = PredictiveScalingMetricSpecification
pMetricSpecification_
    }

-- | The timestamps for the data points, in UTC format.
loadForecast_timestamps :: Lens.Lens' LoadForecast [Prelude.UTCTime]
loadForecast_timestamps :: Lens' LoadForecast [UTCTime]
loadForecast_timestamps = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 :: Lens' LoadForecast [Double]
loadForecast_values = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 :: Lens' LoadForecast PredictiveScalingMetricSpecification
loadForecast_metricSpecification = 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 Data.FromXML LoadForecast where
  parseXML :: [Node] -> Either String LoadForecast
parseXML [Node]
x =
    [ISO8601]
-> [Double] -> PredictiveScalingMetricSpecification -> LoadForecast
LoadForecast'
      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
"Timestamps"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member"
                  )
      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
"Values"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member"
                  )
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"MetricSpecification")

instance Prelude.Hashable LoadForecast where
  hashWithSalt :: Int -> LoadForecast -> Int
hashWithSalt Int
_salt LoadForecast' {[Double]
[ISO8601]
PredictiveScalingMetricSpecification
metricSpecification :: PredictiveScalingMetricSpecification
values :: [Double]
timestamps :: [ISO8601]
$sel:metricSpecification:LoadForecast' :: LoadForecast -> PredictiveScalingMetricSpecification
$sel:values:LoadForecast' :: LoadForecast -> [Double]
$sel:timestamps:LoadForecast' :: LoadForecast -> [ISO8601]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [ISO8601]
timestamps
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Double]
values
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` PredictiveScalingMetricSpecification
metricSpecification

instance Prelude.NFData LoadForecast where
  rnf :: LoadForecast -> ()
rnf LoadForecast' {[Double]
[ISO8601]
PredictiveScalingMetricSpecification
metricSpecification :: PredictiveScalingMetricSpecification
values :: [Double]
timestamps :: [ISO8601]
$sel:metricSpecification:LoadForecast' :: LoadForecast -> PredictiveScalingMetricSpecification
$sel:values:LoadForecast' :: LoadForecast -> [Double]
$sel:timestamps:LoadForecast' :: LoadForecast -> [ISO8601]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf [ISO8601]
timestamps
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Double]
values
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf PredictiveScalingMetricSpecification
metricSpecification