{-# 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.DataSync.UpdateTaskExecution
-- 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)
--
-- Updates execution of a task.
--
-- You can modify bandwidth throttling for a task execution that is running
-- or queued. For more information, see
-- <https://docs.aws.amazon.com/datasync/latest/userguide/working-with-task-executions.html#adjust-bandwidth-throttling Adjusting Bandwidth Throttling for a Task Execution>.
--
-- The only @Option@ that can be modified by @UpdateTaskExecution@ is
-- @ BytesPerSecond @.
module Amazonka.DataSync.UpdateTaskExecution
  ( -- * Creating a Request
    UpdateTaskExecution (..),
    newUpdateTaskExecution,

    -- * Request Lenses
    updateTaskExecution_taskExecutionArn,
    updateTaskExecution_options,

    -- * Destructuring the Response
    UpdateTaskExecutionResponse (..),
    newUpdateTaskExecutionResponse,

    -- * Response Lenses
    updateTaskExecutionResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DataSync.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

-- | /See:/ 'newUpdateTaskExecution' smart constructor.
data UpdateTaskExecution = UpdateTaskExecution'
  { -- | The Amazon Resource Name (ARN) of the specific task execution that is
    -- being updated.
    UpdateTaskExecution -> Text
taskExecutionArn :: Prelude.Text,
    UpdateTaskExecution -> Options
options :: Options
  }
  deriving (UpdateTaskExecution -> UpdateTaskExecution -> Bool
(UpdateTaskExecution -> UpdateTaskExecution -> Bool)
-> (UpdateTaskExecution -> UpdateTaskExecution -> Bool)
-> Eq UpdateTaskExecution
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateTaskExecution -> UpdateTaskExecution -> Bool
$c/= :: UpdateTaskExecution -> UpdateTaskExecution -> Bool
== :: UpdateTaskExecution -> UpdateTaskExecution -> Bool
$c== :: UpdateTaskExecution -> UpdateTaskExecution -> Bool
Prelude.Eq, ReadPrec [UpdateTaskExecution]
ReadPrec UpdateTaskExecution
Int -> ReadS UpdateTaskExecution
ReadS [UpdateTaskExecution]
(Int -> ReadS UpdateTaskExecution)
-> ReadS [UpdateTaskExecution]
-> ReadPrec UpdateTaskExecution
-> ReadPrec [UpdateTaskExecution]
-> Read UpdateTaskExecution
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateTaskExecution]
$creadListPrec :: ReadPrec [UpdateTaskExecution]
readPrec :: ReadPrec UpdateTaskExecution
$creadPrec :: ReadPrec UpdateTaskExecution
readList :: ReadS [UpdateTaskExecution]
$creadList :: ReadS [UpdateTaskExecution]
readsPrec :: Int -> ReadS UpdateTaskExecution
$creadsPrec :: Int -> ReadS UpdateTaskExecution
Prelude.Read, Int -> UpdateTaskExecution -> ShowS
[UpdateTaskExecution] -> ShowS
UpdateTaskExecution -> String
(Int -> UpdateTaskExecution -> ShowS)
-> (UpdateTaskExecution -> String)
-> ([UpdateTaskExecution] -> ShowS)
-> Show UpdateTaskExecution
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateTaskExecution] -> ShowS
$cshowList :: [UpdateTaskExecution] -> ShowS
show :: UpdateTaskExecution -> String
$cshow :: UpdateTaskExecution -> String
showsPrec :: Int -> UpdateTaskExecution -> ShowS
$cshowsPrec :: Int -> UpdateTaskExecution -> ShowS
Prelude.Show, (forall x. UpdateTaskExecution -> Rep UpdateTaskExecution x)
-> (forall x. Rep UpdateTaskExecution x -> UpdateTaskExecution)
-> Generic UpdateTaskExecution
forall x. Rep UpdateTaskExecution x -> UpdateTaskExecution
forall x. UpdateTaskExecution -> Rep UpdateTaskExecution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateTaskExecution x -> UpdateTaskExecution
$cfrom :: forall x. UpdateTaskExecution -> Rep UpdateTaskExecution x
Prelude.Generic)

