{-# 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.SageMaker.Types.BlueGreenUpdatePolicy
-- 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.SageMaker.Types.BlueGreenUpdatePolicy where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.TrafficRoutingConfig

-- | Currently, the @BlueGreenUpdatePolicy@ API is not supported.
--
-- /See:/ 'newBlueGreenUpdatePolicy' smart constructor.
data BlueGreenUpdatePolicy = BlueGreenUpdatePolicy'
  { BlueGreenUpdatePolicy -> Maybe Natural
maximumExecutionTimeoutInSeconds :: Prelude.Maybe Prelude.Natural,
    BlueGreenUpdatePolicy -> Maybe Natural
terminationWaitInSeconds :: Prelude.Maybe Prelude.Natural,
    BlueGreenUpdatePolicy -> TrafficRoutingConfig
trafficRoutingConfiguration :: TrafficRoutingConfig
  }
  deriving (BlueGreenUpdatePolicy -> BlueGreenUpdatePolicy -> Bool
(BlueGreenUpdatePolicy -> BlueGreenUpdatePolicy -> Bool)
-> (BlueGreenUpdatePolicy -> BlueGreenUpdatePolicy -> Bool)
-> Eq BlueGreenUpdatePolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BlueGreenUpdatePolicy -> BlueGreenUpdatePolicy -> Bool
$c/= :: BlueGreenUpdatePolicy -> BlueGreenUpdatePolicy -> Bool
== :: BlueGreenUpdatePolicy -> BlueGreenUpdatePolicy -> Bool
$c== :: BlueGreenUpdatePolicy -> BlueGreenUpdatePolicy -> Bool
Prelude.Eq, ReadPrec [BlueGreenUpdatePolicy]
ReadPrec BlueGreenUpdatePolicy
Int -> ReadS BlueGreenUpdatePolicy
ReadS [BlueGreenUpdatePolicy]
(Int -> ReadS BlueGreenUpdatePolicy)
-> ReadS [BlueGreenUpdatePolicy]
-> ReadPrec BlueGreenUpdatePolicy
-> ReadPrec [BlueGreenUpdatePolicy]
-> Read BlueGreenUpdatePolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BlueGreenUpdatePolicy]
$creadListPrec :: ReadPrec [BlueGreenUpdatePolicy]
readPrec :: ReadPrec BlueGreenUpdatePolicy
$creadPrec :: ReadPrec BlueGreenUpdatePolicy
readList :: ReadS [BlueGreenUpdatePolicy]
$creadList :: ReadS [BlueGreenUpdatePolicy]
readsPrec :: Int -> ReadS BlueGreenUpdatePolicy
$creadsPrec :: Int -> ReadS BlueGreenUpdatePolicy
Prelude.Read, Int -> BlueGreenUpdatePolicy -> ShowS
[BlueGreenUpdatePolicy] -> ShowS
BlueGreenUpdatePolicy -> String
(Int -> BlueGreenUpdatePolicy -> ShowS)
-> (BlueGreenUpdatePolicy -> String)
-> ([BlueGreenUpdatePolicy] -> ShowS)
-> Show BlueGreenUpdatePolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BlueGreenUpdatePolicy] -> ShowS
$cshowList :: [BlueGreenUpdatePolicy] -> ShowS
show :: BlueGreenUpdatePolicy -> String
$cshow :: BlueGreenUpdatePolicy -> String
showsPrec :: Int -> BlueGreenUpdatePolicy -> ShowS
$cshowsPrec :: Int -> BlueGreenUpdatePolicy -> ShowS
Prelude.Show, (forall x. BlueGreenUpdatePolicy -> Rep BlueGreenUpdatePolicy x)
-> (forall x. Rep BlueGreenUpdatePolicy x -> BlueGreenUpdatePolicy)
-> Generic BlueGreenUpdatePolicy
forall x. Rep BlueGreenUpdatePolicy x -> BlueGreenUpdatePolicy
forall x. BlueGreenUpdatePolicy -> Rep BlueGreenUpdatePolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BlueGreenUpdatePolicy x -> BlueGreenUpdatePolicy
$cfrom :: forall x. BlueGreenUpdatePolicy -> Rep BlueGreenUpdatePolicy x
Prelude.Generic)

