{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.UpdatePipelineNotifications
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- With the UpdatePipelineNotifications operation, you can update Amazon
-- Simple Notification Service (Amazon SNS) notifications for a pipeline.
--
-- When you update notifications for a pipeline, Elastic Transcoder returns
-- the values that you specified in the request.
module Amazonka.ElasticTranscoder.UpdatePipelineNotifications
  ( -- * Creating a Request
    UpdatePipelineNotifications (..),
    newUpdatePipelineNotifications,

    -- * Request Lenses
    updatePipelineNotifications_id,
    updatePipelineNotifications_notifications,

    -- * Destructuring the Response
    UpdatePipelineNotificationsResponse (..),
    newUpdatePipelineNotificationsResponse,

    -- * Response Lenses
    updatePipelineNotificationsResponse_pipeline,
    updatePipelineNotificationsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ElasticTranscoder.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | The @UpdatePipelineNotificationsRequest@ structure.
--
-- /See:/ 'newUpdatePipelineNotifications' smart constructor.
data UpdatePipelineNotifications = UpdatePipelineNotifications'
  { -- | The identifier of the pipeline for which you want to change notification
    -- settings.
    UpdatePipelineNotifications -> Text
id :: Prelude.Text,
    -- | The topic ARN for the Amazon Simple Notification Service (Amazon SNS)
    -- topic that you want to notify to report job status.
    --
    -- To receive notifications, you must also subscribe to the new topic in
    -- the Amazon SNS console.
    --
    -- -   __Progressing__: The topic ARN for the Amazon Simple Notification
    --     Service (Amazon SNS) topic that you want to notify when Elastic
    --     Transcoder has started to process jobs that are added to this
    --     pipeline. This is the ARN that Amazon SNS returned when you created
    --     the topic.
    --
    -- -   __Complete__: The topic ARN for the Amazon SNS topic that you want
    --     to notify when Elastic Transcoder has finished processing a job.
    --     This is the ARN that Amazon SNS returned when you created the topic.
    --
    -- -   __Warning__: The topic ARN for the Amazon SNS topic that you want to
    --     notify when Elastic Transcoder encounters a warning condition. This
    --     is the ARN that Amazon SNS returned when you created the topic.
    --
    -- -   __Error__: The topic ARN for the Amazon SNS topic that you want to
    --     notify when Elastic Transcoder encounters an error condition. This
    --     is the ARN that Amazon SNS returned when you created the topic.
    UpdatePipelineNotifications -> Notifications
notifications :: Notifications
  }
  deriving (UpdatePipelineNotifications -> UpdatePipelineNotifications -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdatePipelineNotifications -> UpdatePipelineNotifications -> Bool
$c/= :: UpdatePipelineNotifications -> UpdatePipelineNotifications -> Bool
== :: UpdatePipelineNotifications -> UpdatePipelineNotifications -> Bool
$c== :: UpdatePipelineNotifications -> UpdatePipelineNotifications -> Bool
Prelude.Eq, ReadPrec [UpdatePipelineNotifications]
ReadPrec UpdatePipelineNotifications
Int -> ReadS UpdatePipelineNotifications
ReadS [UpdatePipelineNotifications]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdatePipelineNotifications]
$creadListPrec :: ReadPrec [UpdatePipelineNotifications]
readPrec :: ReadPrec UpdatePipelineNotifications
$creadPrec :: ReadPrec UpdatePipelineNotifications
readList :: ReadS [UpdatePipelineNotifications]
$creadList :: ReadS [UpdatePipelineNotifications]
readsPrec :: Int -> ReadS UpdatePipelineNotifications
$creadsPrec :: Int -> ReadS UpdatePipelineNotifications
Prelude.Read, Int -> UpdatePipelineNotifications -> ShowS
[UpdatePipelineNotifications] -> ShowS
UpdatePipelineNotifications -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdatePipelineNotifications] -> ShowS
$cshowList :: [UpdatePipelineNotifications] -> ShowS
show :: UpdatePipelineNotifications -> String
$cshow :: UpdatePipelineNotifications -> String
showsPrec :: Int -> UpdatePipelineNotifications -> ShowS
$cshowsPrec :: Int -> UpdatePipelineNotifications -> ShowS
Prelude.Show, forall x.
Rep UpdatePipelineNotifications x -> UpdatePipelineNotifications
forall x.
UpdatePipelineNotifications -> Rep UpdatePipelineNotifications x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdatePipelineNotifications x -> UpdatePipelineNotifications
$cfrom :: forall x.
UpdatePipelineNotifications -> Rep UpdatePipelineNotifications x
Prelude.Generic)

