{-# 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.LookoutMetrics.Types.AlertSummary
-- 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.LookoutMetrics.Types.AlertSummary where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LookoutMetrics.Types.AlertStatus
import Amazonka.LookoutMetrics.Types.AlertType
import qualified Amazonka.Prelude as Prelude

-- | Provides a summary of an alert\'s configuration.
--
-- /See:/ 'newAlertSummary' smart constructor.
data AlertSummary = AlertSummary'
  { -- | The ARN of the alert.
    AlertSummary -> Maybe Text
alertArn :: Prelude.Maybe Prelude.Text,
    -- | The name of the alert.
    AlertSummary -> Maybe Text
alertName :: Prelude.Maybe Prelude.Text,
    -- | The minimum severity for an anomaly to trigger the alert.
    AlertSummary -> Maybe Natural
alertSensitivityThreshold :: Prelude.Maybe Prelude.Natural,
    -- | The status of the alert.
    AlertSummary -> Maybe AlertStatus
alertStatus :: Prelude.Maybe AlertStatus,
    -- | The type of the alert.
    AlertSummary -> Maybe AlertType
alertType :: Prelude.Maybe AlertType,
    -- | The ARN of the detector to which the alert is attached.
    AlertSummary -> Maybe Text
anomalyDetectorArn :: Prelude.Maybe Prelude.Text,
    -- | The time at which the alert was created.
    AlertSummary -> Maybe POSIX
creationTime :: Prelude.Maybe Data.POSIX,
    -- | The time at which the alert was last modified.
    AlertSummary -> Maybe POSIX
lastModificationTime :: Prelude.Maybe Data.POSIX,
    -- | The alert\'s
    -- <https://docs.aws.amazon.com/lookoutmetrics/latest/dev/detectors-tags.html tags>.
    AlertSummary -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (AlertSummary -> AlertSummary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AlertSummary -> AlertSummary -> Bool
$c/= :: AlertSummary -> AlertSummary -> Bool
== :: AlertSummary -> AlertSummary -> Bool
$c== :: AlertSummary -> AlertSummary -> Bool
Prelude.Eq, ReadPrec [AlertSummary]
ReadPrec AlertSummary
Int -> ReadS AlertSummary
ReadS [AlertSummary]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AlertSummary]
$creadListPrec :: ReadPrec [AlertSummary]
readPrec :: ReadPrec AlertSummary
$creadPrec :: ReadPrec AlertSummary
readList :: ReadS [AlertSummary]
$creadList :: ReadS [AlertSummary]
readsPrec :: Int -> ReadS AlertSummary
$creadsPrec :: Int -> ReadS AlertSummary
Prelude.Read, Int -> AlertSummary -> ShowS
[AlertSummary] -> ShowS
AlertSummary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AlertSummary] -> ShowS
$cshowList :: [AlertSummary] -> ShowS
show :: AlertSummary -> String
$cshow :: AlertSummary -> String
showsPrec :: Int -> AlertSummary -> ShowS
$cshowsPrec :: Int -> AlertSummary -> ShowS
Prelude.Show, forall x. Rep AlertSummary x -> AlertSummary
forall x. AlertSummary -> Rep AlertSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AlertSummary x -> AlertSummary
$cfrom :: forall x. AlertSummary -> Rep AlertSummary x
Prelude.Generic)

-- |
-- Create a value of 'AlertSummary' 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:
--
-- 'alertArn', 'alertSummary_alertArn' - The ARN of the alert.
--
-- 'alertName', 'alertSummary_alertName' - The name of the alert.
--
-- 'alertSensitivityThreshold', 'alertSummary_alertSensitivityThreshold' - The minimum severity for an anomaly to trigger the alert.
--
-- 'alertStatus', 'alertSummary_alertStatus' - The status of the alert.
--
-- 'alertType', 'alertSummary_alertType' - The type of the alert.
--
-- 'anomalyDetectorArn', 'alertSummary_anomalyDetectorArn' - The ARN of the detector to which the alert is attached.
--
-- 'creationTime', 'alertSummary_creationTime' - The time at which the alert was created.
--
-- 'lastModificationTime', 'alertSummary_lastModificationTime' - The time at which the alert was last modified.
--
-- 'tags', 'alertSummary_tags' - The alert\'s
-- <https://docs.aws.amazon.com/lookoutmetrics/latest/dev/detectors-tags.html tags>.
newAlertSummary ::
  AlertSummary
