{-# 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.AutoScalingPlans.Types.ScalingPlan
-- 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.AutoScalingPlans.Types.ScalingPlan where

import Amazonka.AutoScalingPlans.Types.ApplicationSource
import Amazonka.AutoScalingPlans.Types.ScalingInstruction
import Amazonka.AutoScalingPlans.Types.ScalingPlanStatusCode
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

-- | Represents a scaling plan.
--
-- /See:/ 'newScalingPlan' smart constructor.
data ScalingPlan = ScalingPlan'
  { -- | The Unix time stamp when the scaling plan was created.
    ScalingPlan -> Maybe POSIX
creationTime :: Prelude.Maybe Data.POSIX,
    -- | A simple message about the current status of the scaling plan.
    ScalingPlan -> Maybe Text
statusMessage :: Prelude.Maybe Prelude.Text,
    -- | The Unix time stamp when the scaling plan entered the current status.
    ScalingPlan -> Maybe POSIX
statusStartTime :: Prelude.Maybe Data.POSIX,
    -- | The name of the scaling plan.
    ScalingPlan -> Text
scalingPlanName :: Prelude.Text,
    -- | The version number of the scaling plan.
    ScalingPlan -> Integer
scalingPlanVersion :: Prelude.Integer,
    -- | A CloudFormation stack or a set of tags. You can create one scaling plan
    -- per application source.
    ScalingPlan -> ApplicationSource
applicationSource :: ApplicationSource,
    -- | The scaling instructions.
    ScalingPlan -> [ScalingInstruction]
scalingInstructions :: [ScalingInstruction],
    -- | The status of the scaling plan.
    --
    -- -   @Active@ - The scaling plan is active.
    --
    -- -   @ActiveWithProblems@ - The scaling plan is active, but the scaling
    --     configuration for one or more resources could not be applied.
    --
    -- -   @CreationInProgress@ - The scaling plan is being created.
    --
    -- -   @CreationFailed@ - The scaling plan could not be created.
    --
    -- -   @DeletionInProgress@ - The scaling plan is being deleted.
    --
    -- -   @DeletionFailed@ - The scaling plan could not be deleted.
    --
    -- -   @UpdateInProgress@ - The scaling plan is being updated.
    --
    -- -   @UpdateFailed@ - The scaling plan could not be updated.
    ScalingPlan -> ScalingPlanStatusCode
statusCode :: ScalingPlanStatusCode
  }
  deriving (ScalingPlan -> ScalingPlan -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ScalingPlan -> ScalingPlan -> Bool
$c/= :: ScalingPlan -> ScalingPlan -> Bool
== :: ScalingPlan -> ScalingPlan -> Bool
$c== :: ScalingPlan -> ScalingPlan -> Bool
Prelude.Eq, ReadPrec [ScalingPlan]
ReadPrec ScalingPlan
Int -> ReadS ScalingPlan
ReadS [ScalingPlan]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ScalingPlan]
$creadListPrec :: ReadPrec [ScalingPlan]
readPrec :: ReadPrec ScalingPlan
$creadPrec :: ReadPrec ScalingPlan
readList :: ReadS [ScalingPlan]
$creadList :: ReadS [ScalingPlan]
readsPrec :: Int -> ReadS ScalingPlan
$creadsPrec :: Int -> ReadS ScalingPlan
Prelude.Read, Int -> ScalingPlan -> ShowS
[ScalingPlan] -> ShowS
ScalingPlan -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ScalingPlan] -> ShowS
$cshowList :: [ScalingPlan] -> ShowS
show :: ScalingPlan -> String
$cshow :: ScalingPlan -> String
showsPrec :: Int -> ScalingPlan -> ShowS
$cshowsPrec :: Int -> ScalingPlan -> ShowS
Prelude.Show, forall x. Rep ScalingPlan x -> ScalingPlan
forall x. ScalingPlan -> Rep ScalingPlan x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ScalingPlan x -> ScalingPlan
$cfrom :: forall x. ScalingPlan -> Rep ScalingPlan x
Prelude.Generic)

