{-# 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.CodeDeploy.Types.AlarmConfiguration
-- 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.CodeDeploy.Types.AlarmConfiguration where

import Amazonka.CodeDeploy.Types.Alarm
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

-- | Information about alarms associated with a deployment or deployment
-- group.
--
-- /See:/ 'newAlarmConfiguration' smart constructor.
data AlarmConfiguration = AlarmConfiguration'
  { -- | A list of alarms configured for the deployment or deployment group. A
    -- maximum of 10 alarms can be added.
    AlarmConfiguration -> Maybe [Alarm]
alarms :: Prelude.Maybe [Alarm],
    -- | Indicates whether the alarm configuration is enabled.
    AlarmConfiguration -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | Indicates whether a deployment should continue if information about the
    -- current state of alarms cannot be retrieved from Amazon CloudWatch. The
    -- default value is false.
    --
    -- -   @true@: The deployment proceeds even if alarm status information
    --     can\'t be retrieved from Amazon CloudWatch.
    --
    -- -   @false@: The deployment stops if alarm status information can\'t be
    --     retrieved from Amazon CloudWatch.
    AlarmConfiguration -> Maybe Bool
ignorePollAlarmFailure :: Prelude.Maybe Prelude.Bool
  }
  deriving (AlarmConfiguration -> AlarmConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AlarmConfiguration -> AlarmConfiguration -> Bool
$c/= :: AlarmConfiguration -> AlarmConfiguration -> Bool
== :: AlarmConfiguration -> AlarmConfiguration -> Bool
$c== :: AlarmConfiguration -> AlarmConfiguration -> Bool
Prelude.Eq, ReadPrec [AlarmConfiguration]
ReadPrec AlarmConfiguration
Int -> ReadS AlarmConfiguration
ReadS [AlarmConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AlarmConfiguration]
$creadListPrec :: ReadPrec [AlarmConfiguration]
readPrec :: ReadPrec AlarmConfiguration
$creadPrec :: ReadPrec AlarmConfiguration
readList :: ReadS [AlarmConfiguration]
$creadList :: ReadS [AlarmConfiguration]
readsPrec :: Int -> ReadS AlarmConfiguration
$creadsPrec :: Int -> ReadS AlarmConfiguration
Prelude.Read, Int -> AlarmConfiguration -> ShowS
[AlarmConfiguration] -> ShowS
AlarmConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AlarmConfiguration] -> ShowS
$cshowList :: [AlarmConfiguration] -> ShowS
show :: AlarmConfiguration -> String
$cshow :: AlarmConfiguration -> String
showsPrec :: Int -> AlarmConfiguration -> ShowS
$cshowsPrec :: Int -> AlarmConfiguration -> ShowS
Prelude.Show, forall x. Rep AlarmConfiguration x -> AlarmConfiguration
forall x. AlarmConfiguration -> Rep AlarmConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AlarmConfiguration x -> AlarmConfiguration
$cfrom :: forall x. AlarmConfiguration -> Rep AlarmConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'AlarmConfiguration' 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', 'alarmConfiguration_alarms' - A list of alarms configured for the deployment or deployment group. A
-- maximum of 10 alarms can be added.
--
-- 'enabled', 'alarmConfiguration_enabled' - Indicates whether the alarm configuration is enabled.
--
-- 'ignorePollAlarmFailure', 'alarmConfiguration_ignorePollAlarmFailure' - Indicates whether a deployment should continue if information about the
-- current state of alarms cannot be retrieved from Amazon CloudWatch. The
-- default value is false.
--
-- -   @true@: The deployment proceeds even if alarm status information
--     can\'t be retrieved from Amazon CloudWatch.
--
-- -   @false@: The deployment stops if alarm status information can\'t be
--     retrieved from Amazon CloudWatch.
newAlarmConfiguration ::
  AlarmConfiguration
newAlarmConfiguration :: AlarmConfiguration
newAlarmConfiguration =
  AlarmConfiguration'
    { $sel:alarms:AlarmConfiguration' :: Maybe [Alarm]
alarms = forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:AlarmConfiguration' :: Maybe Bool
enabled = forall a. Maybe a
Prelude.Nothing,
      $sel:ignorePollAlarmFailure:AlarmConfiguration' :: Maybe Bool
ignorePollAlarmFailure = forall a. Maybe a
Prelude.Nothing
    }

-- | A list of alarms configured for the deployment or deployment group. A
-- maximum of 10 alarms can be added.
alarmConfiguration_alarms :: Lens.Lens' AlarmConfiguration (Prelude.Maybe [Alarm])
alarmConfiguration_alarms :: Lens' AlarmConfiguration (Maybe [Alarm])
alarmConfiguration_alarms = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlarmConfiguration' {Maybe [Alarm]
alarms :: Maybe [Alarm]
$sel:alarms:AlarmConfiguration' :: AlarmConfiguration -> Maybe [Alarm]
alarms} -> Maybe [Alarm]
alarms) (\s :: AlarmConfiguration
s@AlarmConfiguration' {} Maybe [Alarm]
a -> AlarmConfiguration
s {$sel:alarms:AlarmConfiguration' :: Maybe [Alarm]
alarms = Maybe [Alarm]
a} :: AlarmConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Indicates whether the alarm configuration is enabled.
alarmConfiguration_enabled :: Lens.Lens' AlarmConfiguration (Prelude.Maybe Prelude.Bool)
alarmConfiguration_enabled :: Lens' AlarmConfiguration (Maybe Bool)
alarmConfiguration_enabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlarmConfiguration' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:AlarmConfiguration' :: AlarmConfiguration -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: AlarmConfiguration
s@AlarmConfiguration' {} Maybe Bool
a -> AlarmConfiguration
s {$sel:enabled:AlarmConfiguration' :: Maybe Bool
enabled = Maybe Bool
a} :: AlarmConfiguration)

