{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.CloudWatch.PutCompositeAlarm
-- 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)
--
-- Creates or updates a /composite alarm/. When you create a composite
-- alarm, you specify a rule expression for the alarm that takes into
-- account the alarm states of other alarms that you have created. The
-- composite alarm goes into ALARM state only if all conditions of the rule
-- are met.
--
-- The alarms specified in a composite alarm\'s rule expression can include
-- metric alarms and other composite alarms.
--
-- Using composite alarms can reduce alarm noise. You can create multiple
-- metric alarms, and also create a composite alarm and set up alerts only
-- for the composite alarm. For example, you could create a composite alarm
-- that goes into ALARM state only when more than one of the underlying
-- metric alarms are in ALARM state.
--
-- Currently, the only alarm actions that can be taken by composite alarms
-- are notifying SNS topics.
--
-- It is possible to create a loop or cycle of composite alarms, where
-- composite alarm A depends on composite alarm B, and composite alarm B
-- also depends on composite alarm A. In this scenario, you can\'t delete
-- any composite alarm that is part of the cycle because there is always
-- still a composite alarm that depends on that alarm that you want to
-- delete.
--
-- To get out of such a situation, you must break the cycle by changing the
-- rule of one of the composite alarms in the cycle to remove a dependency
-- that creates the cycle. The simplest change to make to break a cycle is
-- to change the @AlarmRule@ of one of the alarms to @False@.
--
-- Additionally, the evaluation of composite alarms stops if CloudWatch
-- detects a cycle in the evaluation path.
--
-- When this operation creates an alarm, the alarm state is immediately set
-- to @INSUFFICIENT_DATA@. The alarm is then evaluated and its state is set
-- appropriately. Any actions associated with the new state are then
-- executed. For a composite alarm, this initial time after creation is the
-- only time that the alarm can be in @INSUFFICIENT_DATA@ state.
--
-- When you update an existing alarm, its state is left unchanged, but the
-- update completely overwrites the previous configuration of the alarm.
--
-- If you are an IAM user, you must have @iam:CreateServiceLinkedRole@ to
-- create a composite alarm that has Systems Manager OpsItem actions.
module Amazonka.CloudWatch.PutCompositeAlarm
  ( -- * Creating a Request
    PutCompositeAlarm (..),
    newPutCompositeAlarm,

    -- * Request Lenses
    putCompositeAlarm_alarmDescription,
    putCompositeAlarm_oKActions,
    putCompositeAlarm_actionsEnabled,
    putCompositeAlarm_insufficientDataActions,
    putCompositeAlarm_alarmActions,
    putCompositeAlarm_tags,
    putCompositeAlarm_alarmName,
    putCompositeAlarm_alarmRule,

    -- * Destructuring the Response
    PutCompositeAlarmResponse (..),
    newPutCompositeAlarmResponse,
  )
where

import Amazonka.CloudWatch.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newPutCompositeAlarm' smart constructor.
data PutCompositeAlarm = PutCompositeAlarm'
  { -- | The description for the composite alarm.
    PutCompositeAlarm -> Maybe Text
alarmDescription :: Prelude.Maybe Prelude.Text,
    -- | The actions to execute when this alarm transitions to an @OK@ state from
    -- any other state. Each action is specified as an Amazon Resource Name
    -- (ARN).
    --
    -- Valid Values: @arn:aws:sns:region:account-id:sns-topic-name @
    PutCompositeAlarm -> Maybe [Text]
oKActions :: Prelude.Maybe [Prelude.Text],
    -- | Indicates whether actions should be executed during any changes to the
    -- alarm state of the composite alarm. The default is @TRUE@.
    PutCompositeAlarm -> Maybe Bool
actionsEnabled :: Prelude.Maybe Prelude.Bool,
    -- | The actions to execute when this alarm transitions to the
    -- @INSUFFICIENT_DATA@ state from any other state. Each action is specified
    -- as an Amazon Resource Name (ARN).
    --
    -- Valid Values: @arn:aws:sns:region:account-id:sns-topic-name @
    PutCompositeAlarm -> Maybe [Text]
insufficientDataActions :: Prelude.Maybe [Prelude.Text],
    -- | The actions to execute when this alarm transitions to the @ALARM@ state
    -- from any other state. Each action is specified as an Amazon Resource
    -- Name (ARN).
    --
    -- Valid Values: @arn:aws:sns:region:account-id:sns-topic-name @ |
    -- @arn:aws:ssm:region:account-id:opsitem:severity @
    PutCompositeAlarm -> Maybe [Text]
alarmActions :: Prelude.Maybe [Prelude.Text],
    -- | A list of key-value pairs to associate with the composite alarm. You can
    -- associate as many as 50 tags with an alarm.
    --
    -- Tags can help you organize and categorize your resources. You can also
    -- use them to scope user permissions, by granting a user permission to
    -- access or change only resources with certain tag values.
    PutCompositeAlarm -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The name for the composite alarm. This name must be unique within the
    -- Region.
    PutCompositeAlarm -> Text
alarmName :: Prelude.Text,
    -- | An expression that specifies which other alarms are to be evaluated to
    -- determine this composite alarm\'s state. For each alarm that you
    -- reference, you designate a function that specifies whether that alarm
    -- needs to be in ALARM state, OK state, or INSUFFICIENT_DATA state. You
    -- can use operators (AND, OR and NOT) to combine multiple functions in a
    -- single expression. You can use parenthesis to logically group the
    -- functions in your expression.
    --
    -- You can use either alarm names or ARNs to reference the other alarms
    -- that are to be evaluated.
    --
    -- Functions can include the following:
    --
    -- -   @ALARM(\"alarm-name or alarm-ARN\")@ is TRUE if the named alarm is
    --     in ALARM state.
    --
    -- -   @OK(\"alarm-name or alarm-ARN\")@ is TRUE if the named alarm is in
    --     OK state.
    --
    -- -   @INSUFFICIENT_DATA(\"alarm-name or alarm-ARN\")@ is TRUE if the
    --     named alarm is in INSUFFICIENT_DATA state.
    --
    -- -   @TRUE@ always evaluates to TRUE.
    --
    -- -   @FALSE@ always evaluates to FALSE.
    --
    -- TRUE and FALSE are useful for testing a complex @AlarmRule@ structure,
    -- and for testing your alarm actions.
    --
    -- Alarm names specified in @AlarmRule@ can be surrounded with
    -- double-quotes (\"), but do not have to be.
    --
    -- The following are some examples of @AlarmRule@:
    --
    -- -   @ALARM(CPUUtilizationTooHigh) AND ALARM(DiskReadOpsTooHigh)@
    --     specifies that the composite alarm goes into ALARM state only if
    --     both CPUUtilizationTooHigh and DiskReadOpsTooHigh alarms are in
    --     ALARM state.
    --
    -- -   @ALARM(CPUUtilizationTooHigh) AND NOT ALARM(DeploymentInProgress)@
    --     specifies that the alarm goes to ALARM state if
    --     CPUUtilizationTooHigh is in ALARM state and DeploymentInProgress is
    --     not in ALARM state. This example reduces alarm noise during a known
    --     deployment window.
    --
    -- -   @(ALARM(CPUUtilizationTooHigh) OR ALARM(DiskReadOpsTooHigh)) AND OK(NetworkOutTooHigh)@
    --     goes into ALARM state if CPUUtilizationTooHigh OR DiskReadOpsTooHigh
    --     is in ALARM state, and if NetworkOutTooHigh is in OK state. This
    --     provides another example of using a composite alarm to prevent
    --     noise. This rule ensures that you are not notified with an alarm
    --     action on high CPU or disk usage if a known network problem is also
    --     occurring.
    --
    -- The @AlarmRule@ can specify as many as 100 \"children\" alarms. The
    -- @AlarmRule@ expression can have as many as 500 elements. Elements are
    -- child alarms, TRUE or FALSE statements, and parentheses.
    PutCompositeAlarm -> Text
alarmRule :: Prelude.Text
  }
  deriving (PutCompositeAlarm -> PutCompositeAlarm -> Bool
(PutCompositeAlarm -> PutCompositeAlarm -> Bool)
-> (PutCompositeAlarm -> PutCompositeAlarm -> Bool)
-> Eq PutCompositeAlarm
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutCompositeAlarm -> PutCompositeAlarm -> Bool
$c/= :: PutCompositeAlarm -> PutCompositeAlarm -> Bool
== :: PutCompositeAlarm -> PutCompositeAlarm -> Bool
$c== :: PutCompositeAlarm -> PutCompositeAlarm -> Bool
Prelude.Eq, ReadPrec [PutCompositeAlarm]
ReadPrec PutCompositeAlarm
Int -> ReadS PutCompositeAlarm
ReadS [PutCompositeAlarm]
(Int -> ReadS PutCompositeAlarm)
-> ReadS [PutCompositeAlarm]
-> ReadPrec PutCompositeAlarm
-> ReadPrec [PutCompositeAlarm]
-> Read PutCompositeAlarm
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutCompositeAlarm]
$creadListPrec :: ReadPrec [PutCompositeAlarm]
readPrec :: ReadPrec PutCompositeAlarm
$creadPrec :: ReadPrec PutCompositeAlarm
readList :: ReadS [PutCompositeAlarm]
$creadList :: ReadS [PutCompositeAlarm]
readsPrec :: Int -> ReadS PutCompositeAlarm
$creadsPrec :: Int -> ReadS PutCompositeAlarm
Prelude.Read, Int -> PutCompositeAlarm -> ShowS
[PutCompositeAlarm] -> ShowS
PutCompositeAlarm -> String
(Int -> PutCompositeAlarm -> ShowS)
-> (PutCompositeAlarm -> String)
-> ([PutCompositeAlarm] -> ShowS)
-> Show PutCompositeAlarm
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutCompositeAlarm] -> ShowS
$cshowList :: [PutCompositeAlarm] -> ShowS
show :: PutCompositeAlarm -> String
$cshow :: PutCompositeAlarm -> String
showsPrec :: Int -> PutCompositeAlarm -> ShowS
$cshowsPrec :: Int -> PutCompositeAlarm -> ShowS
Prelude.Show, (forall x. PutCompositeAlarm -> Rep PutCompositeAlarm x)
-> (forall x. Rep PutCompositeAlarm x -> PutCompositeAlarm)
-> Generic PutCompositeAlarm
forall x. Rep PutCompositeAlarm x -> PutCompositeAlarm
forall x. PutCompositeAlarm -> Rep PutCompositeAlarm x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutCompositeAlarm x -> PutCompositeAlarm
$cfrom :: forall x. PutCompositeAlarm -> Rep PutCompositeAlarm x
Prelude.Generic)

-- |
-- Create a value of 'PutCompositeAlarm' 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:
--
-- 'alarmDescription', 'putCompositeAlarm_alarmDescription' - The description for the composite alarm.
--
-- 'oKActions', 'putCompositeAlarm_oKActions' - The actions to execute when this alarm transitions to an @OK@ state from
-- any other state. Each action is specified as an Amazon Resource Name
-- (ARN).
--
-- Valid Values: @arn:aws:sns:region:account-id:sns-topic-name @
--
-- 'actionsEnabled', 'putCompositeAlarm_actionsEnabled' - Indicates whether actions should be executed during any changes to the
-- alarm state of the composite alarm. The default is @TRUE@.
--
-- 'insufficientDataActions', 'putCompositeAlarm_insufficientDataActions' - The actions to execute when this alarm transitions to the
-- @INSUFFICIENT_DATA@ state from any other state. Each action is specified
-- as an Amazon Resource Name (ARN).
--
-- Valid Values: @arn:aws:sns:region:account-id:sns-topic-name @
--
-- 'alarmActions', 'putCompositeAlarm_alarmActions' - The actions to execute when this alarm transitions to the @ALARM@ state
-- from any other state. Each action is specified as an Amazon Resource
-- Name (ARN).
--
-- Valid Values: @arn:aws:sns:region:account-id:sns-topic-name @ |
-- @arn:aws:ssm:region:account-id:opsitem:severity @
--
-- 'tags', 'putCompositeAlarm_tags' - A list of key-value pairs to associate with the composite alarm. You can
-- associate as many as 50 tags with an alarm.
--
-- Tags can help you organize and categorize your resources. You can also
-- use them to scope user permissions, by granting a user permission to
-- access or change only resources with certain tag values.
--
-- 'alarmName', 'putCompositeAlarm_alarmName' - The name for the composite alarm. This name must be unique within the
-- Region.
--
-- 'alarmRule', 'putCompositeAlarm_alarmRule' - An expression that specifies which other alarms are to be evaluated to
-- determine this composite alarm\'s state. For each alarm that you
-- reference, you designate a function that specifies whether that alarm
-- needs to be in ALARM state, OK state, or INSUFFICIENT_DATA state. You
-- can use operators (AND, OR and NOT) to combine multiple functions in a
-- single expression. You can use parenthesis to logically group the
-- functions in your expression.
--
-- You can use either alarm names or ARNs to reference the other alarms
-- that are to be evaluated.
--
-- Functions can include the following:
--
-- -   @ALARM(\"alarm-name or alarm-ARN\")@ is TRUE if the named alarm is
--     in ALARM state.
--
-- -   @OK(\"alarm-name or alarm-ARN\")@ is TRUE if the named alarm is in
--     OK state.
--
-- -   @INSUFFICIENT_DATA(\"alarm-name or alarm-ARN\")@ is TRUE if the
--     named alarm is in INSUFFICIENT_DATA state.
--
-- -   @TRUE@ always evaluates to TRUE.
--
-- -   @FALSE@ always evaluates to FALSE.
--
-- TRUE and FALSE are useful for testing a complex @AlarmRule@ structure,
-- and for testing your alarm actions.
--
-- Alarm names specified in @AlarmRule@ can be surrounded with
-- double-quotes (\"), but do not have to be.
--
-- The following are some examples of @AlarmRule@:
--
-- -   @ALARM(CPUUtilizationTooHigh) AND ALARM(DiskReadOpsTooHigh)@
--     specifies that the composite alarm goes into ALARM state only if
--     both CPUUtilizationTooHigh and DiskReadOpsTooHigh alarms are in
--     ALARM state.
--
-- -   @ALARM(CPUUtilizationTooHigh) AND NOT ALARM(DeploymentInProgress)@
--     specifies that the alarm goes to ALARM state if
--     CPUUtilizationTooHigh is in ALARM state and DeploymentInProgress is
--     not in ALARM state. This example reduces alarm noise during a known
--     deployment window.
--
-- -   @(ALARM(CPUUtilizationTooHigh) OR ALARM(DiskReadOpsTooHigh)) AND OK(NetworkOutTooHigh)@
--     goes into ALARM state if CPUUtilizationTooHigh OR DiskReadOpsTooHigh
--     is in ALARM state, and if NetworkOutTooHigh is in OK state. This
--     provides another example of using a composite alarm to prevent
--     noise. This rule ensures that you are not notified with an alarm
--     action on high CPU or disk usage if a known network problem is also
--     occurring.
--
-- The @AlarmRule@ can specify as many as 100 \"children\" alarms. The
-- @AlarmRule@ expression can have as many as 500 elements. Elements are
-- child alarms, TRUE or FALSE statements, and parentheses.
newPutCompositeAlarm ::
  -- | 'alarmName'
  Prelude.Text ->
  -- | 'alarmRule'
  Prelude.Text ->
  PutCompositeAlarm
newPutCompositeAlarm :: Text -> Text -> PutCompositeAlarm
newPutCompositeAlarm Text
pAlarmName_ Text
pAlarmRule_ =
  PutCompositeAlarm' :: Maybe Text
-> Maybe [Text]
-> Maybe Bool
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Tag]
-> Text
-> Text
-> PutCompositeAlarm
PutCompositeAlarm'
    { $sel:alarmDescription:PutCompositeAlarm' :: Maybe Text
alarmDescription =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:oKActions:PutCompositeAlarm' :: Maybe [Text]
oKActions = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:actionsEnabled:PutCompositeAlarm' :: Maybe Bool
actionsEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:insufficientDataActions:PutCompositeAlarm' :: Maybe [Text]
insufficientDataActions = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:alarmActions:PutCompositeAlarm' :: Maybe [Text]
alarmActions = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:PutCompositeAlarm' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:alarmName:PutCompositeAlarm' :: Text
alarmName = Text
pAlarmName_,
      $sel:alarmRule:PutCompositeAlarm' :: Text
alarmRule = Text
pAlarmRule_
    }

-- | The description for the composite alarm.
putCompositeAlarm_alarmDescription :: Lens.Lens' PutCompositeAlarm (Prelude.Maybe Prelude.Text)
putCompositeAlarm_alarmDescription :: (Maybe Text -> f (Maybe Text))
-> PutCompositeAlarm -> f PutCompositeAlarm
putCompositeAlarm_alarmDescription = (PutCompositeAlarm -> Maybe Text)
-> (PutCompositeAlarm -> Maybe Text -> PutCompositeAlarm)
-> Lens
     PutCompositeAlarm PutCompositeAlarm (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutCompositeAlarm' {Maybe Text
alarmDescription :: Maybe Text
$sel:alarmDescription:PutCompositeAlarm' :: PutCompositeAlarm -> Maybe Text
alarmDescription} -> Maybe Text
alarmDescription) (\s :: PutCompositeAlarm
s@PutCompositeAlarm' {} Maybe Text
a -> PutCompositeAlarm
s {$sel:alarmDescription:PutCompositeAlarm' :: Maybe Text
alarmDescription = Maybe Text
a} :: PutCompositeAlarm)

-- | The actions to execute when this alarm transitions to an @OK@ state from
-- any other state. Each action is specified as an Amazon Resource Name
-- (ARN).
--
-- Valid Values: @arn:aws:sns:region:account-id:sns-topic-name @
putCompositeAlarm_oKActions :: Lens.Lens' PutCompositeAlarm (Prelude.Maybe [Prelude.Text])
putCompositeAlarm_oKActions :: (Maybe [Text] -> f (Maybe [Text]))
-> PutCompositeAlarm -> f PutCompositeAlarm
putCompositeAlarm_oKActions = (PutCompositeAlarm -> Maybe [Text])
-> (PutCompositeAlarm -> Maybe [Text] -> PutCompositeAlarm)
-> Lens
     PutCompositeAlarm PutCompositeAlarm (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutCompositeAlarm' {Maybe [Text]
oKActions :: Maybe [Text]
$sel:oKActions:PutCompositeAlarm' :: PutCompositeAlarm -> Maybe [Text]
oKActions} -> Maybe [Text]
oKActions) (\s :: PutCompositeAlarm
s@PutCompositeAlarm' {} Maybe [Text]
a -> PutCompositeAlarm
s {$sel:oKActions:PutCompositeAlarm' :: Maybe [Text]
oKActions = Maybe [Text]
a} :: PutCompositeAlarm) ((Maybe [Text] -> f (Maybe [Text]))
 -> PutCompositeAlarm -> f PutCompositeAlarm)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> PutCompositeAlarm
-> f PutCompositeAlarm
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Indicates whether actions should be executed during any changes to the
-- alarm state of the composite alarm. The default is @TRUE@.
putCompositeAlarm_actionsEnabled :: Lens.Lens' PutCompositeAlarm (Prelude.Maybe Prelude.Bool)
putCompositeAlarm_actionsEnabled :: (Maybe Bool -> f (Maybe Bool))
-> PutCompositeAlarm -> f PutCompositeAlarm
putCompositeAlarm_actionsEnabled = (PutCompositeAlarm -> Maybe Bool)
-> (PutCompositeAlarm -> Maybe Bool -> PutCompositeAlarm)
-> Lens
     PutCompositeAlarm PutCompositeAlarm (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutCompositeAlarm' {Maybe Bool
actionsEnabled :: Maybe Bool
$sel:actionsEnabled:PutCompositeAlarm' :: PutCompositeAlarm -> Maybe Bool
actionsEnabled} -> Maybe Bool
actionsEnabled) (\s :: PutCompositeAlarm
s@PutCompositeAlarm' {} Maybe Bool
a -> PutCompositeAlarm
s {$sel:actionsEnabled:PutCompositeAlarm' :: Maybe Bool
actionsEnabled = Maybe Bool
a} :: PutCompositeAlarm)

-- | The actions to execute when this alarm transitions to the
-- @INSUFFICIENT_DATA@ state from any other state. Each action is specified
-- as an Amazon Resource Name (ARN).
--
-- Valid Values: @arn:aws:sns:region:account-id:sns-topic-name @
putCompositeAlarm_insufficientDataActions :: Lens.Lens' PutCompositeAlarm (Prelude.Maybe [Prelude.Text])
putCompositeAlarm_insufficientDataActions :: (Maybe [Text] -> f (Maybe [Text]))
-> PutCompositeAlarm -> f PutCompositeAlarm
putCompositeAlarm_insufficientDataActions = (PutCompositeAlarm -> Maybe [Text])
-> (PutCompositeAlarm -> Maybe [Text] -> PutCompositeAlarm)
-> Lens
     PutCompositeAlarm PutCompositeAlarm (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutCompositeAlarm' {Maybe [Text]
insufficientDataActions :: Maybe [Text]
$sel:insufficientDataActions:PutCompositeAlarm' :: PutCompositeAlarm -> Maybe [Text]
insufficientDataActions} -> Maybe [Text]
insufficientDataActions) (\s :: PutCompositeAlarm
s@PutCompositeAlarm' {} Maybe [Text]
a -> PutCompositeAlarm
s {$sel:insufficientDataActions:PutCompositeAlarm' :: Maybe [Text]
insufficientDataActions = Maybe [Text]
a} :: PutCompositeAlarm) ((Maybe [Text] -> f (Maybe [Text]))
 -> PutCompositeAlarm -> f PutCompositeAlarm)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> PutCompositeAlarm
-> f PutCompositeAlarm
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The actions to execute when this alarm transitions to the @ALARM@ state
-- from any other state. Each action is specified as an Amazon Resource
-- Name (ARN).
--
-- Valid Values: @arn:aws:sns:region:account-id:sns-topic-name @ |
-- @arn:aws:ssm:region:account-id:opsitem:severity @
putCompositeAlarm_alarmActions :: Lens.Lens' PutCompositeAlarm (Prelude.Maybe [Prelude.Text])
putCompositeAlarm_alarmActions :: (Maybe [Text] -> f (Maybe [Text]))
-> PutCompositeAlarm -> f PutCompositeAlarm
putCompositeAlarm_alarmActions = (PutCompositeAlarm -> Maybe [Text])
-> (PutCompositeAlarm -> Maybe [Text] -> PutCompositeAlarm)
-> Lens
     PutCompositeAlarm PutCompositeAlarm (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutCompositeAlarm' {Maybe [Text]
alarmActions :: Maybe [Text]
$sel:alarmActions:PutCompositeAlarm' :: PutCompositeAlarm -> Maybe [Text]
alarmActions} -> Maybe [Text]
alarmActions) (\s :: PutCompositeAlarm
s@PutCompositeAlarm' {} Maybe [Text]
a -> PutCompositeAlarm
s {$sel:alarmActions:PutCompositeAlarm' :: Maybe [Text]
alarmActions = Maybe [Text]
a} :: PutCompositeAlarm) ((Maybe [Text] -> f (Maybe [Text]))
 -> PutCompositeAlarm -> f PutCompositeAlarm)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> PutCompositeAlarm
-> f PutCompositeAlarm
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A list of key-value pairs to associate with the composite alarm. You can
-- associate as many as 50 tags with an alarm.
--
-- Tags can help you organize and categorize your resources. You can also
-- use them to scope user permissions, by granting a user permission to
-- access or change only resources with certain tag values.
putCompositeAlarm_tags :: Lens.Lens' PutCompositeAlarm (Prelude.Maybe [Tag])
putCompositeAlarm_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> PutCompositeAlarm -> f PutCompositeAlarm
putCompositeAlarm_tags = (PutCompositeAlarm -> Maybe [Tag])
-> (PutCompositeAlarm -> Maybe [Tag] -> PutCompositeAlarm)
-> Lens
     PutCompositeAlarm PutCompositeAlarm (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutCompositeAlarm' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:PutCompositeAlarm' :: PutCompositeAlarm -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: PutCompositeAlarm
s@PutCompositeAlarm' {} Maybe [Tag]
a -> PutCompositeAlarm
s {$sel:tags:PutCompositeAlarm' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: PutCompositeAlarm) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> PutCompositeAlarm -> f PutCompositeAlarm)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> PutCompositeAlarm
-> f PutCompositeAlarm
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name for the composite alarm. This name must be unique within the
-- Region.
putCompositeAlarm_alarmName :: Lens.Lens' PutCompositeAlarm Prelude.Text
putCompositeAlarm_alarmName :: (Text -> f Text) -> PutCompositeAlarm -> f PutCompositeAlarm
putCompositeAlarm_alarmName = (PutCompositeAlarm -> Text)
-> (PutCompositeAlarm -> Text -> PutCompositeAlarm)
-> Lens PutCompositeAlarm PutCompositeAlarm Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutCompositeAlarm' {Text
alarmName :: Text
$sel:alarmName:PutCompositeAlarm' :: PutCompositeAlarm -> Text
alarmName} -> Text
alarmName) (\s :: PutCompositeAlarm
s@PutCompositeAlarm' {} Text
a -> PutCompositeAlarm
s {$sel:alarmName:PutCompositeAlarm' :: Text
alarmName = Text
a} :: PutCompositeAlarm)

