计算
弹性云服务器 ECS
Flexus云服务
裸金属服务器 BMS
弹性伸缩 AS
镜像服务 IMS
专属主机 DeH
函数工作流 FunctionGraph
云手机服务器 CPH
Huawei Cloud EulerOS
网络
虚拟私有云 VPC
弹性公网IP EIP
虚拟专用网络 VPN
弹性负载均衡 ELB
NAT网关 NAT
云专线 DC
VPC终端节点 VPCEP
云连接 CC
企业路由器 ER
企业交换机 ESW
全球加速 GA
安全与合规
安全技术与应用
Web应用防火墙 WAF
企业主机安全 HSS
云防火墙 CFW
安全云脑 SecMaster
DDoS防护 AAD
数据加密服务 DEW
数据库安全服务 DBSS
云堡垒机 CBH
数据安全中心 DSC
云证书管理服务 CCM
边缘安全 EdgeSec
CDN与智能边缘
内容分发网络 CDN
CloudPond云服务
智能边缘云 IEC
迁移
主机迁移服务 SMS
对象存储迁移服务 OMS
云数据迁移 CDM
迁移中心 MgC
大数据
MapReduce服务 MRS
数据湖探索 DLI
表格存储服务 CloudTable
云搜索服务 CSS
数据接入服务 DIS
数据仓库服务 GaussDB(DWS)
数据治理中心 DataArts Studio
数据可视化 DLV
数据湖工厂 DLF
湖仓构建 LakeFormation
数智融合计算服务 DataArtsFabric
企业应用
云桌面 Workspace
应用与数据集成平台 ROMA Connect
云解析服务 DNS
专属云
专属计算集群 DCC
IoT物联网
IoT物联网
设备接入 IoTDA
智能边缘平台 IEF
云生态
合作伙伴中心
云商店
开发者工具
SDK开发指南
API签名指南
Terraform
华为云命令行工具服务 KooCLI
其他
产品价格详情
系统权限
管理控制台
客户关联华为云合作伙伴须知
消息中心
公共问题
视频
视频直播 Live
视频点播 VOD
媒体处理 MPC
实时音视频 SparkRTC
数字内容生产线 MetaStudio
开发与运维
应用管理与运维平台 ServiceStage
软件开发生产线 CodeArts
需求管理 CodeArts Req
部署 CodeArts Deploy
性能测试 CodeArts PerfTest
编译构建 CodeArts Build
流水线 CodeArts Pipeline
制品仓库 CodeArts Artifact
测试计划 CodeArts TestPlan
代码检查 CodeArts Check
代码托管 CodeArts Repo
云应用引擎 CAE
华为云Astro轻应用
华为云Astro大屏应用
开源治理服务 CodeArts Governance
存储
对象存储服务 OBS
云硬盘 EVS
云备份 CBR
存储容灾服务 SDRS
高性能弹性文件服务 SFS Turbo
弹性文件服务 SFS
云硬盘备份 VBS
云服务器备份 CSBS
数据快递服务 DES
专属分布式存储服务 DSS
容器
云容器引擎 CCE
容器镜像服务 SWR
应用服务网格 ASM
华为云UCS
云容器实例 CCI
管理与监管
云监控服务 CES
统一身份认证服务 IAM
资源编排服务 RFS
云审计服务 CTS
标签管理服务 TMS
云日志服务 LTS
配置审计 Config
资源访问管理 RAM
消息通知服务 SMN
应用运维管理 AOM
应用性能管理 APM
组织 Organizations
优化顾问 OA
IAM 身份中心
云运维中心 COC
资源治理中心 RGC
应用身份管理服务 OneAccess
数据库
云数据库 RDS
文档数据库服务 DDS
数据管理服务 DAS
数据复制服务 DRS
云数据库 GeminiDB
云数据库 GaussDB
分布式数据库中间件 DDM
数据库和应用迁移 UGO
云数据库 TaurusDB
人工智能
人脸识别服务 FRS
图引擎服务 GES
图像识别 Image
内容审核 Moderation
文字识别 OCR
AI开发平台ModelArts
图像搜索 ImageSearch
对话机器人服务 CBS
华为HiLens
视频智能分析服务 VIAS
语音交互服务 SIS
应用中间件
分布式缓存服务 DCS
API网关 APIG
微服务引擎 CSE
分布式消息服务Kafka版
分布式消息服务RabbitMQ版
分布式消息服务RocketMQ版
多活高可用服务 MAS
事件网格 EG
企业协同
华为云会议 Meeting
云通信
消息&短信 MSGSMS
云化转型
云架构中心
云采用框架
用户服务
账号中心
费用中心
成本中心
资源中心
企业管理
工单管理
国际站常见问题
ICP备案
我的凭证
支持计划
客户运营能力
合作伙伴支持计划
专业服务
区块链
区块链服务 BCS
Web3节点引擎服务 NES
解决方案
SAP
高性能计算 HPC
开天aPaaS
云消息服务 KooMessage
云手机服务 KooPhone
云空间服务 KooDrive

