Updated on 2022-08-15 GMT+08:00

Updating a VPC Channel

Function

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

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 a project ID, see "Appendix" > "Obtaining a Project ID" in this document.

instance_id

Yes

String

Gateway ID.

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 (-), and underscores (_) are allowed.

port

No

Integer

Host port of the VPC channel.

This parameter is valid only when the VPC channel type is set to 2. The value range is 1–65535.

This parameter is required only when the VPC channel type is set to 2.

balance_strategy

No

Integer

Distribution algorithm.

  • 1: WRR

  • 2: WLC

  • 3: SH

  • 4: URI hashing

This parameter is required only when the VPC channel type is set to 2.

Default: 1

Enumeration values:

  • 1

  • 2

  • 3

  • 4

member_type

No

String

Member type of the VPC channel.

  • ip

  • ecs

This parameter is required only when the VPC channel type is set to 2.

Default: ecs

Enumeration values:

  • ip

  • ecs

members

Yes

Array of MemberInfo objects

Backend server list. Only one backend server is included if the VPC channel type is set to 1.

vpc_health_config

Yes

VpcHealthConfig object

Table 4 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. Select a server group for the backend service address.

Currently, this parameter is not supported.

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 valid when the member type is instance. The value can contain 1 to 64 characters, including letters, digits, hyphens (-), and underscores (_).

ecs_name

No

String

Backend server name.

This parameter is valid when the member type is instance. The value can contain 1 to 64 characters, including letters, digits, periods (.), hyphens (-), and underscores (_).

Table 5 VpcHealthConfig

Parameter

Mandatory

Type

Description

protocol

Yes

String

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

Enumeration values:

  • TCP

  • HTTP

  • HTTPS

path

No

String

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

method

No

String

Request method for health checks.

Default: GET

Enumeration values:

  • GET

  • HEAD

port

No

Integer

Destination port for health checks. By default, the host port of the VPC channel is used.

Minimum: 1

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

Maximum: 10

threshold_abnormal

Yes

Integer

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

Minimum: 2

Maximum: 10

time_interval

Yes

Integer

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

Minimum: 5

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

Maximum: 30

Response Parameters

Status code: 200

Table 6 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 (-), and underscores (_) are allowed.

port

Integer

Host port of the VPC channel.

This parameter is valid only when the VPC channel type is set to 2. The value range is 1–65535.

This parameter is required only when the VPC channel type is set to 2.

balance_strategy

Integer

Distribution algorithm.

  • 1: WRR

  • 2: WLC

  • 3: SH

  • 4: URI hashing

This parameter is required only when the VPC channel type is set to 2.

Default: 1

Enumeration values:

  • 1

  • 2

  • 3

  • 4

member_type

String

Member type of the VPC channel.

  • ip

  • ecs

This parameter is required only when the VPC channel type is set to 2.

Default: ecs

Enumeration values:

  • ip

  • ecs

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 cloud server groups.

Currently, this parameter is not supported.

Table 7 MemberGroupInfo

Parameter

Type

Description

member_group_name

String

Name of the backend server group of the VPC channel.

member_group_remark

String

Description of the backend server group.

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

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.

Status code: 400

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 401

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 403

Table 10 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 404

Table 11 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 500

Table 12 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Example Requests

{
  "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
  },
  "members" : [ {
    "host" : "192.168.0.5",
    "weight" : 1
  }, {
    "host" : "192.168.1.124",
    "weight" : 2
  } ]
}

Example Responses

Status code: 200

OK

{
  "balance_strategy" : 2,
  "create_time" : "2020-07-23T07:11:57Z",
  "member_type" : "ip",
  "port" : 22,
  "status" : 1,
  "name" : "VPC_demo",
  "type" : 2
}

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.