Updated on 2024-08-06 GMT+08:00

Updating a VPC Channel

Function

This API is used to update the parameters of a VPC channel.

If the VPC channel is overwritten with an empty backend instance list, all the existing backend instances will be deleted.

If the VPC channel is overwritten with an empty backend server group list, all the existing backend server groups will be deleted.

Calling Method

For details, see Calling APIs.

URI

PUT /v2/{project_id}/apigw/instances/{instance_id}/vpc-channels/{vpc_channel_id}

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain it, see Obtaining a Project ID.

instance_id

Yes

String

Gateway ID, which can be obtained from the gateway information on the APIG console.

vpc_channel_id

Yes

String

VPC channel ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token. It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is a token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

name

Yes

String

VPC channel name.

It can contain 3 to 64 characters, starting with a letter. Only letters, digits, hyphens (-), underscores (_), and periods (.) are allowed.

port

Yes

Integer

Host port of the VPC channel.

Range: 1–65535.

balance_strategy

Yes

Integer

Distribution algorithm.

  • 1: Weighted round robin (WRR).

  • 2: Weighted least connections (WLC).

  • 3: Source hashing.

  • 4: URI hashing.

Default: 1

Enumeration values:

  • 1

  • 2

  • 3

  • 4

member_type

Yes

String

Member type of the VPC channel.

  • ip

  • ecs

Default: ecs

Enumeration values:

  • ip

  • ecs

type

No

Integer

VPC channel type. The default type is server.

  • 2: Server type.

  • 3: Microservice type.

Default: 2

Enumeration values:

  • 2

  • 3

dict_code

No

String

Dictionary code of the VPC channel.

The value can contain letters, digits, hyphens (-), underscores (_), and periods (.).

This parameter is currently not supported.

Minimum: 3

Maximum: 64

member_groups

No

Array of MemberGroupCreate objects

Backend server groups of the VPC channel.

members

No

Array of MemberInfo objects

Backend instances of the VPC channel.

vpc_health_config

No

VpcHealthConfig object

Health check details.

microservice_info

No

MicroServiceCreate object

Microservice details.

Table 4 MemberGroupCreate

Parameter

Mandatory

Type

Description

member_group_name

Yes

String

Name of the VPC channel's backend server group. It can contain 3 to 64 characters, starting with a letter. Only letters, digits, underscores (_), hyphens (-), and periods (.) are allowed.

member_group_remark

No

String

Description of the backend server group.

Maximum: 255

member_group_weight

No

Integer

Weight of the backend server group.

If the server group contains servers and a weight has been set for it, the weight is automatically used to assign weights to servers in this group.

Minimum: 0

Maximum: 100

dict_code

No

String

Dictionary code of the backend server group.

The value can contain letters, digits, hyphens (-), underscores (_), and periods (.).

Currently, this parameter is not supported.

Minimum: 3

Maximum: 64

microservice_version

No

String

Version of the backend server group. This parameter is supported only when the VPC channel type is microservice.

Maximum: 64

microservice_port

No

Integer

Port of the backend server group. This parameter is supported only when the VPC channel type is microservice. If the port number is 0, all addresses in the backend server group use the original load balancing port to inherit logic.

Minimum: 0

Maximum: 65535

microservice_labels

No

Array of MicroserviceLabel objects

Tags of the backend server group. This parameter is supported only when the VPC channel type is microservice.

Table 5 MicroserviceLabel

Parameter

Mandatory

Type

Description

label_name

Yes

String

Tag name.

Start and end with a letter or digit. Use only letters, digits, hyphens (-), underscores (_), and periods (.). (Max. 63 characters.)

Minimum: 1

Maximum: 63

label_value

Yes

String

Tag value.

Start and end with a letter or digit. Use only letters, digits, hyphens (-), underscores (_), and periods (.). (Max. 63 characters.)

Minimum: 1

Maximum: 63

Table 6 MemberInfo

Parameter

Mandatory

Type

Description

host

No

String

Backend server address.

This parameter is required when the member type is IP address.

Maximum: 64

weight

No

Integer

Weight.

The higher the weight is, the more requests a backend service will receive.

Minimum: 0

Maximum: 10000

is_backup

No

Boolean

Indicates whether the backend service is a standby node.

After you enable this function, the backend service serves as a standby node. It works only when all non-standby nodes are faulty.

This function is supported only when your gateway has been upgraded to the corresponding version. If your gateway does not support this function, contact technical support.

Default: false

member_group_name

No

String

Backend server group name. The server group facilitates backend service address modification.

status

No

Integer

Backend server status.

  • 1: available

  • 2: unavailable

