{-# 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.CodeDeploy.Types.BlueGreenDeploymentConfiguration
-- 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.CodeDeploy.Types.BlueGreenDeploymentConfiguration where

import Amazonka.CodeDeploy.Types.BlueInstanceTerminationOption
import Amazonka.CodeDeploy.Types.DeploymentReadyOption
import Amazonka.CodeDeploy.Types.GreenFleetProvisioningOption
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about blue\/green deployment options for a deployment group.
--
-- /See:/ 'newBlueGreenDeploymentConfiguration' smart constructor.
data BlueGreenDeploymentConfiguration = BlueGreenDeploymentConfiguration'
  { -- | Information about the action to take when newly provisioned instances
    -- are ready to receive traffic in a blue\/green deployment.
    BlueGreenDeploymentConfiguration -> Maybe DeploymentReadyOption
deploymentReadyOption :: Prelude.Maybe DeploymentReadyOption,
    -- | Information about how instances are provisioned for a replacement
    -- environment in a blue\/green deployment.
    BlueGreenDeploymentConfiguration
-> Maybe GreenFleetProvisioningOption
greenFleetProvisioningOption :: Prelude.Maybe GreenFleetProvisioningOption,
    -- | Information about whether to terminate instances in the original fleet
    -- during a blue\/green deployment.
    BlueGreenDeploymentConfiguration
-> Maybe BlueInstanceTerminationOption
terminateBlueInstancesOnDeploymentSuccess :: Prelude.Maybe BlueInstanceTerminationOption
  }
  deriving (BlueGreenDeploymentConfiguration
-> BlueGreenDeploymentConfiguration -> Bool
(BlueGreenDeploymentConfiguration
 -> BlueGreenDeploymentConfiguration -> Bool)
-> (BlueGreenDeploymentConfiguration
    -> BlueGreenDeploymentConfiguration -> Bool)
-> Eq BlueGreenDeploymentConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BlueGreenDeploymentConfiguration
-> BlueGreenDeploymentConfiguration -> Bool
$c/= :: BlueGreenDeploymentConfiguration
-> BlueGreenDeploymentConfiguration -> Bool
== :: BlueGreenDeploymentConfiguration
-> BlueGreenDeploymentConfiguration -> Bool
$c== :: BlueGreenDeploymentConfiguration
-> BlueGreenDeploymentConfiguration -> Bool
Prelude.Eq, ReadPrec [BlueGreenDeploymentConfiguration]
ReadPrec BlueGreenDeploymentConfiguration
Int -> ReadS BlueGreenDeploymentConfiguration
ReadS [BlueGreenDeploymentConfiguration]
(Int -> ReadS BlueGreenDeploymentConfiguration)
-> ReadS [BlueGreenDeploymentConfiguration]
-> ReadPrec BlueGreenDeploymentConfiguration
-> ReadPrec [BlueGreenDeploymentConfiguration]
-> Read BlueGreenDeploymentConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BlueGreenDeploymentConfiguration]
$creadListPrec :: ReadPrec [BlueGreenDeploymentConfiguration]
readPrec :: ReadPrec BlueGreenDeploymentConfiguration
$creadPrec :: ReadPrec BlueGreenDeploymentConfiguration
readList :: ReadS [BlueGreenDeploymentConfiguration]
$creadList :: ReadS [BlueGreenDeploymentConfiguration]
readsPrec :: Int -> ReadS BlueGreenDeploymentConfiguration
$creadsPrec :: Int -> ReadS BlueGreenDeploymentConfiguration
Prelude.Read, Int -> BlueGreenDeploymentConfiguration -> ShowS
[BlueGreenDeploymentConfiguration] -> ShowS
BlueGreenDeploymentConfiguration -> String
(Int -> BlueGreenDeploymentConfiguration -> ShowS)
-> (BlueGreenDeploymentConfiguration -> String)
-> ([BlueGreenDeploymentConfiguration] -> ShowS)
-> Show BlueGreenDeploymentConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BlueGreenDeploymentConfiguration] -> ShowS
$cshowList :: [BlueGreenDeploymentConfiguration] -> ShowS
show :: BlueGreenDeploymentConfiguration -> String
$cshow :: BlueGreenDeploymentConfiguration -> String
showsPrec :: Int -> BlueGreenDeploymentConfiguration -> ShowS
$cshowsPrec :: Int -> BlueGreenDeploymentConfiguration -> ShowS
Prelude.Show, (forall x.
 BlueGreenDeploymentConfiguration
 -> Rep BlueGreenDeploymentConfiguration x)