-- |
-- Create a value of 'BlueGreenUpdatePolicy' 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:
--
-- 'maximumExecutionTimeoutInSeconds', 'blueGreenUpdatePolicy_maximumExecutionTimeoutInSeconds' -
--
-- 'terminationWaitInSeconds', 'blueGreenUpdatePolicy_terminationWaitInSeconds' -
--
-- 'trafficRoutingConfiguration', 'blueGreenUpdatePolicy_trafficRoutingConfiguration' -
newBlueGreenUpdatePolicy ::
  -- | 'trafficRoutingConfiguration'
  TrafficRoutingConfig ->
  BlueGreenUpdatePolicy
newBlueGreenUpdatePolicy :: TrafficRoutingConfig -> BlueGreenUpdatePolicy
newBlueGreenUpdatePolicy
  TrafficRoutingConfig
pTrafficRoutingConfiguration_ =
    BlueGreenUpdatePolicy' :: Maybe Natural
-> Maybe Natural -> TrafficRoutingConfig -> BlueGreenUpdatePolicy
BlueGreenUpdatePolicy'
      { $sel:maximumExecutionTimeoutInSeconds:BlueGreenUpdatePolicy' :: Maybe Natural
maximumExecutionTimeoutInSeconds =
          Maybe Natural
forall a. Maybe a
Prelude.Nothing,
        $sel:terminationWaitInSeconds:BlueGreenUpdatePolicy' :: Maybe Natural
terminationWaitInSeconds = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
        $sel:trafficRoutingConfiguration:BlueGreenUpdatePolicy' :: TrafficRoutingConfig
trafficRoutingConfiguration =
          TrafficRoutingConfig
pTrafficRoutingConfiguration_
      }

-- |
blueGreenUpdatePolicy_maximumExecutionTimeoutInSeconds :: Lens.Lens' BlueGreenUpdatePolicy (Prelude.Maybe Prelude.Natural)
blueGreenUpdatePolicy_maximumExecutionTimeoutInSeconds :: (Maybe Natural -> f (Maybe Natural))
-> BlueGreenUpdatePolicy -> f BlueGreenUpdatePolicy
blueGreenUpdatePolicy_maximumExecutionTimeoutInSeconds = (BlueGreenUpdatePolicy -> Maybe Natural)
-> (BlueGreenUpdatePolicy
    -> Maybe Natural -> BlueGreenUpdatePolicy)
-> Lens
     BlueGreenUpdatePolicy
     BlueGreenUpdatePolicy
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BlueGreenUpdatePolicy' {Maybe Natural
maximumExecutionTimeoutInSeconds :: Maybe Natural
$sel:maximumExecutionTimeoutInSeconds:BlueGreenUpdatePolicy' :: BlueGreenUpdatePolicy -> Maybe Natural
maximumExecutionTimeoutInSeconds} -> Maybe Natural
maximumExecutionTimeoutInSeconds) (\s :: BlueGreenUpdatePolicy
s@BlueGreenUpdatePolicy' {} Maybe Natural
a -> BlueGreenUpdatePolicy
s {$sel:maximumExecutionTimeoutInSeconds:BlueGreenUpdatePolicy' :: Maybe Natural
maximumExecutionTimeoutInSeconds = Maybe Natural
a} :: BlueGreenUpdatePolicy)

-- |
blueGreenUpdatePolicy_terminationWaitInSeconds :: Lens.Lens' BlueGreenUpdatePolicy (Prelude.Maybe Prelude.Natural)
blueGreenUpdatePolicy_terminationWaitInSeconds :: (Maybe Natural -> f (Maybe Natural))
-> BlueGreenUpdatePolicy -> f BlueGreenUpdatePolicy
blueGreenUpdatePolicy_terminationWaitInSeconds = (BlueGreenUpdatePolicy -> Maybe Natural)
-> (BlueGreenUpdatePolicy
    -> Maybe Natural -> BlueGreenUpdatePolicy)
-> Lens
     BlueGreenUpdatePolicy
     BlueGreenUpdatePolicy
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BlueGreenUpdatePolicy' {Maybe Natural
terminationWaitInSeconds :: Maybe Natural
$sel:terminationWaitInSeconds:BlueGreenUpdatePolicy' :: BlueGreenUpdatePolicy -> Maybe Natural
terminationWaitInSeconds} -> Maybe Natural
terminationWaitInSeconds) (\s :: BlueGreenUpdatePolicy
s@BlueGreenUpdatePolicy' {} Maybe Natural
a -> BlueGreenUpdatePolicy
s {$sel:terminationWaitInSeconds:BlueGreenUpdatePolicy' :: Maybe Natural
terminationWaitInSeconds = Maybe Natural
a} :: BlueGreenUpdatePolicy)