Enumeration values:

  • 1

  • 2

port

No

Integer

Backend server port.

Minimum: 0

Maximum: 65535

ecs_id

No

String

Backend server ID.

This parameter is required if the backend instance type is ecs. The value can contain 1 to 64 characters, including letters, digits, hyphens (-), and underscores (_).

Maximum: 255

ecs_name

No

String

Backend server name.

This parameter is required if the backend instance type is ecs. The value can contain 1 to 64 characters, including letters, digits, hyphens (-), underscores (_), and periods (.).

Maximum: 64

Table 7 VpcHealthConfig

Parameter

Mandatory

Type

Description

protocol

Yes

String

Protocol for performing health checks on backend servers in the VPC channel.

  • TCP

  • HTTP

  • HTTPS

Enumeration values:

  • TCP

  • HTTP

  • HTTPS

path

No

String

Destination path for health checks. This parameter is required if protocol is set to http or https.

method

No

String

Request method for health checks.

Default: GET

Enumeration values:

  • GET

  • HEAD

port

No

Integer

Destination port for health checks. If this parameter is not specified or set to 0, the host port of the VPC channel is used.

If this parameter is set to a non-zero value, the corresponding port is used for health checks.

Minimum: 0

Maximum: 65535

threshold_normal

Yes

Integer

Healthy threshold. It refers to the number of consecutive successful checks required for a backend server to be considered healthy.

Minimum: 1

Maximum: 10

threshold_abnormal

Yes

Integer

Unhealthy threshold, which refers to the number of consecutive failed checks required for a backend server to be considered unhealthy.

Minimum: 1

Maximum: 10

time_interval

Yes

Integer

Interval between consecutive checks. Unit: s. The value must be greater than the value of timeout.

Minimum: 1

Maximum: 300

http_code

No

String

Response codes for determining a successful HTTP response. The value can be any integer within 100–599 in one of the following formats:

  • Multiple values, for example, 200,201,202

  • Range, for example, 200-299

  • Multiple values and ranges, for example, 201,202,210-299. This parameter is required if protocol is set to http.

enable_client_ssl

No

Boolean

Indicates whether to enable two-way authentication. If this function is enabled, the certificate specified in the backend_client_certificate configuration item of the gateway is used.

Default: false

status

No

Integer

Health check result.

  • 1: available

  • 2: unavailable

Enumeration values:

  • 1

  • 2

timeout

Yes

Integer

Timeout for determining whether a health check fails. Unit: s. The value must be less than the value of time_interval.

Minimum: 1

Maximum: 30

Table 8 MicroServiceCreate

Parameter

Mandatory

Type

Description

service_type

No

String

Microservice type. Options:

  • CSE: CSE microservice registration center

  • CCE: CCE workload

  • CCE_SERVICE: CCE Service

Enumeration values:

  • CSE

  • CCE

  • CCE_SERVICE

cse_info

No

MicroServiceInfoCSEBase object

CSE microservice details. This parameter is required if service_type is set to CSE.

cce_info

No

MicroServiceInfoCCEBase object

CCE workload details. This parameter is required if service_type is set to CCE. Either app_name or any of label_key and label_value must be set. If only app_name is set, label_key='app' and label_value=app_name.

cce_service_info

No

MicroServiceInfoCCEServiceBase object

CCE Service details.

Table 9 MicroServiceInfoCSEBase

Parameter

Mandatory

Type

Description

engine_id

Yes

String

Microservice engine ID.

Maximum: 64

service_id

Yes

String

Microservice ID.

Maximum: 64

Table 10 MicroServiceInfoCCEBase

Parameter

Mandatory

Type

Description

cluster_id

Yes

String

CCE cluster ID.

Maximum: 64

namespace

Yes

String

Namespace.

Maximum: 64

workload_type

Yes

String

Workload type.

  • deployment

  • statefulset

  • daemonset

Enumeration values:

  • deployment

  • statefulset

  • daemonset

app_name

No

String

App name. Start with a letter, and include only letters, digits, periods (.), hyphens (-), and underscores (_). (1 to 64 characters)

Minimum: 1

Maximum: 64

label_key

No

String

Service label key. Start with a letter or digit, and use only letters, digits, and these special characters: -_./:(). (1 to 64 characters)

Minimum: 1

Maximum: 64

label_value

No

String

Service label value. Start with a letter, and include only letters, digits, periods (.), hyphens (-), and underscores (_). (1 to 64 characters)

Minimum: 1

Maximum: 64

Table 11 MicroServiceInfoCCEServiceBase

Parameter

Mandatory

Type

Description

cluster_id

Yes

String

CCE cluster ID.

Maximum: 64

namespace

Yes

String

Namespace. 1 to 63 characters. Use lowercase letters, digits, and hyphens (-). Start with a letter and end with a letter or digit.

Minimum: 1

Maximum: 63

service_name

Yes

String

Service name. Start with a letter, and use only letters, digits, periods (.), hyphens (-), and underscores (_). (1 to 64 characters)

Minimum: 1

Maximum: 64

Response Parameters

Status code: 200

Table 12 Response body parameters

Parameter

Type

Description

name

String

VPC channel name.

It can contain 3 to 64 characters, starting with a letter. Only letters, digits, hyphens (-), underscores (_), and periods (.) are allowed.

port

Integer

Host port of the VPC channel.

Range: 1–65535.

balance_strategy

Integer

Distribution algorithm.

  • 1: Weighted round robin (WRR).

  • 2: Weighted least connections (WLC).

  • 3: Source hashing.

  • 4: URI hashing.

Default: 1

Enumeration values:

  • 1

  • 2

  • 3

  • 4

member_type

String

Member type of the VPC channel.

  • ip

  • ecs

Default: ecs

Enumeration values:

  • ip

  • ecs

type

Integer

VPC channel type. The default type is server.

  • 2: Server type.

  • 3: Microservice type.

Default: 2

Enumeration values:

  • 2

  • 3

dict_code

String

Dictionary code of the VPC channel.

The value can contain letters, digits, hyphens (-), underscores (_), and periods (.).

This parameter is currently not supported.

Minimum: 3

Maximum: 64

create_time

String

Time when the VPC channel is created.

id

String

VPC channel ID.

status

Integer

VPC channel status.

  • 1: normal

  • 2: abnormal

Enumeration values:

  • 1

  • 2

member_groups

Array of MemberGroupInfo objects

Backend server groups.

microservice_info

MicroServiceInfo object

Microservice information.

Table 13 MemberGroupInfo

Parameter

Type

Description

member_group_name

String

Name of the VPC channel's backend server group. It can contain 3 to 64 characters, starting with a letter. Only letters, digits, underscores (_), hyphens (-), and periods (.) are allowed.

member_group_remark

String

Description of the backend server group.

Maximum: 255

member_group_weight

Integer

Weight of the backend server group.

If the server group contains servers and a weight has been set for it, the weight is automatically used to assign weights to servers in this group.

Minimum: 0

Maximum: 100

dict_code

String

Dictionary code of the backend server group.

The value can contain letters, digits, hyphens (-), underscores (_), and periods (.).

Currently, this parameter is not supported.

Minimum: 3

Maximum: 64

microservice_version

String

Version of the backend server group. This parameter is supported only when the VPC channel type is microservice.

Maximum: 64

microservice_port

Integer

Port of the backend server group. This parameter is supported only when the VPC channel type is microservice. If the port number is 0, all addresses in the backend server group use the original load balancing port to inherit logic.

Minimum: 0

Maximum: 65535

microservice_labels

Array of MicroserviceLabel objects

Tags of the backend server group. This parameter is supported only when the VPC channel type is microservice.

member_group_id

String

ID of the backend server group of the VPC channel.

create_time

String

Time when the backend server group is created.

update_time

String

Time when the backend server group is updated.

Table 14 MicroserviceLabel

Parameter

Type

Description

label_name

String

Tag name.

Start and end with a letter or digit. Use only letters, digits, hyphens (-), underscores (_), and periods (.). (Max. 63 characters.)

Minimum: 1

Maximum: 63

label_value

String

Tag value.

Start and end with a letter or digit. Use only letters, digits, hyphens (-), underscores (_), and periods (.). (Max. 63 characters.)

Minimum: 1

Maximum: 63

Table 15 MicroServiceInfo

Parameter

Type

Description

id

String

Microservice ID.

instance_id

String

Gateway ID.

service_type

String

Microservice type. Options:

  • CSE: CSE microservice registration center

  • CCE: CCE workload

  • CCE_SERVICE: CCE Service

Enumeration values:

  • CSE

  • CCE

  • CCE_SERVICE

cse_info

MicroServiceInfoCSE object

CSE microservice details.

cce_info

MicroServiceInfoCCE object

CCE microservice workload details.

cce_service_info

MicroServiceInfoCCEService object

CCE microservice Service details.

update_time

String

Microservice update time.

create_time

String

Microservice creation time.

Table 16 MicroServiceInfoCSE

Parameter

Type

Description

engine_id

String

Microservice engine ID.

Maximum: 64

service_id

String

Microservice ID.

Maximum: 64

engine_name

String

Microservice engine name.

