Updated on 2024-04-18 GMT+08:00

Querying Active/Standby Backend Server Groups

Function

This API is used to query all active/standby backend server groups.

Constraints

This API has the following constraints:

  • Parameters marker, limit, and page_reverse are used for pagination query.

  • Parameters marker and page_reverse take effect only when they are used together with parameter limit.

Calling Method

For details, see Calling APIs.

URI

GET /v3/{project_id}/elb/master-slave-pools

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Specifies the project ID.

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

marker

No

String

Specifies the ID of the last record on the previous page. Note:

  • This parameter must be used together with limit.

  • If this parameter is not specified, the first page will be queried.

  • This parameter cannot be left blank or set to an invalid ID.

limit

No

Integer

Specifies the number of records on each page.

Minimum: 0

Maximum: 2000

Default: 2000

page_reverse

No

Boolean

Specifies whether to use reverse query. Values:

  • true: Query the previous page.

  • false (default): Query the next page.

Note:

  • This parameter must be used together with limit.

  • If page_reverse is set to true and you want to query the previous page, set the value of marker to the value of previous_marker.

description

No

Array

Specifies supplementary information about the active/standby backend server group. Multiple descriptions can be queried in the format of description=xxx&description=xxx.

healthmonitor_id

No

Array

Specifies the ID of the health check configured for the active/standby backend server group. Multiple IDs can be queried in the format of healthmonitor_id=xxx&healthmonitor_id=xxx.

id

No

Array

Specifies the ID of the active/standby backend server group. Multiple IDs can be queried in the format of id=xxx&id=xxx.

name

No

Array

Specifies the name of the active/standby backend cloud server group. Multiple names can be queried in the format of name=xxx&name=xxx.

loadbalancer_id

No

Array

Specifies the ID of the load balancer with which the active/standby backend server group is associated. Multiple IDs can be queried in the format of loadbalancer_id=xxx&loadbalancer_id=xxx.

protocol

No

Array

Specifies the protocol used by the backend server group to receive requests from the load balancer. The value can be TCP, UDP, HTTP, HTTPS, or QUIC.

Multiple protocols can be queried in the format of protocol=xxx&protocol=xxx.

lb_algorithm

No

Array

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

The value can be one of the following:

  • ROUND_ROBIN: weighted round robin

  • LEAST_CONNECTIONS: weighted least connections

  • SOURCE_IP: source IP hash

  • QUIC_CID: connection ID

Multiple algorithms can be queried in the format of lb_algorithm=xxx&lb_algorithm=xxx.

enterprise_project_id

No

Array

Specifies the enterprise project ID.

  • If this parameter is not passed, resources in the default enterprise project are queried, and authentication is performed based on the default enterprise project.

  • If this parameter is passed, its value can be the ID of an existing enterprise project (resources in the specific enterprise project are required) or all_granted_eps (resources in all enterprise projects are queried).

Multiple IDs can be queried in the format of enterprise_project_id=xxx&enterprise_project_id=xxx.

ip_version

No

Array

Specifies the IP address version supported by the active/standby backend server group. Multiple versions can be queried in the format of ip_version=xxx&ip_version=xxx.

member_address

No

Array

Specifies the private IP address bound to the backend server. This parameter is used only as a query condition and is not included in the response. Multiple IP addresses can be queried in the format of member_address=xxx&member_address=xxx.

member_device_id

No

Array

Specifies the ID of the cloud server that serves as a backend server. This parameter is used only as a query condition and is not included in the response. Multiple IDs can be queried in the format of member_device_id=xxx&member_device_id=xxx.

listener_id

No

Array

Specifies the ID of the listener to which the forwarding policy is added. Multiple IDs can be queried in the format of listener_id=xxx&listener_id=xxx.

member_instance_id

No

Array

Specifies the backend server ID. This parameter is used only as a query condition and is not included in the response. Multiple IDs can be queried in the format of member_instance_id=xxx&member_instance_id=xxx.

vpc_id

No

Array

Specifies the ID of the VPC where the active/standby backend server group works.

type

No

Array

Specifies the type of the active/standby backend server group.

Values:

  • 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.

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Specifies the token used for IAM authentication.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

request_id

String

Specifies the request ID. The value is automatically generated.

page_info

PageInfo object

Specifies the pagination information.

pools

Array of MasterSlavePool objects

Specifies the active/standby backend server groups.

Table 5 PageInfo

Parameter

Type

Description

previous_marker

String

Specifies the ID of the first record in the pagination query result.

