Querying Backend Servers
Function
This API is used to query the backend servers under the current project.
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/members
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Specifies the project ID. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
marker |
No |
String |
Specifies the ID of the last record on the previous page. Note:
|
limit |
No |
Integer |
Specifies the number of records on each page. Value range: 0–2000 Default value: 2000 |
page_reverse |
No |
Boolean |
Specifies whether to use reverse query. Value options:
Note:
|
name |
No |
Array of strings |
Specifies the backend server name. Multiple names can be queried in the format of name=xxx&name=xxx. |
weight |
No |
Array of integers |
Specifies the weight of the backend server. Requests are routed to backend servers in the same backend server group based on their weights. If the weight is 0, the backend server will not accept new requests. This parameter is invalid when lb_algorithm is set to SOURCE_IP for the backend server group that contains the backend server. Multiple weights can be queried in the format of weight=xxx&weight=xxx. |
admin_state_up |
No |
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 ECSs exist. If ECSs exist, the value is true. Otherwise, the value is false. |
subnet_cidr_id |
No |
Array of strings |
Specifies the ID of the subnet where the backend server works. This subnet must be in the same VPC as the subnet of the load balancer with which the backend server is associated. Only IPv4 subnets are supported. Multiple IDs can be queried in the format of subnet_cidr_id=xxx&subnet_cidr_id=xxx. |
address |
No |
Array of strings |
Specifies the IP address of the backend server. This address must be in the subnet specified by subnet_cidr_id, for example, 192.168.3.11. The IP address can only be the IP address of the primary NIC. Multiple IP addresses can be queried in the format of address=xxx&address=xxx. |
protocol_port |
No |
Array of integers |
Specifies the port used by the backend servers. Multiple ports can be queried in the format of protocol_port=xxx&protocol_port=xxx. |
id |
No |
Array of strings |
Specifies the backend server ID. Multiple IDs can be queried in the format of id=xxx&id=xxx. |
operating_status |
No |
Array of strings |
Specifies the operating status of the backend server. Value options:
Multiple statuses can be queried in the format of operating_status=xxx&operating_status=xxx. |
enterprise_project_id |
No |
Array of strings |
Specifies the ID of the enterprise project.
Multiple values can be queried in the format of enterprise_project_id=xxx&enterprise_project_id=xxx. |
ip_version |
No |
Array of strings |
Specifies the IP address version supported by the backend server group. The value can be v4 or v6. Multiple versions can be queried in the format of ip_version=xxx&ip_version=xxx. |
pool_id |
No |
Array of strings |
Specifies the ID of the backend server group to which the backend server belongs. Multiple IDs can be queried in the format of pool_id=xxx&pool_id=xxx. |
loadbalancer_id |
No |
Array of strings |
Specifies the ID of the load balancer with which the load balancer is associated. Multiple IDs can be queried in the format of loadbalancer_id=xxx&loadbalancer_id=xxx. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
Specifies the token used for IAM authentication. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
request_id |
String |
Specifies the request ID. Note: The value is automatically generated. |
page_info |
PageInfo object |
Pagination information. |
members |
Array of MemberInfo objects |
Specifies the backend servers. |
Parameter |
Type |
Description |
---|---|---|
previous_marker |
String |
Specifies the ID of the first record in the pagination query result. When page_reverse is set to true, this parameter is used together to query resources on the previous page. |
next_marker |
String |
Specifies the ID of the last record in the pagination query result. |
current_count |
Integer |
Specifies the number of records. |
Parameter |
Type |
Description |
---|---|---|
id |
String |
Specifies the backend server ID. Note: The value of this parameter is not the ID of the server but an ID automatically generated for the backend server that has already been associated with the load balancer. |
name |
String |
Specifies the backend server name. Note: The name is not an ECS name. |
project_id |
String |
Specifies the ID of the project where the backend server is used. |
pool_id |
String |
Specifies the ID of the backend server group to which the backend server belongs. This parameter is unsupported. Please do not use it. |
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 ECSs exist. If ECSs 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. neutron_subnet_id defines IPv4 subnets, and neutron_network_id defines IPv6 subnets. You can query parameters neutron_subnet_id and neutron_network_id in the response by calling the API GET https://{VPC_Endpoint}/v1/{project_id}/subnets to get the IPv4 subnet ID and IPv6 subnet ID respectively. Note:
|
protocol_port |
Integer |
Specifies the port used by the backend server to receive requests. Note:
|
weight |
Integer |
Specifies the weight of the backend server. Requests are routed to backend servers in the same backend server group based on their weights. The value ranges from 0 to 100, and the default value is 1. The larger the weight is, the higher proportion of requests the backend server receives. If the weight is set to 0, the backend server will not accept new requests. If lb_algorithm is set to SOURCE_IP or QUIC_CID, this parameter will not take effect. |
address |
String |
Specifies the private IP address bound to the backend server. Note:
|
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.
|
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 if listener_id under status is not specified. Value options:
|
status |
Array of MemberStatus objects |
Specifies the health status of the backend server if listener_id under status is specified. If listener_id under status is not specified, operating_status of member takes precedence. |
loadbalancer_id |
String |
Specifies the ID of the load balancer with which the backend server is associated. This parameter is unsupported. Please do not use it. |
loadbalancers |
Array of ResourceID objects |
Specifies the IDs of the load balancers associated with the backend server. This parameter is unsupported. Please do not use it. |
created_at |
String |
Specifies the time when a backend server was added. 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 a backend server 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. |
member_type |
String |
Specifies the type of the backend server. Value options:
|
instance_id |
String |
Specifies the ID of the instance associated with the backend server. If this parameter is left blank, the backend server is not a real device. It may be an IP address. |
reason |
Specifies why health check fails. |
Parameter |
Type |
Description |
---|---|---|
listener_id |
String |
Specifies the listener ID. |
operating_status |
String |
Specifies the health status of the backend server. Value options:
|
reason |
Specifies why health check fails. |
Parameter |
Type |
Description |
---|---|---|
reason_code |
String |
Specifies the code of the health check failures. Value options:
|
expected_response |
String |
Specifies the expected HTTP status code. This parameter will take effect only when type is set to HTTP, HTTPS, or GRPC. The status code cannot be null if reason_code is RESPONSE_MISMATCH. Value ranges:
|
healthcheck_response |
String |
Specifies the returned HTTP status code in the response. This parameter will take effect only when type is set to HTTP, HTTPS, or GRPC. The status code cannot be null if reason_code is RESPONSE_MISMATCH. Value range: A specific status code. If type is set to GRPC, the status code ranges from 0 to 99. If type is set to other values, the status code ranges from 200 to 599. For example, the status code can be 0 or 200. |
Example Requests
Querying all backend servers under the current project
GET https://{ELB_Endpoint}/v3/7a9941d34fc1497d8d0797429ecfd354/elb/members
Example Responses
Status code: 200
Successful request.
{ "request_id" : "9bd54b2c-b6c6-4635-9495-dd89bdd917ad", "members" : [ { "name" : "member-1", "weight" : 1, "admin_state_up" : true, "project_id" : "86f9bb15ce80442680229fcd4dc96582", "address" : "192.168.0.157", "protocol_port" : 80, "id" : "f5e20309-c79c-470c-b59c-3c8378792897", "operating_status" : "ONLINE", "status" : [ { "listener_id" : "0663b12d-4a8f-4ee1-8ba2-dd09f2c92ef7", "operating_status" : "ONLINE" }, { "listener_id" : "19ac6a54-336f-44ce-9679-50c4f56e9407", "operating_status" : "ONLINE" } ], "instance_id" : "39b7d471-fbb4-4e6d-ac81-635b4415a27f", "device_id" : "39b7d471-fbb4-4e6d-ac81-635b4415a27f", "device_owner" : "compute:cn-southwest-242a", "member_type" : "instance", "created_at" : "2023-05-04T06:55:33Z", "updated_at" : "2023-05-08T01:34:02Z", "loadbalancer_id" : "9eafbe79-4d48-46f6-95e6-0bc3da57b96d", "loadbalancers" : [ { "id" : "9eafbe79-4d48-46f6-95e6-0bc3da57b96d" } ], "pool_id" : "46cd9381-3d99-4e32-b799-efaf5c274586", "ip_version" : "v4", "subnet_cidr_id" : "1aee2ab8-f238-4c26-8659-2a7a0c201d0a" }, { "name" : "member-2", "admin_state_up" : true, "project_id" : "86f9bb15ce80442680229fcd4dc96582", "address" : "192.168.0.157", "protocol_port" : 80, "id" : "f834d6c6-b376-4031-931e-57cb36bca4a8", "operating_status" : "OFFLINE", "status" : [ ], "instance_id" : "39b7d471-fbb4-4e6d-ac81-635b4415a27f", "device_id" : "39b7d471-fbb4-4e6d-ac81-635b4415a27f", "device_owner" : "compute:cn-southwest-242a", "member_type" : "instance", "created_at" : "2023-05-04T12:46:55Z", "updated_at" : "2023-05-05T03:56:40Z", "loadbalancers" : [ ], "pool_id" : "d17d07db-5bab-4a15-aa6f-8561af133ca7", "ip_version" : "v4", "subnet_cidr_id" : "1aee2ab8-f238-4c26-8659-2a7a0c201d0a" } ], "page_info" : { "next_marker" : "fb1ce58f-2525-4bd9-9606-10851533bd22", "previous_marker" : "fb19f821-5d5f-4d72-b11c-503e874d3915", "current_count" : 2 } }
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 |
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 ListAllMembersSolution { 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(); ListAllMembersRequest request = new ListAllMembersRequest(); try { ListAllMembersResponse response = client.listAllMembers(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 |
# 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 = ListAllMembersRequest() response = client.list_all_members(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 |
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.ListAllMembersRequest{} response, err := client.ListAllMembers(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.
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 |
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 ListAllMembersSolution { 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(); ListAllMembersRequest request = new ListAllMembersRequest(); try { ListAllMembersResponse response = client.listAllMembers(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 |
# 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 = ListAllMembersRequest() response = client.list_all_members(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 |
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.ListAllMembersRequest{} response, err := client.ListAllMembers(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.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot