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

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

-- | The code for the alert. For example, @NOT_PROCESSED@.
alert_alertCode :: Lens.Lens' Alert Prelude.Text
alert_alertCode :: Lens' Alert Text
alert_alertCode = 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)

-- | 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 :: Lens' Alert Text
alert_alertMessage = 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)

-- | The timestamp when the alert was last modified.
alert_lastModifiedTime :: Lens.Lens' Alert Prelude.UTCTime
alert_lastModifiedTime :: Lens' Alert UTCTime
alert_lastModifiedTime = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The Amazon Resource Names (ARNs) related to this alert.
alert_relatedResourceArns :: Lens.Lens' Alert [Prelude.Text]
alert_relatedResourceArns :: Lens' Alert [Text]
alert_relatedResourceArns = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon Resource Name (ARN) of the resource.
alert_resourceArn :: Lens.Lens' Alert Prelude.Text
alert_resourceArn :: Lens' Alert Text
alert_resourceArn = 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)

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

instance Prelude.Hashable Alert where
  hashWithSalt :: Int -> Alert -> Int
hashWithSalt Int
_salt Alert' {[Text]
Text
POSIX
resourceArn :: Text
relatedResourceArns :: [Text]
lastModifiedTime :: POSIX
alertMessage :: Text
alertCode :: Text
$sel:resourceArn:Alert' :: Alert -> Text
$sel:relatedResourceArns:Alert' :: Alert -> [Text]
$sel:lastModifiedTime:Alert' :: Alert -> POSIX
$sel:alertMessage:Alert' :: Alert -> Text
$sel:alertCode:Alert' :: Alert -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
alertCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
alertMessage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` POSIX
lastModifiedTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
relatedResourceArns
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceArn

instance Prelude.NFData Alert where
  rnf :: Alert -> ()
rnf Alert' {[Text]
Text
POSIX
resourceArn :: Text
relatedResourceArns :: [Text]
lastModifiedTime :: POSIX
alertMessage :: Text
alertCode :: Text
$sel:resourceArn:Alert' :: Alert -> Text
$sel:relatedResourceArns:Alert' :: Alert -> [Text]
$sel:lastModifiedTime:Alert' :: Alert -> POSIX
$sel:alertMessage:Alert' :: Alert -> Text
$sel:alertCode:Alert' :: Alert -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
alertCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
alertMessage
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf POSIX
lastModifiedTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
relatedResourceArns
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
resourceArn