newAlertSummary :: AlertSummary
newAlertSummary =
  AlertSummary'
    { $sel:alertArn:AlertSummary' :: Maybe Text
alertArn = forall a. Maybe a
Prelude.Nothing,
      $sel:alertName:AlertSummary' :: Maybe Text
alertName = forall a. Maybe a
Prelude.Nothing,
      $sel:alertSensitivityThreshold:AlertSummary' :: Maybe Natural
alertSensitivityThreshold = forall a. Maybe a
Prelude.Nothing,
      $sel:alertStatus:AlertSummary' :: Maybe AlertStatus
alertStatus = forall a. Maybe a
Prelude.Nothing,
      $sel:alertType:AlertSummary' :: Maybe AlertType
alertType = forall a. Maybe a
Prelude.Nothing,
      $sel:anomalyDetectorArn:AlertSummary' :: Maybe Text
anomalyDetectorArn = forall a. Maybe a
Prelude.Nothing,
      $sel:creationTime:AlertSummary' :: Maybe POSIX
creationTime = forall a. Maybe a
Prelude.Nothing,
      $sel:lastModificationTime:AlertSummary' :: Maybe POSIX
lastModificationTime = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:AlertSummary' :: Maybe (HashMap Text Text)
tags = forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN of the alert.
alertSummary_alertArn :: Lens.Lens' AlertSummary (Prelude.Maybe Prelude.Text)
alertSummary_alertArn :: Lens' AlertSummary (Maybe Text)
alertSummary_alertArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlertSummary' {Maybe Text
alertArn :: Maybe Text
$sel:alertArn:AlertSummary' :: AlertSummary -> Maybe Text
alertArn} -> Maybe Text
alertArn) (\s :: AlertSummary
s@AlertSummary' {} Maybe Text
a -> AlertSummary
s {$sel:alertArn:AlertSummary' :: Maybe Text
alertArn = Maybe Text
a} :: AlertSummary)

-- | The name of the alert.
alertSummary_alertName :: Lens.Lens' AlertSummary (Prelude.Maybe Prelude.Text)
alertSummary_alertName :: Lens' AlertSummary (Maybe Text)
alertSummary_alertName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlertSummary' {Maybe Text
alertName :: Maybe Text
$sel:alertName:AlertSummary' :: AlertSummary -> Maybe Text
alertName} -> Maybe Text
alertName) (\s :: AlertSummary
s@AlertSummary' {} Maybe Text
a -> AlertSummary
s {$sel:alertName:AlertSummary' :: Maybe Text
alertName = Maybe Text
a} :: AlertSummary)

-- | The minimum severity for an anomaly to trigger the alert.
alertSummary_alertSensitivityThreshold :: Lens.Lens' AlertSummary (Prelude.Maybe Prelude.Natural)
alertSummary_alertSensitivityThreshold :: Lens' AlertSummary (Maybe Natural)
alertSummary_alertSensitivityThreshold = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlertSummary' {Maybe Natural
alertSensitivityThreshold :: Maybe Natural
$sel:alertSensitivityThreshold:AlertSummary' :: AlertSummary -> Maybe Natural
alertSensitivityThreshold} -> Maybe Natural
alertSensitivityThreshold) (\s :: AlertSummary
s@AlertSummary' {} Maybe Natural
a -> AlertSummary
s {$sel:alertSensitivityThreshold:AlertSummary' :: Maybe Natural
alertSensitivityThreshold = Maybe Natural
a} :: AlertSummary)