-- |
blueGreenUpdatePolicy_trafficRoutingConfiguration :: Lens.Lens' BlueGreenUpdatePolicy TrafficRoutingConfig
blueGreenUpdatePolicy_trafficRoutingConfiguration :: (TrafficRoutingConfig -> f TrafficRoutingConfig)
-> BlueGreenUpdatePolicy -> f BlueGreenUpdatePolicy
blueGreenUpdatePolicy_trafficRoutingConfiguration = (BlueGreenUpdatePolicy -> TrafficRoutingConfig)
-> (BlueGreenUpdatePolicy
    -> TrafficRoutingConfig -> BlueGreenUpdatePolicy)
-> Lens
     BlueGreenUpdatePolicy
     BlueGreenUpdatePolicy
     TrafficRoutingConfig
     TrafficRoutingConfig
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BlueGreenUpdatePolicy' {TrafficRoutingConfig
trafficRoutingConfiguration :: TrafficRoutingConfig
$sel:trafficRoutingConfiguration:BlueGreenUpdatePolicy' :: BlueGreenUpdatePolicy -> TrafficRoutingConfig
trafficRoutingConfiguration} -> TrafficRoutingConfig
trafficRoutingConfiguration) (\s :: BlueGreenUpdatePolicy
s@BlueGreenUpdatePolicy' {} TrafficRoutingConfig
a -> BlueGreenUpdatePolicy
s {$sel:trafficRoutingConfiguration:BlueGreenUpdatePolicy' :: TrafficRoutingConfig
trafficRoutingConfiguration = TrafficRoutingConfig
a} :: BlueGreenUpdatePolicy)

instance Core.FromJSON BlueGreenUpdatePolicy where
  parseJSON :: Value -> Parser BlueGreenUpdatePolicy
parseJSON =
    String
-> (Object -> Parser BlueGreenUpdatePolicy)
-> Value
-> Parser BlueGreenUpdatePolicy
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BlueGreenUpdatePolicy"
      ( \Object
x ->
          Maybe Natural
-> Maybe Natural -> TrafficRoutingConfig -> BlueGreenUpdatePolicy
BlueGreenUpdatePolicy'
            (Maybe Natural
 -> Maybe Natural -> TrafficRoutingConfig -> BlueGreenUpdatePolicy)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Natural -> TrafficRoutingConfig -> BlueGreenUpdatePolicy)
forall (f :: * -> *) a b. Functor 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
"MaximumExecutionTimeoutInSeconds")
            Parser
  (Maybe Natural -> TrafficRoutingConfig -> BlueGreenUpdatePolicy)
-> Parser (Maybe Natural)
-> Parser (TrafficRoutingConfig -> BlueGreenUpdatePolicy)
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
"TerminationWaitInSeconds")
            Parser (TrafficRoutingConfig -> BlueGreenUpdatePolicy)
-> Parser TrafficRoutingConfig -> Parser BlueGreenUpdatePolicy
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser TrafficRoutingConfig
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"TrafficRoutingConfiguration")
      )

instance Prelude.Hashable BlueGreenUpdatePolicy

instance Prelude.NFData BlueGreenUpdatePolicy

instance Core.ToJSON BlueGreenUpdatePolicy where
  toJSON :: BlueGreenUpdatePolicy -> Value
toJSON BlueGreenUpdatePolicy' {Maybe Natural
TrafficRoutingConfig
trafficRoutingConfiguration :: TrafficRoutingConfig
terminationWaitInSeconds :: Maybe Natural
maximumExecutionTimeoutInSeconds :: Maybe Natural
$sel:trafficRoutingConfiguration:BlueGreenUpdatePolicy' :: BlueGreenUpdatePolicy -> TrafficRoutingConfig
$sel:terminationWaitInSeconds:BlueGreenUpdatePolicy' :: BlueGreenUpdatePolicy -> Maybe Natural
$sel:maximumExecutionTimeoutInSeconds:BlueGreenUpdatePolicy' :: BlueGreenUpdatePolicy -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"MaximumExecutionTimeoutInSeconds" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maximumExecutionTimeoutInSeconds,
            (Text
"TerminationWaitInSeconds" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
terminationWaitInSeconds,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"TrafficRoutingConfiguration"
                  Text -> TrafficRoutingConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= TrafficRoutingConfig
trafficRoutingConfiguration
              )
          ]
      )