简介
本文档提供关于批量任务接口的 API 概览以及 SDK 示例代码。
说明:
触发任务(工作流)
接口文档及示例函数名
API 文档 | 示例函数名 |
ci_create_image_inspect_workflow_batch_jobs |
示例代码
def ci_create_image_inspect_workflow_batch_jobs():# 触发任务(工作流)body = {# 批量任务名称# 存量触发任务名称,支持中文、英文、数字、—和_,长度限制128字符# 必选'Name': 'image-inspect-auto-move-batch-process',# 批量处理任务类型:# 支持 Job(独立异步任务) Workflow(工作流)'Type': 'Workflow',# 待操作的对象信息# 必传参数'Input': {# 'UrlFile': 'https://test-12500000000.cos.ap-beijing.myqcloud.com/url.txt',# Object 前缀'Prefix': '/',},# 操作规则# 必传参数'Operation': {# 按对象的last modify时间过滤的触发范围,若传入此参数,则当前任务仅处理指定事件范围内的对象# 非必传'TimeInterval': {'Start': '2023-05-01T00:00:00+0800','End': '2023-06-01T00:00:00+0800'},# 必传参数'WorkflowIds': 'w2504f47ad46exxxxxxxxxxxxxx',},}response = client.ci_create_inventory_trigger_jobs(Bucket=bucket_name,JobBody=body,ContentType='application/xml')print(response)return response
参数说明
调用 ci_create_inventory_trigger_jobs 函数,具体请求参数如下:
参数名称 | 描述 | 类型 | 是否必选 |
Bucket | 存储桶名称。 | String | 是 |
JobBody | Dict | 是 |
返回结果说明
触发任务(独立节点)
接口文档及示例函数名
API 文档 | 示例函数名 |
ci_create_image_inspect_batch_jobs |
示例代码
def ci_create_image_inspect_batch_jobs():# 触发任务(独立节点)body = {# 批量任务名称# 存量触发任务名称,支持中文、英文、数字、—和_,长度限制128字符# 必选'Name': 'image-inspect-auto-move-batch-process',# 批量处理任务类型:# 支持 Job(独立异步任务) Workflow(工作流)'Type': 'Job',# 待操作的对象信息# 必传参数'Input': {# 'UrlFile': 'https://test-12500000000.cos.ap-beijing.myqcloud.com/url.txt',# Object 前缀'Prefix': '/',},# 操作规则# 必传参数'Operation': {# 按对象的 last modify 时间过滤的触发范围,若传入此参数,则当前任务仅处理指定事件范围内的对象# 非必传'TimeInterval': {'Start': '2023-05-01T00:00:00+0800','End': '2023-06-01T00:00:00+0800'},# 创建的任务类型,此处固定值为 ImageInspect# 必传参数'Tag': 'ImageInspect',# 任务参数集合# 必传参数'JobParam': {# 异常图片检测配置# 非必选'ImageInspect': {# 是否开启检测到异常图片检测后自动对图片进行处理的动作,false/true,非必选,默认 false'AutoProcess': 'true',# 在检测到为异常图片后的处理动作,有效值为:# BackupObject:移动图片到固定目录下,目录名为 abnormal_images_backup/,由后台自动创建# SwitchObjectToPrivate:将图片权限设置为私有# DeleteObject:删除图片# 非必选参数,默认值为 BackupObject'ProcessType': 'BackupObject'},},},}response = client.ci_create_inventory_trigger_jobs(Bucket=bucket_name,JobBody=body,ContentType='application/xml')print(response)return response
参数说明
调用 ci_create_inventory_trigger_jobs 函数,具体请求参数如下:
参数名称 | 描述 | 类型 | 是否必选 |
Bucket | 存储桶名称。 | String | 是 |
JobBody | Dict | 是 |
返回结果说明
取消任务
接口文档及示例函数名
API 文档 | 示例函数名 |
ci_cancel_inventory_trigger_jobs |
示例代码
def ci_cancel_inventory_trigger_jobs():# 取消任务response = client.ci_delete_inventory_trigger_jobs(Bucket=bucket_name, # 桶名称JobId='b97c37f492adf11xxxxxxxxxxxx', # 需要删除的 ID)print(response)return response
参数说明
调用 ci_delete_inventory_trigger_jobs 函数,具体请求参数如下:
参数名称 | 描述 | 类型 | 是否必选 |
Bucket | 存储桶名称。 | String | 是 |
JobId | 需要取消的批量任务 ID。 | String | 是 |
返回结果说明
response 为取消批量任务的响应结果。
查询任务
接口文档及示例函数名
API 文档 | 示例函数名 |
ci_get_inventory_trigger_jobs |
示例代码
def ci_get_inventory_trigger_jobs():# 查询指定批量处理任务response = client.ci_get_inventory_trigger_jobs(Bucket=bucket_name, # 桶名称JobID='bb16331089f7xxxxxxxxx540019ee59',)print(response)return response
参数说明
调用 ci_get_inventory_trigger_jobs 函数,具体请求参数如下:
参数名称 | 描述 | 类型 | 是否必选 |
Bucket | 存储桶名称。 | String | 是 |
JobID | 需要查询的批量任务 ID。 | String | 是 |
返回结果说明
批量拉取任务
接口文档及示例函数名
API 文档 | 示例函数名 |
ci_list_inventory_trigger_jobs |
示例代码
def ci_list_inventory_trigger_jobs():# 获取批量任务列表response = client.ci_list_inventory_trigger_jobs(Bucket=bucket_name, # 桶名称# JobId='bc9xxxxxxxxxxxxxxxxxxxxxxxxxxx',# WorkflowId='w30edxxxxxxxxxxxxx3a0d8',# Type='Job',# States='Success',# NextToken='1'# Size=1,# StartCreationTime='2025-01-01T00:00:00+0800',# EndCreationTime='2025-01-02T00:00:00+0800'# OrderByTime='Asc')print(response)return response
参数说明
调用 ci_list_inventory_trigger_jobs 函数,具体请求参数如下:
参数名称 | 描述 | 类型 | 是否必选 |
Bucket | 存储桶名称。 | String | 是 |
JobId | 需要查询的批量任务 ID。 | String | 否 |
StartCreationTime | 拉取创建时间大于等于该时间的任务。格式为:%Y-%m-%dT%H:%m:%S%z 。 | String | 否 |
EndCreationTime | 拉取创建时间小于等于该时间的任务。格式为:%Y-%m-%dT%H:%m:%S%z。 | String | 否 |
OrderByTime | Desc 或者 Asc。默认为 Desc。 | String | 否 |
States | 拉取该状态的任务,以 , 分隔支持多状态 All,Submitted,Running,Success,Failed,Pause,Cancel。默认为 All。 | String | 否 |
Size | 拉取的最大任务数。默认为10。最大为100。 | Int | 否 |
NextToken | 请求的上下文,用于翻页。 | String | 否 |
Type | 拉取批量任务类型,工作流类型 Workflow 、任务类型 Job。 | String | 否 |
WorkflowId | 工作流 ID。 | String | 否 |
Name | 批量触发任务名称。 | String | 否 |
返回结果说明