-- | The status of the alert.
alertSummary_alertStatus :: Lens.Lens' AlertSummary (Prelude.Maybe AlertStatus)
alertSummary_alertStatus :: Lens' AlertSummary (Maybe AlertStatus)
alertSummary_alertStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlertSummary' {Maybe AlertStatus
alertStatus :: Maybe AlertStatus
$sel:alertStatus:AlertSummary' :: AlertSummary -> Maybe AlertStatus
alertStatus} -> Maybe AlertStatus
alertStatus) (\s :: AlertSummary
s@AlertSummary' {} Maybe AlertStatus
a -> AlertSummary
s {$sel:alertStatus:AlertSummary' :: Maybe AlertStatus
alertStatus = Maybe AlertStatus
a} :: AlertSummary)

-- | The type of the alert.
alertSummary_alertType :: Lens.Lens' AlertSummary (Prelude.Maybe AlertType)
alertSummary_alertType :: Lens' AlertSummary (Maybe AlertType)
alertSummary_alertType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlertSummary' {Maybe AlertType
alertType :: Maybe AlertType
$sel:alertType:AlertSummary' :: AlertSummary -> Maybe AlertType
alertType} -> Maybe AlertType
alertType) (\s :: AlertSummary
s@AlertSummary' {} Maybe AlertType
a -> AlertSummary
s {$sel:alertType:AlertSummary' :: Maybe AlertType
alertType = Maybe AlertType
a} :: AlertSummary)

-- | The ARN of the detector to which the alert is attached.
alertSummary_anomalyDetectorArn :: Lens.Lens' AlertSummary (Prelude.Maybe Prelude.Text)
alertSummary_anomalyDetectorArn :: Lens' AlertSummary (Maybe Text)
alertSummary_anomalyDetectorArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlertSummary' {Maybe Text
anomalyDetectorArn :: Maybe Text
$sel:anomalyDetectorArn:AlertSummary' :: AlertSummary -> Maybe Text
anomalyDetectorArn} -> Maybe Text
anomalyDetectorArn) (\s :: AlertSummary
s@AlertSummary' {} Maybe Text
a -> AlertSummary
s {$sel:anomalyDetectorArn:AlertSummary' :: Maybe Text
anomalyDetectorArn = Maybe Text
a} :: AlertSummary)

-- | The time at which the alert was created.
alertSummary_creationTime :: Lens.Lens' AlertSummary (Prelude.Maybe Prelude.UTCTime)
alertSummary_creationTime :: Lens' AlertSummary (Maybe UTCTime)
alertSummary_creationTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlertSummary' {Maybe POSIX
creationTime :: Maybe POSIX
$sel:creationTime:AlertSummary' :: AlertSummary -> Maybe POSIX
creationTime} -> Maybe POSIX
creationTime) (\s :: AlertSummary
s@AlertSummary' {} Maybe POSIX
a -> AlertSummary
s {$sel:creationTime:AlertSummary' :: Maybe POSIX
creationTime = Maybe POSIX
a} :: AlertSummary) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The time at which the alert was last modified.
alertSummary_lastModificationTime :: Lens.Lens' AlertSummary (Prelude.Maybe Prelude.UTCTime)
alertSummary_lastModificationTime :: Lens' AlertSummary (Maybe UTCTime)
alertSummary_lastModificationTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlertSummary' {Maybe POSIX
lastModificationTime :: Maybe POSIX
$sel:lastModificationTime:AlertSummary' :: AlertSummary -> Maybe POSIX
lastModificationTime} -> Maybe POSIX
lastModificationTime) (\s :: AlertSummary
s@AlertSummary' {} Maybe POSIX
a -> AlertSummary
s {$sel:lastModificationTime:AlertSummary' :: Maybe POSIX
lastModificationTime = Maybe POSIX
a} :: AlertSummary) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The alert\'s
-- <https://docs.aws.amazon.com/lookoutmetrics/latest/dev/detectors-tags.html tags>.
alertSummary_tags :: Lens.Lens' AlertSummary (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
alertSummary_tags :: Lens' AlertSummary (Maybe (HashMap Text Text))
alertSummary_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlertSummary' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:AlertSummary' :: AlertSummary -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: AlertSummary
s@AlertSummary' {} Maybe (HashMap Text Text)
a -> AlertSummary
s {$sel:tags:AlertSummary' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: AlertSummary) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON AlertSummary where
  parseJSON :: Value -> Parser AlertSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AlertSummary"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Natural
-> Maybe AlertStatus
-> Maybe AlertType
-> Maybe Text
-> Maybe POSIX
-> Maybe POSIX
-> Maybe (HashMap Text Text)
-> AlertSummary
AlertSummary'
            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
"AlertArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"AlertName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"AlertSensitivityThreshold")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"AlertStatus")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"AlertType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"AnomalyDetectorArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CreationTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"LastModificationTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Tags" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable AlertSummary where
  hashWithSalt :: Int -> AlertSummary -> Int
