{-# 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.AppConfig.Types.DeploymentStrategy
-- 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.AppConfig.Types.DeploymentStrategy where

import Amazonka.AppConfig.Types.GrowthType
import Amazonka.AppConfig.Types.ReplicateTo
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | /See:/ 'newDeploymentStrategy' smart constructor.
data DeploymentStrategy = DeploymentStrategy'
  { -- | The percentage of targets that received a deployed configuration during
    -- each interval.
    DeploymentStrategy -> Maybe Double
growthFactor :: Prelude.Maybe Prelude.Double,
    -- | Save the deployment strategy to a Systems Manager (SSM) document.
    DeploymentStrategy -> Maybe ReplicateTo
replicateTo :: Prelude.Maybe ReplicateTo,
    -- | The name of the deployment strategy.
    DeploymentStrategy -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The deployment strategy ID.
    DeploymentStrategy -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | Total amount of time the deployment lasted.
    DeploymentStrategy -> Maybe Natural
deploymentDurationInMinutes :: Prelude.Maybe Prelude.Natural,
    -- | The amount of time AppConfig monitored for alarms before considering the
    -- deployment to be complete and no longer eligible for automatic roll
    -- back.
    DeploymentStrategy -> Maybe Natural
finalBakeTimeInMinutes :: Prelude.Maybe Prelude.Natural,
    -- | The description of the deployment strategy.
    DeploymentStrategy -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The algorithm used to define how percentage grew over time.
    DeploymentStrategy -> Maybe GrowthType
growthType :: Prelude.Maybe GrowthType
  }
  deriving (DeploymentStrategy -> DeploymentStrategy -> Bool
(DeploymentStrategy -> DeploymentStrategy -> Bool)
-> (DeploymentStrategy -> DeploymentStrategy -> Bool)
-> Eq DeploymentStrategy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeploymentStrategy -> DeploymentStrategy -> Bool
$c/= :: DeploymentStrategy -> DeploymentStrategy -> Bool
== :: DeploymentStrategy -> DeploymentStrategy -> Bool
$c== :: DeploymentStrategy -> DeploymentStrategy -> Bool
Prelude.Eq, ReadPrec [DeploymentStrategy]
ReadPrec DeploymentStrategy
Int -> ReadS DeploymentStrategy
ReadS [DeploymentStrategy]
(Int -> ReadS DeploymentStrategy)
-> ReadS [DeploymentStrategy]
-> ReadPrec DeploymentStrategy
-> ReadPrec [DeploymentStrategy]
-> Read DeploymentStrategy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeploymentStrategy]
$creadListPrec :: ReadPrec [DeploymentStrategy]
readPrec :: ReadPrec DeploymentStrategy
$creadPrec :: ReadPrec DeploymentStrategy
readList :: ReadS [DeploymentStrategy]
$creadList :: ReadS [DeploymentStrategy]
readsPrec :: Int -> ReadS DeploymentStrategy
$creadsPrec :: Int -> ReadS DeploymentStrategy
Prelude.Read, Int -> DeploymentStrategy -> ShowS
[DeploymentStrategy] -> ShowS
DeploymentStrategy -> String
(Int -> DeploymentStrategy -> ShowS)
-> (DeploymentStrategy -> String)
-> ([DeploymentStrategy] -> ShowS)
-> Show DeploymentStrategy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeploymentStrategy] -> ShowS
$cshowList :: [DeploymentStrategy] -> ShowS
show :: DeploymentStrategy -> String
$cshow :: DeploymentStrategy -> String
showsPrec :: Int -> DeploymentStrategy -> ShowS
$cshowsPrec :: Int -> DeploymentStrategy -> ShowS
Prelude.Show, (forall x. DeploymentStrategy -> Rep DeploymentStrategy x)
-> (forall x. Rep DeploymentStrategy x -> DeploymentStrategy)
-> Generic DeploymentStrategy
forall x. Rep DeploymentStrategy x -> DeploymentStrategy
forall x. DeploymentStrategy -> Rep DeploymentStrategy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeploymentStrategy x -> DeploymentStrategy
$cfrom :: forall x. DeploymentStrategy -> Rep DeploymentStrategy x
Prelude.Generic)