service_name

String

Microservice name.

register_address

String

Registration center address.

cse_app_id

String

App to which the microservice belongs.

version

String

Microservice version, which has been discarded and is reflected in the version of the backend server group.

Maximum: 64

Table 17 MicroServiceInfoCCE

Parameter

Type

Description

cluster_id

String

CCE cluster ID.

Maximum: 64

namespace

String

Namespace.

Maximum: 64

workload_type

String

Workload type.

  • deployment

  • statefulset

  • daemonset

Enumeration values:

  • deployment

  • statefulset

  • daemonset

app_name

String

App name. Start with a letter, and include only letters, digits, periods (.), hyphens (-), and underscores (_). (1 to 64 characters)

Minimum: 1

Maximum: 64

label_key

String

Service label key. Start with a letter or digit, and use only letters, digits, and these special characters: -_./:(). (1 to 64 characters)

Minimum: 1

Maximum: 64

label_value

String

Service label value. Start with a letter, and include only letters, digits, periods (.), hyphens (-), and underscores (_). (1 to 64 characters)

Minimum: 1

Maximum: 64

cluster_name

String

CCE cluster name.

Table 18 MicroServiceInfoCCEService

Parameter

Type

Description

cluster_id

String

CCE cluster ID.

Maximum: 64

namespace

String

Namespace. 1 to 63 characters. Use lowercase letters, digits, and hyphens (-). Start with a letter and end with a letter or digit.

Minimum: 1

Maximum: 63

service_name

String

Service name. Start with a letter, and use only letters, digits, periods (.), hyphens (-), and underscores (_). (1 to 64 characters)

Minimum: 1

Maximum: 64

cluster_name

String

CCE cluster name.

Status code: 400

Table 19 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 401

Table 20 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 403

Table 21 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 404

Table 22 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 500

Table 23 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Example Requests

  • Updating a VPC channel of the server type

    {
      "balance_strategy" : 2,
      "member_type" : "ip",
      "name" : "VPC_demo",
      "port" : 22,
      "type" : 2,
      "vpc_health_config" : {
        "http_code" : "200",
        "path" : "/vpc/demo",
        "port" : 22,
        "protocol" : "http",
        "threshold_abnormal" : 5,
        "threshold_normal" : 2,
        "time_interval" : 10,
        "timeout" : 5,
        "enable_client_ssl" : false
      },
      "member_groups" : [ {
        "member_group_name" : "test",
        "member_group_weight" : 1,
        "member_group_remark" : "remark"
      }, {
        "member_group_name" : "default",
        "member_group_weight" : 2,
        "member_group_remark" : "remark"
      } ],
      "members" : [ {
        "host" : "192.168.0.5",
        "weight" : 1,
        "member_group_name" : "test"
      }, {
        "host" : "192.168.1.124",
        "weight" : 2,
        "member_group_name" : "default"
      } ]
    }
  • Updating a VPC channel of the microservice type

    {
      "balance_strategy" : 1,
      "member_type" : "ip",
      "name" : "VPC_demo",
      "port" : 22,
      "type" : 3,
      "vpc_health_config" : {
        "http_code" : "200",
        "path" : "/vpc/demo",
        "port" : 22,
        "protocol" : "http",
        "threshold_abnormal" : 5,
        "threshold_normal" : 2,
        "time_interval" : 10,
        "timeout" : 5,
        "enable_client_ssl" : false
      },
      "member_groups" : [ {
        "member_group_name" : "test",
        "member_group_weight" : 1,
        "member_group_remark" : "remark",
        "microservice_version" : "v1",
        "microservice_port" : 80
      }, {
        "member_group_name" : "default",
        "member_group_weight" : 2,
        "member_group_remark" : "remark",
        "microservice_version" : "v2",
        "microservice_port" : 80,
        "microservice_labels" : [ {
          "label_name" : "cluster_id",
          "label_value" : "c429700c-5dc4-482a-9c0e-99f6c0635113"
        } ]
      } ],
      "members" : [ {
        "host" : "192.168.0.5",
        "weight" : 1,
        "member_group_name" : "test"
      }, {
        "host" : "192.168.1.124",
        "weight" : 2,
        "member_group_name" : "default"
      } ],
      "microservice_info" : {
        "service_type" : "CCE",
        "cce_info" : {
          "cluster_id" : "ab1485b4f91b45abbcd560be591f7309",
          "namespace" : "default",
          "workload_type" : "deployment",
          "app_name" : "testapp"
        }
      }
    }

Example Responses

Status code: 200

