{-# 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.AlarmCapabilities
-- 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.AlarmCapabilities where

import qualified Amazonka.Core as Core
import Amazonka.IoTEvents.Types.AcknowledgeFlow
import Amazonka.IoTEvents.Types.InitializationConfiguration
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains the configuration information of alarm state changes.
--
-- /See:/ 'newAlarmCapabilities' smart constructor.
data AlarmCapabilities = AlarmCapabilities'
  { -- | Specifies whether to get notified for alarm state changes.
    AlarmCapabilities -> Maybe AcknowledgeFlow
acknowledgeFlow :: Prelude.Maybe AcknowledgeFlow,
    -- | Specifies the default alarm state. The configuration applies to all
    -- alarms that were created based on this alarm model.
    AlarmCapabilities -> Maybe InitializationConfiguration
initializationConfiguration :: Prelude.Maybe InitializationConfiguration
  }
  deriving (AlarmCapabilities -> AlarmCapabilities -> Bool
(AlarmCapabilities -> AlarmCapabilities -> Bool)
-> (AlarmCapabilities -> AlarmCapabilities -> Bool)
-> Eq AlarmCapabilities
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AlarmCapabilities -> AlarmCapabilities -> Bool
$c/= :: AlarmCapabilities -> AlarmCapabilities -> Bool
== :: AlarmCapabilities -> AlarmCapabilities -> Bool
$c== :: AlarmCapabilities -> AlarmCapabilities -> Bool
Prelude.Eq, ReadPrec [AlarmCapabilities]
ReadPrec AlarmCapabilities
Int -> ReadS AlarmCapabilities
ReadS [AlarmCapabilities]
(Int -> ReadS AlarmCapabilities)
-> ReadS [AlarmCapabilities]
-> ReadPrec AlarmCapabilities
-> ReadPrec [AlarmCapabilities]
-> Read AlarmCapabilities
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AlarmCapabilities]
$creadListPrec :: ReadPrec [AlarmCapabilities]
readPrec :: ReadPrec AlarmCapabilities
$creadPrec :: ReadPrec AlarmCapabilities
readList :: ReadS [AlarmCapabilities]
$creadList :: ReadS [AlarmCapabilities]
readsPrec :: Int -> ReadS AlarmCapabilities
$creadsPrec :: Int -> ReadS AlarmCapabilities
Prelude.Read, Int -> AlarmCapabilities -> ShowS
[AlarmCapabilities] -> ShowS
AlarmCapabilities -> String
(Int -> AlarmCapabilities -> ShowS)
-> (AlarmCapabilities -> String)
-> ([AlarmCapabilities] -> ShowS)
-> Show AlarmCapabilities
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AlarmCapabilities] -> ShowS
$cshowList :: [AlarmCapabilities] -> ShowS
show :: AlarmCapabilities -> String
$cshow :: AlarmCapabilities -> String
showsPrec :: Int -> AlarmCapabilities -> ShowS
$cshowsPrec :: Int -> AlarmCapabilities -> ShowS
Prelude.Show, (forall x. AlarmCapabilities -> Rep AlarmCapabilities x)
-> (forall x. Rep AlarmCapabilities x -> AlarmCapabilities)
-> Generic AlarmCapabilities
forall x. Rep AlarmCapabilities x -> AlarmCapabilities
forall x. AlarmCapabilities -> Rep AlarmCapabilities x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AlarmCapabilities x -> AlarmCapabilities
$cfrom :: forall x. AlarmCapabilities -> Rep AlarmCapabilities x
Prelude.Generic)

-- |
-- Create a value of 'AlarmCapabilities' 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:
--
-- 'acknowledgeFlow', 'alarmCapabilities_acknowledgeFlow' - Specifies whether to get notified for alarm state changes.
--
-- 'initializationConfiguration', 'alarmCapabilities_initializationConfiguration' - Specifies the default alarm state. The configuration applies to all
-- alarms that were created based on this alarm model.
newAlarmCapabilities ::
  AlarmCapabilities
newAlarmCapabilities :: AlarmCapabilities
newAlarmCapabilities =
  AlarmCapabilities' :: Maybe AcknowledgeFlow
