{-# 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.ServerlessApplicationRepository.Types.RollbackConfiguration
-- 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.ServerlessApplicationRepository.Types.RollbackConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.ServerlessApplicationRepository.Types.RollbackTrigger

-- | This property corresponds to the /AWS CloudFormation
-- <https://docs.aws.amazon.com/goto/WebAPI/cloudformation-2010-05-15/RollbackConfiguration RollbackConfiguration>/
-- Data Type.
--
-- /See:/ 'newRollbackConfiguration' smart constructor.
data RollbackConfiguration = RollbackConfiguration'
  { -- | This property corresponds to the content of the same name for the /AWS
    -- CloudFormation
    -- <https://docs.aws.amazon.com/goto/WebAPI/cloudformation-2010-05-15/RollbackConfiguration RollbackConfiguration>/
    -- Data Type.
    RollbackConfiguration -> Maybe [RollbackTrigger]
rollbackTriggers :: Prelude.Maybe [RollbackTrigger],
    -- | This property corresponds to the content of the same name for the /AWS
    -- CloudFormation
    -- <https://docs.aws.amazon.com/goto/WebAPI/cloudformation-2010-05-15/RollbackConfiguration RollbackConfiguration>/
    -- Data Type.
    RollbackConfiguration -> Maybe Int
monitoringTimeInMinutes :: Prelude.Maybe Prelude.Int
  }
  deriving (RollbackConfiguration -> RollbackConfiguration -> Bool
(RollbackConfiguration -> RollbackConfiguration -> Bool)
-> (RollbackConfiguration -> RollbackConfiguration -> Bool)
-> Eq RollbackConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RollbackConfiguration -> RollbackConfiguration -> Bool
$c/= :: RollbackConfiguration -> RollbackConfiguration -> Bool
== :: RollbackConfiguration -> RollbackConfiguration -> Bool
$c== :: RollbackConfiguration -> RollbackConfiguration -> Bool
Prelude.Eq, ReadPrec [RollbackConfiguration]
ReadPrec RollbackConfiguration
Int -> ReadS RollbackConfiguration
ReadS [RollbackConfiguration]
(Int -> ReadS RollbackConfiguration)
-> ReadS [RollbackConfiguration]
-> ReadPrec RollbackConfiguration
-> ReadPrec [RollbackConfiguration]
-> Read RollbackConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RollbackConfiguration]
$creadListPrec :: ReadPrec [RollbackConfiguration]
readPrec :: ReadPrec RollbackConfiguration
$creadPrec :: ReadPrec RollbackConfiguration
readList :: ReadS [RollbackConfiguration]
$creadList :: ReadS [RollbackConfiguration]
readsPrec :: Int -> ReadS RollbackConfiguration
$creadsPrec :: Int -> ReadS RollbackConfiguration
Prelude.Read, Int -> RollbackConfiguration -> ShowS
[RollbackConfiguration] -> ShowS
RollbackConfiguration -> String
(Int -> RollbackConfiguration -> ShowS)
-> (RollbackConfiguration -> String)
-> ([RollbackConfiguration] -> ShowS)
-> Show RollbackConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RollbackConfiguration] -> ShowS
$cshowList :: [RollbackConfiguration] -> ShowS
show :: RollbackConfiguration -> String
$cshow :: RollbackConfiguration -> String
showsPrec :: Int -> RollbackConfiguration -> ShowS
$cshowsPrec :: Int -> RollbackConfiguration -> ShowS
Prelude.Show, (forall x. RollbackConfiguration -> Rep RollbackConfiguration x)
-> (forall x. Rep RollbackConfiguration x -> RollbackConfiguration)
-> Generic RollbackConfiguration
forall x. Rep RollbackConfiguration x -> RollbackConfiguration
forall x. RollbackConfiguration -> Rep RollbackConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RollbackConfiguration x -> RollbackConfiguration
$cfrom :: forall x. RollbackConfiguration -> Rep RollbackConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'RollbackConfiguration' 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:
--
-- 'rollbackTriggers', 'rollbackConfiguration_rollbackTriggers' - This property corresponds to the content of the same name for the /AWS
-- CloudFormation
-- <https://docs.aws.amazon.com/goto/WebAPI/cloudformation-2010-05-15/RollbackConfiguration RollbackConfiguration>/
-- Data Type.
--
-- 'monitoringTimeInMinutes', 'rollbackConfiguration_monitoringTimeInMinutes' - This property corresponds to the content of the same name for the /AWS
-- CloudFormation
-- <https://docs.aws.amazon.com/goto/WebAPI/cloudformation-2010-05-15/RollbackConfiguration RollbackConfiguration>/
-- Data Type.
newRollbackConfiguration ::
  RollbackConfiguration
newRollbackConfiguration :: RollbackConfiguration
newRollbackConfiguration =
  RollbackConfiguration' :: Maybe [RollbackTrigger] -> Maybe Int -> RollbackConfiguration