-> (forall x.
    Rep BlueGreenDeploymentConfiguration x
    -> BlueGreenDeploymentConfiguration)
-> Generic BlueGreenDeploymentConfiguration
forall x.
Rep BlueGreenDeploymentConfiguration x
-> BlueGreenDeploymentConfiguration
forall x.
BlueGreenDeploymentConfiguration
-> Rep BlueGreenDeploymentConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BlueGreenDeploymentConfiguration x
-> BlueGreenDeploymentConfiguration
$cfrom :: forall x.
BlueGreenDeploymentConfiguration
-> Rep BlueGreenDeploymentConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'BlueGreenDeploymentConfiguration' 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:
--
-- 'deploymentReadyOption', 'blueGreenDeploymentConfiguration_deploymentReadyOption' - Information about the action to take when newly provisioned instances
-- are ready to receive traffic in a blue\/green deployment.
--
-- 'greenFleetProvisioningOption', 'blueGreenDeploymentConfiguration_greenFleetProvisioningOption' - Information about how instances are provisioned for a replacement
-- environment in a blue\/green deployment.
--
-- 'terminateBlueInstancesOnDeploymentSuccess', 'blueGreenDeploymentConfiguration_terminateBlueInstancesOnDeploymentSuccess' - Information about whether to terminate instances in the original fleet
-- during a blue\/green deployment.
newBlueGreenDeploymentConfiguration ::
  BlueGreenDeploymentConfiguration
newBlueGreenDeploymentConfiguration :: BlueGreenDeploymentConfiguration
newBlueGreenDeploymentConfiguration =
  BlueGreenDeploymentConfiguration' :: Maybe DeploymentReadyOption
-> Maybe GreenFleetProvisioningOption
-> Maybe BlueInstanceTerminationOption
-> BlueGreenDeploymentConfiguration
BlueGreenDeploymentConfiguration'
    { $sel:deploymentReadyOption:BlueGreenDeploymentConfiguration' :: Maybe DeploymentReadyOption
deploymentReadyOption =
        Maybe DeploymentReadyOption
forall a. Maybe a
Prelude.Nothing,
      $sel:greenFleetProvisioningOption:BlueGreenDeploymentConfiguration' :: Maybe GreenFleetProvisioningOption
greenFleetProvisioningOption =
        Maybe GreenFleetProvisioningOption
forall a. Maybe a
Prelude.Nothing,
      $sel:terminateBlueInstancesOnDeploymentSuccess:BlueGreenDeploymentConfiguration' :: Maybe BlueInstanceTerminationOption
terminateBlueInstancesOnDeploymentSuccess =
        Maybe BlueInstanceTerminationOption
forall a. Maybe a
Prelude.Nothing
    }

-- | Information about the action to take when newly provisioned instances
-- are ready to receive traffic in a blue\/green deployment.
blueGreenDeploymentConfiguration_deploymentReadyOption :: Lens.Lens' BlueGreenDeploymentConfiguration (Prelude.Maybe DeploymentReadyOption)
blueGreenDeploymentConfiguration_deploymentReadyOption :: (Maybe DeploymentReadyOption -> f (Maybe DeploymentReadyOption))
-> BlueGreenDeploymentConfiguration
-> f BlueGreenDeploymentConfiguration
blueGreenDeploymentConfiguration_deploymentReadyOption = (BlueGreenDeploymentConfiguration -> Maybe DeploymentReadyOption)
-> (BlueGreenDeploymentConfiguration
    -> Maybe DeploymentReadyOption -> BlueGreenDeploymentConfiguration)
-> Lens
     BlueGreenDeploymentConfiguration
     BlueGreenDeploymentConfiguration
     (Maybe DeploymentReadyOption)
     (Maybe DeploymentReadyOption)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BlueGreenDeploymentConfiguration' {Maybe DeploymentReadyOption
