文档首页/ 测试计划 CodeArts TestPlan/ API参考/ API/ 接口测试管理/ 查询全局变量参数列表V4 - ListVariables
更新时间:2026-07-07 GMT+08:00
分享

查询全局变量参数列表V4 - ListVariables

功能介绍

根据工程唯一标识,查询全局变量参数列表,V4版本的api

调用方法

请参见如何调用API

URI

GET /v4/{project_id}/variables

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

参数解释:

项目UUID,项目唯一标识,固定长度32位字符(字母和数字)。获取方式请参见获取项目ID

约束限制:

不涉及

取值范围:

项目uuid应符合如下规则:长度等于32位字符,包含大小写字母、数字

默认取值:

不涉及

表2 Query参数

参数

是否必选

参数类型

描述

group_id

String

参数解释

分组唯一标识

约束限制

不涉及

取值范围

32个字符组成的字符串

默认取值

不涉及

获取方法

进入页面 环境参数,从接口GET /v4/{project_id}/variables 请求地址中获取group_id对应的值

page_no

String

参数解释

当前页数

约束限制

不涉及

取值范围

0-999999999

默认取值

不涉及

page_size

String

参数解释

每页的记录数

约束限制

不涉及

取值范围

0-1000

默认取值

不涉及

请求参数

表3 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

参数解释:

用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。

约束限制:

必传。

取值范围:

字符串长度不少于1,不超过10万。

默认取值:

不涉及。

响应参数

状态码:200

表4 响应Body参数

参数

参数类型

描述

code

String

参数解释

接口调用失败错误码

取值范围

不超过256个字符组成的字符串

error

CommonResponseErrorOfAPITest object

参数解释

统一错误返回

取值范围

不涉及

reason

String

参数解释

接口调用失败原因

取值范围

不超过1000个字符组成的字符串

result

PageResults object

参数解释

结果

取值范围

不涉及

status

String

参数解释

接口调用状态

取值范围

  • success,请求成功

  • error,请求报错

costTimeResult

String

参数解释

提交耗时

取值范围

不超过256个字符组成的字符串

表5 CommonResponseErrorOfAPITest

参数

参数类型

描述

code

String

参数解释

接口调用失败错误码

取值范围

不超过256个字符组成的字符串

reason

String

参数解释

接口调用失败原因

取值范围

不超过1000个字符组成的字符串

表6 PageResults

参数

参数类型

描述

page_list

Array of VariableRes objects

参数解释

全局变量列表

取值范围

不涉及

page_no

Integer

参数解释

当前分页

约束限制

不涉及

取值范围

0-999999999

默认取值

不涉及

page_size

Integer

参数解释

分页大小

约束限制

不涉及

取值范围

0-100

默认取值

不涉及

total_page

Integer

参数解释

分页总数

取值范围

0-999999999

total_size

Long

参数解释

全局变量总数

取值范围

0-999999999

表7 VariableRes

参数

参数类型

描述

by_order

Integer

参数解释

变量顺序

取值范围

0-9999

category

String

参数解释

变量静态/动态类型

取值范围

Dynamic或者Static

create_time

String

参数解释

创建时间(格式:yyyy-MM-dd HH:mm:ss)

取值范围

不涉及

create_time_stamp

Long

参数解释

创建时间戳(单位:毫秒)

取值范围

不涉及

create_time_string

String

参数解释

创建时间字符串(格式:yyyy-MM-dd HH:mm:ss)

取值范围

不涉及

create_user

String

参数解释

创建者

取值范围

不超过255个字符组成的字符串

currentPermission

String

参数解释

当前用户权限

取值范围

不涉及

description

String

参数解释

变量描述信息

dynamicParamFlag

Boolean

参数解释

是否为动态变量

取值范围

true或false,true表示是动态变量,false表示非动态变量

functionParams

String

参数解释

变量参数

groupId

String

参数解释

分组唯一标识

取值范围

32个字符组成的字符串

id

String

参数解释

变量编号

取值范围

32个字符组成的字符串

isSensitiveInfo

Boolean

参数解释

是否为敏感变量

取值范围

true或false,true表示是敏感变量,false表示非敏感变量

isSensitiveModified

Boolean

参数解释

敏感变量是否被修改

取值范围

true或false,true表示敏感变量被修改,false表示敏感变量未被修改

locked

Integer

参数解释

是否被锁定

  • 0,未上锁

  • 1,上锁

name

String

参数解释

变量名

取值范围

0-300个字符组成的字符串

node_id

String

参数解释

节点唯一标识

取值范围

32个字符组成的字符串

node_type

Integer

参数解释

节点类型

取值范围

  • 0,变量节点

  • null,变量节点

  • 1,目录节点

parent_id

String

参数解释

所属父节点编号

取值范围

32个字符组成的字符串

parent_node_id

AnyType

参数解释

父节点唯一标识

取值范围

