Updated on 2024-04-19 GMT+08:00

Querying VPC Endpoints

Function

This API is used to query VPC endpoints.

Calling Method

For details, see Calling APIs.

URI

GET /v1/{project_id}/vpc-endpoints

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID.

Minimum: 1

Maximum: 64

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

endpoint_service_name

No

String

Specifies the name of the VPC endpoint service. The name is case insensitive and supports fuzzy match.

Minimum: 1

Maximum: 128

vpc_id

No

String

Specifies the ID of the VPC where the VPC endpoint is to be created.

Minimum: 1

Maximum: 64

id

No

String

Specifies the unique ID of the VPC endpoint.

Minimum: 1

Maximum: 64

limit

No

Integer

Specifies the maximum number of VPC endpoints displayed on each page. The value ranges from 0 to 500 and is generally 10, 20, or 50. The default number is 10.

Minimum: 1

Maximum: 1000

Default: 10

offset

No

Integer

Specifies the offset. All VPC endpoint services after this offset will be queried. The offset must be an integer greater than 0 but less than the number of VPC endpoint services.

Minimum: 0

sort_key

No

String

Specifies the sorting field of the VPC endpoints, which can be: ●create_at: VPC endpoints are sorted by creation time. ●update_at: VPC endpoints are sorted by update time. The default field is create_at.

Default: create_at

sort_dir

No

String

Specifies the sorting method of VPC endpoints, which can be: ● desc: VPC endpoints are sorted in descending order. ● asc: VPC endpoints are sorted in ascending order. The default method is desc.

Default: desc

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Specifies the user token. It can be obtained by calling the IAM API. The value of X-Subject-Token in the response header is the user token.

Content-Type

No

String

Specifies the MIME type of the request body. Default value application/json is recommended. For APIs used to upload objects or images, the MIME type varies depending on the flow type.

Default: application/json

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

endpoints

Array of EndpointResponseBody objects

Specifies the VPC endpoints.

total_count

Integer

Specifies the total number of VPC endpoints that meet the search criteria. The number is not affected by limit or offset.

Table 5 EndpointResponseBody

Parameter

Type

Description

id

String

Specifies the unique ID of the VPC endpoint.

Minimum: 1

Maximum: 64

service_type

String

Specifies the type of the VPC endpoint service that the VPC endpoint is used to connect to.

  • gateway: indicates the VPC endpoint services that are configured by the O&M personnel. You can use them directly without creating them by yourselves.

  • interface: indicates the cloud services configured by the O&M personnel and private services created by yourselves. You cannot configure these cloud services, but can use them. You can query the public VPC endpoint services to view the VPC endpoint services that are visible and accessible to all users and are configured by the O&M personnel. You can create interface VPC endpoint services.

status

String

Specifies the status of the VPC endpoint.

  • pendingAcceptance: The VPC endpoint is to be accepted.

  • creating: The VPC endpoint is being created.

  • accepted: The VPC endpoint has been accepted.

  • rejected: The VPC endpoint has been rejected.

  • failed: The VPC endpoint failed to be created.

  • deleting: The VPC endpoint is being deleted.

active_status

Array of strings

Specifies the account status.

  • frozen: The account is frozen.

  • active: The account is normal.

endpoint_service_name

String

Specifies the name of the VPC endpoint service.

marker_id

Integer

Specifies the packet ID of the VPC endpoint.

endpoint_service_id

String

Specifies the ID of the VPC endpoint service.

Minimum: 1

Maximum: 64

enable_dns

Boolean

Specifies whether to create a domain name.

  • true: Create a domain name.

  • false: Do not create a domain name. Note When you create a VPC endpoint for connecting to a gateway VPC endpoint service, no domain name is created regardless of whether enable_dns is set to true or false.

dns_names

Array of strings

Specifies the domain name for accessing the associated VPC endpoint service. This parameter is available when enable_dns is set to true.

Minimum: 0

Maximum: 32

ip

String

Specifies the IP address for accessing the associated VPC endpoint service. This parameter is returned only under the following conditions:

  • You query a VPC endpoint for accessing an interface VPC endpoint service.

  • Connection approval is enabled for the VPC endpoint service, and the connection has been approved. status of the VPC endpoint can be accepted or rejected. The rejected status only appears when the VPC endpoint is accepted and then rejected.

Minimum: 1

Maximum: 64

vpc_id

String

Specifies the ID of the VPC where the VPC endpoint is to be created.

