{-# 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.IoTEvents.Types.AlarmEventActions
-- 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.IoTEvents.Types.AlarmEventActions where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTEvents.Types.AlarmAction
import qualified Amazonka.Prelude as Prelude

-- | Contains information about one or more alarm actions.
--
-- /See:/ 'newAlarmEventActions' smart constructor.
data AlarmEventActions = AlarmEventActions'
  { -- | Specifies one or more supported actions to receive notifications when
    -- the alarm state changes.
    AlarmEventActions -> Maybe [AlarmAction]
alarmActions :: Prelude.Maybe [AlarmAction]
  }
  deriving (AlarmEventActions -> AlarmEventActions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AlarmEventActions -> AlarmEventActions -> Bool
$c/= :: AlarmEventActions -> AlarmEventActions -> Bool
== :: AlarmEventActions -> AlarmEventActions -> Bool
$c== :: AlarmEventActions -> AlarmEventActions -> Bool
Prelude.Eq, ReadPrec [AlarmEventActions]
ReadPrec AlarmEventActions
Int -> ReadS AlarmEventActions
ReadS [AlarmEventActions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AlarmEventActions]
$creadListPrec :: ReadPrec [AlarmEventActions]
readPrec :: ReadPrec AlarmEventActions
$creadPrec :: ReadPrec AlarmEventActions
readList :: ReadS [AlarmEventActions]
$creadList :: ReadS [AlarmEventActions]
readsPrec :: Int -> ReadS AlarmEventActions
$creadsPrec :: Int -> ReadS AlarmEventActions
Prelude.Read, Int -> AlarmEventActions -> ShowS
[AlarmEventActions] -> ShowS
AlarmEventActions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AlarmEventActions] -> ShowS
$cshowList :: [AlarmEventActions] -> ShowS
show :: AlarmEventActions -> String
$cshow :: AlarmEventActions -> String
showsPrec :: Int -> AlarmEventActions -> ShowS
$cshowsPrec :: Int -> AlarmEventActions -> ShowS
Prelude.Show, forall x. Rep AlarmEventActions x -> AlarmEventActions
forall x. AlarmEventActions -> Rep AlarmEventActions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AlarmEventActions x -> AlarmEventActions
$cfrom :: forall x. AlarmEventActions -> Rep AlarmEventActions x
Prelude.Generic)

-- |
-- Create a value of 'AlarmEventActions' 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:
--
-- 'alarmActions', 'alarmEventActions_alarmActions' - Specifies one or more supported actions to receive notifications when
-- the alarm state changes.
newAlarmEventActions ::
  AlarmEventActions
newAlarmEventActions :: AlarmEventActions
newAlarmEventActions =
  AlarmEventActions' {$sel:alarmActions:AlarmEventActions' :: Maybe [AlarmAction]
alarmActions = forall a. Maybe a
Prelude.Nothing}

-- | Specifies one or more supported actions to receive notifications when
-- the alarm state changes.
alarmEventActions_alarmActions :: Lens.Lens' AlarmEventActions (Prelude.Maybe [AlarmAction])
alarmEventActions_alarmActions :: Lens' AlarmEventActions (Maybe [AlarmAction])
alarmEventActions_alarmActions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlarmEventActions' {Maybe [AlarmAction]
alarmActions :: Maybe [AlarmAction]
$sel:alarmActions:AlarmEventActions' :: AlarmEventActions -> Maybe [AlarmAction]
alarmActions} -> Maybe [AlarmAction]
alarmActions) (\s :: AlarmEventActions
s@AlarmEventActions' {} Maybe [AlarmAction]
a -> AlarmEventActions
s {$sel:alarmActions:AlarmEventActions' :: Maybe [AlarmAction]
alarmActions = Maybe [AlarmAction]
a} :: AlarmEventActions) 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

instance Data.FromJSON AlarmEventActions where
  parseJSON :: Value -> Parser AlarmEventActions
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AlarmEventActions"
      ( \Object
x ->
          Maybe [AlarmAction] -> AlarmEventActions
AlarmEventActions'
            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
"alarmActions" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable AlarmEventActions where
  hashWithSalt :: Int -> AlarmEventActions -> Int
hashWithSalt Int
_salt AlarmEventActions' {Maybe [AlarmAction]
alarmActions :: Maybe [AlarmAction]
$sel:alarmActions:AlarmEventActions' :: AlarmEventActions -> Maybe [AlarmAction]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [AlarmAction]
alarmActions

instance Prelude.NFData AlarmEventActions where
  rnf :: AlarmEventActions -> ()
rnf AlarmEventActions' {Maybe [AlarmAction]
alarmActions :: Maybe [AlarmAction]
$sel:alarmActions:AlarmEventActions' :: AlarmEventActions -> Maybe [AlarmAction]
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe [AlarmAction]
alarmActions

instance Data.ToJSON AlarmEventActions where
  toJSON :: AlarmEventActions -> Value
toJSON AlarmEventActions' {Maybe [AlarmAction]
alarmActions :: Maybe [AlarmAction]
$sel:alarmActions:AlarmEventActions' :: AlarmEventActions -> Maybe [AlarmAction]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"alarmActions" 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 [AlarmAction]
alarmActions]
      )