{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoTSiteWise.Types.Alarms where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $sel:notificationLambdaArn:Alarms' :: Maybe Text
notificationLambdaArn = 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 :: Lens' Alarms (Maybe Text)
alarms_notificationLambdaArn = 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 :: Lens' Alarms Text
alarms_alarmRoleArn = 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 Data.FromJSON Alarms where
  parseJSON :: Value -> Parser Alarms
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Alarms"
      ( \Object
x ->
          Maybe Text -> Text -> Alarms
Alarms'
            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
"notificationLambdaArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"alarmRoleArn")
      )

instance Prelude.Hashable Alarms where
  hashWithSalt :: Int -> Alarms -> Int
hashWithSalt Int
_salt Alarms' {Maybe Text
Text
alarmRoleArn :: Text
notificationLambdaArn :: Maybe Text
$sel:alarmRoleArn:Alarms' :: Alarms -> Text
$sel:notificationLambdaArn:Alarms' :: Alarms -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
notificationLambdaArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
alarmRoleArn

instance Prelude.NFData Alarms where
  rnf :: Alarms -> ()
rnf Alarms' {Maybe Text
Text
alarmRoleArn :: Text
notificationLambdaArn :: Maybe Text
$sel:alarmRoleArn:Alarms' :: Alarms -> Text
$sel:notificationLambdaArn:Alarms' :: Alarms -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
notificationLambdaArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
alarmRoleArn

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"notificationLambdaArn" 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 Text
notificationLambdaArn,
            forall a. a -> Maybe a
Prelude.Just (Key
"alarmRoleArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
alarmRoleArn)
          ]
      )