-- |
-- Create a value of 'DeploymentStrategy' 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:
--
-- 'growthFactor', 'deploymentStrategy_growthFactor' - The percentage of targets that received a deployed configuration during
-- each interval.
--
-- 'replicateTo', 'deploymentStrategy_replicateTo' - Save the deployment strategy to a Systems Manager (SSM) document.
--
-- 'name', 'deploymentStrategy_name' - The name of the deployment strategy.
--
-- 'id', 'deploymentStrategy_id' - The deployment strategy ID.
--
-- 'deploymentDurationInMinutes', 'deploymentStrategy_deploymentDurationInMinutes' - Total amount of time the deployment lasted.
--
-- 'finalBakeTimeInMinutes', 'deploymentStrategy_finalBakeTimeInMinutes' - The amount of time AppConfig monitored for alarms before considering the
-- deployment to be complete and no longer eligible for automatic roll
-- back.
--
-- 'description', 'deploymentStrategy_description' - The description of the deployment strategy.
--
-- 'growthType', 'deploymentStrategy_growthType' - The algorithm used to define how percentage grew over time.
newDeploymentStrategy ::
  DeploymentStrategy
newDeploymentStrategy :: DeploymentStrategy
newDeploymentStrategy =
  DeploymentStrategy' :: Maybe Double
-> Maybe ReplicateTo
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> Maybe Natural
-> Maybe Text
-> Maybe GrowthType
-> DeploymentStrategy
DeploymentStrategy'
    { $sel:growthFactor:DeploymentStrategy' :: Maybe Double
growthFactor = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:replicateTo:DeploymentStrategy' :: Maybe ReplicateTo
replicateTo = Maybe ReplicateTo
forall a. Maybe a
Prelude.Nothing,
      $sel:name:DeploymentStrategy' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:DeploymentStrategy' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:deploymentDurationInMinutes:DeploymentStrategy' :: Maybe Natural
deploymentDurationInMinutes = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:finalBakeTimeInMinutes:DeploymentStrategy' :: Maybe Natural
finalBakeTimeInMinutes = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:description:DeploymentStrategy' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:growthType:DeploymentStrategy' :: Maybe GrowthType
growthType = Maybe GrowthType
forall a. Maybe a
Prelude.Nothing
    }

-- | The percentage of targets that received a deployed configuration during
-- each interval.
deploymentStrategy_growthFactor :: Lens.Lens' DeploymentStrategy (Prelude.Maybe Prelude.Double)
deploymentStrategy_growthFactor :: (Maybe Double -> f (Maybe Double))
-> DeploymentStrategy -> f DeploymentStrategy
deploymentStrategy_growthFactor = (DeploymentStrategy -> Maybe Double)
-> (DeploymentStrategy -> Maybe Double -> DeploymentStrategy)
-> Lens
     DeploymentStrategy DeploymentStrategy (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentStrategy' {Maybe Double
growthFactor :: Maybe Double
$sel:growthFactor:DeploymentStrategy' :: DeploymentStrategy -> Maybe Double
growthFactor} -> Maybe Double
growthFactor) (\s :: DeploymentStrategy
s@DeploymentStrategy' {} Maybe Double
a -> DeploymentStrategy
s {$sel:growthFactor:DeploymentStrategy' :: Maybe Double
growthFactor = Maybe Double
a} :: DeploymentStrategy)

-- | Save the deployment strategy to a Systems Manager (SSM) document.
deploymentStrategy_replicateTo :: Lens.Lens' DeploymentStrategy (Prelude.Maybe ReplicateTo)
deploymentStrategy_replicateTo :: (Maybe ReplicateTo -> f (Maybe ReplicateTo))
-> DeploymentStrategy -> f DeploymentStrategy
deploymentStrategy_replicateTo = (DeploymentStrategy -> Maybe ReplicateTo)
-> (DeploymentStrategy -> Maybe ReplicateTo -> DeploymentStrategy)
-> Lens
     DeploymentStrategy
     DeploymentStrategy
     (Maybe ReplicateTo)
     (Maybe ReplicateTo)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentStrategy' {Maybe ReplicateTo
replicateTo :: Maybe ReplicateTo
$sel:replicateTo:DeploymentStrategy' :: DeploymentStrategy -> Maybe ReplicateTo
replicateTo} -> Maybe ReplicateTo
replicateTo) (\s :: DeploymentStrategy
s@DeploymentStrategy' {} Maybe ReplicateTo
a -> DeploymentStrategy
s {$sel:replicateTo:DeploymentStrategy' :: Maybe ReplicateTo
replicateTo = Maybe ReplicateTo
a} :: DeploymentStrategy)