-- |
-- Create a value of 'UpdatePipelineNotifications' 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:
--
-- 'id', 'updatePipelineNotifications_id' - The identifier of the pipeline for which you want to change notification
-- settings.
--
-- 'notifications', 'updatePipelineNotifications_notifications' - The topic ARN for the Amazon Simple Notification Service (Amazon SNS)
-- topic that you want to notify to report job status.
--
-- To receive notifications, you must also subscribe to the new topic in
-- the Amazon SNS console.
--
-- -   __Progressing__: The topic ARN for the Amazon Simple Notification
--     Service (Amazon SNS) topic that you want to notify when Elastic
--     Transcoder has started to process jobs that are added to this
--     pipeline. This is the ARN that Amazon SNS returned when you created
--     the topic.
--
-- -   __Complete__: The topic ARN for the Amazon SNS topic that you want
--     to notify when Elastic Transcoder has finished processing a job.
--     This is the ARN that Amazon SNS returned when you created the topic.
--
-- -   __Warning__: The topic ARN for the Amazon SNS topic that you want to
--     notify when Elastic Transcoder encounters a warning condition. This
--     is the ARN that Amazon SNS returned when you created the topic.
--
-- -   __Error__: The topic ARN for the Amazon SNS topic that you want to
--     notify when Elastic Transcoder encounters an error condition. This
--     is the ARN that Amazon SNS returned when you created the topic.
newUpdatePipelineNotifications ::
  -- | 'id'
  Prelude.Text ->
  -- | 'notifications'
  Notifications ->
  UpdatePipelineNotifications
newUpdatePipelineNotifications :: Text -> Notifications -> UpdatePipelineNotifications
newUpdatePipelineNotifications Text
pId_ Notifications
pNotifications_ =
  UpdatePipelineNotifications'
    { $sel:id:UpdatePipelineNotifications' :: Text
id = Text
pId_,
      $sel:notifications:UpdatePipelineNotifications' :: Notifications
notifications = Notifications
pNotifications_
    }

-- | The identifier of the pipeline for which you want to change notification
-- settings.
updatePipelineNotifications_id :: Lens.Lens' UpdatePipelineNotifications Prelude.Text
updatePipelineNotifications_id :: Lens' UpdatePipelineNotifications Text
updatePipelineNotifications_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePipelineNotifications' {Text
id :: Text
$sel:id:UpdatePipelineNotifications' :: UpdatePipelineNotifications -> Text
id} -> Text
id) (\s :: UpdatePipelineNotifications
s@UpdatePipelineNotifications' {} Text
a -> UpdatePipelineNotifications
s {$sel:id:UpdatePipelineNotifications' :: Text
id = Text
a} :: UpdatePipelineNotifications)

-- | The topic ARN for the Amazon Simple Notification Service (Amazon SNS)
-- topic that you want to notify to report job status.
--
-- To receive notifications, you must also subscribe to the new topic in
-- the Amazon SNS console.
--
-- -   __Progressing__: The topic ARN for the Amazon Simple Notification
--     Service (Amazon SNS) topic that you want to notify when Elastic
--     Transcoder has started to process jobs that are added to this
--     pipeline. This is the ARN that Amazon SNS returned when you created
--     the topic.
--
-- -   __Complete__: The topic ARN for the Amazon SNS topic that you want
--     to notify when Elastic Transcoder has finished processing a job.
--     This is the ARN that Amazon SNS returned when you created the topic.
--
-- -   __Warning__: The topic ARN for the Amazon SNS topic that you want to
--     notify when Elastic Transcoder encounters a warning condition. This
--     is the ARN that Amazon SNS returned when you created the topic.
--
-- -   __Error__: The topic ARN for the Amazon SNS topic that you want to
--     notify when Elastic Transcoder encounters an error condition. This
--     is the ARN that Amazon SNS returned when you created the topic.
updatePipelineNotifications_notifications :: Lens.Lens' UpdatePipelineNotifications Notifications
updatePipelineNotifications_notifications :: Lens' UpdatePipelineNotifications Notifications
updatePipelineNotifications_notifications = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePipelineNotifications' {Notifications
notifications :: Notifications
$sel:notifications:UpdatePipelineNotifications' :: UpdatePipelineNotifications -> Notifications
notifications} -> Notifications
notifications) (\s :: UpdatePipelineNotifications
s@UpdatePipelineNotifications' {} Notifications
a -> UpdatePipelineNotifications
s {$sel:notifications:UpdatePipelineNotifications' :: Notifications
notifications = Notifications
a} :: UpdatePipelineNotifications)