-- |
-- Create a value of 'ScalingPlan' 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:
--
-- 'creationTime', 'scalingPlan_creationTime' - The Unix time stamp when the scaling plan was created.
--
-- 'statusMessage', 'scalingPlan_statusMessage' - A simple message about the current status of the scaling plan.
--
-- 'statusStartTime', 'scalingPlan_statusStartTime' - The Unix time stamp when the scaling plan entered the current status.
--
-- 'scalingPlanName', 'scalingPlan_scalingPlanName' - The name of the scaling plan.
--
-- 'scalingPlanVersion', 'scalingPlan_scalingPlanVersion' - The version number of the scaling plan.
--
-- 'applicationSource', 'scalingPlan_applicationSource' - A CloudFormation stack or a set of tags. You can create one scaling plan
-- per application source.
--
-- 'scalingInstructions', 'scalingPlan_scalingInstructions' - The scaling instructions.
--
-- 'statusCode', 'scalingPlan_statusCode' - The status of the scaling plan.
--
-- -   @Active@ - The scaling plan is active.
--
-- -   @ActiveWithProblems@ - The scaling plan is active, but the scaling
--     configuration for one or more resources could not be applied.
--
-- -   @CreationInProgress@ - The scaling plan is being created.
--
-- -   @CreationFailed@ - The scaling plan could not be created.
--
-- -   @DeletionInProgress@ - The scaling plan is being deleted.
--
-- -   @DeletionFailed@ - The scaling plan could not be deleted.
--
-- -   @UpdateInProgress@ - The scaling plan is being updated.
--
-- -   @UpdateFailed@ - The scaling plan could not be updated.
newScalingPlan ::
  -- | 'scalingPlanName'
  Prelude.Text ->
  -- | 'scalingPlanVersion'
  Prelude.Integer ->
  -- | 'applicationSource'
  ApplicationSource ->
  -- | 'statusCode'
  ScalingPlanStatusCode ->
  ScalingPlan
newScalingPlan :: Text
-> Integer
-> ApplicationSource
-> ScalingPlanStatusCode
-> ScalingPlan
newScalingPlan
  Text
pScalingPlanName_
  Integer
pScalingPlanVersion_
  ApplicationSource
pApplicationSource_
  ScalingPlanStatusCode
pStatusCode_ =
    ScalingPlan'
      { $sel:creationTime:ScalingPlan' :: Maybe POSIX
creationTime = forall a. Maybe a
Prelude.Nothing,
        $sel:statusMessage:ScalingPlan' :: Maybe Text
statusMessage = forall a. Maybe a
Prelude.Nothing,
        $sel:statusStartTime:ScalingPlan' :: Maybe POSIX
statusStartTime = forall a. Maybe a
Prelude.Nothing,
        $sel:scalingPlanName:ScalingPlan' :: Text
scalingPlanName = Text
pScalingPlanName_,
        $sel:scalingPlanVersion:ScalingPlan' :: Integer
scalingPlanVersion = Integer
pScalingPlanVersion_,
        $sel:applicationSource:ScalingPlan' :: ApplicationSource
applicationSource = ApplicationSource
pApplicationSource_,
        $sel:scalingInstructions:ScalingPlan' :: [ScalingInstruction]
scalingInstructions = forall a. Monoid a => a
Prelude.mempty,
        $sel:statusCode:ScalingPlan' :: ScalingPlanStatusCode
statusCode = ScalingPlanStatusCode
pStatusCode_
      }

-- | The Unix time stamp when the scaling plan was created.
scalingPlan_creationTime :: Lens.Lens' ScalingPlan (Prelude.Maybe Prelude.UTCTime)
scalingPlan_creationTime :: Lens' ScalingPlan (Maybe UTCTime)
scalingPlan_creationTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingPlan' {Maybe POSIX
creationTime :: Maybe POSIX
$sel:creationTime:ScalingPlan' :: ScalingPlan -> Maybe POSIX
creationTime} -> Maybe POSIX
creationTime) (\s :: ScalingPlan
s@ScalingPlan' {} Maybe POSIX
a -> ScalingPlan
s {$sel:creationTime:ScalingPlan' :: Maybe POSIX
creationTime = Maybe POSIX
a} :: ScalingPlan) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | A simple message about the current status of the scaling plan.
scalingPlan_statusMessage :: Lens.Lens' ScalingPlan (Prelude.Maybe Prelude.Text)
scalingPlan_statusMessage :: Lens' ScalingPlan (Maybe Text)
scalingPlan_statusMessage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingPlan' {Maybe Text
statusMessage :: Maybe Text
$sel:statusMessage:ScalingPlan' :: ScalingPlan -> Maybe Text
statusMessage} -> Maybe Text
statusMessage) (\s :: ScalingPlan
s@ScalingPlan' {} Maybe Text
a -> ScalingPlan
s {$sel:statusMessage:ScalingPlan' :: Maybe Text
statusMessage = Maybe Text
a} :: ScalingPlan)

-- | The Unix time stamp when the scaling plan entered the current status.
scalingPlan_statusStartTime :: Lens.Lens' ScalingPlan (Prelude.Maybe Prelude.UTCTime)
scalingPlan_statusStartTime :: Lens' ScalingPlan (Maybe UTCTime)
scalingPlan_statusStartTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingPlan' {Maybe POSIX
statusStartTime :: Maybe POSIX
$sel:statusStartTime:ScalingPlan' :: ScalingPlan -> Maybe POSIX
statusStartTime} -> Maybe POSIX
statusStartTime) (\s :: ScalingPlan
s@ScalingPlan' {} Maybe POSIX
a -> ScalingPlan
s {$sel:statusStartTime:ScalingPlan' :: Maybe POSIX
statusStartTime = Maybe POSIX
a} :: ScalingPlan) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The name of the scaling plan.
scalingPlan_scalingPlanName :: Lens.Lens' ScalingPlan Prelude.Text
scalingPlan_scalingPlanName :: Lens' ScalingPlan Text
scalingPlan_scalingPlanName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingPlan' {Text
scalingPlanName :: Text
$sel:scalingPlanName:ScalingPlan' :: ScalingPlan -> Text
scalingPlanName} -> Text
scalingPlanName) (\s :: ScalingPlan
s@ScalingPlan' {} Text
a -> ScalingPlan
s {$sel:scalingPlanName:ScalingPlan' :: Text
scalingPlanName = Text
a} :: ScalingPlan)

-- | The version number of the scaling plan.
scalingPlan_scalingPlanVersion :: Lens.Lens' ScalingPlan Prelude.Integer
scalingPlan_scalingPlanVersion :: Lens' ScalingPlan Integer
scalingPlan_scalingPlanVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingPlan' {Integer
scalingPlanVersion :: Integer
$sel:scalingPlanVersion:ScalingPlan' :: ScalingPlan -> Integer
scalingPlanVersion} -> Integer
scalingPlanVersion) (\s :: ScalingPlan
s@ScalingPlan' {} Integer
a -> ScalingPlan
s {$sel:scalingPlanVersion:ScalingPlan' :: Integer
scalingPlanVersion = Integer
a} :: ScalingPlan)

-- | A CloudFormation stack or a set of tags. You can create one scaling plan
-- per application source.
scalingPlan_applicationSource :: Lens.Lens' ScalingPlan ApplicationSource
scalingPlan_applicationSource :: Lens' ScalingPlan ApplicationSource
scalingPlan_applicationSource = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingPlan' {ApplicationSource
applicationSource :: ApplicationSource
$sel:applicationSource:ScalingPlan' :: ScalingPlan -> ApplicationSource
applicationSource} -> ApplicationSource
applicationSource) (\s :: ScalingPlan
s@ScalingPlan' {} ApplicationSource
a -> ScalingPlan
s {$sel:applicationSource:ScalingPlan' :: ApplicationSource
applicationSource = ApplicationSource
a} :: ScalingPlan)

-- | The scaling instructions.
scalingPlan_scalingInstructions :: Lens.Lens' ScalingPlan [ScalingInstruction]
scalingPlan_scalingInstructions :: Lens' ScalingPlan [ScalingInstruction]
scalingPlan_scalingInstructions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingPlan' {[ScalingInstruction]
scalingInstructions :: [ScalingInstruction]
$sel:scalingInstructions:ScalingPlan' :: ScalingPlan -> [ScalingInstruction]
scalingInstructions} -> [ScalingInstruction]
scalingInstructions) (\s :: ScalingPlan
s@ScalingPlan' {} [ScalingInstruction]
a -> ScalingPlan
s {$sel:scalingInstructions:ScalingPlan' :: [ScalingInstruction]
scalingInstructions = [ScalingInstruction]
a} :: ScalingPlan) 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 status of the scaling plan.
--
-- -   @Active@ - The scaling plan is active.
--
-- -   @ActiveWithProblems@ - The scaling plan is active, but the scaling
--     configuration for one or more resources could not be applied.
--
-- -   @CreationInProgress@ - The scaling plan is being created.
--
-- -   @CreationFailed@ - The scaling plan could not be created.
--
-- -   @DeletionInProgress@ - The scaling plan is being deleted.
--
-- -   @DeletionFailed@ - The scaling plan could not be deleted.
--
-- -   @UpdateInProgress@ - The scaling plan is being updated.
--
-- -   @UpdateFailed@ - The scaling plan could not be updated.
scalingPlan_statusCode :: Lens.Lens' ScalingPlan ScalingPlanStatusCode
scalingPlan_statusCode :: Lens' ScalingPlan ScalingPlanStatusCode
scalingPlan_statusCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingPlan' {ScalingPlanStatusCode
statusCode :: ScalingPlanStatusCode
$sel:statusCode:ScalingPlan' :: ScalingPlan -> ScalingPlanStatusCode
statusCode} -> ScalingPlanStatusCode
statusCode) (\s :: ScalingPlan
s@ScalingPlan' {} ScalingPlanStatusCode
a -> ScalingPlan
s {$sel:statusCode:ScalingPlan' :: ScalingPlanStatusCode
statusCode = ScalingPlanStatusCode
a} :: ScalingPlan)

