{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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
-- @ @<https://docs.aws.amazon.com/datasync/latest/userguide/API_Options.html#DataSync-Type-Options-BytesPerSecond 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 qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DataSync.Types
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
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]
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
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. 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'
    { $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 :: Lens' UpdateTaskExecution Text
updateTaskExecution_taskExecutionArn = 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 :: Lens' UpdateTaskExecution Options
updateTaskExecution_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 :: (Service -> Service)
-> UpdateTaskExecution -> Request UpdateTaskExecution
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 UpdateTaskExecution
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateTaskExecution)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateTaskExecutionResponse
UpdateTaskExecutionResponse'
            forall (f :: * -> *) a b. Functor 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 UpdateTaskExecution where
  hashWithSalt :: Int -> UpdateTaskExecution -> Int
hashWithSalt Int
_salt UpdateTaskExecution' {Text
Options
options :: Options
taskExecutionArn :: Text
$sel:options:UpdateTaskExecution' :: UpdateTaskExecution -> Options
$sel:taskExecutionArn:UpdateTaskExecution' :: UpdateTaskExecution -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
taskExecutionArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Options
options

instance Prelude.NFData UpdateTaskExecution where
  rnf :: UpdateTaskExecution -> ()
rnf UpdateTaskExecution' {Text
Options
options :: Options
taskExecutionArn :: Text
$sel:options:UpdateTaskExecution' :: UpdateTaskExecution -> Options
$sel:taskExecutionArn:UpdateTaskExecution' :: UpdateTaskExecution -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
taskExecutionArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Options
options

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

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"TaskExecutionArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
taskExecutionArn),
            forall a. a -> Maybe a
Prelude.Just (Key
"Options" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Options
options)
          ]
      )

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

instance Data.ToQuery UpdateTaskExecution where
  toQuery :: UpdateTaskExecution -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:httpStatus:UpdateTaskExecutionResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
updateTaskExecutionResponse_httpStatus :: Lens.Lens' UpdateTaskExecutionResponse Prelude.Int
updateTaskExecutionResponse_httpStatus :: Lens' UpdateTaskExecutionResponse Int
updateTaskExecutionResponse_httpStatus = 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 where
  rnf :: UpdateTaskExecutionResponse -> ()
rnf UpdateTaskExecutionResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateTaskExecutionResponse' :: UpdateTaskExecutionResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus