Replaces backend servers in a server group.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes ReplaceServersInServerGroup

The operation that you want to perform. Set the value to ReplaceServersInServerGroup.

ServerGroupId String Yes sgp-5114d593o96qxy****

The ID of the server group.

Note You cannot perform this operation on a server group of the Function type.
AddedServers Array Yes

The list of backend servers that you want to add. You can add at most 40 backend servers.

Description String No test

The description of the backend server. The description must be 2 to 256 characters in length and can contain letters, digits, periods (.), underscores (_), hyphens (-), commas (,), semicolons (;), forward slashes (/), and at signs (@).

Port Integer Yes 80

The port used by the server group. Valid values: 1 to 65535.

ServerId String Yes i-bp1f9kdprbgy9uiu****

The ID of the backend server.

  • If the server group type is Instance, set the ServerId parameter to the ID of an Elastic Compute Service (ECS) instance, an elastic network interface (ENI), or an elastic container instance. These backend servers are specified by Ecs, Eni, or Eci.
  • If the server group type is Ip, set the ServerId parameter to an IP address specified in the server group.
Note You cannot perform this operation on a server group of the Function type. You can call the ListServerGroups operation to query information about the server group so that you can set ServerId to a proper value.
ServerIp String No 192.168.1.1

The IP address in inclusive ENI mode.

ServerType String Yes Ecs

The type of the backend server. Valid values:

  • Ecs: an ECS instance
  • Eni: an ENI
  • Eci: an elastic container instance
Weight Integer No 100

The weight of the backend server.

Valid values: 0 to 100. Default value: 100. If the weight of a backend server is set to 0, no requests are forwarded to the backend server.

RemovedServers Array Yes

The backend servers that you want to remove.

ServerId String Yes ecs-bp1ac9uozods2uc****

The ID of the backend server.

  • If the server group type is Instance, set the ServerId parameter to the ID of an ECS instance, an ENI, or an elastic container instance. These backend servers are specified by Ecs, Eni, or Eci.
  • If the server group type is Ip, set the ServerId parameter to an IP address specified in the server group.
Note You cannot perform this operation on a server group of the Function type. You can call the ListServerGroups operation to query information about the server group so that you can set ServerId to a proper value.
ServerIp String No 192.168.1.12

The IP address in inclusive ENI mode.

ServerType String Yes ecs

The type of the backend server. Valid values:

  • Ecs: an ECS instance
  • Eni: an ENI
  • Eci: an elastic container instance
Port Integer Yes 81

The port used by the backend server. Valid values: 1 to 65535.

ClientToken String No 593B0448-D13E-4C56-AC0D-FDF0FDE0E9A3

The client token that is used to ensure the idempotence of the request.

You can use the client to generate the value, but you must make sure that the value is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length.

Note If you do not set this parameter, the system automatically uses RequestId as ClientToken. RequestId may be different for each API request.
DryRun Boolean No true

Specifies whether only to precheck the request. Valid values:

  • true: prechecks the request without creating the resource. The system prechecks the required parameters, request syntax, and limits. If the request fails to pass the precheck, an error message is returned. If the request passes the precheck, the DryRunOperation error code is returned.
  • false: prechecks the request. If the request passes the precheck, the system returns an HTTP 2xx status code and performs the operation. This is the default value.

Response parameters

Parameter Type Example Description
JobId String 72dcd26b-f12d-4c27-b3af-18f6aed5****

The ID of the asynchronous task.

RequestId String 365F4154-92F6-4AE4-92F8-7FF34B540710

The ID of the request.

Examples

Sample requests

http(s)://[Endpoint]/?Action=ReplaceServersInServerGroup
&ServerGroupId=sgp-5114d593o96qxy****
&AddedServers=[{"Description":"test","Port":80,"ServerId":"i-bp1f9kdprbgy9uiu****","ServerIp":"192.168.1.1","ServerType":"Ecs","Weight":100}]
&RemovedServers=[{"ServerId":"ecs-bp1ac9uozods2uc****","ServerIp":"192.168.1.12","ServerType":"ecs","Port":81}]
&ClientToken=593B0448-D13E-4C56-AC0D-FDF0FDE0E9A3
&DryRun=true
&Common request parameters

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<ReplaceServersInServerGroupResponse>
    <JobId>72dcd26b-f12d-4c27-b3af-18f6aed5****</JobId>
    <RequestId>365F4154-92F6-4AE4-92F8-7FF34B540710</RequestId>
</ReplaceServersInServerGroupResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "JobId" : "72dcd26b-f12d-4c27-b3af-18f6aed5****",
  "RequestId" : "365F4154-92F6-4AE4-92F8-7FF34B540710"
}

Error codes

HttpCode Error code Error message Description
400 ResourceQuotaExceeded.ServerAddedNum The quota of %s is exceeded for resource %s, usage %s/%s. The error message returned because the quota %s of the specified resource %s is exhausted. The current usage is %s.
400 IncorrectStatus.ServerGroup The status of %s [%s] is incorrect. The error message returned because the server group is in a state that does not support the operation.
400 Conflict.BackendServer There is already %s having the same configuration with %s. The error message returned because an existing %s has the same configuration.
404 ResourceNotFound.ServerGroup The specified resource %s is not found. The error message returned because the specified resource %s does not exist.
404 ResourceNotFound.Ecs The specified resource %s is not found. The error message returned because the specified resource %s does not exist.
404 ResourceNotFound.Eci The specified resource %s is not found. The error message returned because the specified resource %s does not exist.
404 ResourceNotFound.Eni The specified resource %s is not found. The error message returned because the specified resource %s does not exist.
404 ResourceNotFound.BackendServer The specified resource %s is not found. The error message returned because the specified resource %s does not exist.

For a list of error codes, visit the API Error Center.