查询所有实例列表

功能介绍

查询租户的实例列表,支持按照条件查询。

调用方法

请参见如何调用API

URI

GET /v2/{project_id}/instances

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

参数解释

项目ID,获取方式请参见获取项目ID

约束限制

不涉及。

取值范围

不涉及。

默认取值

不涉及。

表2 Query参数

参数

是否必选

参数类型

描述

engine

String

参数解释

引擎类型:rabbitmq。

约束限制

不涉及。

取值范围

不涉及。

默认取值

不涉及。

name

String

参数解释

实例名称。获取方式:登录RabbitMQ控制台,在RabbitMQ实例详情页面查找实例名称。

约束限制

不涉及。

取值范围

不涉及。

默认取值

不涉及。

instance_id

String

参数解释

实例ID。获取方法如下:登录RabbitMQ控制台,在RabbitMQ实例详情页面查找实例ID。

约束限制

不涉及。

取值范围

不涉及。

默认取值

不涉及。

status

String

参数解释

实例状态,详细状态说明请参考实例状态说明

约束限制

不涉及。

取值范围

不涉及。

默认取值

不涉及。

include_failure

String

参数解释

是否返回创建失败的实例数。

约束限制

不涉及。

取值范围

  • true:返回创建失败的实例数。

  • false:不返回创建失败的实例数。

默认取值

不涉及。

exact_match_name

String

参数解释

是否按照实例名称进行精确匹配查询。

约束限制

不涉及。

取值范围

  • true:按照实例名称进行精确匹配查询。

  • false:按照模糊匹配实例名称查询。

默认取值

false

enterprise_project_id

String

参数解释

企业项目ID。

约束限制

不涉及。

取值范围

不涉及。

默认取值

不涉及。

offset

String

参数解释

偏移量,表示从此偏移量开始查询。

约束限制

不涉及。

取值范围

大于等于0

默认取值

不涉及。

limit

String

参数解释

当次查询返回的最大实例个数。

约束限制

不涉及。

取值范围

1~50

默认取值

10

请求参数

响应参数

状态码:200

表3 响应Body参数

参数

参数类型

描述

instances

Array of ShowInstanceResp objects

参数解释

实例列表。

instance_num

Integer

参数解释

实例个数。

取值范围

不涉及。

表4 ShowInstanceResp

参数

参数类型

描述

access_user

String

参数解释

认证用户名。

取值范围

不涉及。

broker_num

Integer

参数解释

代理个数。

取值范围

  • 1

  • 3

  • 5

  • 7

name

String

参数解释

实例名称。

取值范围

不涉及。

engine

String

参数解释

消息引擎。

取值范围

不涉及。

engine_version

String

参数解释

消息引擎版本。

取值范围

不涉及。

specification

String

参数解释

实例规格。

取值范围

  • 单机实例:返回vm规格。

  • 集群实例:返回vm规格和节点数。

storage_space

Integer

参数解释

消息存储空间,单位:GB。

取值范围

不涉及。

used_storage_space

Integer

参数解释

已使用的消息存储空间,单位:GB。

取值范围

不涉及。

dns_enable

Boolean

参数解释

实例是否开启域名访问功能。

取值范围

  • true:开启

  • false:未开启

connect_address

String

参数解释

实例内网连接IP地址。

取值范围

不涉及。

connect_domain_name

String

参数解释

实例内网连接域名。

取值范围

不涉及。

public_connect_address

String

参数解释

实例公网连接IP地址。

取值范围

不涉及。

public_connect_domain_name

String

参数解释

实例公网连接域名。

取值范围

不涉及。

port

Integer

参数解释

实例连接端口。

取值范围

不涉及。

status

String

参数解释

实例状态。

取值范围

详细状态说明请参考实例状态说明

description

String

参数解释

实例描述。

取值范围

不涉及。

instance_id

String

参数解释

实例ID。

取值范围

不涉及。

resource_spec_code

String

参数解释

资源规格标识。

