Updated on 2025-09-22 GMT+08:00

Updating a Backend Server Group

Function

This API is used to update a backend server group.

Constraints

The backend server group can be updated only when the provisioning status of the associated load balancer is ACTIVE.

Calling Method

For details, see Calling APIs.

URI

PUT /v3/{project_id}/elb/pools/{pool_id}

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

pool_id

Yes

String

Definition: Specifies the backend server group ID.

Constraints: N/A

Range: N/A

Default value: N/A

project_id

Yes

String

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

Constraints: N/A

Range: The value can contain a maximum of 32 characters, including digits and lowercase letters.

Default value: N/A

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition: Specifies the token used for IAM authentication.

Constraints: N/A

Range: N/A

Default value: N/A

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

pool

Yes

UpdatePoolOption object

Definition: Specifies the request parameters for updating a backend server group.

Constraints: N/A

Table 4 UpdatePoolOption

Parameter

Mandatory

Type

Description

admin_state_up

No

Boolean

Definition: Specifies the administrative status of the backend server group.

Constraints: The value can only be true.

Range: true (enabled)

Default value: N/A

description

No

String

Definition: Specifies supplementary information about the backend server group.

Constraints: N/A

Range: N/A

Default value: N/A

lb_algorithm

No

String

Definition: Specifies the load balancing algorithm used by the load balancer to route requests to backend servers in the associated backend server group.

Constraints:

  • If the value is SOURCE_IP or QUIC_CID, the weights of backend servers in the backend server group are invalid.

  • QUIC_CID is available only when the protocol of the backend server group is QUIC.

Range:

  • ROUND_ROBIN: weighted round robin

  • LEAST_CONNECTIONS: weighted least connections

  • SOURCE_IP: source IP hash

  • QUIC_CID: connection ID

Default value: N/A

name

No

String

Definition: Specifies the backend server group name.

Constraints: N/A

Range: N/A

Default value: N/A

session_persistence

No

UpdatePoolSessionPersistenceOption object

Definition: Specifies the sticky session.

Constraints: Slow start and sticky session cannot be enabled at the same time. If both are enabled, sticky session will be invalid.

slow_start

No

UpdatePoolSlowStartOption object

Definition: Specifies slow start details. After you enable slow start, new backend servers added to the backend server group are warmed up, and the number of requests they can receive increases linearly during the configured slow start duration.

Constraints:

  • This parameter is valid only when the backend server group protocol is HTTP, HTTPS, or GRPC. For other protocols, an error will be reported.

  • Slow start and sticky session cannot be enabled at the same time. If both are enabled, sticky session will be invalid.

member_deletion_protection_enable

No

Boolean

Definition: Whether to enable removal protection for the backend server. Once the option is enabled, backend servers cannot be removed from the backend server group.

Constraints:

Once the option is enabled, an error will be returned when the following APIs are called to:

  • Delete a load balancer and its associated resources (DELETE /v3/{project_id}/elb/loadbalancers/{loadbalancer_id}/force-elb).

  • Delete a load balancer and its associated EIPs (POST /v3/{project_id}/elb/loadbalancers/{loadbalancer_id}/delete-cascade).

  • Delete a listener and its associated resources (DELETE /v3/{project_id}/elb/listeners/{listener_id}/force).

  • Delete a backend server group and its associated resources (DELETE /v3/{project_id}/elb/pools/{pool_id}/delete-cascade).

  • Remove a backend server (DELETE /v3/{project_id}/elb/pools/{pool_id}/members/{member_id}).

  • Remove backend servers in batches (POST /v3/{project_id}/elb/pools/{pool_id}/members/batch-delete).

Range: false (disable this option) or true (enable this option).

Default value: false

NOTE:
Disable deletion protection or removal protection for your resources before deregistering your account.

vpc_id

No

String

Definition: Specifies the ID of the VPC where the backend server group works.

Constraints: This parameter can be updated only when vpc_id is left blank.

Range: N/A

Default value: N/A

type

No

String

Definition: Specifies the type of the backend server group.

Constraints:

  • This parameter can be updated only when type is left blank.

  • instance: Any type of backend servers can be added. vpc_id is mandatory.

  • ip: Only IP as backend servers can be added. vpc_id cannot be specified.

  • "": Any type of backend servers can be added.

Range: N/A

Default value: N/A

protection_status

No

String

Definition: Specifies the protection status.

Constraints: N/A

Value options:

  • nonProtection: The resource is not protected.

  • consoleProtection: Modification is not allowed on the console.

Default value: N/A

protection_reason

No

String

Definition: Specifies why modification protection is enabled.

Constraints: This parameter is valid only when protection_status is set to consoleProtection.

Range: The value can contain a maximum of 255 Unicode characters, excluding angle brackets (<>).

Default value: N/A

any_port_enable

No

Boolean

Definition: Specifies whether to enable any_port_enable for a backend server group. If this option is enabled, the listener routes the requests to the backend server over the same port as the frontend port. If this option is disabled, the listener routes the requests over the port specified by protocol_port.

Constraints: This option is available only for TCP, UDP, or QUIC backend server groups.

Range: false (disable this option) or true (enable this option).

Default value: false

connection_drain

No

ConnectionDrain object

Definition: Specifies the configurations of deregistration delay.

This parameter takes effect when:

  • A backend server is removed from a backend server group.

  • A backend server is detected unhealthy or health checks fail.

  • The weight of a backend server is 0.

Constraints: This parameter is only available for TCP, UDP, and QUIC backend server groups and TCP and UDP listeners.

pool_health

No

PoolHealth object

Definition: Specifies the configurations of the pool health feature.

Constraints: N/A

quic_cid_hash_strategy

No

QuicCidHashStrategy object

Definition: Specifies multi-path distribution configuration based on destination connection IDs.

Constraints: N/A

az_affinity

No

UpdateAzAffinity object

Definition: Specifies how AZ affinity is configured for the backend server group.

Constraints: N/A

Table 5 UpdatePoolSessionPersistenceOption

Parameter

Mandatory

Type

Description

cookie_name

No

String

Definition: Specifies the cookie name.

Constraints:

  • This parameter takes effect only when type is set to APP_COOKIE. Otherwise, an error will be returned.

Range: The value can contain a maximum of 1,024 characters.

Default value: N/A

type

No

String

Definition: Specifies the sticky session type.

Note:

  • If the protocol of the backend server group is TCP or UDP, only SOURCE_IP takes effect.

  • If the protocol of the backend server group is HTTP or HTTPS, only HTTP_COOKIE and APP_COOKIE take effect.

  • If the backend server group's protocol is QUIC, session_persistence must be set to true and type set to SOURCE_IP.

Range: SOURCE_IP, HTTP_COOKIE, or APP_COOKIE.

Default value: N/A

persistence_timeout

No

Integer

Definition: Specifies the stickiness duration, in minutes.

Constraints: This parameter will not take effect when type is set to APP_COOKIE.

Range:

  • If the protocol of the backend server group is TCP, UDP, or QUIC, the value ranges from 1 to 60, and the default value is 1.

  • If the protocol of the backend server group is HTTP or HTTPS, the value ranges from 1 to 1440, and the default value is 1440.

Default value: N/A

Table 6 UpdatePoolSlowStartOption

Parameter

Mandatory

Type

Description

enable

No

Boolean

Definition: Specifies whether to enable slow start.

Constraints: N/A

  • true: Enable slow start.

  • false: Disable slow start.

Default value: N/A

duration

No

Integer

Definition: Specifies the slow start duration, in seconds.

Constraints: N/A

Range: 30 to 1200

Default value: N/A

Table 7 ConnectionDrain

Parameter

Mandatory

Type

Description

enable

No

Boolean

Definition: Specifies whether to enable connection_drain.

Constraints: N/A

Range: The value can be true (enable this option) or false (disable this option).

Default value: N/A

timeout

No

Integer

Definition: Specifies the deregistration delay timeout, in seconds.

Constraints: N/A

Range: 10 to 4000, in seconds.

Constraints: N/A

Table 8 PoolHealth

Parameter

Mandatory

Type

Description

minimum_healthy_member_count

No

Integer

Definition: Specifies the number of healthy backend servers below which the backend server group is considered as unhealthy.

Range:

  • 0 (default): pool_health does not take effect.

  • 1: pool_health takes effect.

Table 9 QuicCidHashStrategy

Parameter

Mandatory

Type

Description

len

Yes

Integer

Definition: Specifies the length of the hash factor in the connection ID.

Constraints: This parameter is valid only when the load balancing algorithm is QUIC_CID.

Range: 1 to 20

Default value: 3

offset

Yes

Integer

Definition: Specifies the start position in the connection ID as the hash factor.

Constraints: This parameter is valid only when the load balancing algorithm is QUIC_CID.

Range: 0 to 19

Default value: 1

Table 10 UpdateAzAffinity

Parameter

Mandatory

Type

Description

enable

No

Boolean

Definition: Specifies whether to enable AZ affinity for the backend server group. If this parameter is set to true, ELB forwards traffic across the backend servers in the same AZ as the load balancer.

Constraints:

  • AZ affinity cannot be enabled for a backend server group that has IP as backend servers whose availability_zone is not specified.

  • AZ affinity cannot be enabled if the backend server is bound to a TLS listener.

  • This parameter is available for backend server groups that are associated with IP, UDP, and TCP listeners.

  • If the parameter is set to true, parameter pool_health will be ignored.

Range: false (disable this option) or true (enable this option).

Default value: N/A

az_minimum_healthy_member_percentage

No

Integer

Definition: Specifies a percentage that is used to determine the health of an AZ. If the percentage of healthy servers in the AZ of the load balancer falls below the specified value, az_unhealthy_fallback_strategy is triggered. az_minimum_healthy_member_percentage shows the percentage of backend servers that are healthy in a backend server group of an AZ. The number of healthy servers is rounded up. For example, in AZ A, if there are three backend servers in the backend server group and az_minimum_healthy_member_percentage is set to 66%, the number of healthy servers is rounded up to 2 (3 × 0.66 = 1.98). If there are fewer than two healthy servers in AZ A, az_unhealthy_fallback_strategy is triggered. If az_minimum_healthy_member_percentage is set to 67%, the number of healthy servers is rounded up to 3 (3 × 0.67 = 2.01). If there are fewer than three healthy servers in AZ A, az_unhealthy_fallback_strategy is triggered.

Constraints:

  • If enable is set to true, az_minimum_healthy_member_percentage and az_minimum_healthy_member_count cannot be set to -1 at the same time.

  • If enable is set to true, either az_minimum_healthy_member_percentage or az_minimum_healthy_member_count must be set to -1.

Range: an integer ranging from -1 to 100. An integer from 0 to 100 indicates the percentage of healthy servers in the AZ of the load balancer. -1 indicates that az_minimum_healthy_member_count takes effect.

Default value: N/A

az_minimum_healthy_member_count

No

Integer

Definition: Specifies a number that is used to determine the health of an AZ. If the number of healthy servers in the AZ of the load balancer falls below the specified value, az_unhealthy_fallback_strategy is triggered. az_minimum_healthy_member_count shows the number of healthy servers in a backend server group of an AZ.

Constraints:

  • If enable is set to true, az_minimum_healthy_member_percentage and az_minimum_healthy_member_count cannot be set to -1 at the same time.

  • If enable is set to true, either az_minimum_healthy_member_percentage or az_minimum_healthy_member_count must be set to -1.

Range: an integer ranging from -1 to 10000. An integer from 0 to 10000 indicates the number of healthy servers in the AZ of the load balancer. -1 indicates that az_minimum_healthy_member_percentage takes effect.

Default value: N/A

az_unhealthy_fallback_strategy

No

String

