更新时间:2024-10-11 GMT+08:00
分享

查询实例详情

功能介绍

查询设备接入实例详情。

调用方法

请参见如何调用API

URI

GET /v5/iot/{project_id}/iotda-instances/{instance_id}

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

参数说明:项目ID。获取方法请参见 获取项目ID

instance_id

String

参数说明:实例ID。

取值范围:长度不超过36,由小写字母[a-f]、数字、连接符(-)的组成。

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

参数说明:用户Token。通过调用IAM服务 获取IAM用户Token接口获取,接口返回的响应消息头中“X-Subject-Token”就是需要获取的用户Token。简要的获取方法样例请参见 Token认证

响应参数

状态码: 200

表3 响应Body参数

参数

参数类型

描述

instance_type

String

参数说明:实例类型。

取值范围

  • standard:标准版实例

  • enterprise:企业版实例

instance_id

String

参数说明:实例ID。

取值范围:长度不超过36,由小写字母[a-f]、数字、连接符(-)的组成。

charge_mode

String

参数说明:实例的付费方式。

取值范围

  • prePaid:包年/包月

  • postPaid:按需计费

name

String

参数说明:实例名称。

取值范围:由中文字符,英文字母、数字及“_”、“-”组成,且长度为[1-64]个字符。

flavor

Flavor object

参数说明:设备接入实例的规格参数。

status

String

参数说明:实例状态。

取值范围

  • CREATING:实例正在创建

  • ACTIVE:实例正常

  • FROZEN:实例冻结

  • TRADING: 实例正在进行交易

  • MODIFYING:实例正在变更规格

  • FAILED:实例创建失败

description

String

参数说明:设备接入实例的描述信息。

取值范围:长度不超过256,只允许中文、字母、数字、以及_,,.。、&-等字符的组合。

access_infos

Array of AccessInfo objects

参数说明:设备接入实例的接入信息。

create_time

String

参数说明:实例的创建时间。时间格式例如:2023-01-28T06:57:52Z。

update_time

String

参数说明:实例的最近一次更新的时间。时间格式例如:2023-01-28T06:57:52Z。

enterprise_project_id

String

参数说明:企业项目Id。

tags

Array of Tag objects

参数说明: 设备接入实例的标签信息。如果实例有标签,则会有该字段,否则该字段为空。

order_id

String

参数说明:订单号,仅包年包月实例返回该参数。查看订单详情请参考查询订单详情

operate_window

OperateWindow object

实例维护时间窗,用户在变更实例规格时,可以指定在该时间窗内进行变更。

additional_params

AdditionalParamsResp object

企业版附加参数信息。

表4 Flavor

参数

参数类型

描述

type

String

参数说明:待创建设备接入实例的规格名称。详情请参见产品规格说明中的规格编码。

size

Integer

参数说明:待创建设备接入标准版实例的单元数量。详情请参见产品规格说明。当instance_type是standard时,该参数必填。

表5 AccessInfo

参数

参数类型

描述

type

String

参数说明:接入地址的类型,如应用接入的HTTPS协议的取值为:APP_HTTPS,设备接入的MQTT协议的取值为:DEVICE_MQTT。

取值范围

  • APP_HTTPS:应用接入HTTPS协议

  • APP_AMQP:应用接入AMQP协议

  • APP_MQTT:应用接入MQTT协议

  • DEVICE_COAP:设备接入COAP协议

  • DEVICE_MQTT:设备接入MQTT协议

  • DEVICE_HTTPS:设备接入HTTPS协议

port

Integer

参数说明:实例的应用/设备的安全接入端口。

non_tls_port

Integer

参数说明:实例的应用/设备的非安全接入端口。返回null时表示该类型的接入地址不支持非安全端口接入。

websocket_port

Integer

参数说明:基于WebSocket的MQTT接入端口。返回null时表示该类型的接入地址不支持WebSocket端口接入。

domain_name

String

参数说明:实例的接入域名。

private_addresses

Array of strings

参数说明:实例的私网接入地址列表。

public_address

Array of strings

参数说明:实例的公网接入地址。

ipv6_address

Array of strings

参数说明:实例的ipv6接入地址列表。

ip_whitelist

IPWhiteList object

IP白名单

约束:只有企业版实例的APP_HTTPS协议支持配置IP白名单。

表6 IPWhiteList

参数

参数类型

描述

enable

Boolean

参数说明:启用Ip白名单访问控制。

allow_list

Array of IpAllowList objects

参数说明:允许访问企业版实例的IP地址列表。

表7 IpAllowList

参数

参数类型

描述

address

String

参数说明:白名单ip地址。

description

String

参数说明:描述。

表8 Tag

参数

参数类型

描述

key

String

参数说明:标签键,标签的键可用字母(包含中文)、数字、空格和以下字符:下划线(_)点(.)冒号(:)等号(=)加号(+)中划线(-)以及@,首尾不能有空格字符。

