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

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

-- | Information about alarms associated with the deployment group.
--
-- /See:/ 'newAlarmConfiguration' smart constructor.
data AlarmConfiguration = 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 -> Maybe Bool
ignorePollAlarmFailure :: Prelude.Maybe Prelude.Bool,
    -- | Indicates whether the alarm configuration is enabled.
    AlarmConfiguration -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | A list of alarms configured for the deployment group. A maximum of 10
    -- alarms can be added to a deployment group.
    AlarmConfiguration -> Maybe [Alarm]
alarms :: Prelude.Maybe [Alarm]
  }
  deriving (AlarmConfiguration -> AlarmConfiguration -> Bool
(AlarmConfiguration -> AlarmConfiguration -> Bool)
-> (AlarmConfiguration -> AlarmConfiguration -> Bool)
-> Eq AlarmConfiguration
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]
(Int -> ReadS AlarmConfiguration)
-> ReadS [AlarmConfiguration]
-> ReadPrec AlarmConfiguration
-> ReadPrec [AlarmConfiguration]
-> Read 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
(Int -> AlarmConfiguration -> ShowS)
-> (AlarmConfiguration -> String)
-> ([AlarmConfiguration] -> ShowS)
-> Show AlarmConfiguration
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. AlarmConfiguration -> Rep AlarmConfiguration x)
-> (forall x. Rep AlarmConfiguration x -> AlarmConfiguration)
-> Generic AlarmConfiguration
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:
--
-- '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.
--
-- 'enabled', 'alarmConfiguration_enabled' - Indicates whether the alarm configuration is enabled.
--
-- 'alarms', 'alarmConfiguration_alarms' - A list of alarms configured for the deployment group. A maximum of 10
-- alarms can be added to a deployment group.
newAlarmConfiguration ::
  AlarmConfiguration
newAlarmConfiguration :: AlarmConfiguration
newAlarmConfiguration =
  AlarmConfiguration' :: Maybe Bool -> Maybe Bool -> Maybe [Alarm] -> AlarmConfiguration
AlarmConfiguration'
    { $sel:ignorePollAlarmFailure:AlarmConfiguration' :: Maybe Bool
ignorePollAlarmFailure =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:AlarmConfiguration' :: Maybe Bool
enabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:alarms:AlarmConfiguration' :: Maybe [Alarm]
alarms = Maybe [Alarm]
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Bool -> f (Maybe Bool))
-> AlarmConfiguration -> f AlarmConfiguration
alarmConfiguration_ignorePollAlarmFailure = (AlarmConfiguration -> Maybe Bool)
-> (AlarmConfiguration -> Maybe Bool -> AlarmConfiguration)
-> Lens
     AlarmConfiguration AlarmConfiguration (Maybe Bool) (Maybe Bool)
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)

-- | Indicates whether the alarm configuration is enabled.
alarmConfiguration_enabled :: Lens.Lens' AlarmConfiguration (Prelude.Maybe Prelude.Bool)
alarmConfiguration_enabled :: (Maybe Bool -> f (Maybe Bool))
-> AlarmConfiguration -> f AlarmConfiguration
alarmConfiguration_enabled = (AlarmConfiguration -> Maybe Bool)
-> (AlarmConfiguration -> Maybe Bool -> AlarmConfiguration)
-> Lens
     AlarmConfiguration AlarmConfiguration (Maybe Bool) (Maybe Bool)
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)

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

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

instance Prelude.Hashable AlarmConfiguration

instance Prelude.NFData AlarmConfiguration

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