Help Center/ Cloud Connect/ API Reference/ API/ Global Connection Bandwidth Tag Management/ Querying the List of Global Connection Bandwidths in an Account
Updated on 2024-11-19 GMT+08:00

Querying the List of Global Connection Bandwidths in an Account

Function

This API is used to query the list of global connection bandwidths in an account.

Calling Method

For details, see Calling APIs.

URI

POST /v3/gcb/resource-instances/filter

Table 1 Query Parameters

Parameter

Mandatory

Type

Description

limit

No

Integer

Number of records to be queried.

offset

No

Integer

Index offset.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

request_id

No

String

Request ID.

without_any_tag

No

Boolean

If this parameter is set to true, all resources without tags are queried. In this case, the tags, tags_any, not_tags, and not_tags_any fields are not required.

tags

No

Array of QueryTag objects

The instances to be queried contain tags listed in tags. Each instance to be queried contains a maximum of 20 keys. Each tag key has a maximum of 10 tag values. The tag value corresponding to each tag key can be an empty array but the structure cannot be missing. Each tag key and each value of the same tag key must be unique. The response returns resources containing all tags in this list. Keys in this list are in the AND relationship and values in each key-value structure are in the OR relationship. If no searching condition is specified, full data is returned.

tags_any

No

Array of QueryTag objects

The instances to be queried contain any tag listed in tags_any. Each instance to be queried contains a maximum of 20 keys. Each tag key has a maximum of 10 tag values. The tag value corresponding to each tag key can be an empty array but the structure cannot be missing. Each tag key and each value of the same tag key must be unique. The response returns resources containing any tag in this list. Keys in this list are in the OR relationship and values in each key-value structure are also in the OR relationship. If no searching condition is specified, full data is returned.

not_tags

No

Array of QueryTag objects

The instances to be queried do not contain any tag listed in not_tags. Each instance to be queried contains a maximum of 20 keys. Each tag key has a maximum of 10 tag values. The tag value corresponding to each tag key can be an empty array but the structure cannot be missing. Keys must be unique and values of a key must be unique. The response returns resources containing no tags in this list. Keys in this list are in the AND relationship and values in each key-value structure are in the OR relationship. If no searching condition is specified, full data is returned.

not_tags_any

No

Array of QueryTag objects

The instances to be queried do not contain all tags listed in not_tags_any. Each instance to be queried contains a maximum of 20 keys. Each tag key has a maximum of 10 tag values. The tag value corresponding to each tag key can be an empty array but the structure cannot be missing. Keys must be unique and values of a key must be unique. The response returns resources containing no tag in this list. Keys in this list are in the OR relationship and values in each key-value structure are also in the OR relationship. If no filtering criteria is specified, full data is returned.

matches

No

Array of TmsMatch objects

Whether to match the tags: The tag key must be set to resource_name. If there is a tag value, fuzzy matching is used. If the tag value is an empty string, exact matching is used.

Table 4 QueryTag

Parameter

Mandatory

Type

Description

key

Yes

String

Tag key.

values

Yes

Array of strings

List of tag values.

Table 5 TmsMatch

Parameter

Mandatory

Type

Description

key

Yes

String

Tag key, Currently, only resource_name is supported. Other key values will be available later.

value

Yes

String

Tag value.

Response Parameters

Status code: 200

Table 6 Response body parameters

Parameter

Type

Description

resources

Array of TmsResource objects

Resource list.

total_count

Integer

Total records.

request_id

String

Request ID.

Table 7 TmsResource

Parameter

Type

Description

resource_id

String

Resource ID.

tags

Array of Tag objects

Tag list. If there is no tag added for the instance, an empty array is returned.

resource_name

String

Resource name. This parameter is an empty string by default if there is no resource name.

Table 8 Tag

Parameter

Type

Description

key

String

Tag key. The key can contain a maximum of 128 Unicode characters, including letters, digits, hyphens (-), and underscores (_).

value

String

Tag value. The value can contain a maximum of 255 Unicode characters, including letters, digits, hyphens (-), underscores (_), and periods (.).

Example Requests

Querying the list of global connection bandwidths in an account

POST https://{cc_endpoint}/v3/gcb/resource-instances/filter

{
  "matches" : [ {
    "key" : "resource_name",
    "value" : "resource1"
  } ],
  "not_tags" : [ {
    "key" : "key1",
    "values" : [ "value1", "value2" ]
  } ],
  "tags" : [ {
    "key" : "key1",
    "values" : [ "value1", "value2" ]
  } ],
  "tags_any" : [ {
    "key" : "key1",
    "values" : [ "value1", "value2" ]
  } ],
  "not_tags_any" : [ {
    "key" : "key1",
    "values" : [ "value1", "value2" ]
  } ]
}

Example Responses

Status code: 200

The list of global connection bandwidths in an account has been queried.

{
  "resources" : [ {
    "resource_id" : "cb9d7ead-834a-4275-93e1-217f79df9dc1",
    "resource_name" : "test",
    "tags" : [ {
      "key" : "key1",
      "value" : "value1"
    } ]
  } ],
  "request_id" : "e3371202-7e85-4c16-bb4b-4e3c092734f7",
  "total_count" : 1
}

SDK Sample Code

The SDK sample code is as follows.

Querying the list of global connection bandwidths in an account

 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.GlobalCredentials;
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.cc.v3.region.CcRegion;
import com.huaweicloud.sdk.cc.v3.*;
import com.huaweicloud.sdk.cc.v3.model.*;

import java.util.List;
import java.util.ArrayList;

public class ListGcbResourceByTagSolution {

    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 GlobalCredentials()
                .withAk(ak)
                .withSk(sk);

        CcClient client = CcClient.newBuilder()
                .withCredential(auth)
                .withRegion(CcRegion.valueOf("<YOUR REGION>"))
                .build();
        ListGcbResourceByTagRequest request = new ListGcbResourceByTagRequest();
        QueryResourceByTagRequestBody body = new QueryResourceByTagRequestBody();
        List<TmsMatch> listbodyMatches = new ArrayList<>();
        listbodyMatches.add(
            new TmsMatch()
                .withKey("resource_name")
                .withValue("resource1")
        );
        List<String> listNotTagsAnyValues = new ArrayList<>();
        listNotTagsAnyValues.add("value1");
        listNotTagsAnyValues.add("value2");
        List<QueryTag> listbodyNotTagsAny = new ArrayList<>();
        listbodyNotTagsAny.add(
            new QueryTag()
                .withKey("key1")
                .withValues(listNotTagsAnyValues)
        );
        List<String> listNotTagsValues = new ArrayList<>();
        listNotTagsValues.add("value1");
        listNotTagsValues.add("value2");
        List<QueryTag> listbodyNotTags = new ArrayList<>();
        listbodyNotTags.add(
            new QueryTag()
                .withKey("key1")
                .withValues(listNotTagsValues)
        );
        List<String> listTagsAnyValues = new ArrayList<>();
        listTagsAnyValues.add("value1");
        listTagsAnyValues.add("value2");
        List<QueryTag> listbodyTagsAny = new ArrayList<>();
        listbodyTagsAny.add(
            new QueryTag()
                .withKey("key1")
                .withValues(listTagsAnyValues)
        );
        List<String> listTagsValues = new ArrayList<>();
        listTagsValues.add("value1");
        listTagsValues.add("value2");
        List<QueryTag> listbodyTags = new ArrayList<>();
        listbodyTags.add(
            new QueryTag()
                .withKey("key1")
                .withValues(listTagsValues)
        );
        body.withMatches(listbodyMatches);
        body.withNotTagsAny(listbodyNotTagsAny);
        body.withNotTags(listbodyNotTags);
        body.withTagsAny(listbodyTagsAny);
        body.withTags(listbodyTags);
        request.withBody(body);
        try {
            ListGcbResourceByTagResponse response = client.listGcbResourceByTag(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());
        }
    }
}

Querying the list of global connection bandwidths in an account

 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import GlobalCredentials
from huaweicloudsdkcc.v3.region.cc_region import CcRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkcc.v3 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 = GlobalCredentials(ak, sk)

    client = CcClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(CcRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ListGcbResourceByTagRequest()
        listMatchesbody = [
            TmsMatch(
                key="resource_name",
                value="resource1"
            )
        ]
        listValuesNotTagsAny = [
            "value1",
            "value2"
        ]
        listNotTagsAnybody = [
            QueryTag(
                key="key1",
                values=listValuesNotTagsAny
            )
        ]
        listValuesNotTags = [
            "value1",
            "value2"
        ]
        listNotTagsbody = [
            QueryTag(
                key="key1",
                values=listValuesNotTags
            )
        ]
        listValuesTagsAny = [
            "value1",
            "value2"
        ]
        listTagsAnybody = [
            QueryTag(
                key="key1",
                values=listValuesTagsAny
            )
        ]
        listValuesTags = [
            "value1",
            "value2"
        ]
        listTagsbody = [
            QueryTag(
                key="key1",
                values=listValuesTags
            )
        ]
        request.body = QueryResourceByTagRequestBody(
            matches=listMatchesbody,
            not_tags_any=listNotTagsAnybody,
            not_tags=listNotTagsbody,
            tags_any=listTagsAnybody,
            tags=listTagsbody
        )
        response = client.list_gcb_resource_by_tag(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Querying the list of global connection bandwidths in an account

 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/global"
    cc "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cc/v3"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cc/v3/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cc/v3/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 := global.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        Build()

    client := cc.NewCcClient(
        cc.CcClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.ListGcbResourceByTagRequest{}
	var listMatchesbody = []model.TmsMatch{
        {
            Key: "resource_name",
            Value: "resource1",
        },
    }
	var listValuesNotTagsAny = []string{
        "value1",
	    "value2",
    }
	var listNotTagsAnybody = []model.QueryTag{
        {
            Key: "key1",
            Values: listValuesNotTagsAny,
        },
    }
	var listValuesNotTags = []string{
        "value1",
	    "value2",
    }
	var listNotTagsbody = []model.QueryTag{
        {
            Key: "key1",
            Values: listValuesNotTags,
        },
    }
	var listValuesTagsAny = []string{
        "value1",
	    "value2",
    }
	var listTagsAnybody = []model.QueryTag{
        {
            Key: "key1",
            Values: listValuesTagsAny,
        },
    }
	var listValuesTags = []string{
        "value1",
	    "value2",
    }
	var listTagsbody = []model.QueryTag{
        {
            Key: "key1",
            Values: listValuesTags,
        },
    }
	request.Body = &model.QueryResourceByTagRequestBody{
		Matches: &listMatchesbody,
		NotTagsAny: &listNotTagsAnybody,
		NotTags: &listNotTagsbody,
		TagsAny: &listTagsAnybody,
		Tags: &listTagsbody,
	}
	response, err := client.ListGcbResourceByTag(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

200

The list of global connection bandwidths in an account has been queried.

Error Codes

See Error Codes.