value

String

参数说明:标签值,可为空字符串和null,标签的值可用字母(包含中文)、数字、空格和以下字符:下划线(_)点(.)冒号(:)等号(=)加号(+)中划线(-)以及@。

表9 OperateWindow

参数

参数类型

描述

start_time

String

参数说明:变更时间窗开始时间,UTC时间,格式为:"HH:mm"

end_time

String

参数说明:变更时间窗结束时间,UTC时间,格式为:"HH:mm"

表10 AdditionalParamsResp

参数

参数类型

描述

vpc_id

String

参数说明:企业版实例的VPCID。

subnet_id

String

参数说明:企业版实例的子网ID。

security_group_id

String

参数说明:企业版实例的安全组ID。

ciphering_algorithm

String

参数说明:实例支持的加密算法。

取值范围

  • COMMON_ALGORITHM: 通用加密算法(支持RSA,SHA256等国际通用的密码算法)

  • SM_ALGORITHM: 支持SM系列商密算法(支持SM2,SM3,SM4等国密算法)

forwarding_info

ForwardingInfo object

企业版实例的SNAT配置信息。

表11 ForwardingInfo

参数

参数类型

描述

eip

String

参数说明:NAT网关绑定的EIP。

enable_snat

Boolean

参数说明:是否启用SNAT配置。

取值范围

  • true: SNAT配置已启用

  • false: SNAT配置未启用

请求示例

查询指定实例。

GET https://{endpoint}/v5/iot/{project_id}/iotda-instances/{instance_id}

响应示例

状态码: 200

OK

{
  "instance_type" : "standard",
  "instance_id" : "8561675c-d8a3-4956-9884-9cf9cbdd3134",
  "charge_mode" : "prePaid",
  "name" : "iotda_instance",
  "flavor" : {
    "type" : "iotda.standard.s1",
    "size" : 1
  },
  "status" : "ACTIVE",
  "create_time" : "2023-01-28T06:57:52Z",
  "update_time" : "2023-01-28T06:58:52Z",
  "description" : "IoTDA instance for production.",
  "access_infos" : [ {
    "type" : "APP_AMQP",
    "port" : 5671,
    "non_tls_port" : null,
    "websocket_port" : null,
    "domain_name" : "example.myhuaweicloud.com",
    "public_address" : [ ],
    "ipv6_address" : [ ],
    "ip_whitelist" : null
  }, {
    "type" : "APP_HTTPS",
    "port" : 443,
    "non_tls_port" : null,
    "websocket_port" : null,
    "domain_name" : "example1.myhuaweicloud.com",
    "public_address" : [ ],
    "ipv6_address" : [ ],
    "ip_whitelist" : null
  }, {
    "type" : "DEVICE_MQTT",
    "port" : 8883,
    "non_tls_port" : 1883,
    "websocket_port" : 443,
    "domain_name" : "example2.myhuaweicloud.com",
    "public_address" : [ ],
    "ipv6_address" : [ ],
    "ip_whitelist" : null
  }, {
    "type" : "DEVICE_COAP",
    "port" : 5684,
    "non_tls_port" : 5683,
    "websocket_port" : null,
    "domain_name" : "example3.myhuaweicloud.com",
    "public_address" : [ ],
    "ipv6_address" : [ ],
    "ip_whitelist" : null
  } ],
  "enterprise_project_id" : "d22e47e9-cfad-4254-8a29-d2a56a07681d",
  "tags" : [ {
    "key" : "testTagName",
    "value" : "testTagValue"
  } ],
  "order_id" : "CS22121614500ABCD",
  "operate_window" : {
    "start_time" : "22:00",
    "end_time" : "24:00"
  },
  "additional_params" : null
}

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
48
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.iotdm.v5.region.IoTDMRegion;
import com.huaweicloud.sdk.iotdm.v5.*;
import com.huaweicloud.sdk.iotdm.v5.model.*;


public class ShowInstanceSolution {

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

        IoTDMClient client = IoTDMClient.newBuilder()
                .withCredential(auth)
                .withRegion(IoTDMRegion.valueOf("<YOUR REGION>"))
                .build();
        ShowInstanceRequest request = new ShowInstanceRequest();
        request.withInstanceId("{instance_id}");
        try {
            ShowInstanceResponse response = client.showInstance(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
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkiotdm.v5.region.iotdm_region import IoTDMRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkiotdm.v5 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 = IoTDMClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(IoTDMRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ShowInstanceRequest()
        request.instance_id = "{instance_id}"
        response = client.show_instance(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
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    iotdm "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iotdm/v5"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iotdm/v5/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iotdm/v5/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 := iotdm.NewIoTDMClient(
        iotdm.IoTDMClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

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

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

状态码

状态码

描述

200

OK

400

Bad Request

401

Unauthorized

错误码

请参见错误码

相关文档