取值范围

  • dms.instance.rabbitmq.single.c3.2u4g:RabbitMQ单机,vm规格2u4g

  • dms.instance.rabbitmq.single.c3.4u8g:RabbitMQ单机,vm规格4u8g

  • dms.instance.rabbitmq.single.c3.8u16g:RabbitMQ单机,vm规格8u16g

  • dms.instance.rabbitmq.single.c3.16u32g:RabbitMQ单机,vm规格16u32g

  • dms.instance.rabbitmq.cluster.c3.4u8g.3:RabbitMQ集群,vm规格4u8g,3个节点

  • dms.instance.rabbitmq.cluster.c3.4u8g.5:RabbitMQ集群,vm规格4u8g,5个节点

  • dms.instance.rabbitmq.cluster.c3.4u8g.7:RabbitMQ集群,vm规格4u8g,7个节点

  • dms.instance.rabbitmq.cluster.c3.8u16g.3:RabbitMQ集群,vm规格8u16g,3个节点

  • dms.instance.rabbitmq.cluster.c3.8u16g.5:RabbitMQ集群,vm规格8u16g,5个节点

  • dms.instance.rabbitmq.cluster.c3.8u16g.7:RabbitMQ集群,vm规格8u16g,7个节点

  • dms.instance.rabbitmq.cluster.c3.16u32g.3:RabbitMQ集群,vm规格16u32g,3个节点

  • dms.instance.rabbitmq.cluster.c3.16u32g.5:RabbitMQ集群,vm规格16u32g,5个节点

  • dms.instance.rabbitmq.cluster.c3.16u32g.7:RabbitMQ集群,vm规格16u32g,7个节点

charging_mode

Integer

参数解释

付费模式。

取值范围

  • 1:按需计费。

  • 0:包年/包月计费。

vpc_id

String

参数解释

VPC ID。

取值范围

不涉及。

vpc_name

String

参数解释

VPC的名称。

取值范围

不涉及。

created_at

String

参数解释

完成创建时间。格式为时间戳,指从格林威治时间 1970年01月01日00时00分00秒起至指定时间的偏差总毫秒数。

取值范围

不涉及。

user_id

String

参数解释

用户ID。

取值范围

不涉及。

user_name

String

参数解释

用户名。

取值范围

不涉及。

order_id

String

参数解释

订单ID,只有在包周期计费时才会有order_id值,其他计费方式order_id值为空。

取值范围

不涉及。

maintain_begin

String

参数解释

维护时间窗开始时间,格式为HH:mm:ss。

取值范围

不涉及。

maintain_end

String

参数解释

维护时间窗结束时间,格式为HH:mm:ss。

取值范围

不涉及。

enable_publicip

Boolean

参数解释

RabbitMQ实例是否开启公网访问功能。

取值范围

  • true:开启

  • false:未开启

publicip_address

String

参数解释

RabbitMQ实例绑定的弹性IP地址。

如果未开启公网访问功能,该字段值为null。

取值范围

  • true:开启

  • false:未开启

publicip_id

String

参数解释

RabbitMQ实例绑定的弹性IP地址的ID。

如果未开启公网访问功能,该字段值为null。

取值范围

不涉及。

management_connect_address

String

参数解释

RabbitMQ实例的管理地址。

取值范围

不涉及。

management_connect_domain_name

String

参数解释

RabbitMQ实例的管理域名。

取值范围

不涉及。

public_management_connect_address

String

参数解释

RabbitMQ实例的公网管理地址。

取值范围

不涉及。

public_management_connect_domain_name

String

参数解释

RabbitMQ实例的公网管理域名。

取值范围

不涉及。

ssl_enable

Boolean

参数解释

是否开启安全认证。

取值范围

  • true:开启

  • false:未开启

enterprise_project_id

String

参数解释

企业项目ID。

取值范围

不涉及。

is_logical_volume

Boolean

参数解释

实例扩容时用于区分老实例与新实例。

取值范围

  • true:新创建的实例,允许磁盘动态扩容不需要重启。

  • false:特别老的实例不支持磁盘扩容。

extend_times

Integer

参数解释

实例扩容磁盘次数,如果超过20次则无法扩容磁盘。

取值范围

不涉及。

type

String

参数解释

实例类型。

取值范围

  • single:单机。

  • cluster:集群。

product_id

String

参数解释

产品标识。

取值范围

不涉及。

security_group_id

String

参数解释

安全组ID。

取值范围

不涉及。

security_group_name

String

参数解释

租户安全组名称。

取值范围

不涉及。

subnet_id

String

参数解释

子网ID。

取值范围

不涉及。

available_zones

Array of strings

参数解释

实例节点所在的可用区ID。

available_zone_names

Array of strings

参数解释

实例节点所在的可用区名称。

total_storage_space

Integer

参数解释

总共消息存储空间,单位:GB。

取值范围

不涉及。

storage_resource_id

String

参数解释

存储资源ID。

取值范围

不涉及。

storage_spec_code

String

参数解释

IO规格。

取值范围

不涉及。

ipv6_enable

Boolean

参数解释

是否开启IPv6。

取值范围

  • true:开启。

  • false:不开启。

ipv6_connect_addresses

Array of strings

参数解释

IPv6的连接地址。

tags

Array of TagEntity objects

参数解释

标签列表。

表5 TagEntity

参数

参数类型

描述

key

String

参数解释

标签键。

取值范围

不涉及。

value

String

参数解释

标签值。

取值范围

不涉及。

请求示例

