Help Center/ VPC Endpoint/ API Reference/ API/ VPC Endpoint Services/ Modifying a VPC Endpoint Service
Updated on 2024-09-11 GMT+08:00

Modifying a VPC Endpoint Service

Function

This API is used to modify a VPC endpoint service.

Calling Method

For details, see Calling APIs.

URI

PUT /v1/{project_id}/vpc-endpoint-services/{vpc_endpoint_service_id}

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID.

Minimum: 1

Maximum: 64

vpc_endpoint_service_id

Yes

String

Specifies the ID of the VPC endpoint service.

Minimum: 1

Maximum: 64

Request Parameters

Table 2 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

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

approval_enabled

No

Boolean

Specifies whether approval is required. ● false: No approval is required. The created VPC endpoint is in the accepted state by default. ● true: Approval is required. The created endpoint connection can be used only after being approved by the user of the VPC endpoint service. The default value is true.

Default: true

service_name

No

String

Specifies the name of the VPC endpoint service. The name can contain a maximum of 16 characters, including letters, digits, underscores (_), and hyphens (-).

Minimum: 0

Maximum: 16

ports

No

Array of PortList objects

Specifies the port mapping list of the service. Duplicate port mappings are not allowed in the same VPC endpoint service. If multiple VPC endpoint services share the same port ID, service ports and terminal ports of all these endpoint services cannot be duplicated when the protocol is the same. A maximum of 200 port mappings can be created at a time. The new value of this parameter will completely the existing one.

port_id

No

String

Specifies the ID of the NIC that ECS private IP address is bound to.

Minimum: 1

Maximum: 64

tcp_proxy

No

String

Specifies whether to transfer client information, such as source IP addresses, source port numbers, and marker IDs, to the server. The information can be sent to the server in the following ways:

  • TCP TOA: The client information is placed into the tcp option field and sent to the server. Note: TCP TOA is available only when the backend resource is an OBS resource.

  • Proxy Protocol: The client information is placed into the tcp payload field and sent to the server. tcp_proxy is available only when the server can parse the tcp option and tcp payload fields. The value can be one of the following:

  • close: Neither TCP TOA nor Proxy Protocol information is carried.

  • toa_open: TCP TOA information is carried.

  • proxy_open: Proxy Protocol information in carried.

  • open: Both TCP TOA and Proxy Protocol information are carried. The default value is close.

description

No

String

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

Minimum: 0

Maximum: 512

ip

No

String

Specifies the IPv4 address or domain name of the interface VPC endpoint in VLAN scenarios.

Table 4 PortList

Parameter

Mandatory

Type

Description

client_port

No

Integer

Specifies the port to be accessed by a VPC endpoint. This port is provided by the VPC endpoint, allowing you to access the VPC endpoint service. Supported range: 1 to 65535.

Minimum: 1

Maximum: 65535

Minimum: 1

Maximum: 65535

server_port

No

Integer

Specifies the port for accessing the VPC endpoint service. This port is associated with backend resources to provide VPC endpoint services. Supported range: 1 to 65535

Minimum: 1

Maximum: 65535

Minimum: 1

Maximum: 65535

protocol

No

String

Port mapping protocol. TCP is supported.

Default: TCP

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

id

String

Specifies the unique ID of the VPC endpoint service.

Minimum: 1

Maximum: 64

port_id

String

Specifies the ID that identifies the backend resource of the VPC endpoint service. The ID is in UUID format. The value can be:

  • LB: indicates the port ID of the private IP address of a load balancer (recommended).

  • VM: indicates the NIC ID of an ECS IP address.

  • VIP: indicates the NIC ID of the virtual server for which the virtual IP address is configured. (This value has been discarded. LB is recommended.)

Minimum: 1

Maximum: 64

service_name

String

Specifies the name of the VPC endpoint service.

Minimum: 0

Maximum: 128

server_type

String

Specifies the resource type.

  • VM: cloud server

  • VIP: virtual IP address

  • LB: enhanced load balancer

vpc_id

String

Specifies the ID of the VPC where the backend resource of the VPC endpoint service is located.