RollbackConfiguration'
    { $sel:rollbackTriggers:RollbackConfiguration' :: Maybe [RollbackTrigger]
rollbackTriggers =
        Maybe [RollbackTrigger]
forall a. Maybe a
Prelude.Nothing,
      $sel:monitoringTimeInMinutes:RollbackConfiguration' :: Maybe Int
monitoringTimeInMinutes = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | This property corresponds to the content of the same name for the /AWS
-- CloudFormation
-- <https://docs.aws.amazon.com/goto/WebAPI/cloudformation-2010-05-15/RollbackConfiguration RollbackConfiguration>/
-- Data Type.
rollbackConfiguration_rollbackTriggers :: Lens.Lens' RollbackConfiguration (Prelude.Maybe [RollbackTrigger])
rollbackConfiguration_rollbackTriggers :: (Maybe [RollbackTrigger] -> f (Maybe [RollbackTrigger]))
-> RollbackConfiguration -> f RollbackConfiguration
rollbackConfiguration_rollbackTriggers = (RollbackConfiguration -> Maybe [RollbackTrigger])
-> (RollbackConfiguration
    -> Maybe [RollbackTrigger] -> RollbackConfiguration)
-> Lens
     RollbackConfiguration
     RollbackConfiguration
     (Maybe [RollbackTrigger])
     (Maybe [RollbackTrigger])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RollbackConfiguration' {Maybe [RollbackTrigger]
rollbackTriggers :: Maybe [RollbackTrigger]
$sel:rollbackTriggers:RollbackConfiguration' :: RollbackConfiguration -> Maybe [RollbackTrigger]
rollbackTriggers} -> Maybe [RollbackTrigger]
rollbackTriggers) (\s :: RollbackConfiguration
s@RollbackConfiguration' {} Maybe [RollbackTrigger]
a -> RollbackConfiguration
s {$sel:rollbackTriggers:RollbackConfiguration' :: Maybe [RollbackTrigger]
rollbackTriggers = Maybe [RollbackTrigger]
a} :: RollbackConfiguration) ((Maybe [RollbackTrigger] -> f (Maybe [RollbackTrigger]))
 -> RollbackConfiguration -> f RollbackConfiguration)
-> ((Maybe [RollbackTrigger] -> f (Maybe [RollbackTrigger]))
    -> Maybe [RollbackTrigger] -> f (Maybe [RollbackTrigger]))
-> (Maybe [RollbackTrigger] -> f (Maybe [RollbackTrigger]))
-> RollbackConfiguration
-> f RollbackConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [RollbackTrigger]
  [RollbackTrigger]
  [RollbackTrigger]
  [RollbackTrigger]
-> Iso
     (Maybe [RollbackTrigger])
     (Maybe [RollbackTrigger])
     (Maybe [RollbackTrigger])
     (Maybe [RollbackTrigger])
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
  [RollbackTrigger]
  [RollbackTrigger]
  [RollbackTrigger]
  [RollbackTrigger]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | This property corresponds to the content of the same name for the /AWS
-- CloudFormation
-- <https://docs.aws.amazon.com/goto/WebAPI/cloudformation-2010-05-15/RollbackConfiguration RollbackConfiguration>/
-- Data Type.
rollbackConfiguration_monitoringTimeInMinutes :: Lens.Lens' RollbackConfiguration (Prelude.Maybe Prelude.Int)
rollbackConfiguration_monitoringTimeInMinutes :: (Maybe Int -> f (Maybe Int))
-> RollbackConfiguration -> f RollbackConfiguration
rollbackConfiguration_monitoringTimeInMinutes = (RollbackConfiguration -> Maybe Int)
-> (RollbackConfiguration -> Maybe Int -> RollbackConfiguration)
-> Lens
     RollbackConfiguration RollbackConfiguration (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RollbackConfiguration' {Maybe Int
monitoringTimeInMinutes :: Maybe Int
$sel:monitoringTimeInMinutes:RollbackConfiguration' :: RollbackConfiguration -> Maybe Int
monitoringTimeInMinutes} -> Maybe Int
monitoringTimeInMinutes) (\s :: RollbackConfiguration
s@RollbackConfiguration' {} Maybe Int
a -> RollbackConfiguration
s {$sel:monitoringTimeInMinutes:RollbackConfiguration' :: Maybe Int
monitoringTimeInMinutes = Maybe Int
a} :: RollbackConfiguration)

instance Prelude.Hashable RollbackConfiguration

instance Prelude.NFData RollbackConfiguration

instance Core.ToJSON RollbackConfiguration where
  toJSON :: RollbackConfiguration -> Value
toJSON RollbackConfiguration' {Maybe Int
Maybe [RollbackTrigger]
monitoringTimeInMinutes :: Maybe Int
rollbackTriggers :: Maybe [RollbackTrigger]
$sel:monitoringTimeInMinutes:RollbackConfiguration' :: RollbackConfiguration -> Maybe Int
$sel:rollbackTriggers:RollbackConfiguration' :: RollbackConfiguration -> Maybe [RollbackTrigger]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"rollbackTriggers" Text -> [RollbackTrigger] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([RollbackTrigger] -> Pair)
-> Maybe [RollbackTrigger] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [RollbackTrigger]
rollbackTriggers,
            (Text
"monitoringTimeInMinutes" 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
monitoringTimeInMinutes
          ]
      )