{-# 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.AppConfig.Types.Monitor
-- 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.AppConfig.Types.Monitor where

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

-- | Amazon CloudWatch alarms to monitor during the deployment process.
--
-- /See:/ 'newMonitor' smart constructor.
data Monitor = Monitor'
  { -- | ARN of an IAM role for AppConfig to monitor @AlarmArn@.
    Monitor -> Maybe Text
alarmRoleArn :: Prelude.Maybe Prelude.Text,
    -- | ARN of the Amazon CloudWatch alarm.
    Monitor -> Maybe Text
alarmArn :: Prelude.Maybe Prelude.Text
  }
  deriving (Monitor -> Monitor -> Bool
(Monitor -> Monitor -> Bool)
-> (Monitor -> Monitor -> Bool) -> Eq Monitor
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Monitor -> Monitor -> Bool
$c/= :: Monitor -> Monitor -> Bool
== :: Monitor -> Monitor -> Bool
$c== :: Monitor -> Monitor -> Bool
Prelude.Eq, ReadPrec [Monitor]
ReadPrec Monitor
Int -> ReadS Monitor
ReadS [Monitor]
(Int -> ReadS Monitor)
-> ReadS [Monitor]
-> ReadPrec Monitor
-> ReadPrec [Monitor]
-> Read Monitor
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Monitor]
$creadListPrec :: ReadPrec [Monitor]
readPrec :: ReadPrec Monitor
$creadPrec :: ReadPrec Monitor
readList :: ReadS [Monitor]
$creadList :: ReadS [Monitor]
readsPrec :: Int -> ReadS Monitor
$creadsPrec :: Int -> ReadS Monitor
Prelude.Read, Int -> Monitor -> ShowS
[Monitor] -> ShowS
Monitor -> String
(Int -> Monitor -> ShowS)
-> (Monitor -> String) -> ([Monitor] -> ShowS) -> Show Monitor
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Monitor] -> ShowS
$cshowList :: [Monitor] -> ShowS
show :: Monitor -> String
$cshow :: Monitor -> String
showsPrec :: Int -> Monitor -> ShowS
$cshowsPrec :: Int -> Monitor -> ShowS
Prelude.Show, (forall x. Monitor -> Rep Monitor x)
-> (forall x. Rep Monitor x -> Monitor) -> Generic Monitor
forall x. Rep Monitor x -> Monitor
forall x. Monitor -> Rep Monitor x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Monitor x -> Monitor
$cfrom :: forall x. Monitor -> Rep Monitor x
Prelude.Generic)

-- |
-- Create a value of 'Monitor' 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:
--
-- 'alarmRoleArn', 'monitor_alarmRoleArn' - ARN of an IAM role for AppConfig to monitor @AlarmArn@.
--
-- 'alarmArn', 'monitor_alarmArn' - ARN of the Amazon CloudWatch alarm.
newMonitor ::
  Monitor
newMonitor :: Monitor
newMonitor =
  Monitor' :: Maybe Text -> Maybe Text -> Monitor
Monitor'
    { $sel:alarmRoleArn:Monitor' :: Maybe Text
alarmRoleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:alarmArn:Monitor' :: Maybe Text
alarmArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | ARN of an IAM role for AppConfig to monitor @AlarmArn@.
monitor_alarmRoleArn :: Lens.Lens' Monitor (Prelude.Maybe Prelude.Text)
monitor_alarmRoleArn :: (Maybe Text -> f (Maybe Text)) -> Monitor -> f Monitor
monitor_alarmRoleArn = (Monitor -> Maybe Text)
-> (Monitor -> Maybe Text -> Monitor)
-> Lens Monitor Monitor (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Monitor' {Maybe Text
alarmRoleArn :: Maybe Text
$sel:alarmRoleArn:Monitor' :: Monitor -> Maybe Text
alarmRoleArn} -> Maybe Text
alarmRoleArn) (\s :: Monitor
s@Monitor' {} Maybe Text
a -> Monitor
s {$sel:alarmRoleArn:Monitor' :: Maybe Text
alarmRoleArn = Maybe Text
a} :: Monitor)

-- | ARN of the Amazon CloudWatch alarm.
monitor_alarmArn :: Lens.Lens' Monitor (Prelude.Maybe Prelude.Text)
monitor_alarmArn :: (Maybe Text -> f (Maybe Text)) -> Monitor -> f Monitor
monitor_alarmArn = (Monitor -> Maybe Text)
-> (Monitor -> Maybe Text -> Monitor)
-> Lens Monitor Monitor (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Monitor' {Maybe Text
alarmArn :: Maybe Text
$sel:alarmArn:Monitor' :: Monitor -> Maybe Text
alarmArn} -> Maybe Text
alarmArn) (\s :: Monitor
s@Monitor' {} Maybe Text
a -> Monitor
s {$sel:alarmArn:Monitor' :: Maybe Text
alarmArn = Maybe Text
a} :: Monitor)

instance Core.FromJSON Monitor where
  parseJSON :: Value -> Parser Monitor
parseJSON =
    String -> (Object -> Parser Monitor) -> Value -> Parser Monitor
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Monitor"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Monitor
Monitor'
            (Maybe Text -> Maybe Text -> Monitor)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Monitor)
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
"AlarmRoleArn")
            Parser (Maybe Text -> Monitor)
-> Parser (Maybe Text) -> Parser Monitor
forall (f :: * -> *) a b. Applicative f => 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
"AlarmArn")
      )

instance Prelude.Hashable Monitor

instance Prelude.NFData Monitor

instance Core.ToJSON Monitor where
  toJSON :: Monitor -> Value
toJSON Monitor' {Maybe Text
alarmArn :: Maybe Text
alarmRoleArn :: Maybe Text
$sel:alarmArn:Monitor' :: Monitor -> Maybe Text
$sel:alarmRoleArn:Monitor' :: Monitor -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AlarmRoleArn" 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
alarmRoleArn,
            (Text
"AlarmArn" 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
alarmArn
          ]
      )