简介
本文档提供关于批量任务接口的 API 概览以及 SDK 示例代码。
说明:
触发任务(工作流)
接口文档及示例函数名
API 文档 | 示例函数名 |
CreateInventoryTriggerJob |
示例代码
func CreateInventoryTriggerJob() {u, _ := url.Parse("https://test-123456789.cos.ap-chongqing.myqcloud.com")cu, _ := url.Parse("https://test-123456789.ci.ap-chongqing.myqcloud.com")b := &cos.BaseURL{BucketURL: u, CIURL: cu}c := cos.NewClient(b, &http.Client{Transport: &cos.AuthorizationTransport{SecretID: os.Getenv("COS_SECRETID"),SecretKey: os.Getenv("COS_SECRETKEY"),Transport: &debug.DebugRequestTransport{RequestHeader: true,RequestBody: true,ResponseHeader: true,ResponseBody: true,},},})rand.Seed(time.Now().UnixNano())opt := &cos.CreateInventoryTriggerJobOptions{Name: "trigger-" + strconv.Itoa(rand.Intn(100)),Input: &cos.InventoryTriggerJobInput{Manifest: "https://test-123456789.cos.ap-chongqing.myqcloud.com/cos_bucket_inventory/123456789/test/menu_instant_20220506171340/20220506/manifest.json",},Operation: &cos.InventoryTriggerJobOperation{WorkflowIds: "web6ac56c1ef54dbfa44d7f4103203be9",TimeInterval: cos.InventoryTriggerJobOperationTimeInterval{Start: "2002-02-16T10:45:12+0800",End: "2022-05-16T10:45:12+0800",},},}DescribeInventoryTriggerJobRes, _, err := c.CI.CreateInventoryTriggerJob(context.Background(), opt)log_status(err)fmt.Printf("%+v\\n", DescribeInventoryTriggerJobRes)}
触发任务(独立节点)
接口文档及示例函数名
API 文档 | 示例函数名 |
CreateInventoryTriggerJobByParam |
示例代码
func CreateInventoryTriggerJobByParam() {u, _ := url.Parse("https://test-123456789.cos.ap-chongqing.myqcloud.com")cu, _ := url.Parse("https://test-123456789.ci.ap-chongqing.myqcloud.com")b := &cos.BaseURL{BucketURL: u, CIURL: cu}c := cos.NewClient(b, &http.Client{Transport: &cos.AuthorizationTransport{SecretID: os.Getenv("COS_SECRETID"),SecretKey: os.Getenv("COS_SECRETKEY"),Transport: &debug.DebugRequestTransport{RequestHeader: true,RequestBody: true,ResponseHeader: true,ResponseBody: true,},},})rand.Seed(time.Now().UnixNano())opt := &cos.CreateInventoryTriggerJobOptions{Name: "trigger-" + strconv.Itoa(rand.Intn(100)),Input: &cos.InventoryTriggerJobInput{Prefix: "input/",},Type: "Job",Operation: &cos.InventoryTriggerJobOperation{TimeInterval: cos.InventoryTriggerJobOperationTimeInterval{Start: "2002-02-16T10:45:12+0800",End: "2023-05-16T10:45:12+0800",},Tag: "Transcode",JobParam: &cos.InventoryTriggerJobOperationJobParam{TemplateId: "t00daf332ba39049f8bfb899c1ed0134b0",},JobLevel: 1,UserData: "This is my CreateInventoryTriggerJob",Output: &cos.JobOutput{Region: "ap-chongqing",Bucket: "test-123456789",Object: "output/${InputName}_${InventoryTriggerJobId}.${ext}",},},}DescribeInventoryTriggerJobRes, _, err := c.CI.CreateInventoryTriggerJob(context.Background(), opt)log_status(err)fmt.Printf("%+v\\n", DescribeInventoryTriggerJobRes)}
取消任务
接口文档及示例函数名
API 文档 | 示例函数名 |
CancelInventoryTriggerJobs |
示例代码
func CancelInventoryTriggerJobs() {u, _ := url.Parse("https://test-123456789.cos.ap-chongqing.myqcloud.com")cu, _ := url.Parse("https://test-123456789.ci.ap-chongqing.myqcloud.com")b := &cos.BaseURL{BucketURL: u, CIURL: cu}c := cos.NewClient(b, &http.Client{Transport: &cos.AuthorizationTransport{SecretID: os.Getenv("COS_SECRETID"),SecretKey: os.Getenv("COS_SECRETKEY"),Transport: &debug.DebugRequestTransport{RequestHeader: true,RequestBody: true,ResponseHeader: true,ResponseBody: true,},},})jobId := "b56a3bbc0cd3011ecb09a52540038936c"_, err := c.CI.CancelInventoryTriggerJob(context.Background(), jobId)log_status(err)}
查询任务
接口文档及示例函数名
API 文档 | 示例函数名 |
DescribeInventoryTriggerJob |
示例代码
func DescribeInventoryTriggerJob() {u, _ := url.Parse("https://test-123456789.cos.ap-chongqing.myqcloud.com")cu, _ := url.Parse("https://test-123456789.ci.ap-chongqing.myqcloud.com")b := &cos.BaseURL{BucketURL: u, CIURL: cu}c := cos.NewClient(b, &http.Client{Transport: &cos.AuthorizationTransport{SecretID: os.Getenv("COS_SECRETID"),SecretKey: os.Getenv("COS_SECRETKEY"),Transport: &debug.DebugRequestTransport{RequestHeader: true,RequestBody: true,ResponseHeader: true,ResponseBody: true,},},})jobId := "babc6cfc8cd2111ecb09a52540038936c"DescribeWorkflowRes, _, err := c.CI.DescribeInventoryTriggerJob(context.Background(), jobId)log_status(err)fmt.Printf("%+v\\n", DescribeWorkflowRes)}
批量拉取任务
接口文档及示例函数名
API 文档 | 示例函数名 |
DescribeInventoryTriggerJobs |
示例代码
func DescribeInventoryTriggerJobs() {u, _ := url.Parse("https://test-123456789.cos.ap-chongqing.myqcloud.com")cu, _ := url.Parse("https://test-123456789.ci.ap-chongqing.myqcloud.com")b := &cos.BaseURL{BucketURL: u, CIURL: cu}c := cos.NewClient(b, &http.Client{Transport: &cos.AuthorizationTransport{SecretID: os.Getenv("COS_SECRETID"),SecretKey: os.Getenv("COS_SECRETKEY"),Transport: &debug.DebugRequestTransport{RequestHeader: true,RequestBody: true,ResponseHeader: true,ResponseBody: true,},},})opt := &cos.DescribeInventoryTriggerJobsOptions{States: "All",}DescribeWorkflowRes, _, err := c.CI.DescribeInventoryTriggerJobs(context.Background(), opt)log_status(err)fmt.Printf("%+v\\n", DescribeWorkflowRes)}