-- |
-- Create a value of 'UpdateTaskExecution' 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:
--
-- 'taskExecutionArn', 'updateTaskExecution_taskExecutionArn' - The Amazon Resource Name (ARN) of the specific task execution that is
-- being updated.
--
-- 'options', 'updateTaskExecution_options' - Undocumented member.
newUpdateTaskExecution ::
  -- | 'taskExecutionArn'
  Prelude.Text ->
  -- | 'options'
  Options ->
  UpdateTaskExecution
newUpdateTaskExecution :: Text -> Options -> UpdateTaskExecution
newUpdateTaskExecution Text
pTaskExecutionArn_ Options
pOptions_ =
  UpdateTaskExecution' :: Text -> Options -> UpdateTaskExecution
UpdateTaskExecution'
    { $sel:taskExecutionArn:UpdateTaskExecution' :: Text
taskExecutionArn =
        Text
pTaskExecutionArn_,
      $sel:options:UpdateTaskExecution' :: Options
options = Options
pOptions_
    }

-- | The Amazon Resource Name (ARN) of the specific task execution that is
-- being updated.
updateTaskExecution_taskExecutionArn :: Lens.Lens' UpdateTaskExecution Prelude.Text
updateTaskExecution_taskExecutionArn :: (Text -> f Text) -> UpdateTaskExecution -> f UpdateTaskExecution
updateTaskExecution_taskExecutionArn = (UpdateTaskExecution -> Text)
-> (UpdateTaskExecution -> Text -> UpdateTaskExecution)
-> Lens UpdateTaskExecution UpdateTaskExecution Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTaskExecution' {Text
taskExecutionArn :: Text
$sel:taskExecutionArn:UpdateTaskExecution' :: UpdateTaskExecution -> Text
taskExecutionArn} -> Text
taskExecutionArn) (\s :: UpdateTaskExecution
s@UpdateTaskExecution' {} Text
a -> UpdateTaskExecution
s {$sel:taskExecutionArn:UpdateTaskExecution' :: Text
taskExecutionArn = Text
a} :: UpdateTaskExecution)

-- | Undocumented member.
updateTaskExecution_options :: Lens.Lens' UpdateTaskExecution Options
updateTaskExecution_options :: (Options -> f Options)
-> UpdateTaskExecution -> f UpdateTaskExecution
updateTaskExecution_options = (UpdateTaskExecution -> Options)
-> (UpdateTaskExecution -> Options -> UpdateTaskExecution)
-> Lens UpdateTaskExecution UpdateTaskExecution Options Options
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTaskExecution' {Options
options :: Options
$sel:options:UpdateTaskExecution' :: UpdateTaskExecution -> Options
options} -> Options
options) (\s :: UpdateTaskExecution
s@UpdateTaskExecution' {} Options
a -> UpdateTaskExecution
s {$sel:options:UpdateTaskExecution' :: Options
options = Options
a} :: UpdateTaskExecution)

instance Core.AWSRequest UpdateTaskExecution where
  type
    AWSResponse UpdateTaskExecution =
      UpdateTaskExecutionResponse
  request :: UpdateTaskExecution -> Request UpdateTaskExecution
request = Service -> UpdateTaskExecution -> Request UpdateTaskExecution
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateTaskExecution
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateTaskExecution)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateTaskExecution))
-> Logger
-> Service
-> Proxy UpdateTaskExecution
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateTaskExecution)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateTaskExecutionResponse
UpdateTaskExecutionResponse'
            (Int -> UpdateTaskExecutionResponse)
-> Either String Int -> Either String UpdateTaskExecutionResponse
forall (f :: * -> *) a b. Functor 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 UpdateTaskExecution

instance Prelude.NFData UpdateTaskExecution

instance Core.ToHeaders UpdateTaskExecution where
  toHeaders :: UpdateTaskExecution -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateTaskExecution -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"FmrsService.UpdateTaskExecution" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON UpdateTaskExecution where
  toJSON :: UpdateTaskExecution -> Value
toJSON UpdateTaskExecution' {Text
Options
options :: Options
taskExecutionArn :: Text
$sel:options:UpdateTaskExecution' :: UpdateTaskExecution -> Options
$sel:taskExecutionArn:UpdateTaskExecution' :: UpdateTaskExecution -> 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
"TaskExecutionArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
taskExecutionArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Options" Text -> Options -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Options
options)
          ]
      )