next_marker

String

Specifies the ID of the last record in the pagination query result.

current_count

Integer

Specifies the number of records.

Table 6 MasterSlavePool

Parameter

Type

Description

description

String

Specifies supplementary information about the active/standby backend server group.

id

String

Specifies the ID of the active/standby backend server group.

lb_algorithm

String

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

The value can be one of the following:

  • ROUND_ROBIN: weighted round robin

  • LEAST_CONNECTIONS: weighted least connections

  • SOURCE_IP: source IP hash

  • QUIC_CID: connection ID

Note:[/topic/body/section/table/tgroup/tbody/row/entry/p/br {""}) (br]

  • If the value is SOURCE_IP, the weight parameter will not take effect for backend servers.

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

listeners

Array of ListenerRef objects

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

loadbalancers

Array of LoadBalancerRef objects

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

members

Array of MasterSlaveMember objects

Specifies the backend servers in the active/standby backend server group.

name

String

Specifies the backend server group name.

project_id

String

Specifies the project ID.

protocol

String

Specifies the protocol used by the backend server group to receive requests. The value can be TCP, UDP, HTTP, HTTPS, or QUIC.Note:

  • If the listener's protocol is UDP, the protocol of the backend server group must be UDP or QUIC.

  • If the listener's protocol is TCP, the protocol of the backend server group must be TCP.

  • If the listener's protocol is HTTP, the protocol of the backend server group must be HTTP.

  • If the listener's protocol is HTTPS, the protocol of the backend server group can be HTTP or HTTPS.

  • If the listener's protocol is TERMINATED_HTTPS, the protocol of the backend server group must be HTTP.

  • If the backend server group protocol is QUIC, sticky session must be enabled with type set to SOURCE_IP.

session_persistence

SessionPersistence object

Specifies the sticky session.

ip_version

String

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

  • 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, UDP, or QUIC, the value is dualstack. If the protocol of the backend server group is HTTP or HTTPS, the value is v4.

created_at

String

Specifies the time when a backend server group was created. The format is yyyy-MM-dd'T'HH:mm:ss'Z' (UTC time).

This is a new field in this version, and it 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

Specifies the time when when a backend server group was updated. The format is yyyy-MM-dd'T'HH:mm:ss'Z' (UTC time).

This is a new field in this version, and it 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

Specifies the ID of the VPC where the active/standby backend server group works.

type

String

Specifies the type of the active/standby backend server group.

Values:

  • 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.

enterprise_project_id

String

Specifies the enterprise project ID of the backend server group. All created projects belong to the default enterprise project.

healthmonitor

MasterSlaveHealthMonitor object

Specifies the health check configured for the active/standby backend server group.

any_port_enable

Boolean

Specifies whether to enable Forward to Same Port 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. The value can be:

  • false (default): Disable Forward to Same Port.

  • true: Enable Forward to Same Port.

NOTE:

If Forward to Same Port is disabled, requests will be forwarded to the backend server over the port specified by protocol_port.

Table 7 ListenerRef

Parameter

Type

Description

id

String

Specifies the listener ID.

Table 8 LoadBalancerRef

Parameter

Type

Description

id

String

Specifies the load balancer ID.

Table 9 MasterSlaveMember

Parameter

Type

Description

id

String

Specifies the backend server ID.

name

String

Specifies the backend server name.

admin_state_up

Boolean

Specifies the administrative status of the backend server. The value can be true or false.

Although this parameter can be used in the APIs for creating and updating backend servers, its actual value depends on whether cloud servers exist. If cloud servers exist, the value is true. Otherwise, the value is false.

subnet_cidr_id

String

Specifies the ID of the IPv4 or IPv6 subnet where the backend server resides.

This parameter can be left blank, indicating that IP as a Backend has been enabled for the load balancer. In this case, IP addresses of these servers must be IPv4 addresses, and the protocol of the backend server group must be TCP, HTTP, or HTTPS.

The IPv4 or IPv6 subnet must be in the same VPC as the subnet of the load balancer.

protocol_port

Integer

Specifies the port used by the backend server to receive requests.

NOTE:

This parameter can be left blank because it does not take effect if any_port_enable is set to true for a backend server group.

Minimum: 1

Maximum: 65535

address

String

Specifies the private IP address bound to the backend server.

  • If subnet_cidr_id is left blank, IP as a Backend is enabled. In this case, the IP address must be an IPv4 address.

  • If subnet_cidr_id is not left blank, the IP address can be IPv4 or IPv6. It must be in the subnet specified by subnet_cidr_id and can only be bound to the primary NIC of the backend server.