Minimum: 1

Maximum: 64

pool_id

String

Specifies the cluster ID of the VPC endpoint service.

approval_enabled

Boolean

Specifies whether connection approval is required.

  • false: Connection approval is not required. The created VPC endpoint is in the accepted state.

  • true: Connection approval is required. The created VPC endpoint is in the pendingAcceptance state, and it can be used only after being approved by the user of the VPC endpoint service.

status

String

Specifies the status of the VPC endpoint service.

  • creating: The VPC endpoint service is being created.

  • available: The VPC endpoint service is connectable.

  • failed: The VPC endpoint service failed to be created.

service_type

String

Specifies the type of the VPC endpoint service. There are two types of VPC endpoint services: interface and gateway.

  • 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 create VPC endpoints to connect to gateway and interface VPC endpoint services.

Minimum: 1

Maximum: 16

created_at

String

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

updated_at

String

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

project_id

String

Specifies the project ID.

Minimum: 1

Maximum: 64

ip

String

Specifies the IPv4 address or domain name of the interface VPC endpoint in VLAN scenarios.

ports

Array of PortList objects

Specifies the port mappings opened to the VPC endpoint service. Duplicate port mappings are not allowed in the same VPC endpoint service. If multiple VPC endpoint services share one port_id, either server_port or protocol, or both server_port and protocol of each of these endpoint services must be unique.

tcp_proxy

String

Specifies whether to transfer client information, such as source IP addresses, source port numbers, and marker IDs, to the server. The information can be sent to the server in the following ways:

  • TCP TOA: The client information is placed into the tcp option field and sent to the server. Note: TCP TOA is available only when the backend resource is an OBS resource.

  • Proxy Protocol: The client information is placed into the tcp payload field and sent to the server. tcp_proxy is available only when the server can parse the tcp option and tcp payload fields. The value can be one of the following:

  • close: Neither TCP TOA nor Proxy Protocol information is carried.

  • toa_open: TCP TOA information is carried.

  • proxy_open: Proxy Protocol information in carried.

  • open: Both TCP TOA and Proxy Protocol information are carried. The default value is close.

tags

Array of TagList objects

Specifies resource tags.

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

enable_policy

Boolean

Specifies whether the VPC endpoint policy can be customized.

  • false: The VPC endpoint policy cannot be customized.

  • true: The VPC endpoint policy can be customized. The default value is false.

ip_version

String

Specifies the IP version of the VPC endpoint service. Only professional VPC endpoint services support this parameter. ● ipv4: The IP address of the VPC endpoint service is an IPv4 address. ● ipv6: The IP address of the VPC endpoint service is an IPv6 address.

Table 6 PortList

Parameter

Type

Description

client_port

Integer

Specifies the port to be accessed by a VPC endpoint. This port is provided by the VPC endpoint, allowing you to access the VPC endpoint service. Supported range: 1 to 65535.

Minimum: 1

Maximum: 65535

Minimum: 1

Maximum: 65535

server_port

Integer

Specifies the port for accessing the VPC endpoint service. This port is associated with backend resources to provide VPC endpoint services. Supported range: 1 to 65535

Minimum: 1

Maximum: 65535

Minimum: 1

Maximum: 65535

protocol

String

Port mapping protocol. TCP is supported.

Default: TCP

Table 7 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: 128

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.

Maximum: 255

Example Requests

Modifying a VPC endpoint service (Setting approval_enabled to true, client_port to 8081 and 8082, and server_port to 22 and 23)

PUT https://{endpoint}/v1/{project_id}/vpc-endpoint-services/4189d3c2-8882-4871-a3c2- d380272eed88

{
  "approval_enabled" : true,
  "service_name" : "test",
  "ports" : [ {
    "client_port" : 8081,
    "server_port" : 22,
    "protocol" : "TCP"
  }, {
    "client_port" : 8082,
    "server_port" : 23,
    "protocol" : "TCP"
  } ]
}

Example Responses

Status code: 200

The server has successfully processed the request.

