

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# Neptune 載入器取消工作
<a name="load-api-reference-cancel"></a>

取消載入工作。

若要取消工作，則必須傳送 HTTP `DELETE`請求至 `https://{{your-neptune-endpoint}}:{{port}}/loader` 端點。`loadId` 可以附加到 `/loader` URL 路徑，或包含它以做為 URL 中的變數。

## 取消工作請求語法
<a name="load-api-reference-cancel-syntax"></a>

```
DELETE https://{{your-neptune-endpoint}}:{{port}}/loader?loadId={{loadId}}
```

```
DELETE https://{{your-neptune-endpoint}}:{{port}}/loader/{{loadId}}
```

## 取消任務請求參數
<a name="load-api-reference-cancel-parameters"></a>

**loadId**  
載入工作的 ID。

## 取消任務回應語法
<a name="load-api-reference-cancel-parameters-response"></a>

```
no response body
```

**200 OK**  
成功刪除的載入任務會傳回 `200` 程式碼。

## 取消任務錯誤
<a name="load-api-reference-cancel-parameters-errors"></a>

發生錯誤時，回應的 `BODY` 中會傳回 JSON 物件。`message` 物件包含此錯誤的描述。

**錯誤類別**
+ **`Error 400`** – 無效的 `loadId` 會傳回 HTTP `400` 錯誤的請求錯誤。描述錯誤的訊息。
+ **`Error 500`** – 無法處理的有效請求會傳回 HTTP `500` 內部伺服器錯誤。描述錯誤的訊息。

## 取消任務錯誤訊息
<a name="load-api-reference-cancel-parameters-errors-messages"></a>

以下是來自取消 API 的可能錯誤訊息及錯誤的描述。
+ `The load with id = {{load_id}} does not exist or not active` (HTTP 404) – 找不到載入。檢查 `id` 參數值。
+ `Load cancellation is not permitted on a read replica instance.` (HTTP 405) – 載入是一種寫入操作。在讀取/寫入叢集端點上重試載入。

## 取消任務範例
<a name="load-api-reference-cancel-examples"></a>

**Example 請求**  
以下是使用 `curl` 命令透過 HTTP `DELETE` 傳送的請求。  

```
aws neptunedata cancel-loader-job \
  --endpoint-url https://{{your-neptune-endpoint}}:{{port}} \
  --load-id {{0a237328-afd5-4574-a0bc-c29ce5f54802}}
```
如需詳細資訊，請參閱《 AWS CLI 命令參考》中的 [cancel-loader-job](https://docs.aws.amazon.com/cli/latest/reference/neptunedata/cancel-loader-job.html)。

```
import boto3
from botocore.config import Config

client = boto3.client(
    'neptunedata',
    endpoint_url='https://{{your-neptune-endpoint}}:{{port}}',
    config=Config(read_timeout=None, retries={'total_max_attempts': 1})
)

response = client.cancel_loader_job(
    loadId='{{0a237328-afd5-4574-a0bc-c29ce5f54802}}'
)

print(response)
```

```
awscurl 'https://{{your-neptune-endpoint}}:{{port}}/loader/{{0a237328-afd5-4574-a0bc-c29ce5f54802}}' \
  --region {{us-east-1}} \
  --service neptune-db \
  -X DELETE
```
此範例假設您的 AWS 登入資料已在您的環境中設定。將 {{us-east-1}} 取代為 Neptune 叢集的區域。

```
curl -X DELETE 'https://{{your-neptune-endpoint}}:{{port}}/loader/{{0a237328-afd5-4574-a0bc-c29ce5f54802}}'
```