-- | An expression that specifies which other alarms are to be evaluated to
-- determine this composite alarm\'s state. For each alarm that you
-- reference, you designate a function that specifies whether that alarm
-- needs to be in ALARM state, OK state, or INSUFFICIENT_DATA state. You
-- can use operators (AND, OR and NOT) to combine multiple functions in a
-- single expression. You can use parenthesis to logically group the
-- functions in your expression.
--
-- You can use either alarm names or ARNs to reference the other alarms
-- that are to be evaluated.
--
-- Functions can include the following:
--
-- -   @ALARM(\"alarm-name or alarm-ARN\")@ is TRUE if the named alarm is
--     in ALARM state.
--
-- -   @OK(\"alarm-name or alarm-ARN\")@ is TRUE if the named alarm is in
--     OK state.
--
-- -   @INSUFFICIENT_DATA(\"alarm-name or alarm-ARN\")@ is TRUE if the
--     named alarm is in INSUFFICIENT_DATA state.
--
-- -   @TRUE@ always evaluates to TRUE.
--
-- -   @FALSE@ always evaluates to FALSE.
--
-- TRUE and FALSE are useful for testing a complex @AlarmRule@ structure,
-- and for testing your alarm actions.
--
-- Alarm names specified in @AlarmRule@ can be surrounded with
-- double-quotes (\"), but do not have to be.
--
-- The following are some examples of @AlarmRule@:
--
-- -   @ALARM(CPUUtilizationTooHigh) AND ALARM(DiskReadOpsTooHigh)@
--     specifies that the composite alarm goes into ALARM state only if
--     both CPUUtilizationTooHigh and DiskReadOpsTooHigh alarms are in
--     ALARM state.
--
-- -   @ALARM(CPUUtilizationTooHigh) AND NOT ALARM(DeploymentInProgress)@
--     specifies that the alarm goes to ALARM state if
--     CPUUtilizationTooHigh is in ALARM state and DeploymentInProgress is
--     not in ALARM state. This example reduces alarm noise during a known
--     deployment window.
--
-- -   @(ALARM(CPUUtilizationTooHigh) OR ALARM(DiskReadOpsTooHigh)) AND OK(NetworkOutTooHigh)@
--     goes into ALARM state if CPUUtilizationTooHigh OR DiskReadOpsTooHigh
--     is in ALARM state, and if NetworkOutTooHigh is in OK state. This
--     provides another example of using a composite alarm to prevent
--     noise. This rule ensures that you are not notified with an alarm
--     action on high CPU or disk usage if a known network problem is also
--     occurring.
--
-- The @AlarmRule@ can specify as many as 100 \"children\" alarms. The
-- @AlarmRule@ expression can have as many as 500 elements. Elements are
-- child alarms, TRUE or FALSE statements, and parentheses.
putCompositeAlarm_alarmRule :: Lens.Lens' PutCompositeAlarm Prelude.Text
putCompositeAlarm_alarmRule :: (Text -> f Text) -> PutCompositeAlarm -> f PutCompositeAlarm
putCompositeAlarm_alarmRule = (PutCompositeAlarm -> Text)
-> (PutCompositeAlarm -> Text -> PutCompositeAlarm)
-> Lens PutCompositeAlarm PutCompositeAlarm Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutCompositeAlarm' {Text
alarmRule :: Text
$sel:alarmRule:PutCompositeAlarm' :: PutCompositeAlarm -> Text
alarmRule} -> Text
alarmRule) (\s :: PutCompositeAlarm
s@PutCompositeAlarm' {} Text
a -> PutCompositeAlarm
s {$sel:alarmRule:PutCompositeAlarm' :: Text
alarmRule = Text
a} :: PutCompositeAlarm)

instance Core.AWSRequest PutCompositeAlarm where
  type
    AWSResponse PutCompositeAlarm =
      PutCompositeAlarmResponse
  request :: PutCompositeAlarm -> Request PutCompositeAlarm
request = Service -> PutCompositeAlarm -> Request PutCompositeAlarm
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy PutCompositeAlarm
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutCompositeAlarm)))
response =
    AWSResponse PutCompositeAlarm
