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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.AutoRollbackConfig
import Amazonka.SageMaker.Types.BlueGreenUpdatePolicy

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

-- |
-- Create a value of 'DeploymentConfig' 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:
--
-- 'autoRollbackConfiguration', 'deploymentConfig_autoRollbackConfiguration' -
--
-- 'blueGreenUpdatePolicy', 'deploymentConfig_blueGreenUpdatePolicy' -
newDeploymentConfig ::
  -- | 'blueGreenUpdatePolicy'
  BlueGreenUpdatePolicy ->
  DeploymentConfig
newDeploymentConfig :: BlueGreenUpdatePolicy -> DeploymentConfig
newDeploymentConfig BlueGreenUpdatePolicy
pBlueGreenUpdatePolicy_ =
  DeploymentConfig' :: Maybe AutoRollbackConfig
-> BlueGreenUpdatePolicy -> DeploymentConfig
DeploymentConfig'
    { $sel:autoRollbackConfiguration:DeploymentConfig' :: Maybe AutoRollbackConfig
autoRollbackConfiguration =
        Maybe AutoRollbackConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:blueGreenUpdatePolicy:DeploymentConfig' :: BlueGreenUpdatePolicy
blueGreenUpdatePolicy = BlueGreenUpdatePolicy
pBlueGreenUpdatePolicy_
    }

-- |
deploymentConfig_autoRollbackConfiguration :: Lens.Lens' DeploymentConfig (Prelude.Maybe AutoRollbackConfig)
deploymentConfig_autoRollbackConfiguration :: (Maybe AutoRollbackConfig -> f (Maybe AutoRollbackConfig))
-> DeploymentConfig -> f DeploymentConfig
deploymentConfig_autoRollbackConfiguration = (DeploymentConfig -> Maybe AutoRollbackConfig)
-> (DeploymentConfig
    -> Maybe AutoRollbackConfig -> DeploymentConfig)
-> Lens
     DeploymentConfig
     DeploymentConfig
     (Maybe AutoRollbackConfig)
     (Maybe AutoRollbackConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentConfig' {Maybe AutoRollbackConfig
autoRollbackConfiguration :: Maybe AutoRollbackConfig
$sel:autoRollbackConfiguration:DeploymentConfig' :: DeploymentConfig -> Maybe AutoRollbackConfig
autoRollbackConfiguration} -> Maybe AutoRollbackConfig
autoRollbackConfiguration) (\s :: DeploymentConfig
s@DeploymentConfig' {} Maybe AutoRollbackConfig
a -> DeploymentConfig
s {$sel:autoRollbackConfiguration:DeploymentConfig' :: Maybe AutoRollbackConfig
autoRollbackConfiguration = Maybe AutoRollbackConfig
a} :: DeploymentConfig)

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

instance Core.FromJSON DeploymentConfig where
  parseJSON :: Value -> Parser DeploymentConfig
parseJSON =
    String
-> (Object -> Parser DeploymentConfig)
-> Value
-> Parser DeploymentConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DeploymentConfig"
      ( \Object
x ->
          Maybe AutoRollbackConfig
-> BlueGreenUpdatePolicy -> DeploymentConfig
DeploymentConfig'
            (Maybe AutoRollbackConfig
 -> BlueGreenUpdatePolicy -> DeploymentConfig)
-> Parser (Maybe AutoRollbackConfig)
-> Parser (BlueGreenUpdatePolicy -> DeploymentConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe AutoRollbackConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AutoRollbackConfiguration")
            Parser (BlueGreenUpdatePolicy -> DeploymentConfig)
-> Parser BlueGreenUpdatePolicy -> Parser DeploymentConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser BlueGreenUpdatePolicy
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"BlueGreenUpdatePolicy")
      )

instance Prelude.Hashable DeploymentConfig

instance Prelude.NFData DeploymentConfig

instance Core.ToJSON DeploymentConfig where
  toJSON :: DeploymentConfig -> Value
toJSON DeploymentConfig' {Maybe AutoRollbackConfig
BlueGreenUpdatePolicy
blueGreenUpdatePolicy :: BlueGreenUpdatePolicy
autoRollbackConfiguration :: Maybe AutoRollbackConfig
$sel:blueGreenUpdatePolicy:DeploymentConfig' :: DeploymentConfig -> BlueGreenUpdatePolicy
$sel:autoRollbackConfiguration:DeploymentConfig' :: DeploymentConfig -> Maybe AutoRollbackConfig
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AutoRollbackConfiguration" Text -> AutoRollbackConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (AutoRollbackConfig -> Pair)
-> Maybe AutoRollbackConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AutoRollbackConfig
autoRollbackConfiguration,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"BlueGreenUpdatePolicy"
                  Text -> BlueGreenUpdatePolicy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= BlueGreenUpdatePolicy
blueGreenUpdatePolicy
              )
          ]
      )