Minimum: 1

Maximum: 64

subnet_id

String

Specifies the ID of the subnet in the VPC specified by vpc_id. The ID is in UUID format.

Minimum: 1

Maximum: 64

created_at

String

Specifies when the VPC endpoint was created. The UTC time format YYYY-MM-DDTHH:MM:SSZ is used.

updated_at

String

Specifies the update time of the VPC endpoint. The UTC time format YYYY-MM-DDTHH:MM:SSZ is used.

project_id

String

Specifies the project ID. For details about how to obtain the project ID, see "Obtaining a Project ID".

Minimum: 1

Maximum: 64

tags

Array of TagList objects

Specifies the list of queried tags. If no tag is matched, an empty array is returned.

error

Array of QueryError objects

Specifies the error message. This field is returned when the VPC endpoint is abnormal, that is, the value of status is failed.

whitelist

Array of strings

Specifies the whitelist for controlling access to the VPC endpoint. If you do not specify this parameter, an empty whitelist will be returned. This parameter is available only when you create a VPC endpoint for connecting to an interface VPC endpoint service.

Minimum: 0

Maximum: 32

enable_whitelist

Boolean

Specifies whether access control is enabled.

  • true: Access control is enabled.

  • false: Access control is disabled. If you do not specify this parameter, access control is disabled. This parameter is available only when you create a VPC endpoint for connecting to an interface VPC endpoint service.

routetables

Array of strings

Specifies the IDs of route tables. If this parameter is not specified, the ID of the route table of the default VPC is returned. This parameter is available only when you create a VPC endpoint for connecting to a gateway VPC endpoint service.

Minimum: 0

Maximum: 64

description

String

Specifies the description field. The value can contain characters such as letters and digits, but cannot contain less than signs (<) nor great than signs (>).

Minimum: 0

Maximum: 512

policy_statement

Array of PolicyStatement objects

This field is displayed in the response body only for gateway VPC endpoints that have both VPC endpoint and OBS bucket policies configured.

Array Length: 0 - 10

endpoint_pool_id

String

(To be discarded) Specifies the ID of the cluster associated with the VPC endpoint.

Minimum: 1

Maximum: 64

public_border_group

String

Specifies the information about the public border group associated with the VPC endpoint. This parameter is returned only when the VPC endpoint is associated with an edge pool.

Table 6 TagList

Parameter

Type

Description

key

String

Specifies the tag key. A tag key contains a maximum of 36 Unicode characters. It cannot be left blank. It cannot contain equal signs (=), asterisks (*), less than signs (<), greater than signs (>), backslashes (), commas (,), vertical bars (|), and slashes (/), and the first and last characters cannot be spaces.

Minimum: 1

Maximum: 36

value

String

Specifies the tag key. A tag value contains a maximum of 43 Unicode characters and can be an empty string. It cannot contain equal signs (=), asterisks (*), less than signs(<), greater than signs (>), backslashes (), commas (,), vertical bars (|), and slashes (/), and the first and last characters cannot be spaces.

Minimum: 1

Maximum: 43

Table 7 QueryError

Parameter

Type

Description

error_code

String

Error code.

Minimum: 0

Maximum: 10

error_message

String

Error message.

Minimum: 0

Maximum: 1024

Table 8 PolicyStatement

Parameter

Type

Description

Effect

String

Specifies whether to accept or reject the OBS permissions or object.

Action

Array of strings

Specifies OBS access permissions.

Resource

Array of strings

Specifies the OBS object.

Example Requests

Querying VPC endpoints

GET https://{endpoint}/v1/{project_id}/vpc-endpoints?endpoint_service_name={endpoint_service_name}&vpc_id={vpc_id}&limit={limit}&offset={offset}&id={id}&sort_key={sort_key}&sort_dir={sort_dir}

Example Responses

Status code: 200

The server has successfully processed the request.

