简介
本文档提供关于批量任务接口的 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
触发任务(独立节点)
接口文档及示例函数名
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
取消任务
接口文档及示例函数名
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
查询任务
接口文档及示例函数名
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
批量拉取任务
接口文档及示例函数名
API 文档 | 示例函数名 |
ci_list_inventory_trigger_jobs |
示例代码
def ci_list_inventory_trigger_jobs():# 获取批量任务列表response = client.ci_list_inventory_trigger_jobs(Bucket=bucket_name, # 桶名称)print(response)return response