OK

  • Example 1

    {
      "name" : "VPC_demo",
      "port" : 22,
      "balance_strategy" : 2,
      "member_type" : "ip",
      "dict_code" : "",
      "create_time" : "2020-07-23T07:11:57Z",
      "id" : "18174f5f4f1a4dc29f33aeadd9788e5f",
      "status" : 1,
      "member_groups" : [ {
        "member_group_id" : "c1ce135c705c4066853a0460b318fe16",
        "member_group_name" : "test",
        "member_group_weight" : 1,
        "member_group_remark" : "remark",
        "create_time" : "2020-07-23T07:11:57.244829604Z",
        "update_time" : "2020-07-23T07:11:57.244829604Z"
      }, {
        "member_group_id" : "c1ce135c705c4066853a0460b318fe17",
        "member_group_name" : "default",
        "member_group_weight" : 2,
        "member_group_remark" : "remark",
        "create_time" : "2020-07-23T07:11:57.244829604Z",
        "update_time" : "2020-07-23T07:11:57.244829604Z"
      } ],
      "type" : 2,
      "microservice_info" : {
        "id" : "",
        "instance_id" : "",
        "service_type" : "",
        "cse_info" : {
          "cse_app_id" : "",
          "engine_id" : "",
          "engine_name" : "",
          "register_address" : "",
          "service_id" : "",
          "service_name" : ""
        },
        "cce_info" : {
          "cluster_id" : "",
          "cluster_name" : "",
          "namespace" : "",
          "workload_type" : "",
          "app_name" : ""
        },
        "create_time" : "",
        "update_time" : ""
      }
    }
  • Example 2

    {
      "name" : "VPC_demo",
      "id" : "105c6902457144a4820dff8b1ad63331",
      "balance_strategy" : 1,
      "dict_code" : "",
      "create_time" : "2020-07-23T07:11:57.244829604Z",
      "member_type" : "ip",
      "port" : 22,
      "status" : 1,
      "member_groups" : [ {
        "member_group_id" : "c1ce135c705c4066853a0460b318fe16",
        "member_group_name" : "test",
        "member_group_weight" : 1,
        "member_group_remark" : "remark",
        "create_time" : "2020-07-23T07:11:57.244829604Z",
        "update_time" : "2020-07-23T07:11:57.244829604Z",
        "microservice_version" : "v1",
        "microservice_port" : 80
      }, {
        "member_group_id" : "c1ce135c705c4066853a0460b318fe17",
        "member_group_name" : "default",
        "member_group_weight" : 2,
        "member_group_remark" : "remark",
        "create_time" : "2020-07-23T07:11:57.244829604Z",
        "update_time" : "2020-07-23T07:11:57.244829604Z",
        "microservice_version" : "v2",
        "microservice_port" : 80,
        "microservice_labels" : [ {
          "label_name" : "cluster_id",
          "label_value" : "c429700c-5dc4-482a-9c0e-99f6c0635113"
        } ]
      } ],
      "type" : 3,
      "microservice_info" : {
        "id" : "9483afa235be45158a70c19ab817ac65",
        "instance_id" : "eddc4d25480b4cd6b512f270a1b8b341",
        "service_type" : "CCE",
        "cse_info" : {
          "cse_app_id" : "",
          "engine_id" : "",
          "engine_name" : "",
          "register_address" : "",
          "service_id" : "",
          "service_name" : ""
        },
        "cce_info" : {
          "cluster_id" : "ab1485b4f91b45abbcd560be591f7309",
          "cluster_name" : "cce-test",
          "namespace" : "default",
          "workload_type" : "deployment",
          "app_name" : "testapp"
        },
        "create_time" : "2020-07-23T07:11:57.244829604Z",
        "update_time" : "2020-07-23T07:11:57.244829604Z"
      }
    }

Status code: 400

Bad Request

{
  "error_code" : "APIG.2001",
  "error_msg" : "The request parameters must be specified, parameter name:members"
}

Status code: 401

Unauthorized

{
  "error_code" : "APIG.1002",
  "error_msg" : "Incorrect token or token resolution failed"
}

Status code: 403

Forbidden

{
  "error_code" : "APIG.1005",
  "error_msg" : "No permissions to request this method"
}

Status code: 404

Not Found

{
  "error_code" : "APIG.3023",
  "error_msg" : "The VPC channel does not exist,id:56a7d7358e1b42459c9d730d65b14e59"
}

Status code: 500

Internal Server Error

{
  "error_code" : "APIG.9999",
  "error_msg" : "System error"
}

Status Codes

Status Code

Description

200

OK

400

Bad Request

401

Unauthorized

403

Forbidden

404

Not Found

500

Internal Server Error

Error Codes

See Error Codes.