{-# 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.UpdatePipelineStatus
-- 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)
--
-- The UpdatePipelineStatus operation pauses or reactivates a pipeline, so
-- that the pipeline stops or restarts the processing of jobs.
--
-- Changing the pipeline status is useful if you want to cancel one or more
-- jobs. You can\'t cancel jobs after Elastic Transcoder has started
-- processing them; if you pause the pipeline to which you submitted the
-- jobs, you have more time to get the job IDs for the jobs that you want
-- to cancel, and to send a CancelJob request.
module Amazonka.ElasticTranscoder.UpdatePipelineStatus
  ( -- * Creating a Request
    UpdatePipelineStatus (..),
    newUpdatePipelineStatus,

    -- * Request Lenses
    updatePipelineStatus_id,
    updatePipelineStatus_status,

    -- * Destructuring the Response
    UpdatePipelineStatusResponse (..),
    newUpdatePipelineStatusResponse,

    -- * Response Lenses
    updatePipelineStatusResponse_pipeline,
    updatePipelineStatusResponse_httpStatus,
  )
where

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

-- | The @UpdatePipelineStatusRequest@ structure.
--
-- /See:/ 'newUpdatePipelineStatus' smart constructor.
data UpdatePipelineStatus = UpdatePipelineStatus'
  { -- | The identifier of the pipeline to update.
    UpdatePipelineStatus -> Text
id :: Prelude.Text,
    -- | The desired status of the pipeline:
    --
    -- -   @Active@: The pipeline is processing jobs.
    --
    -- -   @Paused@: The pipeline is not currently processing jobs.
    UpdatePipelineStatus -> Text
status :: Prelude.Text
  }
  deriving (UpdatePipelineStatus -> UpdatePipelineStatus -> Bool
(UpdatePipelineStatus -> UpdatePipelineStatus -> Bool)
-> (UpdatePipelineStatus -> UpdatePipelineStatus -> Bool)
-> Eq UpdatePipelineStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdatePipelineStatus -> UpdatePipelineStatus -> Bool
$c/= :: UpdatePipelineStatus -> UpdatePipelineStatus -> Bool
== :: UpdatePipelineStatus -> UpdatePipelineStatus -> Bool
$c== :: UpdatePipelineStatus -> UpdatePipelineStatus -> Bool
Prelude.Eq, ReadPrec [UpdatePipelineStatus]
ReadPrec UpdatePipelineStatus
Int -> ReadS UpdatePipelineStatus
ReadS [UpdatePipelineStatus]
(Int -> ReadS UpdatePipelineStatus)
-> ReadS [UpdatePipelineStatus]
-> ReadPrec UpdatePipelineStatus
-> ReadPrec [UpdatePipelineStatus]
-> Read UpdatePipelineStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdatePipelineStatus]
$creadListPrec :: ReadPrec [UpdatePipelineStatus]
readPrec :: ReadPrec UpdatePipelineStatus
$creadPrec :: ReadPrec UpdatePipelineStatus
readList :: ReadS [UpdatePipelineStatus]
$creadList :: ReadS [UpdatePipelineStatus]
readsPrec :: Int -> ReadS UpdatePipelineStatus
$creadsPrec :: Int -> ReadS UpdatePipelineStatus
Prelude.Read, Int -> UpdatePipelineStatus -> ShowS
[UpdatePipelineStatus] -> ShowS
UpdatePipelineStatus -> String
(Int -> UpdatePipelineStatus -> ShowS)
-> (UpdatePipelineStatus -> String)
-> ([UpdatePipelineStatus] -> ShowS)
-> Show UpdatePipelineStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdatePipelineStatus] -> ShowS
$cshowList :: [UpdatePipelineStatus] -> ShowS
show :: UpdatePipelineStatus -> String
$cshow :: UpdatePipelineStatus -> String
showsPrec :: Int -> UpdatePipelineStatus -> ShowS
$cshowsPrec :: Int -> UpdatePipelineStatus -> ShowS
Prelude.Show, (forall x. UpdatePipelineStatus -> Rep UpdatePipelineStatus x)
-> (forall x. Rep UpdatePipelineStatus x -> UpdatePipelineStatus)
-> Generic UpdatePipelineStatus
forall x. Rep UpdatePipelineStatus x -> UpdatePipelineStatus
forall x. UpdatePipelineStatus -> Rep UpdatePipelineStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdatePipelineStatus x -> UpdatePipelineStatus
$cfrom :: forall x. UpdatePipelineStatus -> Rep UpdatePipelineStatus x
Prelude.Generic)