instance Core.AWSRequest UpdatePipelineNotifications where
  type
    AWSResponse UpdatePipelineNotifications =
      UpdatePipelineNotificationsResponse
  request :: (Service -> Service)
-> UpdatePipelineNotifications
-> Request UpdatePipelineNotifications
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdatePipelineNotifications
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdatePipelineNotifications)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Pipeline -> Int -> UpdatePipelineNotificationsResponse
UpdatePipelineNotificationsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Pipeline")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable UpdatePipelineNotifications where
  hashWithSalt :: Int -> UpdatePipelineNotifications -> Int
hashWithSalt Int
_salt UpdatePipelineNotifications' {Text
Notifications
notifications :: Notifications
id :: Text
$sel:notifications:UpdatePipelineNotifications' :: UpdatePipelineNotifications -> Notifications
$sel:id:UpdatePipelineNotifications' :: UpdatePipelineNotifications -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Notifications
notifications

instance Prelude.NFData UpdatePipelineNotifications where
  rnf :: UpdatePipelineNotifications -> ()
rnf UpdatePipelineNotifications' {Text
Notifications
notifications :: Notifications
id :: Text
$sel:notifications:UpdatePipelineNotifications' :: UpdatePipelineNotifications -> Notifications
$sel:id:UpdatePipelineNotifications' :: UpdatePipelineNotifications -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Notifications
notifications

instance Data.ToHeaders UpdatePipelineNotifications where
  toHeaders :: UpdatePipelineNotifications -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToJSON UpdatePipelineNotifications where
  toJSON :: UpdatePipelineNotifications -> Value
toJSON UpdatePipelineNotifications' {Text
Notifications
notifications :: Notifications
id :: Text
$sel:notifications:UpdatePipelineNotifications' :: UpdatePipelineNotifications -> Notifications
$sel:id:UpdatePipelineNotifications' :: UpdatePipelineNotifications -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"Notifications" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Notifications
notifications)
          ]
      )

instance Data.ToPath UpdatePipelineNotifications where
  toPath :: UpdatePipelineNotifications -> ByteString
toPath UpdatePipelineNotifications' {Text
Notifications
notifications :: Notifications
id :: Text
$sel:notifications:UpdatePipelineNotifications' :: UpdatePipelineNotifications -> Notifications
$sel:id:UpdatePipelineNotifications' :: UpdatePipelineNotifications -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/2012-09-25/pipelines/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
id,
        ByteString
"/notifications"
      ]

instance Data.ToQuery UpdatePipelineNotifications where
  toQuery :: UpdatePipelineNotifications -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | The @UpdatePipelineNotificationsResponse@ structure.
--
-- /See:/ 'newUpdatePipelineNotificationsResponse' smart constructor.
data UpdatePipelineNotificationsResponse = UpdatePipelineNotificationsResponse'
  { -- | A section of the response body that provides information about the
    -- pipeline associated with this notification.
    UpdatePipelineNotificationsResponse -> Maybe Pipeline
pipeline :: Prelude.Maybe Pipeline,
    -- | The response's http status code.
    UpdatePipelineNotificationsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdatePipelineNotificationsResponse
-> UpdatePipelineNotificationsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdatePipelineNotificationsResponse
-> UpdatePipelineNotificationsResponse -> Bool
$c/= :: UpdatePipelineNotificationsResponse
-> UpdatePipelineNotificationsResponse -> Bool
== :: UpdatePipelineNotificationsResponse
-> UpdatePipelineNotificationsResponse -> Bool
$c== :: UpdatePipelineNotificationsResponse
-> UpdatePipelineNotificationsResponse -> Bool
Prelude.Eq, ReadPrec [UpdatePipelineNotificationsResponse]
ReadPrec UpdatePipelineNotificationsResponse
Int -> ReadS UpdatePipelineNotificationsResponse
ReadS [UpdatePipelineNotificationsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdatePipelineNotificationsResponse]
$creadListPrec :: ReadPrec [UpdatePipelineNotificationsResponse]
readPrec :: ReadPrec UpdatePipelineNotificationsResponse
$creadPrec :: ReadPrec UpdatePipelineNotificationsResponse
readList :: ReadS [UpdatePipelineNotificationsResponse]
$creadList :: ReadS [UpdatePipelineNotificationsResponse]
readsPrec :: Int -> ReadS UpdatePipelineNotificationsResponse
$creadsPrec :: Int -> ReadS UpdatePipelineNotificationsResponse
Prelude.Read, Int -> UpdatePipelineNotificationsResponse -> ShowS
[UpdatePipelineNotificationsResponse] -> ShowS
UpdatePipelineNotificationsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdatePipelineNotificationsResponse] -> ShowS
$cshowList :: [UpdatePipelineNotificationsResponse] -> ShowS
show :: UpdatePipelineNotificationsResponse -> String
$cshow :: UpdatePipelineNotificationsResponse -> String
showsPrec :: Int -> UpdatePipelineNotificationsResponse -> ShowS
$cshowsPrec :: Int -> UpdatePipelineNotificationsResponse -> ShowS
Prelude.Show, forall x.
Rep UpdatePipelineNotificationsResponse x
-> UpdatePipelineNotificationsResponse
forall x.
UpdatePipelineNotificationsResponse
-> Rep UpdatePipelineNotificationsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdatePipelineNotificationsResponse x
-> UpdatePipelineNotificationsResponse
$cfrom :: forall x.
UpdatePipelineNotificationsResponse
-> Rep UpdatePipelineNotificationsResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdatePipelineNotificationsResponse' 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:
--
-- 'pipeline', 'updatePipelineNotificationsResponse_pipeline' - A section of the response body that provides information about the
-- pipeline associated with this notification.
--
-- 'httpStatus', 'updatePipelineNotificationsResponse_httpStatus' - The response's http status code.
newUpdatePipelineNotificationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdatePipelineNotificationsResponse
newUpdatePipelineNotificationsResponse :: Int -> UpdatePipelineNotificationsResponse
newUpdatePipelineNotificationsResponse Int
pHttpStatus_ =
  UpdatePipelineNotificationsResponse'
    { $sel:pipeline:UpdatePipelineNotificationsResponse' :: Maybe Pipeline
pipeline =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdatePipelineNotificationsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A section of the response body that provides information about the
-- pipeline associated with this notification.
updatePipelineNotificationsResponse_pipeline :: Lens.Lens' UpdatePipelineNotificationsResponse (Prelude.Maybe Pipeline)
updatePipelineNotificationsResponse_pipeline :: Lens' UpdatePipelineNotificationsResponse (Maybe Pipeline)
updatePipelineNotificationsResponse_pipeline = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePipelineNotificationsResponse' {Maybe Pipeline
pipeline :: Maybe Pipeline
$sel:pipeline:UpdatePipelineNotificationsResponse' :: UpdatePipelineNotificationsResponse -> Maybe Pipeline
pipeline} -> Maybe Pipeline
pipeline) (\s :: UpdatePipelineNotificationsResponse
s@UpdatePipelineNotificationsResponse' {} Maybe Pipeline
a -> UpdatePipelineNotificationsResponse
s {$sel:pipeline:UpdatePipelineNotificationsResponse' :: Maybe Pipeline
pipeline = Maybe Pipeline
a} :: UpdatePipelineNotificationsResponse)

-- | The response's http status code.
updatePipelineNotificationsResponse_httpStatus :: Lens.Lens' UpdatePipelineNotificationsResponse Prelude.Int
updatePipelineNotificationsResponse_httpStatus :: Lens' UpdatePipelineNotificationsResponse Int
updatePipelineNotificationsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePipelineNotificationsResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdatePipelineNotificationsResponse' :: UpdatePipelineNotificationsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdatePipelineNotificationsResponse
s@UpdatePipelineNotificationsResponse' {} Int
a -> UpdatePipelineNotificationsResponse
s {$sel:httpStatus:UpdatePipelineNotificationsResponse' :: Int
httpStatus = Int
a} :: UpdatePipelineNotificationsResponse)

instance
  Prelude.NFData
    UpdatePipelineNotificationsResponse
  where
  rnf :: UpdatePipelineNotificationsResponse -> ()
rnf UpdatePipelineNotificationsResponse' {Int
Maybe Pipeline
httpStatus :: Int
pipeline :: Maybe Pipeline
$sel:httpStatus:UpdatePipelineNotificationsResponse' :: UpdatePipelineNotificationsResponse -> Int
$sel:pipeline:UpdatePipelineNotificationsResponse' :: UpdatePipelineNotificationsResponse -> Maybe Pipeline
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Pipeline
pipeline
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus