{-# 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.MediaTailor.Types.Alert
-- 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.MediaTailor.Types.Alert where

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

-- | Alert configuration parameters.
--
-- /See:/ 'newAlert' smart constructor.
data Alert = Alert'
  { -- | The Amazon Resource Name (ARN) of the resource.
    Alert -> Text
resourceArn :: Prelude.Text,
    -- | The code for the alert. For example, NOT_PROCESSED.
    Alert -> Text
alertCode :: Prelude.Text,
    -- | The timestamp when the alert was last modified.
    Alert -> POSIX
lastModifiedTime :: Core.POSIX,
    -- | The Amazon Resource Names (ARNs) related to this alert.
    Alert -> [Text]
relatedResourceArns :: [Prelude.Text],
    -- | If an alert is generated for a resource, an explanation of the reason
    -- for the alert.
    Alert -> Text
alertMessage :: Prelude.Text
  }
  deriving (Alert -> Alert -> Bool
(Alert -> Alert -> Bool) -> (Alert -> Alert -> Bool) -> Eq Alert
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Alert -> Alert -> Bool
$c/= :: Alert -> Alert -> Bool
== :: Alert -> Alert -> Bool
$c== :: Alert -> Alert -> Bool
Prelude.Eq, ReadPrec [Alert]
ReadPrec Alert
Int -> ReadS Alert
ReadS [Alert]
(Int -> ReadS Alert)
-> ReadS [Alert]
-> ReadPrec Alert
-> ReadPrec [Alert]
-> Read Alert
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Alert]
$creadListPrec :: ReadPrec [Alert]
readPrec :: ReadPrec Alert
$creadPrec :: ReadPrec Alert
readList :: ReadS [Alert]
$creadList :: ReadS [Alert]
readsPrec :: Int -> ReadS Alert
$creadsPrec :: Int -> ReadS Alert
Prelude.Read, Int -> Alert -> ShowS
[Alert] -> ShowS
Alert -> String
(Int -> Alert -> ShowS)
-> (Alert -> String) -> ([Alert] -> ShowS) -> Show Alert
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Alert] -> ShowS
$cshowList :: [Alert] -> ShowS
show :: Alert -> String
$cshow :: Alert -> String
showsPrec :: Int -> Alert -> ShowS
$cshowsPrec :: Int -> Alert -> ShowS
Prelude.Show, (forall x. Alert -> Rep Alert x)
-> (forall x. Rep Alert x -> Alert) -> Generic Alert
forall x. Rep Alert x -> Alert
forall x. Alert -> Rep Alert x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Alert x -> Alert
$cfrom :: forall x. Alert -> Rep Alert x
Prelude.Generic)

-- |
-- Create a value of 'Alert' 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:
--
-- 'resourceArn', 'alert_resourceArn' - The Amazon Resource Name (ARN) of the resource.
--
-- 'alertCode', 'alert_alertCode' - The code for the alert. For example, NOT_PROCESSED.
--
-- 'lastModifiedTime', 'alert_lastModifiedTime' - The timestamp when the alert was last modified.
--
-- 'relatedResourceArns', 'alert_relatedResourceArns' - The Amazon Resource Names (ARNs) related to this alert.
--
-- 'alertMessage', 'alert_alertMessage' - If an alert is generated for a resource, an explanation of the reason
-- for the alert.
newAlert ::
  -- | 'resourceArn'
  Prelude.Text ->
  -- | 'alertCode'
  Prelude.Text ->
  -- | 'lastModifiedTime'
  Prelude.UTCTime ->
  -- | 'alertMessage'
  Prelude.Text ->
  Alert
newAlert :: Text -> Text -> UTCTime -> Text -> Alert
newAlert
  Text
pResourceArn_
  Text
pAlertCode_
  UTCTime
pLastModifiedTime_
  Text
pAlertMessage_ =
    Alert' :: Text -> Text -> POSIX -> [Text] -> Text -> Alert
Alert'
      { $sel:resourceArn:Alert' :: Text
resourceArn = Text
pResourceArn_,
        $sel:alertCode:Alert' :: Text
alertCode = Text
pAlertCode_,
        $sel:lastModifiedTime:Alert' :: POSIX
lastModifiedTime =
          Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pLastModifiedTime_,
        $sel:relatedResourceArns:Alert' :: [Text]
relatedResourceArns = [Text]
forall a. Monoid a => a
Prelude.mempty,
        $sel:alertMessage:Alert' :: Text
alertMessage = Text
pAlertMessage_
      }