deploymentReadyOption :: Maybe DeploymentReadyOption
$sel:deploymentReadyOption:BlueGreenDeploymentConfiguration' :: BlueGreenDeploymentConfiguration -> Maybe DeploymentReadyOption
deploymentReadyOption} -> Maybe DeploymentReadyOption
deploymentReadyOption) (\s :: BlueGreenDeploymentConfiguration
s@BlueGreenDeploymentConfiguration' {} Maybe DeploymentReadyOption
a -> BlueGreenDeploymentConfiguration
s {$sel:deploymentReadyOption:BlueGreenDeploymentConfiguration' :: Maybe DeploymentReadyOption
deploymentReadyOption = Maybe DeploymentReadyOption
a} :: BlueGreenDeploymentConfiguration)

-- | Information about how instances are provisioned for a replacement
-- environment in a blue\/green deployment.
blueGreenDeploymentConfiguration_greenFleetProvisioningOption :: Lens.Lens' BlueGreenDeploymentConfiguration (Prelude.Maybe GreenFleetProvisioningOption)
blueGreenDeploymentConfiguration_greenFleetProvisioningOption :: (Maybe GreenFleetProvisioningOption
 -> f (Maybe GreenFleetProvisioningOption))
-> BlueGreenDeploymentConfiguration
-> f BlueGreenDeploymentConfiguration
blueGreenDeploymentConfiguration_greenFleetProvisioningOption = (BlueGreenDeploymentConfiguration
 -> Maybe GreenFleetProvisioningOption)
-> (BlueGreenDeploymentConfiguration
    -> Maybe GreenFleetProvisioningOption
    -> BlueGreenDeploymentConfiguration)
-> Lens
     BlueGreenDeploymentConfiguration
     BlueGreenDeploymentConfiguration
     (Maybe GreenFleetProvisioningOption)
     (Maybe GreenFleetProvisioningOption)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BlueGreenDeploymentConfiguration' {Maybe GreenFleetProvisioningOption
greenFleetProvisioningOption :: Maybe GreenFleetProvisioningOption
$sel:greenFleetProvisioningOption:BlueGreenDeploymentConfiguration' :: BlueGreenDeploymentConfiguration
-> Maybe GreenFleetProvisioningOption
greenFleetProvisioningOption} -> Maybe GreenFleetProvisioningOption
greenFleetProvisioningOption) (\s :: BlueGreenDeploymentConfiguration
s@BlueGreenDeploymentConfiguration' {} Maybe GreenFleetProvisioningOption
a -> BlueGreenDeploymentConfiguration
s {$sel:greenFleetProvisioningOption:BlueGreenDeploymentConfiguration' :: Maybe GreenFleetProvisioningOption
greenFleetProvisioningOption = Maybe GreenFleetProvisioningOption
a} :: BlueGreenDeploymentConfiguration)

-- | Information about whether to terminate instances in the original fleet
-- during a blue\/green deployment.
blueGreenDeploymentConfiguration_terminateBlueInstancesOnDeploymentSuccess :: Lens.Lens' BlueGreenDeploymentConfiguration (Prelude.Maybe BlueInstanceTerminationOption)
blueGreenDeploymentConfiguration_terminateBlueInstancesOnDeploymentSuccess :: (Maybe BlueInstanceTerminationOption
 -> f (Maybe BlueInstanceTerminationOption))
-> BlueGreenDeploymentConfiguration
-> f BlueGreenDeploymentConfiguration
blueGreenDeploymentConfiguration_terminateBlueInstancesOnDeploymentSuccess = (BlueGreenDeploymentConfiguration
 -> Maybe BlueInstanceTerminationOption)
-> (BlueGreenDeploymentConfiguration
    -> Maybe BlueInstanceTerminationOption
    -> BlueGreenDeploymentConfiguration)
-> Lens
     BlueGreenDeploymentConfiguration
     BlueGreenDeploymentConfiguration
     (Maybe BlueInstanceTerminationOption)
     (Maybe BlueInstanceTerminationOption)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BlueGreenDeploymentConfiguration' {Maybe BlueInstanceTerminationOption
terminateBlueInstancesOnDeploymentSuccess :: Maybe BlueInstanceTerminationOption
$sel:terminateBlueInstancesOnDeploymentSuccess:BlueGreenDeploymentConfiguration' :: BlueGreenDeploymentConfiguration
-> Maybe BlueInstanceTerminationOption
terminateBlueInstancesOnDeploymentSuccess} -> Maybe BlueInstanceTerminationOption
terminateBlueInstancesOnDeploymentSuccess) (\s :: BlueGreenDeploymentConfiguration
s@BlueGreenDeploymentConfiguration' {} Maybe BlueInstanceTerminationOption
a -> BlueGreenDeploymentConfiguration
s {$sel:terminateBlueInstancesOnDeploymentSuccess:BlueGreenDeploymentConfiguration' :: Maybe BlueInstanceTerminationOption
terminateBlueInstancesOnDeploymentSuccess = Maybe BlueInstanceTerminationOption
a} :: BlueGreenDeploymentConfiguration)