Definition: Specifies how traffic will be distributed across backend servers in an AZ if the percentage or number of healthy servers in the AZ of the load balancer falls below the specified value.

Range:

  • forward_to_all_member_of_local_az: forwards requests across all backend servers in the same AZ as the load balancer, even if some servers are unhealthy.

  • forward_to_healthy_member_of_remote_az: forwards requests across healthy backend servers in different AZs from the load balancer.

  • forward_to_all_healthy_member: forwards requests across healthy backend servers in all AZs.

  • forward_to_all_member: forwards requests across all backend servers in all AZs, even if some servers are unhealthy.

Constraints: N/A

Default value: forward_to_all_member_of_local_az

Response Parameters

Status code: 200

Table 11 Response body parameters

Parameter

Type

Description

request_id

String

Definition: Specifies the request ID.

Range: The value is automatically generated, and can contain characters including digits, lowercase letters, and hyphens (-).

pool

Pool object

Definition: Specifies the response parameters for updating a backend server group.

Table 12 Pool

Parameter

Type

Description

admin_state_up

Boolean

Definition: Specifies the administrative status of the backend server group. The value can only be true.

Range: true (enabled)

az_affinity

AzAffinity object

Definition: Specifies how AZ affinity is configured for the backend server group.

description

String

Definition: Provides supplementary information about the backend server group.

Range: N/A

healthmonitor_id

String

Definition: Specifies the ID of the health check configured for the backend server group.

Range: N/A

id

String

Definition: Specifies the backend server group ID.

Range: N/A

lb_algorithm

String

Definition: Specifies the load balancing algorithm used by the load balancer to route requests to backend servers in the associated backend server group.

Range:

  • ROUND_ROBIN: weighted round robin

  • LEAST_CONNECTIONS: weighted least connections

  • SOURCE_IP: source IP hash

  • QUIC_CID: connection ID

listeners

Array of ListenerRef objects

Definition: Specifies the IDs of the listeners with which the backend server group is associated.

loadbalancers

Array of LoadBalancerRef objects

Definition: Specifies the IDs of the load balancers with which the backend server group is associated.

members

Array of MemberRef objects

Definition: Specifies the IDs of backend servers in the backend server group.

name

String

Definition: Specifies the backend server group name.

Range: N/A

project_id

String

Definition: Specifies the project ID of the backend server group.

Range: N/A

protocol

String

Definition: Specifies the protocol used by the backend server group to receive requests from the load balancer.

Constraints: N/A

Range: The value can be TCP, UDP, TLS, HTTP, HTTPS, GRPC, or QUIC.

Default value: N/A

session_persistence

SessionPersistence object

Definition: Specifies the sticky session.

ip_version

String

Definition: Specifies the IP address version supported by the backend server group.

Range:

  • Shared load balancers: The value is fixed at v4.

  • Dedicated load balancers: The value can be dualstack or v4. If the protocol of the backend server group is TCP or UDP, the value is dualstack. If the protocol of the backend server group is HTTP, the value is v4.

slow_start

SlowStart object

Definition: Specifies slow start details. After you enable slow start, new backend servers added to the backend server group are warmed up, and the number of requests they can receive increases linearly during the configured slow start duration.

member_deletion_protection_enable

Boolean

Definition: Whether to enable removal protection for the backend server. Once the option is enabled, backend servers cannot be removed from the backend server group.

Range: false (disable this option) or true (enable this option).

NOTE:
Disable deletion protection or removal protection for your resources before deregistering your account.

created_at

String

Definition: Specifies the creation time.

Range: The value must be a UTC time in the yyyy-MM-dd'T'HH:mm:ss'Z' format.

Note: This parameter will not be returned for resources associated with existing dedicated load balancers and for resources associated with existing and new shared load balancers.

updated_at

String

Definition: Specifies the update time.

Range: The value must be a UTC time in the yyyy-MM-dd'T'HH:mm:ss'Z' format.

Note: This parameter will not be returned for resources associated with existing dedicated load balancers and for resources associated with existing and new shared load balancers.

