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

import Amazonka.CodeDeploy.Types.DeploymentReadyAction
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about how traffic is rerouted to instances in a replacement
-- environment in a blue\/green deployment.
--
-- /See:/ 'newDeploymentReadyOption' smart constructor.
data DeploymentReadyOption = DeploymentReadyOption'
  { -- | Information about when to reroute traffic from an original environment
    -- to a replacement environment in a blue\/green deployment.
    --
    -- -   CONTINUE_DEPLOYMENT: Register new instances with the load balancer
    --     immediately after the new application revision is installed on the
    --     instances in the replacement environment.
    --
    -- -   STOP_DEPLOYMENT: Do not register new instances with a load balancer
    --     unless traffic rerouting is started using ContinueDeployment. If
    --     traffic rerouting is not started before the end of the specified
    --     wait period, the deployment status is changed to Stopped.
    DeploymentReadyOption -> Maybe DeploymentReadyAction
actionOnTimeout :: Prelude.Maybe DeploymentReadyAction,
    -- | The number of minutes to wait before the status of a blue\/green
    -- deployment is changed to Stopped if rerouting is not started manually.
    -- Applies only to the @STOP_DEPLOYMENT@ option for @actionOnTimeout@.
    DeploymentReadyOption -> Maybe Int
waitTimeInMinutes :: Prelude.Maybe Prelude.Int
  }
  deriving (DeploymentReadyOption -> DeploymentReadyOption -> Bool
(DeploymentReadyOption -> DeploymentReadyOption -> Bool)
-> (DeploymentReadyOption -> DeploymentReadyOption -> Bool)
-> Eq DeploymentReadyOption
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeploymentReadyOption -> DeploymentReadyOption -> Bool
$c/= :: DeploymentReadyOption -> DeploymentReadyOption -> Bool
== :: DeploymentReadyOption -> DeploymentReadyOption -> Bool
$c== :: DeploymentReadyOption -> DeploymentReadyOption -> Bool
Prelude.Eq, ReadPrec [DeploymentReadyOption]
ReadPrec DeploymentReadyOption
Int -> ReadS DeploymentReadyOption
ReadS [DeploymentReadyOption]
(Int -> ReadS DeploymentReadyOption)
-> ReadS [DeploymentReadyOption]
-> ReadPrec DeploymentReadyOption
-> ReadPrec [DeploymentReadyOption]
-> Read DeploymentReadyOption
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeploymentReadyOption]
$creadListPrec :: ReadPrec [DeploymentReadyOption]
readPrec :: ReadPrec DeploymentReadyOption
$creadPrec :: ReadPrec DeploymentReadyOption
readList :: ReadS [DeploymentReadyOption]
$creadList :: ReadS [DeploymentReadyOption]
readsPrec :: Int -> ReadS DeploymentReadyOption
$creadsPrec :: Int -> ReadS DeploymentReadyOption
Prelude.Read, Int -> DeploymentReadyOption -> ShowS
[DeploymentReadyOption] -> ShowS
DeploymentReadyOption -> String
(Int -> DeploymentReadyOption -> ShowS)
-> (DeploymentReadyOption -> String)
-> ([DeploymentReadyOption] -> ShowS)
-> Show DeploymentReadyOption
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeploymentReadyOption] -> ShowS
$cshowList :: [DeploymentReadyOption] -> ShowS
show :: DeploymentReadyOption -> String
$cshow :: DeploymentReadyOption -> String
showsPrec :: Int -> DeploymentReadyOption -> ShowS
$cshowsPrec :: Int -> DeploymentReadyOption -> ShowS
Prelude.Show, (forall x. DeploymentReadyOption -> Rep DeploymentReadyOption x)
-> (forall x. Rep DeploymentReadyOption x -> DeploymentReadyOption)
-> Generic DeploymentReadyOption
forall x. Rep DeploymentReadyOption x -> DeploymentReadyOption
forall x. DeploymentReadyOption -> Rep DeploymentReadyOption x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeploymentReadyOption x -> DeploymentReadyOption
$cfrom :: forall x. DeploymentReadyOption -> Rep DeploymentReadyOption x
Prelude.Generic)

-- |
-- Create a value of 'DeploymentReadyOption' 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:
--
-- 'actionOnTimeout', 'deploymentReadyOption_actionOnTimeout' - Information about when to reroute traffic from an original environment
-- to a replacement environment in a blue\/green deployment.
--
-- -   CONTINUE_DEPLOYMENT: Register new instances with the load balancer
--     immediately after the new application revision is installed on the
--     instances in the replacement environment.
--
-- -   STOP_DEPLOYMENT: Do not register new instances with a load balancer
--     unless traffic rerouting is started using ContinueDeployment. If
--     traffic rerouting is not started before the end of the specified
--     wait period, the deployment status is changed to Stopped.
--
-- 'waitTimeInMinutes', 'deploymentReadyOption_waitTimeInMinutes' - The number of minutes to wait before the status of a blue\/green
-- deployment is changed to Stopped if rerouting is not started manually.
-- Applies only to the @STOP_DEPLOYMENT@ option for @actionOnTimeout@.
newDeploymentReadyOption ::
  DeploymentReadyOption
newDeploymentReadyOption :: DeploymentReadyOption
newDeploymentReadyOption =
  DeploymentReadyOption' :: Maybe DeploymentReadyAction -> Maybe Int -> DeploymentReadyOption
