{-# 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.ElasticTranscoder.Types.Notifications
-- 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.ElasticTranscoder.Types.Notifications where

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

-- | The Amazon Simple Notification Service (Amazon SNS) topic or topics to
-- notify in order to report job status.
--
-- To receive notifications, you must also subscribe to the new topic in
-- the Amazon SNS console.
--
-- /See:/ 'newNotifications' smart constructor.
data Notifications = Notifications'
  { -- | The Amazon SNS topic that you want to notify when Elastic Transcoder
    -- encounters an error condition.
    Notifications -> Maybe Text
error :: Prelude.Maybe Prelude.Text,
    -- | The Amazon SNS topic that you want to notify when Elastic Transcoder
    -- encounters a warning condition.
    Notifications -> Maybe Text
warning :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Simple Notification Service (Amazon SNS) topic that you want
    -- to notify when Elastic Transcoder has started to process the job.
    Notifications -> Maybe Text
progressing :: Prelude.Maybe Prelude.Text,
    -- | The Amazon SNS topic that you want to notify when Elastic Transcoder has
    -- finished processing the job.
    Notifications -> Maybe Text
completed :: Prelude.Maybe Prelude.Text
  }
  deriving (Notifications -> Notifications -> Bool
(Notifications -> Notifications -> Bool)
-> (Notifications -> Notifications -> Bool) -> Eq Notifications
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Notifications -> Notifications -> Bool
$c/= :: Notifications -> Notifications -> Bool
== :: Notifications -> Notifications -> Bool
$c== :: Notifications -> Notifications -> Bool
Prelude.Eq, ReadPrec [Notifications]
ReadPrec Notifications
Int -> ReadS Notifications
ReadS [Notifications]
(Int -> ReadS Notifications)
-> ReadS [Notifications]
-> ReadPrec Notifications
-> ReadPrec [Notifications]
-> Read Notifications
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Notifications]
$creadListPrec :: ReadPrec [Notifications]
readPrec :: ReadPrec Notifications
$creadPrec :: ReadPrec Notifications
readList :: ReadS [Notifications]
$creadList :: ReadS [Notifications]
readsPrec :: Int -> ReadS Notifications
$creadsPrec :: Int -> ReadS Notifications
Prelude.Read, Int -> Notifications -> ShowS
[Notifications] -> ShowS
Notifications -> String
(Int -> Notifications -> ShowS)
-> (Notifications -> String)
-> ([Notifications] -> ShowS)
-> Show Notifications
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Notifications] -> ShowS
$cshowList :: [Notifications] -> ShowS
show :: Notifications -> String
$cshow :: Notifications -> String
showsPrec :: Int -> Notifications -> ShowS
$cshowsPrec :: Int -> Notifications -> ShowS
Prelude.Show, (forall x. Notifications -> Rep Notifications x)
-> (forall x. Rep Notifications x -> Notifications)
-> Generic Notifications
forall x. Rep Notifications x -> Notifications
forall x. Notifications -> Rep Notifications x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Notifications x -> Notifications
$cfrom :: forall x. Notifications -> Rep Notifications x
Prelude.Generic)

-- |
-- Create a value of 'Notifications' 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:
--
-- 'error', 'notifications_error' - The Amazon SNS topic that you want to notify when Elastic Transcoder
-- encounters an error condition.
--
-- 'warning', 'notifications_warning' - The Amazon SNS topic that you want to notify when Elastic Transcoder
-- encounters a warning condition.
--
-- 'progressing', 'notifications_progressing' - The Amazon Simple Notification Service (Amazon SNS) topic that you want
-- to notify when Elastic Transcoder has started to process the job.
--
-- 'completed', 'notifications_completed' - The Amazon SNS topic that you want to notify when Elastic Transcoder has
-- finished processing the job.
newNotifications ::
  Notifications
newNotifications :: Notifications
newNotifications =
  Notifications' :: Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> Notifications
Notifications'
    { $sel:error:Notifications' :: Maybe Text
error = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:warning:Notifications' :: Maybe Text
warning = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:progressing:Notifications' :: Maybe Text
progressing = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:completed:Notifications' :: Maybe Text
completed = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon SNS topic that you want to notify when Elastic Transcoder
-- encounters an error condition.
notifications_error :: Lens.Lens' Notifications (Prelude.Maybe Prelude.Text)
notifications_error :: (Maybe Text -> f (Maybe Text)) -> Notifications -> f Notifications
notifications_error = (Notifications -> Maybe Text)
-> (Notifications -> Maybe Text -> Notifications)
-> Lens Notifications Notifications (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Notifications' {Maybe Text
error :: Maybe Text
$sel:error:Notifications' :: Notifications -> Maybe Text
error} -> Maybe Text
error) (\s :: Notifications
s@Notifications' {} Maybe Text
a -> Notifications
s {$sel:error:Notifications' :: Maybe Text
error = Maybe Text
a} :: Notifications)

