更新时间:2025-07-25 GMT+08:00
分享

查询全局变量参数列表V4

功能介绍

查询全局变量参数列表V4

调用方法

请参见如何调用API

URI

GET /v4/{project_id}/variables

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

参数解释

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

约束限制

不涉及

取值范围

32个字符组成的字符串

默认取值

不涉及

表2 Query参数

参数

是否必选

参数类型

描述

group_id

String

参数解释

分组唯一标识

约束限制

不涉及

取值范围

32个字符组成的字符串

默认取值

不涉及

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

参数解释

接口调用失败错误码

error

CommonResponseErrorOfAPITest object

统一错误返回

reason

String

参数解释

接口调用失败原因

result

PageResults object

结果

status

String

参数解释

接口调用状态

costTimeResult

String

参数解释

提交耗时

表5 CommonResponseErrorOfAPITest

参数

参数类型

描述

code

String

参数解释

接口调用失败错误码

取值范围

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

reason

String

参数解释

接口调用失败原因

取值范围

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

表6 PageResults

参数

参数类型

描述

page_list

Array of VariableRes objects

参数解释

全局变量列表

page_no

Integer

参数解释

当前分页

page_size

Integer

参数解释

分页大小

total_page

Integer

参数解释

分页总数

total_size

Long

参数解释

全局变量总数

表7 VariableRes

参数

参数类型

描述

by_order

Integer

参数解释

变量顺序

category

String

参数解释

变量静态/动态类型

取值范围

Dynamic或者Static

create_time

String

参数解释

变量创建时间

create_time_stamp

Long

参数解释

变量创建时间(时间戳格式)

create_time_string

String

参数解释

变量创建时间(字符串格式)

create_user

String

参数解释

变量创建者

currentPermission

String

参数解释

当前用户权限

description

String

参数解释

变量描述信息

dynamicParamFlag

Boolean

参数解释

是否为动态变量

取值范围

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

functionParams

String

参数解释

变量参数

groupId

String

参数解释

分组唯一标识

id

String

参数解释

变量编号

isSensitiveInfo

Boolean

参数解释

是否为敏感变量

取值范围

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

isSensitiveModified

Boolean

参数解释

敏感变量是否被修改

取值范围

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

locked

Integer

参数解释

是否被锁定

name

String

参数解释

变量名

取值范围

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

node_id

String

参数解释

节点编号

node_type

Integer

参数解释

节点类型

parent_id

String

参数解释

所属父节点编号

parent_node_id

String

参数解释

父节点编号

property

String

参数解释

变量值

取值范围

1-65535个字符组成的字符串

region

String

参数解释

所在区域

sensitiveInfoSetterTime

String

参数解释

敏感变量设置时间

sensitiveInfoSetterUser

String

参数解释

敏感变量设置者

sourceId

String

参数解释

复制的全局变量的源id

type

String

参数解释

变量类型

取值范围

Long|Double|Boolean|BigDecimal|String|Integer|csv

update_time

String

参数解释

变量更新时间

update_time_stamp

Long

参数解释

变量更新时间(时间戳格式)

update_time_string

String

参数解释

变量更新时间(字符串格式)

update_user

String

参数解释

变量更新者

variableType

Integer

参数解释

变量类型

取值范围

0-18

状态码: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
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 := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        Build()

    client := cloudtest.NewCloudtestClient(
        cloudtest.CloudtestClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    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

错误码

请参见错误码

相关文档