DeploymentReadyOption'
    { $sel:actionOnTimeout:DeploymentReadyOption' :: Maybe DeploymentReadyAction
actionOnTimeout =
        Maybe DeploymentReadyAction
forall a. Maybe a
Prelude.Nothing,
      $sel:waitTimeInMinutes:DeploymentReadyOption' :: Maybe Int
waitTimeInMinutes = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | Information about when to reroute traffic from an original environment
-- to a replacement environment in a blue\/green deployment.
--
-- -   CONTINUE_DEPLOYMENT: Register new instances with the load balancer
--     immediately after the new application revision is installed on the
--     instances in the replacement environment.
--
-- -   STOP_DEPLOYMENT: Do not register new instances with a load balancer
--     unless traffic rerouting is started using ContinueDeployment. If
--     traffic rerouting is not started before the end of the specified
--     wait period, the deployment status is changed to Stopped.
deploymentReadyOption_actionOnTimeout :: Lens.Lens' DeploymentReadyOption (Prelude.Maybe DeploymentReadyAction)
deploymentReadyOption_actionOnTimeout :: (Maybe DeploymentReadyAction -> f (Maybe DeploymentReadyAction))
-> DeploymentReadyOption -> f DeploymentReadyOption
deploymentReadyOption_actionOnTimeout = (DeploymentReadyOption -> Maybe DeploymentReadyAction)
-> (DeploymentReadyOption
    -> Maybe DeploymentReadyAction -> DeploymentReadyOption)
-> Lens
     DeploymentReadyOption
     DeploymentReadyOption
     (Maybe DeploymentReadyAction)
     (Maybe DeploymentReadyAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentReadyOption' {Maybe DeploymentReadyAction
actionOnTimeout :: Maybe DeploymentReadyAction
$sel:actionOnTimeout:DeploymentReadyOption' :: DeploymentReadyOption -> Maybe DeploymentReadyAction
actionOnTimeout} -> Maybe DeploymentReadyAction
actionOnTimeout) (\s :: DeploymentReadyOption
s@DeploymentReadyOption' {} Maybe DeploymentReadyAction
a -> DeploymentReadyOption
s {$sel:actionOnTimeout:DeploymentReadyOption' :: Maybe DeploymentReadyAction
actionOnTimeout = Maybe DeploymentReadyAction
a} :: DeploymentReadyOption)

-- | The number of minutes to wait before the status of a blue\/green
-- deployment is changed to Stopped if rerouting is not started manually.
-- Applies only to the @STOP_DEPLOYMENT@ option for @actionOnTimeout@.
deploymentReadyOption_waitTimeInMinutes :: Lens.Lens' DeploymentReadyOption (Prelude.Maybe Prelude.Int)
deploymentReadyOption_waitTimeInMinutes :: (Maybe Int -> f (Maybe Int))
-> DeploymentReadyOption -> f DeploymentReadyOption
deploymentReadyOption_waitTimeInMinutes = (DeploymentReadyOption -> Maybe Int)
-> (DeploymentReadyOption -> Maybe Int -> DeploymentReadyOption)
-> Lens
     DeploymentReadyOption DeploymentReadyOption (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentReadyOption' {Maybe Int
waitTimeInMinutes :: Maybe Int
$sel:waitTimeInMinutes:DeploymentReadyOption' :: DeploymentReadyOption -> Maybe Int
waitTimeInMinutes} -> Maybe Int
waitTimeInMinutes) (\s :: DeploymentReadyOption
s@DeploymentReadyOption' {} Maybe Int
a -> DeploymentReadyOption
s {$sel:waitTimeInMinutes:DeploymentReadyOption' :: Maybe Int
waitTimeInMinutes = Maybe Int
a} :: DeploymentReadyOption)

instance Core.FromJSON DeploymentReadyOption where
  parseJSON :: Value -> Parser DeploymentReadyOption
parseJSON =
    String
-> (Object -> Parser DeploymentReadyOption)
-> Value
-> Parser DeploymentReadyOption
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DeploymentReadyOption"
      ( \Object
x ->
          Maybe DeploymentReadyAction -> Maybe Int -> DeploymentReadyOption
DeploymentReadyOption'
            (Maybe DeploymentReadyAction -> Maybe Int -> DeploymentReadyOption)
-> Parser (Maybe DeploymentReadyAction)
-> Parser (Maybe Int -> DeploymentReadyOption)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe DeploymentReadyAction)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"actionOnTimeout")
            Parser (Maybe Int -> DeploymentReadyOption)
-> Parser (Maybe Int) -> Parser DeploymentReadyOption
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"waitTimeInMinutes")
      )

instance Prelude.Hashable DeploymentReadyOption

instance Prelude.NFData DeploymentReadyOption

instance Core.ToJSON DeploymentReadyOption where
  toJSON :: DeploymentReadyOption -> Value
toJSON DeploymentReadyOption' {Maybe Int
Maybe DeploymentReadyAction
waitTimeInMinutes :: Maybe Int
actionOnTimeout :: Maybe DeploymentReadyAction
$sel:waitTimeInMinutes:DeploymentReadyOption' :: DeploymentReadyOption -> Maybe Int
$sel:actionOnTimeout:DeploymentReadyOption' :: DeploymentReadyOption -> Maybe DeploymentReadyAction
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"actionOnTimeout" Text -> DeploymentReadyAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (DeploymentReadyAction -> Pair)
-> Maybe DeploymentReadyAction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DeploymentReadyAction
actionOnTimeout,
            (Text
"waitTimeInMinutes" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
waitTimeInMinutes
          ]
      )