-- | The Amazon SNS topic that you want to notify when Elastic Transcoder
-- encounters a warning condition.
notifications_warning :: Lens.Lens' Notifications (Prelude.Maybe Prelude.Text)
notifications_warning :: (Maybe Text -> f (Maybe Text)) -> Notifications -> f Notifications
notifications_warning = (Notifications -> Maybe Text)
-> (Notifications -> Maybe Text -> Notifications)
-> Lens Notifications Notifications (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Notifications' {Maybe Text
warning :: Maybe Text
$sel:warning:Notifications' :: Notifications -> Maybe Text
warning} -> Maybe Text
warning) (\s :: Notifications
s@Notifications' {} Maybe Text
a -> Notifications
s {$sel:warning:Notifications' :: Maybe Text
warning = Maybe Text
a} :: Notifications)

-- | The Amazon Simple Notification Service (Amazon SNS) topic that you want
-- to notify when Elastic Transcoder has started to process the job.
notifications_progressing :: Lens.Lens' Notifications (Prelude.Maybe Prelude.Text)
notifications_progressing :: (Maybe Text -> f (Maybe Text)) -> Notifications -> f Notifications
notifications_progressing = (Notifications -> Maybe Text)
-> (Notifications -> Maybe Text -> Notifications)
-> Lens Notifications Notifications (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Notifications' {Maybe Text
progressing :: Maybe Text
$sel:progressing:Notifications' :: Notifications -> Maybe Text
progressing} -> Maybe Text
progressing) (\s :: Notifications
s@Notifications' {} Maybe Text
a -> Notifications
s {$sel:progressing:Notifications' :: Maybe Text
progressing = Maybe Text
a} :: Notifications)

-- | The Amazon SNS topic that you want to notify when Elastic Transcoder has
-- finished processing the job.
notifications_completed :: Lens.Lens' Notifications (Prelude.Maybe Prelude.Text)
notifications_completed :: (Maybe Text -> f (Maybe Text)) -> Notifications -> f Notifications
notifications_completed = (Notifications -> Maybe Text)
-> (Notifications -> Maybe Text -> Notifications)
-> Lens Notifications Notifications (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Notifications' {Maybe Text
completed :: Maybe Text
$sel:completed:Notifications' :: Notifications -> Maybe Text
completed} -> Maybe Text
completed) (\s :: Notifications
s@Notifications' {} Maybe Text
a -> Notifications
s {$sel:completed:Notifications' :: Maybe Text
completed = Maybe Text
a} :: Notifications)

instance Core.FromJSON Notifications where
  parseJSON :: Value -> Parser Notifications
parseJSON =
    String
-> (Object -> Parser Notifications)
-> Value
-> Parser Notifications
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Notifications"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> Notifications
Notifications'
            (Maybe Text
 -> Maybe Text -> Maybe Text -> Maybe Text -> Notifications)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> Notifications)
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
"Error")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> Notifications)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Notifications)
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
"Warning")
            Parser (Maybe Text -> Maybe Text -> Notifications)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Notifications)
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
"Progressing")
            Parser (Maybe Text -> Notifications)
-> Parser (Maybe Text) -> Parser Notifications
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
"Completed")
      )

instance Prelude.Hashable Notifications

instance Prelude.NFData Notifications

instance Core.ToJSON Notifications where
  toJSON :: Notifications -> Value
toJSON Notifications' {Maybe Text
completed :: Maybe Text
progressing :: Maybe Text
warning :: Maybe Text
error :: Maybe Text
$sel:completed:Notifications' :: Notifications -> Maybe Text
$sel:progressing:Notifications' :: Notifications -> Maybe Text
$sel:warning:Notifications' :: Notifications -> Maybe Text
$sel:error:Notifications' :: Notifications -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Error" 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
error,
            (Text
"Warning" 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
warning,
            (Text
"Progressing" 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
progressing,
            (Text
"Completed" 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
completed
          ]
      )