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

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

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

-- |
-- Create a value of 'AutoRollbackConfig' 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:
--
-- 'alarms', 'autoRollbackConfig_alarms' -
newAutoRollbackConfig ::
  AutoRollbackConfig
newAutoRollbackConfig :: AutoRollbackConfig
newAutoRollbackConfig =
  AutoRollbackConfig' :: Maybe (NonEmpty Alarm) -> AutoRollbackConfig
AutoRollbackConfig' {$sel:alarms:AutoRollbackConfig' :: Maybe (NonEmpty Alarm)
alarms = Maybe (NonEmpty Alarm)
forall a. Maybe a
Prelude.Nothing}

-- |
autoRollbackConfig_alarms :: Lens.Lens' AutoRollbackConfig (Prelude.Maybe (Prelude.NonEmpty Alarm))
autoRollbackConfig_alarms :: (Maybe (NonEmpty Alarm) -> f (Maybe (NonEmpty Alarm)))
-> AutoRollbackConfig -> f AutoRollbackConfig
autoRollbackConfig_alarms = (AutoRollbackConfig -> Maybe (NonEmpty Alarm))
-> (AutoRollbackConfig
    -> Maybe (NonEmpty Alarm) -> AutoRollbackConfig)
-> Lens
     AutoRollbackConfig
     AutoRollbackConfig
     (Maybe (NonEmpty Alarm))
     (Maybe (NonEmpty Alarm))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoRollbackConfig' {Maybe (NonEmpty Alarm)
alarms :: Maybe (NonEmpty Alarm)
$sel:alarms:AutoRollbackConfig' :: AutoRollbackConfig -> Maybe (NonEmpty Alarm)
alarms} -> Maybe (NonEmpty Alarm)
alarms) (\s :: AutoRollbackConfig
s@AutoRollbackConfig' {} Maybe (NonEmpty Alarm)
a -> AutoRollbackConfig
s {$sel:alarms:AutoRollbackConfig' :: Maybe (NonEmpty Alarm)
alarms = Maybe (NonEmpty Alarm)
a} :: AutoRollbackConfig) ((Maybe (NonEmpty Alarm) -> f (Maybe (NonEmpty Alarm)))
 -> AutoRollbackConfig -> f AutoRollbackConfig)
-> ((Maybe (NonEmpty Alarm) -> f (Maybe (NonEmpty Alarm)))
    -> Maybe (NonEmpty Alarm) -> f (Maybe (NonEmpty Alarm)))
-> (Maybe (NonEmpty Alarm) -> f (Maybe (NonEmpty Alarm)))
-> AutoRollbackConfig
-> f AutoRollbackConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Alarm) (NonEmpty Alarm) (NonEmpty Alarm) (NonEmpty Alarm)
-> Iso
     (Maybe (NonEmpty Alarm))
     (Maybe (NonEmpty Alarm))
     (Maybe (NonEmpty Alarm))
     (Maybe (NonEmpty Alarm))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (NonEmpty Alarm) (NonEmpty Alarm) (NonEmpty Alarm) (NonEmpty Alarm)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable AutoRollbackConfig

instance Prelude.NFData AutoRollbackConfig

instance Core.ToJSON AutoRollbackConfig where
  toJSON :: AutoRollbackConfig -> Value
toJSON AutoRollbackConfig' {Maybe (NonEmpty Alarm)
alarms :: Maybe (NonEmpty Alarm)
$sel:alarms:AutoRollbackConfig' :: AutoRollbackConfig -> Maybe (NonEmpty Alarm)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"Alarms" Text -> NonEmpty Alarm -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Alarm -> Pair) -> Maybe (NonEmpty Alarm) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Alarm)
alarms]
      )