-> Logger
-> Service
-> Proxy PutCompositeAlarm
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutCompositeAlarm)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse PutCompositeAlarm
PutCompositeAlarmResponse
PutCompositeAlarmResponse'

instance Prelude.Hashable PutCompositeAlarm

instance Prelude.NFData PutCompositeAlarm

instance Core.ToHeaders PutCompositeAlarm where
  toHeaders :: PutCompositeAlarm -> [Header]
toHeaders = [Header] -> PutCompositeAlarm -> [Header]
forall a b. a -> b -> a
Prelude.const [Header]
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath PutCompositeAlarm where
  toPath :: PutCompositeAlarm -> ByteString
toPath = ByteString -> PutCompositeAlarm -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery PutCompositeAlarm where
  toQuery :: PutCompositeAlarm -> QueryString
toQuery PutCompositeAlarm' {Maybe Bool
Maybe [Text]
Maybe [Tag]
Maybe Text
Text
alarmRule :: Text
alarmName :: Text
tags :: Maybe [Tag]
alarmActions :: Maybe [Text]
insufficientDataActions :: Maybe [Text]
actionsEnabled :: Maybe Bool
oKActions :: Maybe [Text]
alarmDescription :: Maybe Text
$sel:alarmRule:PutCompositeAlarm' :: PutCompositeAlarm -> Text
$sel:alarmName:PutCompositeAlarm' :: PutCompositeAlarm -> Text
$sel:tags:PutCompositeAlarm' :: PutCompositeAlarm -> Maybe [Tag]
$sel:alarmActions:PutCompositeAlarm' :: PutCompositeAlarm -> Maybe [Text]
$sel:insufficientDataActions:PutCompositeAlarm' :: PutCompositeAlarm -> Maybe [Text]
$sel:actionsEnabled:PutCompositeAlarm' :: PutCompositeAlarm -> Maybe Bool
$sel:oKActions:PutCompositeAlarm' :: PutCompositeAlarm -> Maybe [Text]
$sel:alarmDescription:PutCompositeAlarm' :: PutCompositeAlarm -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"PutCompositeAlarm" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-08-01" :: Prelude.ByteString),
        ByteString