-- | The Amazon Resource Name (ARN) of the resource.
alert_resourceArn :: Lens.Lens' Alert Prelude.Text
alert_resourceArn :: (Text -> f Text) -> Alert -> f Alert
alert_resourceArn = (Alert -> Text)
-> (Alert -> Text -> Alert) -> Lens Alert Alert Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Alert' {Text
resourceArn :: Text
$sel:resourceArn:Alert' :: Alert -> Text
resourceArn} -> Text
resourceArn) (\s :: Alert
s@Alert' {} Text
a -> Alert
s {$sel:resourceArn:Alert' :: Text
resourceArn = Text
a} :: Alert)

-- | The code for the alert. For example, NOT_PROCESSED.
alert_alertCode :: Lens.Lens' Alert Prelude.Text
alert_alertCode :: (Text -> f Text) -> Alert -> f Alert
alert_alertCode = (Alert -> Text)
-> (Alert -> Text -> Alert) -> Lens Alert Alert Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Alert' {Text
alertCode :: Text
$sel:alertCode:Alert' :: Alert -> Text
alertCode} -> Text
alertCode) (\s :: Alert
s@Alert' {} Text
a -> Alert
s {$sel:alertCode:Alert' :: Text
alertCode = Text
a} :: Alert)

-- | The timestamp when the alert was last modified.
alert_lastModifiedTime :: Lens.Lens' Alert Prelude.UTCTime
alert_lastModifiedTime :: (UTCTime -> f UTCTime) -> Alert -> f Alert
alert_lastModifiedTime = (Alert -> POSIX)
-> (Alert -> POSIX -> Alert) -> Lens Alert Alert POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Alert' {POSIX
lastModifiedTime :: POSIX
$sel:lastModifiedTime:Alert' :: Alert -> POSIX
lastModifiedTime} -> POSIX
lastModifiedTime) (\s :: Alert
s@Alert' {} POSIX
a -> Alert
s {$sel:lastModifiedTime:Alert' :: POSIX
lastModifiedTime = POSIX
a} :: Alert) ((POSIX -> f POSIX) -> Alert -> f Alert)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> Alert
-> f Alert
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The Amazon Resource Names (ARNs) related to this alert.
alert_relatedResourceArns :: Lens.Lens' Alert [Prelude.Text]
alert_relatedResourceArns :: ([Text] -> f [Text]) -> Alert -> f Alert
alert_relatedResourceArns = (Alert -> [Text])
-> (Alert -> [Text] -> Alert) -> Lens Alert Alert [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Alert' {[Text]
relatedResourceArns :: [Text]
$sel:relatedResourceArns:Alert' :: Alert -> [Text]
relatedResourceArns} -> [Text]
relatedResourceArns) (\s :: Alert
s@Alert' {} [Text]
a -> Alert
s {$sel:relatedResourceArns:Alert' :: [Text]
relatedResourceArns = [Text]
a} :: Alert) (([Text] -> f [Text]) -> Alert -> f Alert)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> Alert
-> f Alert
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | If an alert is generated for a resource, an explanation of the reason
-- for the alert.
alert_alertMessage :: Lens.Lens' Alert Prelude.Text
alert_alertMessage :: (Text -> f Text) -> Alert -> f Alert
alert_alertMessage = (Alert -> Text)
-> (Alert -> Text -> Alert) -> Lens Alert Alert Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Alert' {Text
alertMessage :: Text
$sel:alertMessage:Alert' :: Alert -> Text
alertMessage} -> Text
alertMessage) (\s :: Alert
s@Alert' {} Text
a -> Alert
s {$sel:alertMessage:Alert' :: Text
alertMessage = Text
a} :: Alert)

instance Core.FromJSON Alert where
  parseJSON :: Value -> Parser Alert
parseJSON =
    String -> (Object -> Parser Alert) -> Value -> Parser Alert
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Alert"
      ( \Object
x ->
          Text -> Text -> POSIX -> [Text] -> Text -> Alert
Alert'
            (Text -> Text -> POSIX -> [Text] -> Text -> Alert)
-> Parser Text -> Parser (Text -> POSIX -> [Text] -> Text -> Alert)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ResourceArn")
            Parser (Text -> POSIX -> [Text] -> Text -> Alert)
-> Parser Text -> Parser (POSIX -> [Text] -> Text -> Alert)
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
"AlertCode")
            Parser (POSIX -> [Text] -> Text -> Alert)
-> Parser POSIX -> Parser ([Text] -> Text -> Alert)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"LastModifiedTime")
            Parser ([Text] -> Text -> Alert)
-> Parser [Text] -> Parser (Text -> Alert)
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
"RelatedResourceArns"
                            Parser (Maybe [Text]) -> [Text] -> Parser [Text]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Text -> Alert) -> Parser Text -> Parser Alert
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
"AlertMessage")
      )

instance Prelude.Hashable Alert

instance Prelude.NFData Alert