-> Maybe InitializationConfiguration -> AlarmCapabilities
AlarmCapabilities'
    { $sel:acknowledgeFlow:AlarmCapabilities' :: Maybe AcknowledgeFlow
acknowledgeFlow =
        Maybe AcknowledgeFlow
forall a. Maybe a
Prelude.Nothing,
      $sel:initializationConfiguration:AlarmCapabilities' :: Maybe InitializationConfiguration
initializationConfiguration = Maybe InitializationConfiguration
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies whether to get notified for alarm state changes.
alarmCapabilities_acknowledgeFlow :: Lens.Lens' AlarmCapabilities (Prelude.Maybe AcknowledgeFlow)
alarmCapabilities_acknowledgeFlow :: (Maybe AcknowledgeFlow -> f (Maybe AcknowledgeFlow))
-> AlarmCapabilities -> f AlarmCapabilities
alarmCapabilities_acknowledgeFlow = (AlarmCapabilities -> Maybe AcknowledgeFlow)
-> (AlarmCapabilities
    -> Maybe AcknowledgeFlow -> AlarmCapabilities)
-> Lens
     AlarmCapabilities
     AlarmCapabilities
     (Maybe AcknowledgeFlow)
     (Maybe AcknowledgeFlow)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlarmCapabilities' {Maybe AcknowledgeFlow
acknowledgeFlow :: Maybe AcknowledgeFlow
$sel:acknowledgeFlow:AlarmCapabilities' :: AlarmCapabilities -> Maybe AcknowledgeFlow
acknowledgeFlow} -> Maybe AcknowledgeFlow
acknowledgeFlow) (\s :: AlarmCapabilities
s@AlarmCapabilities' {} Maybe AcknowledgeFlow
a -> AlarmCapabilities
s {$sel:acknowledgeFlow:AlarmCapabilities' :: Maybe AcknowledgeFlow
acknowledgeFlow = Maybe AcknowledgeFlow
a} :: AlarmCapabilities)

-- | Specifies the default alarm state. The configuration applies to all
-- alarms that were created based on this alarm model.
alarmCapabilities_initializationConfiguration :: Lens.Lens' AlarmCapabilities (Prelude.Maybe InitializationConfiguration)
alarmCapabilities_initializationConfiguration :: (Maybe InitializationConfiguration
 -> f (Maybe InitializationConfiguration))
-> AlarmCapabilities -> f AlarmCapabilities
alarmCapabilities_initializationConfiguration = (AlarmCapabilities -> Maybe InitializationConfiguration)
-> (AlarmCapabilities
    -> Maybe InitializationConfiguration -> AlarmCapabilities)
-> Lens
     AlarmCapabilities
     AlarmCapabilities
     (Maybe InitializationConfiguration)
     (Maybe InitializationConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlarmCapabilities' {Maybe InitializationConfiguration
initializationConfiguration :: Maybe InitializationConfiguration
$sel:initializationConfiguration:AlarmCapabilities' :: AlarmCapabilities -> Maybe InitializationConfiguration
initializationConfiguration} -> Maybe InitializationConfiguration
initializationConfiguration) (\s :: AlarmCapabilities
s@AlarmCapabilities' {} Maybe InitializationConfiguration
a -> AlarmCapabilities
s {$sel:initializationConfiguration:AlarmCapabilities' :: Maybe InitializationConfiguration
initializationConfiguration = Maybe InitializationConfiguration
a} :: AlarmCapabilities)

instance Core.FromJSON AlarmCapabilities where
  parseJSON :: Value -> Parser AlarmCapabilities
parseJSON =
    String
-> (Object -> Parser AlarmCapabilities)
-> Value
-> Parser AlarmCapabilities
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AlarmCapabilities"
      ( \Object
x ->
          Maybe AcknowledgeFlow
-> Maybe InitializationConfiguration -> AlarmCapabilities
AlarmCapabilities'
            (Maybe AcknowledgeFlow
 -> Maybe InitializationConfiguration -> AlarmCapabilities)
-> Parser (Maybe AcknowledgeFlow)
-> Parser (Maybe InitializationConfiguration -> AlarmCapabilities)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe AcknowledgeFlow)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"acknowledgeFlow")
            Parser (Maybe InitializationConfiguration -> AlarmCapabilities)
-> Parser (Maybe InitializationConfiguration)
-> Parser AlarmCapabilities
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe InitializationConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"initializationConfiguration")
      )

instance Prelude.Hashable AlarmCapabilities

instance Prelude.NFData AlarmCapabilities

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