vpc_id

String

Definition: Specifies the ID of the VPC where the backend server group works.

Range: N/A

type

String

Definition: Specifies the backend server group type.

Range:

  • instance: Any type of backend servers can be added. vpc_id is mandatory.

  • ip: Only IP as backend servers can be added. vpc_id cannot be specified.

  • "": Any type of backend servers can be added.

protection_status

String

Definition: Specifies the protection status.

Range:

  • nonProtection: The resource is not protected.

  • consoleProtection: Modification is not allowed on the console.

protection_reason

String

Definition: Specifies why modification protection is enabled.

Range: The value can contain a maximum of 255 Unicode characters, excluding angle brackets (<>).

any_port_enable

Boolean

Definition: Specifies whether to enable any_port_enable for a backend server group. If this option is enabled, the listener routes the requests to the backend server over the same port as the frontend port. If this option is disabled, the listener routes the requests over the port specified by protocol_port.

Constraints:

This option is available only for TCP, UDP, or QUIC backend server groups.

connection_drain

ConnectionDrain object

Definition: Specifies the configurations of deregistration delay.

This parameter takes effect when:

  • A backend server is removed from a backend server group.

  • A backend server is detected unhealthy or health checks fail.

  • The weight of a backend server is 0.

enterprise_project_id

String

Definition: Specifies the ID of the enterprise project.

Range:

  • 0: The resource belongs to the default enterprise project.

  • A string in UUID format indicates a non-default enterprise project.

pool_health

PoolHealth object

Definition: Specifies the configurations of the pool health feature.

public_border_group

String

Definition: Specifies the public border group.

Range:

  • center: public border group of the central site

  • Edge site name: public border group of an edge site

quic_cid_hash_strategy

QuicCidHashStrategy object

Definition: Specifies multi-path distribution configuration based on destination connection IDs.

Table 13 AzAffinity

Parameter

Type

Description

enable

Boolean

Definition: Specifies whether to enable AZ affinity for the backend server group. If this parameter is set to true, ELB forwards traffic across the backend servers in the same AZ as the load balancer.

Constraints:

  • This parameter is available only for IP, TCP, and UDP backend server groups.

  • This parameter is not available for backend server groups that are associated with TLS listeners.

  • If the parameter is set to true, parameter pool_health will be ignored.

Range: false (disable this option) or true (enable this option).

Default value: N/A

az_minimum_healthy_member_percentage

Integer

Definition: Specifies a percentage that is used to determine the health of an AZ. If the percentage of healthy servers in the AZ of the load balancer falls below the specified value, az_unhealthy_fallback_strategy is triggered. az_minimum_healthy_member_percentage shows the percentage of backend servers that are healthy in a backend server group of an AZ. The number of healthy servers is rounded up. For example, in AZ A, if there are three backend servers in the backend server group and az_minimum_healthy_member_percentage is set to 66%, the number of healthy servers is rounded up to 2 (3 × 0.66 = 1.98). If there are fewer than two healthy servers in AZ A, az_unhealthy_fallback_strategy is triggered. If az_minimum_healthy_member_percentage is set to 67%, the number of healthy servers is rounded up to 3 (3 × 0.67 = 2.01). If there are fewer than three healthy servers in AZ A, az_unhealthy_fallback_strategy is triggered.

Constraints:

  • If enable is set to true, az_minimum_healthy_member_percentage and az_minimum_healthy_member_count cannot be set to -1 at the same time.

  • If enable is set to true, either az_minimum_healthy_member_percentage or az_minimum_healthy_member_count must be set to -1.

Range: an integer ranging from -1 to 100. An integer from 0 to 100 indicates the percentage of healthy servers in the AZ of the load balancer. -1 indicates that az_minimum_healthy_member_count takes effect.

Default value: N/A

az_minimum_healthy_member_count

Integer

