根据条件查询子任务集合 - ListSubTasksByPostUsing
功能介绍
根据条件查询子任务集合
调用方法
请参见如何调用API。
URI
POST /v1/projects/{service_id}/testsuite/results
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| service_id | 是 | String | 服务id |
请求参数
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| X-Auth-Token | 否 | String | 用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| more | 否 | Boolean | 查询结果是否还有更多数据的标志 |
| notSetReleaseDev | 否 | Boolean | 未设置发布版本 |
| page_number | 否 | Integer | 页码 |
| page_size | 否 | Integer | 每页大小 |
| parent_sub_task_id | 否 | String | 父任务id |
| plan_id | 否 | String | 测试计划id |
| release_dev | 否 | Array of strings | 发布的版本,空数组:代表所有未设置的; null或者无此字段,搜索所有版本 有内容:搜索所有版本 |
| results | 否 | Array of integers | 商用cloudTest任务执行结果列表 |
| start_time_begin | 否 | Long | 任务执行第一次时间 |
| start_time_end | 否 | Long | 任务执行最后一次时间 |
| state | 否 | Integer | 状态 |
| states | 否 | Array of integers | 子任务状态列表 |
| sub_task_id | 否 | String | 子任务任务id |
| suite_type | 否 | Integer | 测试套类型 |
| task_id | 否 | String | 任务id |
| task_type_id | 否 | String | 任务类型,1=拨测,2=冒烟 |
| test_service_id | 否 | String | 项目id |
响应参数
状态码:200
| 参数 | 参数类型 | 描述 |
|---|---|---|
| list | Array of objects | 返回结果 |
| page_num | Integer | 页码 |
| page_size | Integer | 分页大小 |
| total_page | Integer | 总页数 |
| total_size | Long | 总条数 |
状态码:201
无
状态码:401
| 参数 | 参数类型 | 描述 |
|---|---|---|
| error_code | String | 错误编码 |
| error_msg | String | 错误原因 |
状态码:403
| 参数 | 参数类型 | 描述 |
|---|---|---|
| error_code | String | 错误编码 |
| error_msg | String | 错误原因 |
状态码:404
| 参数 | 参数类型 | 描述 |
|---|---|---|
| error_code | String | 错误编码 |
| error_msg | String | 错误原因 |
请求示例
post https://{endpoint}/v1/projects/4858a39d9861476ca2cbc71db0d5db2e/testsuite/results
{
"more" : false,
"page_number" : 1,
"page_size" : 15,
"task_id" : "v94g00011idgfcf1",
"suite_type" : 1
} 响应示例
状态码:200
{
"list" : [ {
"id" : "e24c624a465149faab801925e8f8fc47",
"state" : 1,
"progress" : 100,
"caseSuccess" : 0,
"caseFailed" : 1,
"caseNotExecuted" : 0,
"caseOthers" : 0,
"envInfo" : {
"envId" : "85bb2c9e2f96402e982006ab5bd82b3c",
"envName" : "Default Environment"
},
"test_service_id" : "85376aff7fa3447e8749bce4c6c7fc76",
"create_user" : "这是三十字这是三十字这是三十字这是三十字这是三十字这是三十字",
"create_time" : 1784689051000,
"update_user" : "这是三十字这是三十字这是三十字这是三十字这是三十字这是三十字",
"update_time" : 1784689378000,
"task_id" : "v94g00011idgfcf1",
"start_time" : 1784689051438,
"end_time" : 1784689378076,
"task_type_id" : "2",
"case_result_count" : "{\"statistics\":{\"successrate\":0.0},\"caseCount\":1,\"statecount\":{\"2\":0,\"4\":0,\"5\":0,\"-2\":0,\"-4\":1,\"-5\":0,\"-8\":0,\"-10\":0}}",
"case_pass_count" : 0,
"case_failed_count" : 1,
"case_error_count" : 0,
"case_timeout_count" : 0,
"case_block_count" : 0,
"case_other_count" : 0,
"case_total" : 1,
"task_name" : "test_0722_0001",
"taken_time" : 326638,
"job_name" : "[\"j_8Vv553sL\"]",
"execute_way" : "1",
"response_size" : 0,
"release_dev" : "",
"plan_id" : "v91j0000vfrtf0qf",
"job_names" : [ "j_8Vv553sL" ]
} ],
"page_num" : 1,
"page_size" : 15,
"total_page" : 1,
"total_size" : 1
} SDK代码示例
SDK代码示例如下。
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.cloudtest.v1.region.CloudtestRegion; import com.huaweicloud.sdk.cloudtest.v1.*; import com.huaweicloud.sdk.cloudtest.v1.model.*; public class ListSubTasksByPostUsingSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); ICredential auth = new BasicCredentials() .withAk(ak) .withSk(sk); CloudtestClient client = CloudtestClient.newBuilder() .withCredential(auth) .withRegion(CloudtestRegion.valueOf("<YOUR REGION>")) .build(); ListSubTasksByPostUsingRequest request = new ListSubTasksByPostUsingRequest(); request.withServiceId("{service_id}"); SubTaskQueryByPageParams body = new SubTaskQueryByPageParams(); body.withTaskId("v94g00011idgfcf1"); body.withSuiteType(1); body.withPageSize(15); body.withPageNumber(1); body.withMore(false); request.withBody(body); try { ListSubTasksByPostUsingResponse response = client.listSubTasksByPostUsing(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | # coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkcloudtest.v1.region.cloudtest_region import CloudtestRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkcloudtest.v1 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] credentials = BasicCredentials(ak, sk) client = CloudtestClient.new_builder() \ .with_credentials(credentials) \ .with_region(CloudtestRegion.value_of("<YOUR REGION>")) \ .build() try: request = ListSubTasksByPostUsingRequest() request.service_id = "{service_id}" request.body = SubTaskQueryByPageParams( task_id="v94g00011idgfcf1", suite_type=1, page_size=15, page_number=1, more=False ) response = client.list_sub_tasks_by_post_using(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
Go
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" cloudtest "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cloudtest/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cloudtest/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cloudtest/v1/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") auth, err := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). SafeBuild() if err != nil { fmt.Println(err) return } hcClient, err := cloudtest.CloudtestClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). SafeBuild() if err != nil { fmt.Println(err) return } client := cloudtest.NewCloudtestClient(hcClient) request := &model.ListSubTasksByPostUsingRequest{} request.ServiceId = "{service_id}" taskIdSubTaskQueryByPageParams:= "v94g00011idgfcf1" suiteTypeSubTaskQueryByPageParams:= int32(1) pageSizeSubTaskQueryByPageParams:= int32(15) pageNumberSubTaskQueryByPageParams:= int32(1) moreSubTaskQueryByPageParams:= false request.Body = &model.SubTaskQueryByPageParams{ TaskId: &taskIdSubTaskQueryByPageParams, SuiteType: &suiteTypeSubTaskQueryByPageParams, PageSize: &pageSizeSubTaskQueryByPageParams, PageNumber: &pageNumberSubTaskQueryByPageParams, More: &moreSubTaskQueryByPageParams, } response, err := client.ListSubTasksByPostUsing(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
| 状态码 | 描述 |
|---|---|
| 200 | OK |
| 201 | Created |
| 401 | Unauthorized |
| 403 | Forbidden |
| 404 | Not Found |
错误码
请参见错误码。