{-# 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.IoTSiteWise.Types.Alarms
-- 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.IoTSiteWise.Types.Alarms where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains the configuration information of an alarm created in an IoT
-- SiteWise Monitor portal. You can use the alarm to monitor an asset
-- property and get notified when the asset property value is outside a
-- specified range. For more information, see
-- <https://docs.aws.amazon.com/iot-sitewise/latest/appguide/monitor-alarms.html Monitoring with alarms>
-- in the /IoT SiteWise Application Guide/.
--
-- /See:/ 'newAlarms' smart constructor.
data Alarms = Alarms'
  { -- | The
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
    -- of the Lambda function that manages alarm notifications. For more
    -- information, see
    -- <https://docs.aws.amazon.com/iotevents/latest/developerguide/lambda-support.html Managing alarm notifications>
    -- in the /IoT Events Developer Guide/.
    Alarms -> Maybe Text
notificationLambdaArn :: Prelude.Maybe Prelude.Text,
    -- | The
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
    -- of the IAM role that allows the alarm to perform actions and access
    -- Amazon Web Services resources and services, such as IoT Events.
    Alarms -> Text
alarmRoleArn :: Prelude.Text
  }
  deriving (Alarms -> Alarms -> Bool
(Alarms -> Alarms -> Bool)
-> (Alarms -> Alarms -> Bool) -> Eq Alarms
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Alarms -> Alarms -> Bool
$c/= :: Alarms -> Alarms -> Bool
== :: Alarms -> Alarms -> Bool
$c== :: Alarms -> Alarms -> Bool
Prelude.Eq, ReadPrec [Alarms]
ReadPrec Alarms
Int -> ReadS Alarms
ReadS [Alarms]
(Int -> ReadS Alarms)
-> ReadS [Alarms]
-> ReadPrec Alarms
-> ReadPrec [Alarms]
-> Read Alarms
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Alarms]
$creadListPrec :: ReadPrec [Alarms]
readPrec :: ReadPrec Alarms
$creadPrec :: ReadPrec Alarms
readList :: ReadS [Alarms]
$creadList :: ReadS [Alarms]
readsPrec :: Int -> ReadS Alarms
$creadsPrec :: Int -> ReadS Alarms
Prelude.Read, Int -> Alarms -> ShowS
[Alarms] -> ShowS
Alarms -> String
(Int -> Alarms -> ShowS)
-> (Alarms -> String) -> ([Alarms] -> ShowS) -> Show Alarms
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Alarms] -> ShowS
$cshowList :: [Alarms] -> ShowS
show :: Alarms -> String
$cshow :: Alarms -> String
showsPrec :: Int -> Alarms -> ShowS
$cshowsPrec :: Int -> Alarms -> ShowS
Prelude.Show, (forall x. Alarms -> Rep Alarms x)
-> (forall x. Rep Alarms x -> Alarms) -> Generic Alarms
forall x. Rep Alarms x -> Alarms
forall x. Alarms -> Rep Alarms x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Alarms x -> Alarms
$cfrom :: forall x. Alarms -> Rep Alarms x
Prelude.Generic)

-- |
-- Create a value of 'Alarms' 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:
--
-- 'notificationLambdaArn', 'alarms_notificationLambdaArn' - The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
-- of the Lambda function that manages alarm notifications. For more
-- information, see
-- <https://docs.aws.amazon.com/iotevents/latest/developerguide/lambda-support.html Managing alarm notifications>
-- in the /IoT Events Developer Guide/.
--
-- 'alarmRoleArn', 'alarms_alarmRoleArn' - The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
-- of the IAM role that allows the alarm to perform actions and access
-- Amazon Web Services resources and services, such as IoT Events.
newAlarms ::
  -- | 'alarmRoleArn'
  Prelude.Text ->
  Alarms
newAlarms :: Text -> Alarms
newAlarms Text
pAlarmRoleArn_ =
  Alarms' :: Maybe Text -> Text -> Alarms
Alarms'
    { $sel:notificationLambdaArn:Alarms' :: Maybe Text
notificationLambdaArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:alarmRoleArn:Alarms' :: Text
alarmRoleArn = Text
pAlarmRoleArn_
    }

-- | The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
-- of the Lambda function that manages alarm notifications. For more
-- information, see
-- <https://docs.aws.amazon.com/iotevents/latest/developerguide/lambda-support.html Managing alarm notifications>
-- in the /IoT Events Developer Guide/.
alarms_notificationLambdaArn :: Lens.Lens' Alarms (Prelude.Maybe Prelude.Text)
alarms_notificationLambdaArn :: (Maybe Text -> f (Maybe Text)) -> Alarms -> f Alarms
alarms_notificationLambdaArn = (Alarms -> Maybe Text)
-> (Alarms -> Maybe Text -> Alarms)
-> Lens Alarms Alarms (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Alarms' {Maybe Text
notificationLambdaArn :: Maybe Text
$sel:notificationLambdaArn:Alarms' :: Alarms -> Maybe Text
notificationLambdaArn} -> Maybe Text
notificationLambdaArn) (\s :: Alarms
s@Alarms' {} Maybe Text
a -> Alarms
s {$sel:notificationLambdaArn:Alarms' :: Maybe Text
notificationLambdaArn = Maybe Text
a} :: Alarms)

-- | The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
-- of the IAM role that allows the alarm to perform actions and access
-- Amazon Web Services resources and services, such as IoT Events.
alarms_alarmRoleArn :: Lens.Lens' Alarms Prelude.Text
alarms_alarmRoleArn :: (Text -> f Text) -> Alarms -> f Alarms
alarms_alarmRoleArn = (Alarms -> Text)
-> (Alarms -> Text -> Alarms) -> Lens Alarms Alarms Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Alarms' {Text
alarmRoleArn :: Text
$sel:alarmRoleArn:Alarms' :: Alarms -> Text
alarmRoleArn} -> Text
alarmRoleArn) (\s :: Alarms
s@Alarms' {} Text
a -> Alarms
s {$sel:alarmRoleArn:Alarms' :: Text
alarmRoleArn = Text
a} :: Alarms)

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

instance Prelude.Hashable Alarms

instance Prelude.NFData Alarms

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