instance Core.ToPath UpdateTaskExecution where
  toPath :: UpdateTaskExecution -> ByteString
toPath = ByteString -> UpdateTaskExecution -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newUpdateTaskExecutionResponse' smart constructor.
data UpdateTaskExecutionResponse = UpdateTaskExecutionResponse'
  { -- | The response's http status code.
    UpdateTaskExecutionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateTaskExecutionResponse -> UpdateTaskExecutionResponse -> Bool
(UpdateTaskExecutionResponse
 -> UpdateTaskExecutionResponse -> Bool)
-> (UpdateTaskExecutionResponse
    -> UpdateTaskExecutionResponse -> Bool)
-> Eq UpdateTaskExecutionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateTaskExecutionResponse -> UpdateTaskExecutionResponse -> Bool
$c/= :: UpdateTaskExecutionResponse -> UpdateTaskExecutionResponse -> Bool
== :: UpdateTaskExecutionResponse -> UpdateTaskExecutionResponse -> Bool
$c== :: UpdateTaskExecutionResponse -> UpdateTaskExecutionResponse -> Bool
Prelude.Eq, ReadPrec [UpdateTaskExecutionResponse]
ReadPrec UpdateTaskExecutionResponse
Int -> ReadS UpdateTaskExecutionResponse
ReadS [UpdateTaskExecutionResponse]
(Int -> ReadS UpdateTaskExecutionResponse)
-> ReadS [UpdateTaskExecutionResponse]
-> ReadPrec UpdateTaskExecutionResponse
-> ReadPrec [UpdateTaskExecutionResponse]
-> Read UpdateTaskExecutionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateTaskExecutionResponse]
$creadListPrec :: ReadPrec [UpdateTaskExecutionResponse]
readPrec :: ReadPrec UpdateTaskExecutionResponse
$creadPrec :: ReadPrec UpdateTaskExecutionResponse
readList :: ReadS [UpdateTaskExecutionResponse]
$creadList :: ReadS [UpdateTaskExecutionResponse]
readsPrec :: Int -> ReadS UpdateTaskExecutionResponse
$creadsPrec :: Int -> ReadS UpdateTaskExecutionResponse
Prelude.Read, Int -> UpdateTaskExecutionResponse -> ShowS
[UpdateTaskExecutionResponse] -> ShowS
UpdateTaskExecutionResponse -> String
(Int -> UpdateTaskExecutionResponse -> ShowS)
-> (UpdateTaskExecutionResponse -> String)
-> ([UpdateTaskExecutionResponse] -> ShowS)
-> Show UpdateTaskExecutionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateTaskExecutionResponse] -> ShowS
$cshowList :: [UpdateTaskExecutionResponse] -> ShowS
show :: UpdateTaskExecutionResponse -> String
$cshow :: UpdateTaskExecutionResponse -> String
showsPrec :: Int -> UpdateTaskExecutionResponse -> ShowS
$cshowsPrec :: Int -> UpdateTaskExecutionResponse -> ShowS
Prelude.Show, (forall x.
 UpdateTaskExecutionResponse -> Rep UpdateTaskExecutionResponse x)
-> (forall x.
    Rep UpdateTaskExecutionResponse x -> UpdateTaskExecutionResponse)
-> Generic UpdateTaskExecutionResponse
forall x.
Rep UpdateTaskExecutionResponse x -> UpdateTaskExecutionResponse
forall x.
UpdateTaskExecutionResponse -> Rep UpdateTaskExecutionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateTaskExecutionResponse x -> UpdateTaskExecutionResponse
$cfrom :: forall x.
UpdateTaskExecutionResponse -> Rep UpdateTaskExecutionResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateTaskExecutionResponse' 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:
--
-- 'httpStatus', 'updateTaskExecutionResponse_httpStatus' - The response's http status code.
newUpdateTaskExecutionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateTaskExecutionResponse
newUpdateTaskExecutionResponse :: Int -> UpdateTaskExecutionResponse
newUpdateTaskExecutionResponse Int
pHttpStatus_ =
  UpdateTaskExecutionResponse' :: Int -> UpdateTaskExecutionResponse
UpdateTaskExecutionResponse'
    { $sel:httpStatus:UpdateTaskExecutionResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData UpdateTaskExecutionResponse