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

import qualified Amazonka.Core as Core
import Amazonka.IoTEvents.Types.AlarmAction
import qualified Amazonka.Lens as Lens
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
(AlarmEventActions -> AlarmEventActions -> Bool)
-> (AlarmEventActions -> AlarmEventActions -> Bool)
-> Eq AlarmEventActions
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]
(Int -> ReadS AlarmEventActions)
-> ReadS [AlarmEventActions]
-> ReadPrec AlarmEventActions
-> ReadPrec [AlarmEventActions]
-> Read 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
(Int -> AlarmEventActions -> ShowS)
-> (AlarmEventActions -> String)
-> ([AlarmEventActions] -> ShowS)
-> Show AlarmEventActions
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. AlarmEventActions -> Rep AlarmEventActions x)
-> (forall x. Rep AlarmEventActions x -> AlarmEventActions)
-> Generic AlarmEventActions
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' :: Maybe [AlarmAction] -> AlarmEventActions
AlarmEventActions' {$sel:alarmActions:AlarmEventActions' :: Maybe [AlarmAction]
alarmActions = Maybe [AlarmAction]
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 :: (Maybe [AlarmAction] -> f (Maybe [AlarmAction]))
-> AlarmEventActions -> f AlarmEventActions
alarmEventActions_alarmActions = (AlarmEventActions -> Maybe [AlarmAction])
-> (AlarmEventActions -> Maybe [AlarmAction] -> AlarmEventActions)
-> Lens
     AlarmEventActions
     AlarmEventActions
     (Maybe [AlarmAction])
     (Maybe [AlarmAction])
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) ((Maybe [AlarmAction] -> f (Maybe [AlarmAction]))
 -> AlarmEventActions -> f AlarmEventActions)
-> ((Maybe [AlarmAction] -> f (Maybe [AlarmAction]))
    -> Maybe [AlarmAction] -> f (Maybe [AlarmAction]))
-> (Maybe [AlarmAction] -> f (Maybe [AlarmAction]))
-> AlarmEventActions
-> f AlarmEventActions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [AlarmAction] [AlarmAction] [AlarmAction] [AlarmAction]
-> Iso
     (Maybe [AlarmAction])
     (Maybe [AlarmAction])
     (Maybe [AlarmAction])
     (Maybe [AlarmAction])
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 [AlarmAction] [AlarmAction] [AlarmAction] [AlarmAction]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON AlarmEventActions where
  parseJSON :: Value -> Parser AlarmEventActions
parseJSON =
    String
-> (Object -> Parser AlarmEventActions)
-> Value
-> Parser AlarmEventActions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AlarmEventActions"
      ( \Object
x ->
          Maybe [AlarmAction] -> AlarmEventActions
AlarmEventActions'
            (Maybe [AlarmAction] -> AlarmEventActions)
-> Parser (Maybe [AlarmAction]) -> Parser AlarmEventActions
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [AlarmAction]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"alarmActions" Parser (Maybe (Maybe [AlarmAction]))
-> Maybe [AlarmAction] -> Parser (Maybe [AlarmAction])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [AlarmAction]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable AlarmEventActions

instance Prelude.NFData AlarmEventActions

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