ip_version

String

Specifies the IP version supported by the backend server. The value can be v4 (IPv4) or v6 (IPv6), depending on the value of address returned by the system.

device_owner

String

Specifies whether the backend server is associated with an ECS.

  • If this parameter is left blank, the backend server is not associated with an ECS.

  • If the value is compute:{az_name}, the backend server is associated with an ECS. {az_name} indicates the AZ where the ECS resides.

This parameter is unsupported. Please do not use it.

device_id

String

Specifies the ID of the ECS with which the backend server is associated. If this parameter is left blank, the backend server is not associated with an ECS.

This parameter is unsupported. Please do not use it.

operating_status

String

Specifies the health status of the backend server. The value can be one of the following:

  • ONLINE: The backend server is running normally.

  • NO_MONITOR: No health check is configured for the backend server group to which the backend server belongs.

  • OFFLINE: The cloud server used as the backend server is stopped or does not exist.

member_type

String

Specifies the type of the backend server. Values:

  • ip: IP as backend servers

  • instance: ECSs used as backend servers

instance_id

String

Specifies the ID of the ECS used as the backend server. If this parameter is left blank, the backend server is not an ECS. For example, it may be an IP address.

role

String

Specifies the type of the backend server.

status

Array of ListenerMemberInfo objects

Specifies the health status of the backend server if listener_id is specified.

Table 10 ListenerMemberInfo

Parameter

Type

Description

listener_id

String

Specifies the ID of the listener associated with the backend server.

operating_status

String

Specifies the health status of the backend server. The value can be one of the following:

  • ONLINE: The backend server is running normally.

  • NO_MONITOR: No health check is configured for the backend server group to which the backend server belongs.

  • OFFLINE: The cloud server used as the backend server is stopped or does not exist.

Table 11 SessionPersistence

Parameter

Type

Description

cookie_name

String

Specifies the cookie name.

For shared load balancers, the name can contain a maximum of 64 characters, including letters, digits, underscores (_), and hyphens (-).

For dedicated load balancers, the name can contain a maximum of 255 characters, including letters, digits, underscores (_), hyphens (-), and periods (.).

Note:

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

type

String

Specifies the sticky session type. The value can be SOURCE_IP, HTTP_COOKIE, or APP_COOKIE.Note:

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

  • For dedicated load balancers, if the protocol of the backend server group is HTTP or HTTPS, the value can only be HTTP_COOKIE.

  • If the backend server group protocol is QUIC, sticky session must be enabled with type set to SOURCE_IP.

persistence_timeout

Integer

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

  • 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 12 MasterSlaveHealthMonitor

Parameter

Type

Description

admin_state_up

Boolean

Specifies the administrative status of the health check.

  • true (default) indicates that the health check is enabled.

  • false indicates that the health check is disabled.

delay

Integer

Specifies the interval between health checks, in seconds. The value ranges from 1 to 50.

Minimum: 1

Maximum: 50

domain_name

String

Specifies the domain name that HTTP requests are sent to during the health check.

The value can contain only digits, letters, hyphens (-), and periods (.) and must start with a digit or letter.

The value is left blank by default, indicating that the virtual IP address of the load balancer is used as the destination address of HTTP requests.

This parameter is available only when type is set to HTTP.

expected_codes

String

Specifies the expected HTTP status code. This parameter will take effect only when type is set to HTTP or HTTPS.

The value options are as follows:

  • A specific value, for example, 200

  • A list of values that are separated with commas (,), for example, 200, 202

  • A value range, for example, 200-204

The default value is 200. Multiple status codes can be queried in the format of expected_codes=xxx&expected_codes=xxx.

http_method

String

Specifies the HTTP method. The value can be GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, CONNECT, or PATCH. The default value is GET.

This parameter is available when type is set to HTTP or HTTPS.

This parameter is unsupported. Please do not use it.

id

String

Specifies the health check ID.

max_retries

Integer

Specifies the number of consecutive health checks when the health check result of a backend server changes from OFFLINE to ONLINE. The value ranges from 1 to 10.

Minimum: 1

Maximum: 10

max_retries_down

Integer

Specifies the number of consecutive health checks when the health check result of a backend server changes from ONLINE to OFFLINE.

The value ranges from 1 to 10, and the default value is 3.

Minimum: 1

Maximum: 10

monitor_port

Integer

