{-# 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.CloudFormation.Types.RollbackTrigger
-- 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.CloudFormation.Types.RollbackTrigger 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

-- | A rollback trigger CloudFormation monitors during creation and updating
-- of stacks. If any of the alarms you specify goes to ALARM state during
-- the stack operation or within the specified monitoring period
-- afterwards, CloudFormation rolls back the entire stack operation.
--
-- /See:/ 'newRollbackTrigger' smart constructor.
data RollbackTrigger = RollbackTrigger'
  { -- | The Amazon Resource Name (ARN) of the rollback trigger.
    --
    -- If a specified trigger is missing, the entire stack operation fails and
    -- is rolled back.
    RollbackTrigger -> Text
arn :: Prelude.Text,
    -- | The resource type of the rollback trigger. Specify either
    -- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html AWS::CloudWatch::Alarm>
    -- or
    -- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudwatch-compositealarm.html AWS::CloudWatch::CompositeAlarm>
    -- resource types.
    RollbackTrigger -> Text
type' :: Prelude.Text
  }
  deriving (RollbackTrigger -> RollbackTrigger -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RollbackTrigger -> RollbackTrigger -> Bool
$c/= :: RollbackTrigger -> RollbackTrigger -> Bool
== :: RollbackTrigger -> RollbackTrigger -> Bool
$c== :: RollbackTrigger -> RollbackTrigger -> Bool
Prelude.Eq, ReadPrec [RollbackTrigger]
ReadPrec RollbackTrigger
Int -> ReadS RollbackTrigger
ReadS [RollbackTrigger]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RollbackTrigger]
$creadListPrec :: ReadPrec [RollbackTrigger]
readPrec :: ReadPrec RollbackTrigger
$creadPrec :: ReadPrec RollbackTrigger
readList :: ReadS [RollbackTrigger]
$creadList :: ReadS [RollbackTrigger]
readsPrec :: Int -> ReadS RollbackTrigger
$creadsPrec :: Int -> ReadS RollbackTrigger
Prelude.Read, Int -> RollbackTrigger -> ShowS
[RollbackTrigger] -> ShowS
RollbackTrigger -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RollbackTrigger] -> ShowS
$cshowList :: [RollbackTrigger] -> ShowS
show :: RollbackTrigger -> String
$cshow :: RollbackTrigger -> String
showsPrec :: Int -> RollbackTrigger -> ShowS
$cshowsPrec :: Int -> RollbackTrigger -> ShowS
Prelude.Show, forall x. Rep RollbackTrigger x -> RollbackTrigger
forall x. RollbackTrigger -> Rep RollbackTrigger x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RollbackTrigger x -> RollbackTrigger
$cfrom :: forall x. RollbackTrigger -> Rep RollbackTrigger x
Prelude.Generic)

-- |
-- Create a value of 'RollbackTrigger' 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:
--
-- 'arn', 'rollbackTrigger_arn' - The Amazon Resource Name (ARN) of the rollback trigger.
--
-- If a specified trigger is missing, the entire stack operation fails and
-- is rolled back.
--
-- 'type'', 'rollbackTrigger_type' - The resource type of the rollback trigger. Specify either
-- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html AWS::CloudWatch::Alarm>
-- or
-- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudwatch-compositealarm.html AWS::CloudWatch::CompositeAlarm>
-- resource types.
newRollbackTrigger ::
  -- | 'arn'
  Prelude.Text ->
  -- | 'type''
  Prelude.Text ->
  RollbackTrigger
newRollbackTrigger :: Text -> Text -> RollbackTrigger
newRollbackTrigger Text
pArn_ Text
pType_ =
  RollbackTrigger' {$sel:arn:RollbackTrigger' :: Text
arn = Text
pArn_, $sel:type':RollbackTrigger' :: Text
type' = Text
pType_}

-- | The Amazon Resource Name (ARN) of the rollback trigger.
--
-- If a specified trigger is missing, the entire stack operation fails and
-- is rolled back.
rollbackTrigger_arn :: Lens.Lens' RollbackTrigger Prelude.Text
rollbackTrigger_arn :: Lens' RollbackTrigger Text
rollbackTrigger_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RollbackTrigger' {Text
arn :: Text
$sel:arn:RollbackTrigger' :: RollbackTrigger -> Text
arn} -> Text
arn) (\s :: RollbackTrigger
s@RollbackTrigger' {} Text
a -> RollbackTrigger
s {$sel:arn:RollbackTrigger' :: Text
arn = Text
a} :: RollbackTrigger)

-- | The resource type of the rollback trigger. Specify either
-- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html AWS::CloudWatch::Alarm>
-- or
-- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudwatch-compositealarm.html AWS::CloudWatch::CompositeAlarm>
-- resource types.
rollbackTrigger_type :: Lens.Lens' RollbackTrigger Prelude.Text
rollbackTrigger_type :: Lens' RollbackTrigger Text
rollbackTrigger_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RollbackTrigger' {Text
type' :: Text
$sel:type':RollbackTrigger' :: RollbackTrigger -> Text
type'} -> Text
type') (\s :: RollbackTrigger
s@RollbackTrigger' {} Text
a -> RollbackTrigger
s {$sel:type':RollbackTrigger' :: Text
type' = Text
a} :: RollbackTrigger)

instance Data.FromXML RollbackTrigger where
  parseXML :: [Node] -> Either String RollbackTrigger
parseXML [Node]
x =
    Text -> Text -> RollbackTrigger
RollbackTrigger'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Arn")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Type")

instance Prelude.Hashable RollbackTrigger where
  hashWithSalt :: Int -> RollbackTrigger -> Int
hashWithSalt Int
_salt RollbackTrigger' {Text
type' :: Text
arn :: Text
$sel:type':RollbackTrigger' :: RollbackTrigger -> Text
$sel:arn:RollbackTrigger' :: RollbackTrigger -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
type'

instance Prelude.NFData RollbackTrigger where
  rnf :: RollbackTrigger -> ()
rnf RollbackTrigger' {Text
type' :: Text
arn :: Text
$sel:type':RollbackTrigger' :: RollbackTrigger -> Text
$sel:arn:RollbackTrigger' :: RollbackTrigger -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
arn seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
type'

instance Data.ToQuery RollbackTrigger where
  toQuery :: RollbackTrigger -> QueryString
toQuery RollbackTrigger' {Text
type' :: Text
arn :: Text
$sel:type':RollbackTrigger' :: RollbackTrigger -> Text
$sel:arn:RollbackTrigger' :: RollbackTrigger -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"Arn" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
arn, ByteString
"Type" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
type']