-- | The name of the deployment strategy.
deploymentStrategy_name :: Lens.Lens' DeploymentStrategy (Prelude.Maybe Prelude.Text)
deploymentStrategy_name :: (Maybe Text -> f (Maybe Text))
-> DeploymentStrategy -> f DeploymentStrategy
deploymentStrategy_name = (DeploymentStrategy -> Maybe Text)
-> (DeploymentStrategy -> Maybe Text -> DeploymentStrategy)
-> Lens
     DeploymentStrategy DeploymentStrategy (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentStrategy' {Maybe Text
name :: Maybe Text
$sel:name:DeploymentStrategy' :: DeploymentStrategy -> Maybe Text
name} -> Maybe Text
name) (\s :: DeploymentStrategy
s@DeploymentStrategy' {} Maybe Text
a -> DeploymentStrategy
s {$sel:name:DeploymentStrategy' :: Maybe Text
name = Maybe Text
a} :: DeploymentStrategy)

-- | The deployment strategy ID.
deploymentStrategy_id :: Lens.Lens' DeploymentStrategy (Prelude.Maybe Prelude.Text)
deploymentStrategy_id :: (Maybe Text -> f (Maybe Text))
-> DeploymentStrategy -> f DeploymentStrategy
deploymentStrategy_id = (DeploymentStrategy -> Maybe Text)
-> (DeploymentStrategy -> Maybe Text -> DeploymentStrategy)
-> Lens
     DeploymentStrategy DeploymentStrategy (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentStrategy' {Maybe Text
id :: Maybe Text
$sel:id:DeploymentStrategy' :: DeploymentStrategy -> Maybe Text
id} -> Maybe Text
id) (\s :: DeploymentStrategy
s@DeploymentStrategy' {} Maybe Text
a -> DeploymentStrategy
s {$sel:id:DeploymentStrategy' :: Maybe Text
id = Maybe Text
a} :: DeploymentStrategy)

-- | Total amount of time the deployment lasted.
deploymentStrategy_deploymentDurationInMinutes :: Lens.Lens' DeploymentStrategy (Prelude.Maybe Prelude.Natural)
deploymentStrategy_deploymentDurationInMinutes :: (Maybe Natural -> f (Maybe Natural))
-> DeploymentStrategy -> f DeploymentStrategy
deploymentStrategy_deploymentDurationInMinutes = (DeploymentStrategy -> Maybe Natural)
-> (DeploymentStrategy -> Maybe Natural -> DeploymentStrategy)
-> Lens
     DeploymentStrategy
     DeploymentStrategy
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentStrategy' {Maybe Natural
deploymentDurationInMinutes :: Maybe Natural
$sel:deploymentDurationInMinutes:DeploymentStrategy' :: DeploymentStrategy -> Maybe Natural
deploymentDurationInMinutes} -> Maybe Natural
deploymentDurationInMinutes) (\s :: DeploymentStrategy
s@DeploymentStrategy' {} Maybe Natural
a -> DeploymentStrategy
s {$sel:deploymentDurationInMinutes:DeploymentStrategy' :: Maybe Natural
deploymentDurationInMinutes = Maybe Natural
a} :: DeploymentStrategy)

-- | The amount of time AppConfig monitored for alarms before considering the
-- deployment to be complete and no longer eligible for automatic roll
-- back.
deploymentStrategy_finalBakeTimeInMinutes :: Lens.Lens' DeploymentStrategy (Prelude.Maybe Prelude.Natural)
deploymentStrategy_finalBakeTimeInMinutes :: (Maybe Natural -> f (Maybe Natural))
-> DeploymentStrategy -> f DeploymentStrategy
deploymentStrategy_finalBakeTimeInMinutes = (DeploymentStrategy -> Maybe Natural)
-> (DeploymentStrategy -> Maybe Natural -> DeploymentStrategy)
-> Lens
     DeploymentStrategy
     DeploymentStrategy
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentStrategy' {Maybe Natural
finalBakeTimeInMinutes :: Maybe Natural
$sel:finalBakeTimeInMinutes:DeploymentStrategy' :: DeploymentStrategy -> Maybe Natural
finalBakeTimeInMinutes} -> Maybe Natural
finalBakeTimeInMinutes) (\s :: DeploymentStrategy
s@DeploymentStrategy' {} Maybe Natural
a -> DeploymentStrategy
s {$sel:finalBakeTimeInMinutes:DeploymentStrategy' :: Maybe Natural
finalBakeTimeInMinutes = Maybe Natural
a} :: DeploymentStrategy)