Specifies the port used for the health check. If this parameter is left blank, a port of the backend server will be used by default. The port number ranges from 1 to 65535.

Minimum: 1

Maximum: 65535

name

String

Specifies the health check name.

timeout

Integer

Specifies the maximum time required for waiting for a response from the health check, in seconds. It is recommended that you set the value less than that of parameter delay.

Minimum: 1

Maximum: 50

type

String

Specifies the health check protocol. The value can be TCP, UDP_CONNECT, HTTP, or HTTPS.

Note:

  • If the protocol of the backend server group is QUIC, the value can only be UDP_CONNECT.

  • If the protocol of the backend server group is UDP, the value can only be UDP_CONNECT.

  • If the protocol of the backend server group is TCP, the value can only be TCP, HTTP, or HTTPS.

  • If the protocol of the backend server group is HTTP, the value can only be TCP, HTTP, or HTTPS.

  • If the protocol of the backend server group is HTTPS, the value can only be TCP, HTTP, or HTTPS.

url_path

String

Specifies the HTTP request path for the health check. The value must start with a slash (/), and the default value is /. The value can contain letters, digits, hyphens (-), slashes (/), periods (.), percentage signs (%), question marks (?), pound signs (#), ampersand signs (&), and the extended character set _;~!()*[]@$^:',+.

Note: This parameter is available only when type is set to HTTP or HTTPS.

Example Requests

GET https://{ELB_Endpoint}/v3/99a3fff0d03c428eac3678da6a7d0f24/elb/master-slave-pools?limit=2

Example Responses

Status code: 200

Successful request.

{
  "pools" : [ {
    "lb_algorithm" : "ROUND_ROBIN",
    "protocol" : "HTTP",
    "description" : "",
    "loadbalancers" : [ {
      "id" : "309a0f61-0b62-45f2-97d1-742f3434338e"
    } ],
    "project_id" : "99a3fff0d03c428eac3678da6a7d0f24",
    "session_persistence" : {
      "cookie_name" : "my_cookie",
      "type" : "APP_COOKIE",
      "persistence_timeout" : 1
    },
    "healthmonitor" : {
      "monitor_port" : null,
      "id" : "36ce7086-a496-4666-9064-5ba0e6840c75",
      "domain_name" : "",
      "name" : "My Healthmonitor",
      "max_retries" : 3,
      "max_retries_down" : 3,
      "admin_state_up" : true,
      "type" : "HTTP",
      "timeout" : 30,
      "delay" : 1,
      "http_method" : "get",
      "url_path" : "/",
      "expected_codes" : "200"
    },
    "listeners" : [ ],
    "members" : [ {
      "admin_state_up" : true,
      "address" : "172.16.0.210",
      "protocol_port" : 80,
      "id" : "2e7b36d2-66c8-4825-bcd2-211d99978680",
      "operating_status" : "OFFLINE",
      "status" : [ ],
      "instance_id" : "",
      "device_id" : "",
      "device_owner" : "",
      "member_type" : "ip",
      "role" : "master",
      "ip_version" : "v4",
      "name" : "cx-test-master",
      "subnet_cidr_id" : ""
    }, {
      "admin_state_up" : true,
      "address" : "172.16.0.211",
      "protocol_port" : 81,
      "id" : "2e7b36d2-66c8-4823-bsd2-21sa199978681",
      "operating_status" : "OFFLINE",
      "status" : [ ],
      "instance_id" : "",
      "device_id" : "",
      "device_owner" : "",
      "member_type" : "ip",
      "role" : "slave",
      "ip_version" : "v4",
      "name" : "cx-test-slave",
      "subnet_cidr_id" : ""
    } ],
    "id" : "73bd4fe0-ffbb-4b56-aab4-4f26ddf7a103",
    "name" : "",
    "ip_version" : "v4",
    "type" : "ip",
    "vpc_id" : "",
    "created_at" : "2021-03-26T01:33:12Z",
    "updated_at" : "2021-03-26T01:33:12Z"
  }, {
    "lb_algorithm" : "SOURCE_IP",
    "protocol" : "TCP",
    "description" : "",
    "loadbalancers" : [ {
      "id" : "d9763e59-64b7-4e93-aec7-0ff7881ef9bc"
    } ],
    "project_id" : "99a3fff0d03c428eac3678da6a7d0f24",
    "session_persistence" : {
      "cookie_name" : "",
      "type" : "SOURCE_IP",
      "persistence_timeout" : 1
    },
    "healthmonitor" : {
      "monitor_port" : null,
      "id" : "36ce7086-a496-4666-9064-5ba0e6840c75",
      "domain_name" : "",
      "name" : "My Healthmonitor",
      "max_retries" : 3,
      "max_retries_down" : 3,
      "admin_state_up" : true,
      "type" : "HTTP",
      "timeout" : 30,
      "delay" : 1,
      "http_method" : "get",
      "url_path" : "/",
      "expected_codes" : "200"
    },
    "listeners" : [ {
      "id" : "8d21db6f-b475-429e-a9cb-90439b0413b2"
    } ],
    "members" : [ {
      "admin_state_up" : true,
      "address" : "172.16.1.210",
      "protocol_port" : 83,
      "id" : "2e7b36d2-9997-4825-bcd2-211d9990439b",
      "operating_status" : "OFFLINE",
      "status" : [ ],
      "instance_id" : "",
      "device_id" : "",
      "device_owner" : "",
      "member_type" : "ip",
      "role" : "master",
      "ip_version" : "v4",
      "name" : "cx-test-master",
      "subnet_cidr_id" : ""
    }, {
      "admin_state_up" : true,
      "address" : "172.16.1.212",
      "protocol_port" : 82,
      "id" : "227b31d2-66c1-4823-bsd2-21sa199978213",
      "operating_status" : "OFFLINE",
      "status" : [ ],
      "instance_id" : "",
      "device_id" : "",
      "device_owner" : "",
      "member_type" : "ip",
      "role" : "slave",
      "ip_version" : "v4",
      "name" : "cx-test-slave",
      "subnet_cidr_id" : ""
    } ],
    "id" : "74db02d1-5711-4c77-b383-a450e2b93142",
    "name" : "pool_tcp_001",
    "ip_version" : "dualstack",
    "type" : "ip",
    "vpc_id" : "",
    "created_at" : "2021-03-26T01:33:12Z",
    "updated_at" : "2021-03-26T01:33:12Z"
  } ],
  "page_info" : {
    "next_marker" : "74db02d1-5711-4c77-b383-a450e2b93142",
    "previous_marker" : "73bd4fe0-ffbb-4b56-aab4-4f26ddf7a103",
    "current_count" : 2
  },
  "request_id" : "a1a7e852-1928-48f7-bbc9-ca8469898713"
}

SDK Sample Code

The SDK sample code is as follows.

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

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

public class ListMasterSlavePoolsSolution {

    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);

        ElbClient client = ElbClient.newBuilder()
                .withCredential(auth)
                .withRegion(ElbRegion.valueOf("<YOUR REGION>"))
                .build();
        ListMasterSlavePoolsRequest request = new ListMasterSlavePoolsRequest();
        request.withMarker("<marker>");
        request.withLimit(<limit>);
        request.withPageReverse(<page_reverse>);
        request.withDescription();
        request.withHealthmonitorId();
        request.withId();
        request.withName();
        request.withLoadbalancerId();
        request.withProtocol();
        request.withLbAlgorithm();
        request.withEnterpriseProjectId();
        request.withIpVersion();
        request.withMemberAddress();
        request.withMemberDeviceId();
        request.withListenerId();
        request.withMemberInstanceId();
        request.withVpcId();
        request.withType();
        try {
            ListMasterSlavePoolsResponse response = client.listMasterSlavePools(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());
        }
    }
}
 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

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 = __import__('os').getenv("CLOUD_SDK_AK")
    sk = __import__('os').getenv("CLOUD_SDK_SK")

    credentials = BasicCredentials(ak, sk) \

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

    try:
        request = ListMasterSlavePoolsRequest()
        request.marker = "<marker>"
        request.limit = <limit>
        request.page_reverse = <PageReverse>
        request.description = 
        request.healthmonitor_id = 
        request.id = 
        request.name = 
        request.loadbalancer_id = 
        request.protocol = 
        request.lb_algorithm = 
        request.enterprise_project_id = 
        request.ip_version = 
        request.member_address = 
        request.member_device_id = 
        request.listener_id = 
        request.member_instance_id = 
        request.vpc_id = 
        request.type = 
        response = client.list_master_slave_pools(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
 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
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")

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

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

    request := &model.ListMasterSlavePoolsRequest{}
	markerRequest:= "<marker>"
	request.Marker = &markerRequest
	limitRequest:= int32(<limit>)
	request.Limit = &limitRequest
	pageReverseRequest:= <page_reverse>
	request.PageReverse = &pageReverseRequest
	response, err := client.ListMasterSlavePools(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.