Definition: Specifies a number that is used to determine the health of an AZ. If the number of healthy servers in the AZ of the load balancer falls below the specified value, az_unhealthy_fallback_strategy is triggered. az_minimum_healthy_member_count shows the number of healthy servers in a backend server group of an AZ.

Constraints:

  • If enable is set to true, az_minimum_healthy_member_percentage and az_minimum_healthy_member_count cannot be set to -1 at the same time.

  • If enable is set to true, either az_minimum_healthy_member_percentage or az_minimum_healthy_member_count must be set to -1.

Range: an integer ranging from -1 to 10000. An integer from 0 to 10000 indicates the number of healthy servers in the AZ of the load balancer. -1 indicates that az_minimum_healthy_member_percentage takes effect.

Default value: N/A

az_unhealthy_fallback_strategy

String

Definition: Specifies how traffic will be distributed across backend servers in an AZ if the percentage or number of healthy servers in the AZ of the load balancer falls below the specified value.

Range:

  • forward_to_all_member_of_local_az: forwards requests across all backend servers in the same AZ as the load balancer, even if some servers are unhealthy.

  • forward_to_healthy_member_of_remote_az: forwards requests across healthy backend servers in different AZs from the load balancer.

  • forward_to_all_healthy_member: forwards requests across healthy backend servers in all AZs.

  • forward_to_all_member: forwards requests across all backend servers in all AZs, even if some servers are unhealthy.

Constraints: N/A

Default value: forward_to_all_member_of_local_az

Table 14 ListenerRef

Parameter

Type

Description

id

String

Definition: Specifies the listener ID.

Range: N/A

Table 15 LoadBalancerRef

Parameter

Type

Description

id

String

Definition: Specifies the load balancer ID.

Range: N/A

Table 16 MemberRef

Parameter

Type

Description

id

String

Specifies the backend server ID.

Range: N/A

Table 17 SessionPersistence

Parameter

Type

Description

cookie_name

String

Definition: Specifies the cookie name.

Range: The value can contain a maximum of 1,024 characters.

type

String

Definition: Specifies the sticky session type.

Range: SOURCE_IP, HTTP_COOKIE, or APP_COOKIE.

persistence_timeout

Integer

Definition: Specifies the stickiness duration, in minutes. This parameter will not take effect when type is set to APP_COOKIE.

Range:

  • If the protocol of the backend server group is TCP, UDP, or QUIC, the value ranges from 1 to 60, and the default value is 1.

  • If the protocol of the backend server group is HTTP or HTTPS, the value ranges from 1 to 1440, and the default value is 1440.

Table 18 SlowStart

Parameter

Type

Description

enable

Boolean

Definition: Specifies whether to enable slow start.

Range:

  • true: This option will be enabled.

  • false: This option will be disabled.

duration

Integer

Definition: Specifies the slow start duration, in seconds.

Range: 30 to 1200, in seconds.

Table 19 ConnectionDrain

Parameter

Type

Description

enable

Boolean

Definition: Specifies whether to enable connection_drain.

Constraints: N/A

Range: The value can be true (enable this option) or false (disable this option).

Default value: N/A

timeout

Integer

Definition: Specifies the deregistration delay timeout, in seconds.

Constraints: N/A

Range: 10 to 4000, in seconds.

Constraints: N/A

Table 20 PoolHealth

Parameter

Type

Description

minimum_healthy_member_count

Integer

Definition: Specifies the number of healthy backend servers below which the backend server group is considered as unhealthy.

Range:

  • 0 (default): pool_health does not take effect.

  • 1: pool_health takes effect.

Table 21 QuicCidHashStrategy

Parameter

Type

Description

len

Integer

Definition: Specifies the length of the hash factor in the connection ID.

Constraints: This parameter is valid only when the load balancing algorithm is QUIC_CID.

Range: 1 to 20

Default value: 3

offset

Integer

Definition: Specifies the start position in the connection ID as the hash factor.

Constraints: This parameter is valid only when the load balancing algorithm is QUIC_CID.

Range: 0 to 19

Default value: 1

Example Requests

Changing the load balancing algorithm of a backend server group