32个字符组成的字符串

property

String

参数解释

属性

取值范围

不涉及

region

String

参数解释

区域名称

取值范围

不超过32个字符组成的字符串

sensitiveInfoSetterTime

String

参数解释

敏感参数设置时间

取值范围

不涉及

sensitiveInfoSetterUser

String

参数解释

敏感参数设置者名称

取值范围

不涉及

sourceId

String

参数解释

复制的全局变量的源id

type

String

参数解释

变量类型

取值范围

  • Long

  • Double

  • Boolean

  • BigDecimal

  • String

  • Integer

  • csv

update_time

String

参数解释

更新时间(格式:yyyy-MM-dd HH:mm:ss)

取值范围

不涉及

update_time_stamp

Long

参数解释

更新时间戳(单位:毫秒)

取值范围

不涉及

update_time_string

String

参数解释

更新时间字符串(格式:yyyy-MM-dd HH:mm:ss)

取值范围

不涉及

update_user

String

参数解释

更新者

取值范围

不超过32个字符组成的字符串

variableType

Integer

参数解释

变量类型

取值范围 0-18

  • 10,任意长度随机字符串

  • 11,指定范围随机int

  • 12,生成当前整数时间戳(从1970-01-01 00:00 UTC开始的秒数)

  • 13,按照指定的format格式化时间戳,如 $timestamp_format(timestamp, YYYY-MM-DD)

  • 14,生成UUID

  • 15,使用Base64方法编码参数

  • 16,使用指定参数生成MD5哈希值

  • 18,sha512编码参数

状态码:201

Created

状态码:401

表8 响应Body参数

参数

参数类型

描述

error_code

String

参数解释

接口调用失败错误码

取值范围

12-18个字符组成的字符串

error_msg

String

参数解释

接口调用失败错误信息

取值范围

3-1000个字符组成的字符串

状态码:403

表9 响应Body参数

参数

参数类型

描述

error_code

String

参数解释

接口调用失败错误码

取值范围

12-18个字符组成的字符串

error_msg

String

参数解释

接口调用失败错误信息

取值范围

3-1000个字符组成的字符串

状态码:404

表10 响应Body参数

参数

参数类型

描述

error_code

String

参数解释

接口调用失败错误码

取值范围

12-18个字符组成的字符串

error_msg

String

参数解释

接口调用失败错误信息

取值范围

3-1000个字符组成的字符串

请求示例

get https://{endpoint}/v4/26927372bbae40b184fe764e7a0d21f7/variables?group_id=f56886074692465d8b3a50c74c136b53&page_no=1&page_size=0

响应示例

状态码:200

SUCCESS

{
  "status" : "success",
  "result" : {
    "page_no" : 1,
    "page_size" : 1,
    "total_page" : 1,
    "total_size" : 1,
    "page_list" : [ {
      "id" : "a97fc86638e24308a61b68f5abb8ef8f",
      "type" : "String",
      "name" : "New_Variable_1",
      "property" : "test",
      "description" : "",
      "locked" : 1,
      "groupId" : "c8eae5907ad24f43b280babb4a14a8f2",
      "category" : "Static",
      "isSensitiveInfo" : true,
      "isSensitiveModified" : false,
      "sourceId" : null,
      "variableType" : 0,
      "functionParams" : "",
      "dynamicParamFlag" : false,
      "sensitiveInfoSetterUser" : "w30036875",
      "sensitiveInfoSetterTime" : "2025-02-07T02:33:39+0800",
      "currentPermission" : "0",
      "region" : "{region}",
      "create_time_string" : "2025-02-07 14:33:39 GMT+08:00",
      "update_time_string" : "2025-02-07 14:33:39 GMT+08:00",
      "create_time_stamp" : 1738910019000,
      "update_time_stamp" : 1738910019000,
      "create_user" : "w30036875",
      "create_time" : "2025-02-07T02:33:39+0800",
      "update_user" : "w30036875",
      "update_time" : "2025-02-07T02:33:39+0800",
      "parent_id" : "2d8247c5e9424bccb0cfa8a47b5d311c",
      "node_type" : 0,
      "node_id" : "09e85552c6ebbb99527f548abdeafa0",
      "parent_node_id" : null,
      "by_order" : 1
    } ]
  },
  "reason" : null,
  "error" : null,
  "code" : null
}

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
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 ListVariablesSolution {

    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();
        ListVariablesRequest request = new ListVariablesRequest();
        request.withProjectId("{project_id}");
        try {
            ListVariablesResponse response = client.listVariables(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
# 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 = ListVariablesRequest()
        request.project_id = "{project_id}"
        response = client.list_variables(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
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.ListVariablesRequest{}
	request.ProjectId = "{project_id}"
	response, err := client.ListVariables(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

200

SUCCESS

201

Created

401

Unauthorized

403

Forbidden

404

Not Found

错误码

请参见错误码

相关文档