-- |
-- Create a value of 'UpdatePipelineStatus' 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', 'updatePipelineStatus_id' - The identifier of the pipeline to update.
--
-- 'status', 'updatePipelineStatus_status' - The desired status of the pipeline:
--
-- -   @Active@: The pipeline is processing jobs.
--
-- -   @Paused@: The pipeline is not currently processing jobs.
newUpdatePipelineStatus ::
  -- | 'id'
  Prelude.Text ->
  -- | 'status'
  Prelude.Text ->
  UpdatePipelineStatus
newUpdatePipelineStatus :: Text -> Text -> UpdatePipelineStatus
newUpdatePipelineStatus Text
pId_ Text
pStatus_ =
  UpdatePipelineStatus' :: Text -> Text -> UpdatePipelineStatus
UpdatePipelineStatus' {$sel:id:UpdatePipelineStatus' :: Text
id = Text
pId_, $sel:status:UpdatePipelineStatus' :: Text
status = Text
pStatus_}

-- | The identifier of the pipeline to update.
updatePipelineStatus_id :: Lens.Lens' UpdatePipelineStatus Prelude.Text
updatePipelineStatus_id :: (Text -> f Text) -> UpdatePipelineStatus -> f UpdatePipelineStatus
updatePipelineStatus_id = (UpdatePipelineStatus -> Text)
-> (UpdatePipelineStatus -> Text -> UpdatePipelineStatus)
-> Lens UpdatePipelineStatus UpdatePipelineStatus Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePipelineStatus' {Text
id :: Text
$sel:id:UpdatePipelineStatus' :: UpdatePipelineStatus -> Text
id} -> Text
id) (\s :: UpdatePipelineStatus
s@UpdatePipelineStatus' {} Text
a -> UpdatePipelineStatus
s {$sel:id:UpdatePipelineStatus' :: Text
id = Text
a} :: UpdatePipelineStatus)

-- | The desired status of the pipeline:
--
-- -   @Active@: The pipeline is processing jobs.
--
-- -   @Paused@: The pipeline is not currently processing jobs.
updatePipelineStatus_status :: Lens.Lens' UpdatePipelineStatus Prelude.Text
updatePipelineStatus_status :: (Text -> f Text) -> UpdatePipelineStatus -> f UpdatePipelineStatus
updatePipelineStatus_status = (UpdatePipelineStatus -> Text)
-> (UpdatePipelineStatus -> Text -> UpdatePipelineStatus)
-> Lens UpdatePipelineStatus UpdatePipelineStatus Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePipelineStatus' {Text
status :: Text
$sel:status:UpdatePipelineStatus' :: UpdatePipelineStatus -> Text
status} -> Text
status) (\s :: UpdatePipelineStatus
s@UpdatePipelineStatus' {} Text
a -> UpdatePipelineStatus
s {$sel:status:UpdatePipelineStatus' :: Text
status = Text
a} :: UpdatePipelineStatus)

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

instance Prelude.Hashable UpdatePipelineStatus

instance Prelude.NFData UpdatePipelineStatus

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

instance Core.ToJSON UpdatePipelineStatus where
  toJSON :: UpdatePipelineStatus -> Value
toJSON UpdatePipelineStatus' {Text
status :: Text
id :: Text
$sel:status:UpdatePipelineStatus' :: UpdatePipelineStatus -> Text
$sel:id:UpdatePipelineStatus' :: UpdatePipelineStatus -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Status" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
status)]
      )

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

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