instance
  Core.FromJSON
    BlueGreenDeploymentConfiguration
  where
  parseJSON :: Value -> Parser BlueGreenDeploymentConfiguration
parseJSON =
    String
-> (Object -> Parser BlueGreenDeploymentConfiguration)
-> Value
-> Parser BlueGreenDeploymentConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BlueGreenDeploymentConfiguration"
      ( \Object
x ->
          Maybe DeploymentReadyOption
-> Maybe GreenFleetProvisioningOption
-> Maybe BlueInstanceTerminationOption
-> BlueGreenDeploymentConfiguration
BlueGreenDeploymentConfiguration'
            (Maybe DeploymentReadyOption
 -> Maybe GreenFleetProvisioningOption
 -> Maybe BlueInstanceTerminationOption
 -> BlueGreenDeploymentConfiguration)
-> Parser (Maybe DeploymentReadyOption)
-> Parser
     (Maybe GreenFleetProvisioningOption
      -> Maybe BlueInstanceTerminationOption
      -> BlueGreenDeploymentConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe DeploymentReadyOption)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"deploymentReadyOption")
            Parser
  (Maybe GreenFleetProvisioningOption
   -> Maybe BlueInstanceTerminationOption
   -> BlueGreenDeploymentConfiguration)
-> Parser (Maybe GreenFleetProvisioningOption)
-> Parser
     (Maybe BlueInstanceTerminationOption
      -> BlueGreenDeploymentConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe GreenFleetProvisioningOption)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"greenFleetProvisioningOption")
            Parser
  (Maybe BlueInstanceTerminationOption
   -> BlueGreenDeploymentConfiguration)
-> Parser (Maybe BlueInstanceTerminationOption)
-> Parser BlueGreenDeploymentConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            Object -> Text -> Parser (Maybe BlueInstanceTerminationOption)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"terminateBlueInstancesOnDeploymentSuccess"
                        )
      )

instance
  Prelude.Hashable
    BlueGreenDeploymentConfiguration

instance
  Prelude.NFData
    BlueGreenDeploymentConfiguration

instance Core.ToJSON BlueGreenDeploymentConfiguration where
  toJSON :: BlueGreenDeploymentConfiguration -> Value
toJSON BlueGreenDeploymentConfiguration' {Maybe DeploymentReadyOption
Maybe GreenFleetProvisioningOption
Maybe BlueInstanceTerminationOption
terminateBlueInstancesOnDeploymentSuccess :: Maybe BlueInstanceTerminationOption
greenFleetProvisioningOption :: Maybe GreenFleetProvisioningOption
deploymentReadyOption :: Maybe DeploymentReadyOption
$sel:terminateBlueInstancesOnDeploymentSuccess:BlueGreenDeploymentConfiguration' :: BlueGreenDeploymentConfiguration
-> Maybe BlueInstanceTerminationOption
$sel:greenFleetProvisioningOption:BlueGreenDeploymentConfiguration' :: BlueGreenDeploymentConfiguration
-> Maybe GreenFleetProvisioningOption
$sel:deploymentReadyOption:BlueGreenDeploymentConfiguration' :: BlueGreenDeploymentConfiguration -> Maybe DeploymentReadyOption
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"deploymentReadyOption" Text -> DeploymentReadyOption -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (DeploymentReadyOption -> Pair)
-> Maybe DeploymentReadyOption -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DeploymentReadyOption
deploymentReadyOption,
            (Text
"greenFleetProvisioningOption" Text -> GreenFleetProvisioningOption -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (GreenFleetProvisioningOption -> Pair)
-> Maybe GreenFleetProvisioningOption -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe GreenFleetProvisioningOption
greenFleetProvisioningOption,
            (Text
"terminateBlueInstancesOnDeploymentSuccess" Text -> BlueInstanceTerminationOption -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (BlueInstanceTerminationOption -> Pair)
-> Maybe BlueInstanceTerminationOption -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe BlueInstanceTerminationOption
terminateBlueInstancesOnDeploymentSuccess
          ]
      )