

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 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 确定)**  
成功删除的加载任务将返回 `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) – 加载是写入操作。在 read/write 集群终端节点上重试加载。

## 取消任务示例
<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'
```