-- | The description of the deployment strategy.
deploymentStrategy_description :: Lens.Lens' DeploymentStrategy (Prelude.Maybe Prelude.Text)
deploymentStrategy_description :: (Maybe Text -> f (Maybe Text))
-> DeploymentStrategy -> f DeploymentStrategy
deploymentStrategy_description = (DeploymentStrategy -> Maybe Text)
-> (DeploymentStrategy -> Maybe Text -> DeploymentStrategy)
-> Lens
     DeploymentStrategy DeploymentStrategy (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentStrategy' {Maybe Text
description :: Maybe Text
$sel:description:DeploymentStrategy' :: DeploymentStrategy -> Maybe Text
description} -> Maybe Text
description) (\s :: DeploymentStrategy
s@DeploymentStrategy' {} Maybe Text
a -> DeploymentStrategy
s {$sel:description:DeploymentStrategy' :: Maybe Text
description = Maybe Text
a} :: DeploymentStrategy)

-- | The algorithm used to define how percentage grew over time.
deploymentStrategy_growthType :: Lens.Lens' DeploymentStrategy (Prelude.Maybe GrowthType)
deploymentStrategy_growthType :: (Maybe GrowthType -> f (Maybe GrowthType))
-> DeploymentStrategy -> f DeploymentStrategy
deploymentStrategy_growthType = (DeploymentStrategy -> Maybe GrowthType)
-> (DeploymentStrategy -> Maybe GrowthType -> DeploymentStrategy)
-> Lens
     DeploymentStrategy
     DeploymentStrategy
     (Maybe GrowthType)
     (Maybe GrowthType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentStrategy' {Maybe GrowthType
growthType :: Maybe GrowthType
$sel:growthType:DeploymentStrategy' :: DeploymentStrategy -> Maybe GrowthType
growthType} -> Maybe GrowthType
growthType) (\s :: DeploymentStrategy
s@DeploymentStrategy' {} Maybe GrowthType
a -> DeploymentStrategy
s {$sel:growthType:DeploymentStrategy' :: Maybe GrowthType
growthType = Maybe GrowthType
a} :: DeploymentStrategy)

instance Core.FromJSON DeploymentStrategy where
  parseJSON :: Value -> Parser DeploymentStrategy
parseJSON =
    String
-> (Object -> Parser DeploymentStrategy)
-> Value
-> Parser DeploymentStrategy
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DeploymentStrategy"
      ( \Object
x ->
          Maybe Double
-> Maybe ReplicateTo
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> Maybe Natural
-> Maybe Text
-> Maybe GrowthType
-> DeploymentStrategy
DeploymentStrategy'
            (Maybe Double
 -> Maybe ReplicateTo
 -> Maybe Text
 -> Maybe Text
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe Text
 -> Maybe GrowthType
 -> DeploymentStrategy)
-> Parser (Maybe Double)
-> Parser
     (Maybe ReplicateTo
      -> Maybe Text
      -> Maybe Text
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Text
      -> Maybe GrowthType
      -> DeploymentStrategy)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"GrowthFactor")
            Parser
  (Maybe ReplicateTo
   -> Maybe Text
   -> Maybe Text
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Text
   -> Maybe GrowthType
   -> DeploymentStrategy)
-> Parser (Maybe ReplicateTo)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Text
      -> Maybe GrowthType
      -> DeploymentStrategy)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ReplicateTo)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ReplicateTo")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Text
   -> Maybe GrowthType
   -> DeploymentStrategy)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Text
      -> Maybe GrowthType
      -> DeploymentStrategy)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Name")
            Parser
  (Maybe Text
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Text
   -> Maybe GrowthType
   -> DeploymentStrategy)
-> Parser (Maybe Text)
-> Parser
     (Maybe Natural
      -> Maybe Natural
      -> Maybe Text
      -> Maybe GrowthType
      -> DeploymentStrategy)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Id")
            Parser
  (Maybe Natural
   -> Maybe Natural
   -> Maybe Text
   -> Maybe GrowthType
   -> DeploymentStrategy)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Natural
      -> Maybe Text -> Maybe GrowthType -> DeploymentStrategy)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DeploymentDurationInMinutes")
            Parser
  (Maybe Natural
   -> Maybe Text -> Maybe GrowthType -> DeploymentStrategy)
-> Parser (Maybe Natural)
-> Parser (Maybe Text -> Maybe GrowthType -> DeploymentStrategy)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FinalBakeTimeInMinutes")
            Parser (Maybe Text -> Maybe GrowthType -> DeploymentStrategy)
-> Parser (Maybe Text)
-> Parser (Maybe GrowthType -> DeploymentStrategy)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Description")
            Parser (Maybe GrowthType -> DeploymentStrategy)
-> Parser (Maybe GrowthType) -> Parser DeploymentStrategy
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe GrowthType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"GrowthType")
      )

instance Prelude.Hashable DeploymentStrategy

instance Prelude.NFData DeploymentStrategy