"AlarmDescription" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
alarmDescription,
        ByteString
"OKActions"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
oKActions),
        ByteString
"ActionsEnabled" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
actionsEnabled,
        ByteString
"InsufficientDataActions"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            ( ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member"
                ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
insufficientDataActions
            ),
        ByteString
"AlarmActions"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
alarmActions),
        ByteString
"Tags"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Tag] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([Tag] -> QueryString) -> Maybe [Tag] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags),
        ByteString
"AlarmName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
alarmName,
        ByteString
"AlarmRule" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
alarmRule
      ]

-- | /See:/ 'newPutCompositeAlarmResponse' smart constructor.
data PutCompositeAlarmResponse = PutCompositeAlarmResponse'
  {
  }
  deriving (PutCompositeAlarmResponse -> PutCompositeAlarmResponse -> Bool
(PutCompositeAlarmResponse -> PutCompositeAlarmResponse -> Bool)
-> (PutCompositeAlarmResponse -> PutCompositeAlarmResponse -> Bool)
-> Eq PutCompositeAlarmResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutCompositeAlarmResponse -> PutCompositeAlarmResponse -> Bool
$c/= :: PutCompositeAlarmResponse -> PutCompositeAlarmResponse -> Bool
== :: PutCompositeAlarmResponse -> PutCompositeAlarmResponse -> Bool
$c== :: PutCompositeAlarmResponse -> PutCompositeAlarmResponse -> Bool
Prelude.Eq, ReadPrec [PutCompositeAlarmResponse]
ReadPrec PutCompositeAlarmResponse
Int -> ReadS PutCompositeAlarmResponse
ReadS [PutCompositeAlarmResponse]
(Int -> ReadS PutCompositeAlarmResponse)
-> ReadS [PutCompositeAlarmResponse]
-> ReadPrec PutCompositeAlarmResponse
-> ReadPrec [PutCompositeAlarmResponse]
-> Read PutCompositeAlarmResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutCompositeAlarmResponse]
$creadListPrec :: ReadPrec [PutCompositeAlarmResponse]
readPrec :: ReadPrec PutCompositeAlarmResponse
$creadPrec :: ReadPrec PutCompositeAlarmResponse
readList :: ReadS [PutCompositeAlarmResponse]
$creadList :: ReadS [PutCompositeAlarmResponse]
readsPrec :: Int -> ReadS PutCompositeAlarmResponse
$creadsPrec :: Int -> ReadS PutCompositeAlarmResponse
Prelude.Read, Int -> PutCompositeAlarmResponse -> ShowS
[PutCompositeAlarmResponse] -> ShowS
PutCompositeAlarmResponse -> String
(Int -> PutCompositeAlarmResponse -> ShowS)
-> (PutCompositeAlarmResponse -> String)
-> ([PutCompositeAlarmResponse] -> ShowS)
-> Show PutCompositeAlarmResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutCompositeAlarmResponse] -> ShowS
$cshowList :: [PutCompositeAlarmResponse] -> ShowS
show :: PutCompositeAlarmResponse -> String
$cshow :: PutCompositeAlarmResponse -> String
showsPrec :: Int -> PutCompositeAlarmResponse -> ShowS
$cshowsPrec :: Int -> PutCompositeAlarmResponse -> ShowS
Prelude.Show, (forall x.
 PutCompositeAlarmResponse -> Rep PutCompositeAlarmResponse x)
-> (forall x.
    Rep PutCompositeAlarmResponse x -> PutCompositeAlarmResponse)
-> Generic PutCompositeAlarmResponse
forall x.
Rep PutCompositeAlarmResponse x -> PutCompositeAlarmResponse
forall x.
PutCompositeAlarmResponse -> Rep PutCompositeAlarmResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutCompositeAlarmResponse x -> PutCompositeAlarmResponse
$cfrom :: forall x.
PutCompositeAlarmResponse -> Rep PutCompositeAlarmResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutCompositeAlarmResponse' 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.
newPutCompositeAlarmResponse ::
  PutCompositeAlarmResponse
newPutCompositeAlarmResponse :: PutCompositeAlarmResponse
newPutCompositeAlarmResponse =
  PutCompositeAlarmResponse
PutCompositeAlarmResponse'

instance Prelude.NFData PutCompositeAlarmResponse