{
  "id" : "4189d3c2-8882-4871-a3c2-d380272eed83",
  "port_id" : "4189d3c2-8882-4871-a3c2-d380272eed88",
  "vpc_id" : "4189d3c2-8882-4871-a3c2-d380272eed80",
  "pool_id" : "5289d3c2-8882-4871-a3c2-d380272eed80",
  "status" : "available",
  "approval_enabled" : false,
  "service_name" : "test123",
  "service_type" : "interface",
  "server_type" : "VM",
  "project_id" : "6e9dfd51d1124e8d8498dce894923a0d",
  "created_at" : "2022-04-14T09:35:47Z",
  "ports" : [ {
    "client_port" : 8080,
    "server_port" : 90,
    "protocol" : "TCP"
  }, {
    "client_port" : 8081,
    "server_port" : 80,
    "protocol" : "TCP"
  } ],
  "tcp_proxy" : "proxy_open"
}

SDK Sample Code

The SDK sample code is as follows.

Modifying a VPC endpoint service (Setting approval_enabled to true, client_port to 8081 and 8082, and server_port to 22 and 23)

 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
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.*;

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

public class UpdateEndpointServiceSolution {

    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();
        UpdateEndpointServiceRequest request = new UpdateEndpointServiceRequest();
        UpdateEndpointServiceRequestBody body = new UpdateEndpointServiceRequestBody();
        List<PortList> listbodyPorts = new ArrayList<>();
        listbodyPorts.add(
            new PortList()
                .withClientPort(8081)
                .withServerPort(22)
                .withProtocol(PortList.ProtocolEnum.fromValue("TCP"))
        );
        listbodyPorts.add(
            new PortList()
                .withClientPort(8082)
                .withServerPort(23)
                .withProtocol(PortList.ProtocolEnum.fromValue("TCP"))
        );
        body.withPorts(listbodyPorts);
        body.withServiceName("test");
        body.withApprovalEnabled(true);
        request.withBody(body);
        try {
            UpdateEndpointServiceResponse response = client.updateEndpointService(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());
        }
    }
}

Modifying a VPC endpoint service (Setting approval_enabled to true, client_port to 8081 and 8082, and server_port to 22 and 23)

 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
# coding: utf-8

import os
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 = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]

    credentials = BasicCredentials(ak, sk)

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

    try:
        request = UpdateEndpointServiceRequest()
        listPortsbody = [
            PortList(
                client_port=8081,
                server_port=22,
                protocol="TCP"
            ),
            PortList(
                client_port=8082,
                server_port=23,
                protocol="TCP"
            )
        ]
        request.body = UpdateEndpointServiceRequestBody(
            ports=listPortsbody,
            service_name="test",
            approval_enabled=True
        )
        response = client.update_endpoint_service(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Modifying a VPC endpoint service (Setting approval_enabled to true, client_port to 8081 and 8082, and server_port to 22 and 23)

 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"
    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.UpdateEndpointServiceRequest{}
	clientPortPorts:= int32(8081)
	serverPortPorts:= int32(22)
	protocolPorts:= model.GetPortListProtocolEnum().TCP
	clientPortPorts1:= int32(8082)
	serverPortPorts1:= int32(23)
	protocolPorts1:= model.GetPortListProtocolEnum().TCP
	var listPortsbody = []model.PortList{
        {
            ClientPort: &clientPortPorts,
            ServerPort: &serverPortPorts,
            Protocol: &protocolPorts,
        },
        {
            ClientPort: &clientPortPorts1,
            ServerPort: &serverPortPorts1,
            Protocol: &protocolPorts1,
        },
    }
	serviceNameUpdateEndpointServiceRequestBody:= "test"
	approvalEnabledUpdateEndpointServiceRequestBody:= true
	request.Body = &model.UpdateEndpointServiceRequestBody{
		Ports: &listPortsbody,
		ServiceName: &serviceNameUpdateEndpointServiceRequestBody,
		ApprovalEnabled: &approvalEnabledUpdateEndpointServiceRequestBody,
	}
	response, err := client.UpdateEndpointService(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.