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

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

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

-- |
-- Create a value of 'CapacityForecast' 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', 'capacityForecast_timestamps' - The time stamps for the data points, in UTC format.
--
-- 'values', 'capacityForecast_values' - The values of the data points.
newCapacityForecast ::
  CapacityForecast
newCapacityForecast :: CapacityForecast
newCapacityForecast =
  CapacityForecast' :: [ISO8601] -> [Double] -> CapacityForecast
CapacityForecast'
    { $sel:timestamps:CapacityForecast' :: [ISO8601]
timestamps = [ISO8601]
forall a. Monoid a => a
Prelude.mempty,
      $sel:values:CapacityForecast' :: [Double]
values = [Double]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The time stamps for the data points, in UTC format.
capacityForecast_timestamps :: Lens.Lens' CapacityForecast [Prelude.UTCTime]
capacityForecast_timestamps :: ([UTCTime] -> f [UTCTime])
-> CapacityForecast -> f CapacityForecast
capacityForecast_timestamps = (CapacityForecast -> [ISO8601])
-> (CapacityForecast -> [ISO8601] -> CapacityForecast)
-> Lens CapacityForecast CapacityForecast [ISO8601] [ISO8601]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CapacityForecast' {[ISO8601]
timestamps :: [ISO8601]
$sel:timestamps:CapacityForecast' :: CapacityForecast -> [ISO8601]
timestamps} -> [ISO8601]
timestamps) (\s :: CapacityForecast
s@CapacityForecast' {} [ISO8601]
a -> CapacityForecast
s {$sel:timestamps:CapacityForecast' :: [ISO8601]
timestamps = [ISO8601]
a} :: CapacityForecast) (([ISO8601] -> f [ISO8601])
 -> CapacityForecast -> f CapacityForecast)
-> (([UTCTime] -> f [UTCTime]) -> [ISO8601] -> f [ISO8601])
-> ([UTCTime] -> f [UTCTime])
-> CapacityForecast
-> f CapacityForecast
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.
capacityForecast_values :: Lens.Lens' CapacityForecast [Prelude.Double]
capacityForecast_values :: ([Double] -> f [Double]) -> CapacityForecast -> f CapacityForecast
capacityForecast_values = (CapacityForecast -> [Double])
-> (CapacityForecast -> [Double] -> CapacityForecast)
-> Lens CapacityForecast CapacityForecast [Double] [Double]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CapacityForecast' {[Double]
values :: [Double]
$sel:values:CapacityForecast' :: CapacityForecast -> [Double]
values} -> [Double]
values) (\s :: CapacityForecast
s@CapacityForecast' {} [Double]
a -> CapacityForecast
s {$sel:values:CapacityForecast' :: [Double]
values = [Double]
a} :: CapacityForecast) (([Double] -> f [Double])
 -> CapacityForecast -> f CapacityForecast)
-> (([Double] -> f [Double]) -> [Double] -> f [Double])
-> ([Double] -> f [Double])
-> CapacityForecast
-> f CapacityForecast
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

instance Core.FromXML CapacityForecast where
  parseXML :: [Node] -> Either String CapacityForecast
parseXML [Node]
x =
    [ISO8601] -> [Double] -> CapacityForecast
CapacityForecast'
      ([ISO8601] -> [Double] -> CapacityForecast)
-> Either String [ISO8601]
-> Either String ([Double] -> CapacityForecast)
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] -> CapacityForecast)
-> Either String [Double] -> Either String CapacityForecast
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"
                  )

instance Prelude.Hashable CapacityForecast

instance Prelude.NFData CapacityForecast