hashWithSalt Int
_salt AlertSummary' {Maybe Natural
Maybe Text
Maybe (HashMap Text Text)
Maybe POSIX
Maybe AlertStatus
Maybe AlertType
tags :: Maybe (HashMap Text Text)
lastModificationTime :: Maybe POSIX
creationTime :: Maybe POSIX
anomalyDetectorArn :: Maybe Text
alertType :: Maybe AlertType
alertStatus :: Maybe AlertStatus
alertSensitivityThreshold :: Maybe Natural
alertName :: Maybe Text
alertArn :: Maybe Text
$sel:tags:AlertSummary' :: AlertSummary -> Maybe (HashMap Text Text)
$sel:lastModificationTime:AlertSummary' :: AlertSummary -> Maybe POSIX
$sel:creationTime:AlertSummary' :: AlertSummary -> Maybe POSIX
$sel:anomalyDetectorArn:AlertSummary' :: AlertSummary -> Maybe Text
$sel:alertType:AlertSummary' :: AlertSummary -> Maybe AlertType
$sel:alertStatus:AlertSummary' :: AlertSummary -> Maybe AlertStatus
$sel:alertSensitivityThreshold:AlertSummary' :: AlertSummary -> Maybe Natural
$sel:alertName:AlertSummary' :: AlertSummary -> Maybe Text
$sel:alertArn:AlertSummary' :: AlertSummary -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
alertArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
alertName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
alertSensitivityThreshold
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AlertStatus
alertStatus
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AlertType
alertType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
anomalyDetectorArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
creationTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
lastModificationTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
tags

instance Prelude.NFData AlertSummary where
  rnf :: AlertSummary -> ()
rnf AlertSummary' {Maybe Natural
Maybe Text
Maybe (HashMap Text Text)
Maybe POSIX
Maybe AlertStatus
Maybe AlertType
tags :: Maybe (HashMap Text Text)
lastModificationTime :: Maybe POSIX
creationTime :: Maybe POSIX
anomalyDetectorArn :: Maybe Text
alertType :: Maybe AlertType
alertStatus :: Maybe AlertStatus
alertSensitivityThreshold :: Maybe Natural
alertName :: Maybe Text
alertArn :: Maybe Text
$sel:tags:AlertSummary' :: AlertSummary -> Maybe (HashMap Text Text)
$sel:lastModificationTime:AlertSummary' :: AlertSummary -> Maybe POSIX
$sel:creationTime:AlertSummary' :: AlertSummary -> Maybe POSIX
$sel:anomalyDetectorArn:AlertSummary' :: AlertSummary -> Maybe Text
$sel:alertType:AlertSummary' :: AlertSummary -> Maybe AlertType
$sel:alertStatus:AlertSummary' :: AlertSummary -> Maybe AlertStatus
$sel:alertSensitivityThreshold:AlertSummary' :: AlertSummary -> Maybe Natural
$sel:alertName:AlertSummary' :: AlertSummary -> Maybe Text
$sel:alertArn:AlertSummary' :: AlertSummary -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
alertArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
alertName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
alertSensitivityThreshold
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe AlertStatus
alertStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe AlertType
alertType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
anomalyDetectorArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
creationTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastModificationTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
tags