-- | Indicates whether a deployment should continue if information about the
-- current state of alarms cannot be retrieved from Amazon CloudWatch. The
-- default value is false.
--
-- -   @true@: The deployment proceeds even if alarm status information
--     can\'t be retrieved from Amazon CloudWatch.
--
-- -   @false@: The deployment stops if alarm status information can\'t be
--     retrieved from Amazon CloudWatch.
alarmConfiguration_ignorePollAlarmFailure :: Lens.Lens' AlarmConfiguration (Prelude.Maybe Prelude.Bool)
alarmConfiguration_ignorePollAlarmFailure :: Lens' AlarmConfiguration (Maybe Bool)
alarmConfiguration_ignorePollAlarmFailure = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlarmConfiguration' {Maybe Bool
ignorePollAlarmFailure :: Maybe Bool
$sel:ignorePollAlarmFailure:AlarmConfiguration' :: AlarmConfiguration -> Maybe Bool
ignorePollAlarmFailure} -> Maybe Bool
ignorePollAlarmFailure) (\s :: AlarmConfiguration
s@AlarmConfiguration' {} Maybe Bool
a -> AlarmConfiguration
s {$sel:ignorePollAlarmFailure:AlarmConfiguration' :: Maybe Bool
ignorePollAlarmFailure = Maybe Bool
a} :: AlarmConfiguration)

instance Data.FromJSON AlarmConfiguration where
  parseJSON :: Value -> Parser AlarmConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AlarmConfiguration"
      ( \Object
x ->
          Maybe [Alarm] -> Maybe Bool -> Maybe Bool -> AlarmConfiguration
AlarmConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"alarms" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"enabled")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ignorePollAlarmFailure")
      )

instance Prelude.Hashable AlarmConfiguration where
  hashWithSalt :: Int -> AlarmConfiguration -> Int
hashWithSalt Int
_salt AlarmConfiguration' {Maybe Bool
Maybe [Alarm]
ignorePollAlarmFailure :: Maybe Bool
enabled :: Maybe Bool
alarms :: Maybe [Alarm]
$sel:ignorePollAlarmFailure:AlarmConfiguration' :: AlarmConfiguration -> Maybe Bool
$sel:enabled:AlarmConfiguration' :: AlarmConfiguration -> Maybe Bool
$sel:alarms:AlarmConfiguration' :: AlarmConfiguration -> Maybe [Alarm]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Alarm]
alarms
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
enabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
ignorePollAlarmFailure

instance Prelude.NFData AlarmConfiguration where
  rnf :: AlarmConfiguration -> ()
rnf AlarmConfiguration' {Maybe Bool
Maybe [Alarm]
ignorePollAlarmFailure :: Maybe Bool
enabled :: Maybe Bool
alarms :: Maybe [Alarm]
$sel:ignorePollAlarmFailure:AlarmConfiguration' :: AlarmConfiguration -> Maybe Bool
$sel:enabled:AlarmConfiguration' :: AlarmConfiguration -> Maybe Bool
$sel:alarms:AlarmConfiguration' :: AlarmConfiguration -> Maybe [Alarm]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Alarm]
alarms
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
enabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
ignorePollAlarmFailure

instance Data.ToJSON AlarmConfiguration where
  toJSON :: AlarmConfiguration -> Value
toJSON AlarmConfiguration' {Maybe Bool
Maybe [Alarm]
ignorePollAlarmFailure :: Maybe Bool
enabled :: Maybe Bool
alarms :: Maybe [Alarm]
$sel:ignorePollAlarmFailure:AlarmConfiguration' :: AlarmConfiguration -> Maybe Bool
$sel:enabled:AlarmConfiguration' :: AlarmConfiguration -> Maybe Bool
$sel:alarms:AlarmConfiguration' :: AlarmConfiguration -> Maybe [Alarm]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"alarms" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Alarm]
alarms,
            (Key
"enabled" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
enabled,
            (Key
"ignorePollAlarmFailure" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
ignorePollAlarmFailure
          ]
      )