{-# 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.EdgeDeploymentConfig
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SageMaker.Types.EdgeDeploymentConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.FailureHandlingPolicy

-- | Contains information about the configuration of a deployment.
--
-- /See:/ 'newEdgeDeploymentConfig' smart constructor.
data EdgeDeploymentConfig = EdgeDeploymentConfig'
  { -- | Toggle that determines whether to rollback to previous configuration if
    -- the current deployment fails. By default this is turned on. You may turn
    -- this off if you want to investigate the errors yourself.
    EdgeDeploymentConfig -> FailureHandlingPolicy
failureHandlingPolicy :: FailureHandlingPolicy
  }
  deriving (EdgeDeploymentConfig -> EdgeDeploymentConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EdgeDeploymentConfig -> EdgeDeploymentConfig -> Bool
$c/= :: EdgeDeploymentConfig -> EdgeDeploymentConfig -> Bool
== :: EdgeDeploymentConfig -> EdgeDeploymentConfig -> Bool
$c== :: EdgeDeploymentConfig -> EdgeDeploymentConfig -> Bool
Prelude.Eq, ReadPrec [EdgeDeploymentConfig]
ReadPrec EdgeDeploymentConfig
Int -> ReadS EdgeDeploymentConfig
ReadS [EdgeDeploymentConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EdgeDeploymentConfig]
$creadListPrec :: ReadPrec [EdgeDeploymentConfig]
readPrec :: ReadPrec EdgeDeploymentConfig
$creadPrec :: ReadPrec EdgeDeploymentConfig
readList :: ReadS [EdgeDeploymentConfig]
$creadList :: ReadS [EdgeDeploymentConfig]
readsPrec :: Int -> ReadS EdgeDeploymentConfig
$creadsPrec :: Int -> ReadS EdgeDeploymentConfig
Prelude.Read, Int -> EdgeDeploymentConfig -> ShowS
[EdgeDeploymentConfig] -> ShowS
EdgeDeploymentConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EdgeDeploymentConfig] -> ShowS
$cshowList :: [EdgeDeploymentConfig] -> ShowS
show :: EdgeDeploymentConfig -> String
$cshow :: EdgeDeploymentConfig -> String
showsPrec :: Int -> EdgeDeploymentConfig -> ShowS
$cshowsPrec :: Int -> EdgeDeploymentConfig -> ShowS
Prelude.Show, forall x. Rep EdgeDeploymentConfig x -> EdgeDeploymentConfig
forall x. EdgeDeploymentConfig -> Rep EdgeDeploymentConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EdgeDeploymentConfig x -> EdgeDeploymentConfig
$cfrom :: forall x. EdgeDeploymentConfig -> Rep EdgeDeploymentConfig x
Prelude.Generic)

-- |
-- Create a value of 'EdgeDeploymentConfig' 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:
--
-- 'failureHandlingPolicy', 'edgeDeploymentConfig_failureHandlingPolicy' - Toggle that determines whether to rollback to previous configuration if
-- the current deployment fails. By default this is turned on. You may turn
-- this off if you want to investigate the errors yourself.
newEdgeDeploymentConfig ::
  -- | 'failureHandlingPolicy'
  FailureHandlingPolicy ->
  EdgeDeploymentConfig
newEdgeDeploymentConfig :: FailureHandlingPolicy -> EdgeDeploymentConfig
newEdgeDeploymentConfig FailureHandlingPolicy
pFailureHandlingPolicy_ =
  EdgeDeploymentConfig'
    { $sel:failureHandlingPolicy:EdgeDeploymentConfig' :: FailureHandlingPolicy
failureHandlingPolicy =
        FailureHandlingPolicy
pFailureHandlingPolicy_
    }

-- | Toggle that determines whether to rollback to previous configuration if
-- the current deployment fails. By default this is turned on. You may turn
-- this off if you want to investigate the errors yourself.
edgeDeploymentConfig_failureHandlingPolicy :: Lens.Lens' EdgeDeploymentConfig FailureHandlingPolicy
edgeDeploymentConfig_failureHandlingPolicy :: Lens' EdgeDeploymentConfig FailureHandlingPolicy
edgeDeploymentConfig_failureHandlingPolicy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EdgeDeploymentConfig' {FailureHandlingPolicy
failureHandlingPolicy :: FailureHandlingPolicy
$sel:failureHandlingPolicy:EdgeDeploymentConfig' :: EdgeDeploymentConfig -> FailureHandlingPolicy
failureHandlingPolicy} -> FailureHandlingPolicy
failureHandlingPolicy) (\s :: EdgeDeploymentConfig
s@EdgeDeploymentConfig' {} FailureHandlingPolicy
a -> EdgeDeploymentConfig
s {$sel:failureHandlingPolicy:EdgeDeploymentConfig' :: FailureHandlingPolicy
failureHandlingPolicy = FailureHandlingPolicy
a} :: EdgeDeploymentConfig)

instance Data.FromJSON EdgeDeploymentConfig where
  parseJSON :: Value -> Parser EdgeDeploymentConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EdgeDeploymentConfig"
      ( \Object
x ->
          FailureHandlingPolicy -> EdgeDeploymentConfig
EdgeDeploymentConfig'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"FailureHandlingPolicy")
      )

instance Prelude.Hashable EdgeDeploymentConfig where
  hashWithSalt :: Int -> EdgeDeploymentConfig -> Int
hashWithSalt Int
_salt EdgeDeploymentConfig' {FailureHandlingPolicy
failureHandlingPolicy :: FailureHandlingPolicy
$sel:failureHandlingPolicy:EdgeDeploymentConfig' :: EdgeDeploymentConfig -> FailureHandlingPolicy
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` FailureHandlingPolicy
failureHandlingPolicy

instance Prelude.NFData EdgeDeploymentConfig where
  rnf :: EdgeDeploymentConfig -> ()
rnf EdgeDeploymentConfig' {FailureHandlingPolicy
failureHandlingPolicy :: FailureHandlingPolicy
$sel:failureHandlingPolicy:EdgeDeploymentConfig' :: EdgeDeploymentConfig -> FailureHandlingPolicy
..} =
    forall a. NFData a => a -> ()
Prelude.rnf FailureHandlingPolicy
failureHandlingPolicy

instance Data.ToJSON EdgeDeploymentConfig where
  toJSON :: EdgeDeploymentConfig -> Value
toJSON EdgeDeploymentConfig' {FailureHandlingPolicy
failureHandlingPolicy :: FailureHandlingPolicy
$sel:failureHandlingPolicy:EdgeDeploymentConfig' :: EdgeDeploymentConfig -> FailureHandlingPolicy
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              ( Key
"FailureHandlingPolicy"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= FailureHandlingPolicy
failureHandlingPolicy
              )
          ]
      )