PUT https://{ELB_Endpoint}/v3/99a3fff0d03c428eac3678da6a7d0f24/elb/pools/36ce7086-a496-4666-9064-5ba0e6840c75

{
  "pool" : {
    "name" : "My pool.",
    "description" : "My pool update",
    "lb_algorithm" : "LEAST_CONNECTIONS"
  }
}

Example Responses

Status code: 200

Successful request.

{
  "pool" : {
    "type" : "",
    "vpc_id" : "",
    "lb_algorithm" : "LEAST_CONNECTIONS",
    "protocol" : "TCP",
    "description" : "My pool update",
    "admin_state_up" : true,
    "member_deletion_protection_enable" : false,
    "loadbalancers" : [ {
      "id" : "098b2f68-af1c-41a9-8efd-69958722af62"
    } ],
    "project_id" : "99a3fff0d03c428eac3678da6a7d0f24",
    "session_persistence" : null,
    "healthmonitor_id" : null,
    "listeners" : [ {
      "id" : "0b11747a-b139-492f-9692-2df0b1c87193"
    }, {
      "id" : "61942790-2367-482a-8b0e-93840ea2a1c6"
    }, {
      "id" : "fd8f954c-f0f8-4d39-bb1d-41637cd6b1be"
    } ],
    "members" : [ ],
    "id" : "36ce7086-a496-4666-9064-5ba0e6840c75",
    "name" : "My pool.",
    "ip_version" : "dualstack",
    "pool_health" : {
      "minimum_healthy_member_count" : 0
    }
  },
  "request_id" : "8f40128b-c72b-4b64-986a-f7e2c633d75f"
}

SDK Sample Code

The SDK sample code is as follows.

Changing the load balancing algorithm of a backend server group

 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
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.elb.v3.region.ElbRegion;
import com.huaweicloud.sdk.elb.v3.*;
import com.huaweicloud.sdk.elb.v3.model.*;


public class UpdatePoolSolution {

    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");
        String projectId = "{project_id}";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);

        ElbClient client = ElbClient.newBuilder()
                .withCredential(auth)
                .withRegion(ElbRegion.valueOf("<YOUR REGION>"))
                .build();
        UpdatePoolRequest request = new UpdatePoolRequest();
        request.withPoolId("{pool_id}");
        UpdatePoolRequestBody body = new UpdatePoolRequestBody();
        UpdatePoolOption poolbody = new UpdatePoolOption();
        poolbody.withDescription("My pool update")
            .withLbAlgorithm("LEAST_CONNECTIONS")
            .withName("My pool.");
        body.withPool(poolbody);
        request.withBody(body);
        try {
            UpdatePoolResponse response = client.updatePool(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());
        }
    }
}

Changing the load balancing algorithm of a backend server group

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

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkelb.v3.region.elb_region import ElbRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkelb.v3 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"]
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId)

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

    try:
        request = UpdatePoolRequest()
        request.pool_id = "{pool_id}"
        poolbody = UpdatePoolOption(
            description="My pool update",
            lb_algorithm="LEAST_CONNECTIONS",
            name="My pool."
        )
        request.body = UpdatePoolRequestBody(
            pool=poolbody
        )
        response = client.update_pool(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Changing the load balancing algorithm of a backend server group

 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"
    elb "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/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")
    projectId := "{project_id}"

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        Build()

    client := elb.NewElbClient(
        elb.ElbClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.UpdatePoolRequest{}
	request.PoolId = "{pool_id}"
	descriptionPool:= "My pool update"
	lbAlgorithmPool:= "LEAST_CONNECTIONS"
	namePool:= "My pool."
	poolbody := &model.UpdatePoolOption{
		Description: &descriptionPool,
		LbAlgorithm: &lbAlgorithmPool,
		Name: &namePool,
	}
	request.Body = &model.UpdatePoolRequestBody{
		Pool: poolbody,
	}
	response, err := client.UpdatePool(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

Successful request.

Error Codes

See Error Codes.