instance Data.FromJSON ScalingPlan where
  parseJSON :: Value -> Parser ScalingPlan
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ScalingPlan"
      ( \Object
x ->
          Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> Text
-> Integer
-> ApplicationSource
-> [ScalingInstruction]
-> ScalingPlanStatusCode
-> ScalingPlan
ScalingPlan'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CreationTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"StatusMessage")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"StatusStartTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ScalingPlanName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ScalingPlanVersion")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ApplicationSource")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ScalingInstructions"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"StatusCode")
      )

instance Prelude.Hashable ScalingPlan where
  hashWithSalt :: Int -> ScalingPlan -> Int
hashWithSalt Int
_salt ScalingPlan' {Integer
[ScalingInstruction]
Maybe Text
Maybe POSIX
Text
ScalingPlanStatusCode
ApplicationSource
statusCode :: ScalingPlanStatusCode
scalingInstructions :: [ScalingInstruction]
applicationSource :: ApplicationSource
scalingPlanVersion :: Integer
scalingPlanName :: Text
statusStartTime :: Maybe POSIX
statusMessage :: Maybe Text
creationTime :: Maybe POSIX
$sel:statusCode:ScalingPlan' :: ScalingPlan -> ScalingPlanStatusCode
$sel:scalingInstructions:ScalingPlan' :: ScalingPlan -> [ScalingInstruction]
$sel:applicationSource:ScalingPlan' :: ScalingPlan -> ApplicationSource
$sel:scalingPlanVersion:ScalingPlan' :: ScalingPlan -> Integer
$sel:scalingPlanName:ScalingPlan' :: ScalingPlan -> Text
$sel:statusStartTime:ScalingPlan' :: ScalingPlan -> Maybe POSIX
$sel:statusMessage:ScalingPlan' :: ScalingPlan -> Maybe Text
$sel:creationTime:ScalingPlan' :: ScalingPlan -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
creationTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
statusMessage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
statusStartTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
scalingPlanName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Integer
scalingPlanVersion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ApplicationSource
applicationSource
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [ScalingInstruction]
scalingInstructions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ScalingPlanStatusCode
statusCode

instance Prelude.NFData ScalingPlan where
  rnf :: ScalingPlan -> ()
rnf ScalingPlan' {Integer
[ScalingInstruction]
Maybe Text
Maybe POSIX
Text
ScalingPlanStatusCode
ApplicationSource
statusCode :: ScalingPlanStatusCode
scalingInstructions :: [ScalingInstruction]
applicationSource :: ApplicationSource
scalingPlanVersion :: Integer
scalingPlanName :: Text
statusStartTime :: Maybe POSIX
statusMessage :: Maybe Text
creationTime :: Maybe POSIX
$sel:statusCode:ScalingPlan' :: ScalingPlan -> ScalingPlanStatusCode
$sel:scalingInstructions:ScalingPlan' :: ScalingPlan -> [ScalingInstruction]
$sel:applicationSource:ScalingPlan' :: ScalingPlan -> ApplicationSource
$sel:scalingPlanVersion:ScalingPlan' :: ScalingPlan -> Integer
$sel:scalingPlanName:ScalingPlan' :: ScalingPlan -> Text
$sel:statusStartTime:ScalingPlan' :: ScalingPlan -> Maybe POSIX
$sel:statusMessage:ScalingPlan' :: ScalingPlan -> Maybe Text
$sel:creationTime:ScalingPlan' :: ScalingPlan -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
creationTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
statusMessage
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
statusStartTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
scalingPlanName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Integer
scalingPlanVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ApplicationSource
applicationSource
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [ScalingInstruction]
scalingInstructions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ScalingPlanStatusCode
statusCode