更新时间:2024-04-18 GMT+08:00

查询负载均衡器详情

功能介绍

查询负载均衡器详情。

调用方法

请参见如何调用API

URI

GET /v3/{project_id}/elb/loadbalancers/{loadbalancer_id}

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

项目ID。

loadbalancer_id

String

负载均衡器ID。

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

IAM鉴权Token。

响应参数

状态码: 200

表3 响应Body参数

参数

参数类型

描述

request_id

String

请求ID。

注:自动生成 。

loadbalancer

LoadBalancer object

负载均衡器对象。

表4 LoadBalancer

参数

参数类型

描述

id

String

负载均衡器ID。

description

String

负载均衡器描述信息。

最小长度:1

最大长度:255

provisioning_status

String

负载均衡器的配置状态。

取值:

  • ACTIVE:使用中。

  • PENDING_DELETE:删除中。

admin_state_up

Boolean

负载均衡器的启用状态。取值:false停用,true启用。

provider

String

负载均衡器的生产者名称。固定为vlb。

pools

Array of PoolRef objects

负载均衡器直接关联的后端云服务器组的ID列表。

listeners

Array of ListenerRef objects

负载均衡器关联的监听器的ID列表。

operating_status

String

负载均衡器的操作状态。

取值:

  • ONLINE:在线。

name

String

负载均衡器的名称。

project_id

String

负载均衡器所属的项目ID。

vip_subnet_cidr_id

String

负载均衡器所在子网的IPv4子网ID。

vip_address

String

负载均衡器的IPv4虚拟IP地址。

vip_port_id

String

负载均衡器的IPv4对应的port ID。

tags

Array of Tag objects

负载均衡的标签列表。

created_at

String

负载均衡器的创建时间。格式:yyyy-MM-dd'T'HH:mm:ss'Z'

updated_at

String

负载均衡器的更新时间。格式:yyyy-MM-dd'T'HH:mm:ss'Z'

guaranteed

Boolean

是否独享型LB。

取值:

  • false:共享型。

  • true:独享型。

vpc_id

String

负载均衡器所在VPC ID。

eips

Array of EipInfo objects

负载均衡器绑定的EIP。只支持绑定一个EIP。

注:该字段与publicips一致。

ipv6_vip_address

String

双栈类型负载均衡器的IPv6地址。

ipv6_vip_virsubnet_id

String

双栈类型负载均衡器所在子网的IPv6网络ID。

ipv6_vip_port_id

String

双栈类型负载均衡器的IPv6对应的port ID。

availability_zone_list

Array of strings

负载均衡器所在的可用区列表。

enterprise_project_id

String

企业项目ID。创建时不传则返回"0",表示资源属于default企业项目。

注:"0"并不是真实存在的企业项目ID,在创建、更新和查询时不能作为请求参数传入。

billing_info

String

资源账单信息。

取值:

  • 空:按需计费。

最小长度:1

最大长度:1024

l4_flavor_id

String

网络型规格ID。

对于弹性扩缩容实例,表示上限规格。

当传入的规格类型为L4,表示该实例为固定规格实例,按规格计费; 当传入的规格类型为L4_elastic_max,表示该实例为弹性实例,按LCU计费

最小长度:1

最大长度:255

l4_scale_flavor_id

String

四层弹性Flavor ID。

不支持该字段,请勿使用。

最小长度:1

最大长度:255

l7_flavor_id

String

应用型ID。 对于弹性扩缩容实例,表示上限规格ID。

当传入的规格类型为L7,表示该实例为固定规格实例,按规格计费; 当传入的规格类型为L7_elastic_max,表示该实例为弹性实例,按LCU计费

最小长度:1

最大长度:255

l7_scale_flavor_id

String

七层弹性Flavor ID。

不支持该字段,请勿使用。

最小长度:1

最大长度:255

publicips

Array of PublicIpInfo objects

负载均衡器绑定的公网IP。只支持绑定一个公网IP。

注:该字段与eips一致。

global_eips

Array of GlobalEipInfo objects

负载均衡器绑定的global eip。只支持绑定一个globaleip。

elb_virsubnet_ids

Array of strings

下联面子网的网络ID列表。

elb_virsubnet_type

String

下联面子网类型

  • ipv4:ipv4

  • dualstack:双栈

ip_target_enable

Boolean

是否启用跨VPC后端转发。

开启跨VPC后端转发后,后端服务器组不仅支持添加云上VPC内的服务器,还支持添加其他VPC、其他公有云、云下数据中心的服务器。

使用共享VPC的实例使用此特性时,需确保共享资源所有者已开通VPC对等连接,否则通信异常。 仅独享型负载均衡器支持该特性。

取值:

  • true:开启。

  • false:不开启。

使用说明:

  • 开启不能关闭。

frozen_scene

String

负载均衡器的冻结场景。 若负载均衡器有多个冻结场景,用逗号分隔。

取值:

  • POLICE:公安冻结场景。

  • ILLEGAL:违规冻结场景。

  • VERIFY:客户未实名认证冻结场景。

  • PARTNER:合作伙伴冻结(合作伙伴冻结子客户资源)。

  • AREAR:欠费冻结场景。

ipv6_bandwidth

BandwidthRef object

带宽对象ID,仅在创建或更新公网IPv6负载均衡器时有效。若选择创建新EIP并指定共享带宽时,此EIP会被分进共享带宽里面。

deletion_protection_enable

Boolean

是否开启删除保护。

取值:

  • false:不开启。

  • true:开启。

说明:

退场时需要先关闭所有资源的删除保护开关。

仅当前局点启用删除保护特性后才会返回该字段。

autoscaling

AutoscalingRef object

弹性扩缩容配置信息。负载均衡器配置并开启弹性扩缩容后,可根据负载情况自动调整负载均衡器的规格。

使用说明:

  • 仅当租户白名单放开后该字段才有效

  • 开启弹性扩缩容后,l4_flavor_id和l7_flavor_id表示该LB实例弹性规格的上限。

该字段已经废弃,但仍然保留兼容性支持,建议不要使用该字段。如果传入该字段,创建的弹性实例将会有保底规格并产生对应保底规格的费用。

public_border_group

String

LB所属AZ组

charge_mode

String

收费模式。取值:

  • flavor:按规格计费

  • lcu:按使用量计费

waf_failure_action

String

WAF故障时的流量处理策略。discard:丢弃,forward: 转发到后端(默认)

使用说明:只有绑定了waf的LB实例,该字段才会生效。

protection_status

String

修改保护状态, 取值:

  • nonProtection: 不保护,默认值为nonProtection

  • consoleProtection: 控制台修改保护

protection_reason

String

设置保护的原因

说明:

仅当protection_status为consoleProtection时有效。

最小长度:0

最大长度:255

log_group_id

String

LB所绑定的logtank对应的group id

log_topic_id

String

LB所绑定的logtank对应的topic id

表5 PoolRef

参数

参数类型

描述

id

String

后端服务器组ID。

表6 ListenerRef

参数

参数类型

描述

id

String

监听器ID。

表7 Tag

参数

参数类型

描述

key

String

标签键

最小长度:1

最大长度:36

value

String

标签值

最小长度:0

最大长度:43

表8 EipInfo

参数

参数类型

描述

eip_id

String

eip_id

eip_address

String

eip_address

ip_version

Integer

IP版本号。

取值:4表示IPv4,6表示IPv6。

表9 PublicIpInfo

参数

参数类型

描述

publicip_id

String

弹性公网ip配置id

publicip_address

String

IP地址

ip_version

Integer

IP版本信息。 取值范围:4和6 4:IPv4 6:IPv6

表10 GlobalEipInfo

参数

参数类型

描述

global_eip_id

String

global eip的id

global_eip_address

String

global eip的ip地址

ip_version

Integer

IP版本信息。 取值范围:4和6 4:IPv4 6:IPv6

表11 BandwidthRef

参数

参数类型

描述

id

String

共享带宽的id

表12 AutoscalingRef

参数

参数类型

描述

enable

Boolean

当前负载均衡器是否开启弹性扩缩容。

取值:

  • true:开启。

  • false:不开启,默认值。

min_l7_flavor_id

String

弹性扩缩容的最小七层规格ID(规格类型L7_elastic),有七层监听器时,该字段不能为空。

该字段已经废弃,但仍然保留兼容性支持,建议不要使用该字段。如果传入该字段,创建的弹性实例将会有保底规格并产生对应保底规格的费用。

最小长度:1

最大长度:36

请求示例

查询指定负载均衡器的详情信息

GET https://{ELB_Endpoint}/v3/060576782980d5762f9ec014dd2f1148/elb/loadbalancers/3dbde7e5-c277-4ea3-a424-edd339357eff

响应示例

状态码: 200

操作正常返回。

{
  "loadbalancer" : {
    "id" : "3dbde7e5-c277-4ea3-a424-edd339357eff",
    "project_id" : "060576782980d5762f9ec014dd2f1148",
    "name" : "elb-l4-no-delete",
    "description" : null,
    "vip_port_id" : "f079c7ee-65a9-44ef-be86-53d8927e59be",
    "vip_address" : "10.0.0.196",
    "admin_state_up" : true,
    "provisioning_status" : "ACTIVE",
    "operating_status" : "ONLINE",
    "listeners" : [ ],
    "pools" : [ {
      "id" : "1d864dc9-f6ef-4366-b59d-7034cde2328f"
    }, {
      "id" : "c0a2e4a1-c028-4a24-a62f-e721c52f5513"
    }, {
      "id" : "79308896-6169-4c28-acbc-e139eb661996"
    } ],
    "tags" : [ ],
    "provider" : null,
    "created_at" : "2019-12-02T09:55:11Z",
    "updated_at" : "2019-12-02T09:55:11Z",
    "vpc_id" : "70711260-9de9-4d96-9839-0ae698e00109",
    "enterprise_project_id" : "0",
    "availability_zone_list" : [ ],
    "ipv6_vip_address" : null,
    "ipv6_vip_virsubnet_id" : null,
    "ipv6_vip_port_id" : null,
    "publicips" : [ ],
    "elb_virsubnet_ids" : [ "ad5d63bf-3b50-4e88-b4d9-e94a59aade48" ],
    "eips" : [ ],
    "guaranteed" : true,
    "billing_info" : null,
    "l4_flavor_id" : "e5acacda-f861-404e-9871-df480c49d185",
    "l4_scale_flavor_id" : null,
    "l7_flavor_id" : null,
    "l7_scale_flavor_id" : null,
    "vip_subnet_cidr_id" : "396d918a-756e-4163-8450-3bdc860109cf",
    "deletion_protection_enable" : false,
    "autoscaling" : {
      "enable" : true,
      "min_l7_flavor_id" : "0c8cf29d-51cb-4c1d-8e25-1c61cf5c2b00"
    },
    "public_border_group" : "center"
  },
  "request_id" : "1a47cfbf-969f-4e40-8c0e-c2e60b14bcac"
}

SDK代码示例

SDK代码示例如下。

 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
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 ShowLoadBalancerSolution {

    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();
        ShowLoadBalancerRequest request = new ShowLoadBalancerRequest();
        try {
            ShowLoadBalancerResponse response = client.showLoadBalancer(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
# 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 = ShowLoadBalancerRequest()
        response = client.show_load_balancer(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
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.ShowLoadBalancerRequest{}
	response, err := client.ShowLoadBalancer(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

200

操作正常返回。

错误码

请参见错误码