查询所有实例列表。

GET https://{endpoint}/v2/{project_id}/instances

响应示例

状态码:200

查询所有实例列表成功。

{
  "instances" : [ {
    "name" : "api-explorer",
    "engine" : "rabbitmq",
    "port" : 5672,
    "status" : "RUNNING",
    "type" : "single",
    "specification" : "2vCPUs 4GB",
    "engine_version" : "3.8.35",
    "connect_address" : "192.168.0.74",
    "instance_id" : "de873040-d661-4770-aa96-9329c71d7c8a",
    "resource_spec_code" : "dms.instance.rabbitmq.single.c3.2u4g",
    "charging_mode" : 1,
    "vpc_id" : "40a6501e-85ca-4449-a0db-b8bc7f0cec28",
    "vpc_name" : "vpc-a400",
    "created_at" : "1590047080687",
    "product_id" : "00300-30109-0--0",
    "security_group_id" : "bfd68e26-f8ef-4a91-a373-0a8f5c198601",
    "security_group_name" : "Sys-default",
    "subnet_id" : "a7f9a564-30dd-4059-8124-364ca6554578",
    "available_zones" : [ "9f1c5806706d4c1fb0eb72f0a9b18c77" ],
    "available_zone_names" : [ "AZ1" ],
    "user_id" : "3df5acbc24a54fadb62a043c9000a307",
    "user_name" : "********",
    "maintain_begin" : "22:00:00",
    "maintain_end" : "02:00:00",
    "storage_space" : 88,
    "total_storage_space" : 100,
    "used_storage_space" : 4,
    "enable_publicip" : false,
    "ssl_enable" : false,
    "management_connect_address" : "http://192.168.0.74:15672",
    "storage_resource_id" : "52be287d-1d6a-4d30-937e-185b3f176fc4",
    "storage_spec_code" : "dms.physical.storage.normal",
    "enterprise_project_id" : "0",
    "tags" : [ {
      "key" : "key1",
      "value" : "value1"
    }, {
      "key" : "key2",
      "value" : "value2"
    } ],
    "is_logical_volume" : true,
    "extend_times" : 0,
    "ipv6_enable" : false,
    "ipv6_connect_addresses" : [ ]
  } ],
  "instance_num" : 1
}

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
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.rabbitmq.v2.region.RabbitMQRegion;
import com.huaweicloud.sdk.rabbitmq.v2.*;
import com.huaweicloud.sdk.rabbitmq.v2.model.*;


public class ListInstancesDetailsSolution {

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

        RabbitMQClient client = RabbitMQClient.newBuilder()
                .withCredential(auth)
                .withRegion(RabbitMQRegion.valueOf("<YOUR REGION>"))
                .build();
        ListInstancesDetailsRequest request = new ListInstancesDetailsRequest();
        try {
            ListInstancesDetailsResponse response = client.listInstancesDetails(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 huaweicloudsdkrabbitmq.v2.region.rabbitmq_region import RabbitMQRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkrabbitmq.v2 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 = RabbitMQClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(RabbitMQRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ListInstancesDetailsRequest()
        response = client.list_instances_details(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"
    rabbitmq "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/rabbitmq/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/rabbitmq/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/rabbitmq/v2/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 := rabbitmq.NewRabbitMQClient(
        rabbitmq.RabbitMQClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.ListInstancesDetailsRequest{}
	response, err := client.ListInstancesDetails(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的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
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.rabbitmq.v2.region.RabbitMQRegion;
import com.huaweicloud.sdk.rabbitmq.v2.*;
import com.huaweicloud.sdk.rabbitmq.v2.model.*;


public class ListInstancesDetailsSolution {

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

        RabbitMQClient client = RabbitMQClient.newBuilder()
                .withCredential(auth)
                .withRegion(RabbitMQRegion.valueOf("<YOUR REGION>"))
                .build();
        ListInstancesDetailsRequest request = new ListInstancesDetailsRequest();
        try {
            ListInstancesDetailsResponse response = client.listInstancesDetails(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 huaweicloudsdkrabbitmq.v2.region.rabbitmq_region import RabbitMQRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkrabbitmq.v2 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 = RabbitMQClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(RabbitMQRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ListInstancesDetailsRequest()
        response = client.list_instances_details(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"
    rabbitmq "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/rabbitmq/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/rabbitmq/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/rabbitmq/v2/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 := rabbitmq.NewRabbitMQClient(
        rabbitmq.RabbitMQClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.ListInstancesDetailsRequest{}
	response, err := client.ListInstancesDetails(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

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

状态码

状态码

描述

200

查询所有实例列表成功。

错误码

请参见错误码

我们使用cookie来确保您的高速浏览体验。继续浏览本站,即表示您同意我们使用cookie。 详情

文档反馈

文档反馈

意见反馈

0/500

标记内容

同时提交标记内容