{
  "endpoints" : [ {
    "id" : "03184a04-95d5-4555-86c4-e767a371ff99",
    "status" : "accepted",
    "ip" : "192.168.0.232",
    "marker_id" : 16777337,
    "active_status" : "active",
    "vpc_id" : "84758cf5-9c62-43ae-a778-3dbd8370c0a4",
    "service_type" : "interface",
    "project_id" : "295dacf46a4842fcbf7844dc2dc2489d",
    "subnet_id" : "68bfbcc1-dff2-47e4-a9d4-332b9bc1b8de",
    "enable_dns" : "true",
    "dns_names" : [ "test123" ],
    "created_at" : "2018-10-18T06:49:46Z",
    "updated_at" : "2018-10-18T06:49:50Z",
    "endpoint_service_id" : "5133655d-0e28-4090-b669-13f87b355c78",
    "endpoint_service_name" : "test123",
    "endpoint_pool_id" : "ee38223b-aacb-46f0-ba7e-94fa62e35dde",
    "public_border_group" : "br-abc-aaa1",
    "whitelist" : [ "127.0.0.1" ],
    "enable_whitelist" : true
  }, {
    "id" : "43b0e3b0-eec9-49da-866b-6687b75f9fe5",
    "status" : "accepted",
    "ip" : "192.168.0.115",
    "marker_id" : 16777322,
    "active_status" : "active",
    "vpc_id" : "e251b400-2963-4131-b38a-da81e32026ee",
    "service_type" : "interface",
    "project_id" : "295dacf46a4842fcbf7844dc2dc2489d",
    "subnet_id" : "65528a22-59a1-4972-ba64-88984b3207cd",
    "enable_dns" : "true",
    "dns_names" : [ "test123" ],
    "created_at" : "2018-10-18T06:36:20Z",
    "updated_at" : "2018-10-18T06:36:24Z",
    "endpoint_service_id" : "5133655d-0e28-4090-b669-13f87b355c78",
    "endpoint_service_name" : "test123",
    "endpoint_pool_id" : "ee38223b-aacb-46f0-ba7e-94fa62e35dde",
    "whitelist" : [ "127.0.0.1" ],
    "enable_whitelist" : true
  } ],
  "total_count" : 2
}

SDK Sample Code

The SDK sample code is as follows.

 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
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.vpcep.v1.region.VpcepRegion;
import com.huaweicloud.sdk.vpcep.v1.*;
import com.huaweicloud.sdk.vpcep.v1.model.*;


public class ListEndpointsSolution {

    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);

        VpcepClient client = VpcepClient.newBuilder()
                .withCredential(auth)
                .withRegion(VpcepRegion.valueOf("<YOUR REGION>"))
                .build();
        ListEndpointsRequest request = new ListEndpointsRequest();
        request.withEndpointServiceName("<endpoint_service_name>");
        request.withVpcId("<vpc_id>");
        request.withId("<id>");
        request.withLimit(<limit>);
        request.withOffset(<offset>);
        request.withSortKey(ListEndpointsRequest.SortKeyEnum.fromValue("<sort_key>"));
        request.withSortDir(ListEndpointsRequest.SortDirEnum.fromValue("<sort_dir>"));
        try {
            ListEndpointsResponse response = client.listEndpoints(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());
        }
    }
}
 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
# coding: utf-8

from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkvpcep.v1.region.vpcep_region import VpcepRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkvpcep.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 = __import__('os').getenv("CLOUD_SDK_AK")
    sk = __import__('os').getenv("CLOUD_SDK_SK")

    credentials = BasicCredentials(ak, sk) \

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

    try:
        request = ListEndpointsRequest()
        request.endpoint_service_name = "<endpoint_service_name>"
        request.vpc_id = "<vpc_id>"
        request.id = "<id>"
        request.limit = <limit>
        request.offset = <offset>
        request.sort_key = "<sort_key>"
        request.sort_dir = "<sort_dir>"
        response = client.list_endpoints(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
 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
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    vpcep "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/vpcep/v1"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/vpcep/v1/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/vpcep/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 := vpcep.NewVpcepClient(
        vpcep.VpcepClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.ListEndpointsRequest{}
	endpointServiceNameRequest:= "<endpoint_service_name>"
	request.EndpointServiceName = &endpointServiceNameRequest
	vpcIdRequest:= "<vpc_id>"
	request.VpcId = &vpcIdRequest
	idRequest:= "<id>"
	request.Id = &idRequest
	limitRequest:= int32(<limit>)
	request.Limit = &limitRequest
	offsetRequest:= int32(<offset>)
	request.Offset = &offsetRequest
	sortKeyRequest:= model.GetListEndpointsRequestSortKeyEnum().<SORT_KEY>
	request.SortKey = &sortKeyRequest
	sortDirRequest:= model.GetListEndpointsRequestSortDirEnum().<SORT_DIR>
	request.SortDir = &sortDirRequest
	response, err := client.ListEndpoints(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 server has successfully processed the request.

Error Codes

See Error Codes.