-- | When you update status for a pipeline, Elastic Transcoder returns the
-- values that you specified in the request.
--
-- /See:/ 'newUpdatePipelineStatusResponse' smart constructor.
data UpdatePipelineStatusResponse = UpdatePipelineStatusResponse'
  { -- | A section of the response body that provides information about the
    -- pipeline.
    UpdatePipelineStatusResponse -> Maybe Pipeline
pipeline :: Prelude.Maybe Pipeline,
    -- | The response's http status code.
    UpdatePipelineStatusResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdatePipelineStatusResponse
-> UpdatePipelineStatusResponse -> Bool
(UpdatePipelineStatusResponse
 -> UpdatePipelineStatusResponse -> Bool)
-> (UpdatePipelineStatusResponse
    -> UpdatePipelineStatusResponse -> Bool)
-> Eq UpdatePipelineStatusResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdatePipelineStatusResponse
-> UpdatePipelineStatusResponse -> Bool
$c/= :: UpdatePipelineStatusResponse
-> UpdatePipelineStatusResponse -> Bool
== :: UpdatePipelineStatusResponse
-> UpdatePipelineStatusResponse -> Bool
$c== :: UpdatePipelineStatusResponse
-> UpdatePipelineStatusResponse -> Bool
Prelude.Eq, ReadPrec [UpdatePipelineStatusResponse]
ReadPrec UpdatePipelineStatusResponse
Int -> ReadS UpdatePipelineStatusResponse
ReadS [UpdatePipelineStatusResponse]
(Int -> ReadS UpdatePipelineStatusResponse)
-> ReadS [UpdatePipelineStatusResponse]
-> ReadPrec UpdatePipelineStatusResponse
-> ReadPrec [UpdatePipelineStatusResponse]
-> Read UpdatePipelineStatusResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdatePipelineStatusResponse]
$creadListPrec :: ReadPrec [UpdatePipelineStatusResponse]
readPrec :: ReadPrec UpdatePipelineStatusResponse
$creadPrec :: ReadPrec UpdatePipelineStatusResponse
readList :: ReadS [UpdatePipelineStatusResponse]
$creadList :: ReadS [UpdatePipelineStatusResponse]
readsPrec :: Int -> ReadS UpdatePipelineStatusResponse
$creadsPrec :: Int -> ReadS UpdatePipelineStatusResponse
Prelude.Read, Int -> UpdatePipelineStatusResponse -> ShowS
[UpdatePipelineStatusResponse] -> ShowS
UpdatePipelineStatusResponse -> String
(Int -> UpdatePipelineStatusResponse -> ShowS)
-> (UpdatePipelineStatusResponse -> String)
-> ([UpdatePipelineStatusResponse] -> ShowS)
-> Show UpdatePipelineStatusResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdatePipelineStatusResponse] -> ShowS
$cshowList :: [UpdatePipelineStatusResponse] -> ShowS
show :: UpdatePipelineStatusResponse -> String
$cshow :: UpdatePipelineStatusResponse -> String
showsPrec :: Int -> UpdatePipelineStatusResponse -> ShowS
$cshowsPrec :: Int -> UpdatePipelineStatusResponse -> ShowS
Prelude.Show, (forall x.
 UpdatePipelineStatusResponse -> Rep UpdatePipelineStatusResponse x)
-> (forall x.
    Rep UpdatePipelineStatusResponse x -> UpdatePipelineStatusResponse)
-> Generic UpdatePipelineStatusResponse
forall x.
Rep UpdatePipelineStatusResponse x -> UpdatePipelineStatusResponse
forall x.
UpdatePipelineStatusResponse -> Rep UpdatePipelineStatusResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdatePipelineStatusResponse x -> UpdatePipelineStatusResponse
$cfrom :: forall x.
UpdatePipelineStatusResponse -> Rep UpdatePipelineStatusResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdatePipelineStatusResponse' 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', 'updatePipelineStatusResponse_pipeline' - A section of the response body that provides information about the
-- pipeline.
--
-- 'httpStatus', 'updatePipelineStatusResponse_httpStatus' - The response's http status code.
newUpdatePipelineStatusResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdatePipelineStatusResponse
newUpdatePipelineStatusResponse :: Int -> UpdatePipelineStatusResponse
newUpdatePipelineStatusResponse Int
pHttpStatus_ =
  UpdatePipelineStatusResponse' :: Maybe Pipeline -> Int -> UpdatePipelineStatusResponse
UpdatePipelineStatusResponse'
    { $sel:pipeline:UpdatePipelineStatusResponse' :: Maybe Pipeline
pipeline =
        Maybe Pipeline
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdatePipelineStatusResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

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

instance Prelude.NFData UpdatePipelineStatusResponse