Updated on 2026-09-01 GMT+08:00

Create an IoTDA Instance

Function

This API is used to create an IoTDA instance. For details about the supported instance specifications, see Specifications.

Debugging

You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.

  • If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
  • If you are using identity policy-based authorization, the following identity policy-based permissions are required.

    Action

    Access Level

    Resource Type (*: required)

    Condition Key

    Alias

    Dependencies

    iotda:instance:create

    Write

    instance *

    g:EnterpriseProjectId

    -

    -

    -

    • g:TagKeys

    • g:RequestTag/<tag-key>

URI

POST /v5/iot/{project_id}/iotda-instances

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Parameter description : project ID. For details, see Obtaining a Project ID.

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

instance_type

Yes

String

Parameter description : type of the instance to be created. For details about instance types, see Specifications.
  • standard

  • enterprise

Options:

flavor

Yes

Flavor object

Parameter description: specifications of an IoTDA instance.

name

Yes

String

Parameter description: instance name.

Value: Enter 1 to 64 characters, including letters, digits, underscores (_), and hyphens (-).

charge_info

Yes

ChargeInfo object

Parameter description: billing information of an IoTDA instance.

description

No

String

Parameter description: description of an IoTDA instance.

Value: The value can contain a maximum of 256 characters. Use only letters, digits, and special characters (_,.&-).

enterprise_project_id

No

String

Parameter description: enterprise project ID. If this parameter is set to a specific enterprise project ID or 0 (default enterprise project ID), the enterprise project feature is supported. You can obtain the value from Enterprise Project Management Service (EPS).

Value: Enter up to 36 characters, including lowercase letters (a-f), digits, and hyphens (-).

tags

No

Array of Tag objects

Parameter description: tag information of an IoTDA instance.

additional_params

No

AdditionalParams object

Additional parameter information of the enterprise edition.

Table 3 Flavor

Parameter

Mandatory

Type

Description

type

Yes

String

Parameter description : specification name of the IoTDA instance to create. For details, see Specifications.

size

No

Integer

Parameter description : unit number of the standard IoTDA instances to create. For details, see Specifications. This parameter is mandatory when instance_type is set to standard.

Table 4 ChargeInfo

Parameter

Mandatory

Type

Description

charge_mode

Yes

String

Parameter description: payment mode of the instance.

Options:

  • prePaid: yearly/monthly

  • postPaid: pay-per-use

period_type

No

String

Parameter description: period type of the subscribed IoTDA instance. This parameter is valid and mandatory only when charge_mode is set to prePaid.

Options:

  • month

  • year

period_num

No

Integer

Parameter description: number of periods for subscribing to an IoTDA instance. This parameter is valid and mandatory only when charge_mode is set to prePaid.

Value: If period_type is set to month, the value ranges from 1 to 9. If period_type is set to year, the value ranges from 1 to 3.

is_auto_renew

No

Boolean

Parameter description: whether to automatically renew the subscription, specified during yearly/monthly instance creation. The renewal period is the same as the original period, and the payment is automatically made during the renewal.

Options:

  • true

  • false (default value)

is_auto_pay

No

Boolean

Parameter description : whether to automatically pay from the customer's account. This parameter can be specified when a yearly/monthly instance is created. This parameter does not affect the payment mode of automatic renewal.

Value : true : automatic payment. Fees are automatically deducted from the account balance. false : default value. Orders are submitted but not paid. Pay for the order by referring to Paying Yearly/Monthly Product Orders.

promotion_infos

No

String

Parameter description: promotion information.

Table 5 Tag

Parameter

Mandatory

Type

Description

key

Yes

String

Parameter description: tag key. Use letters, digits, spaces, and special characters (_.:=+-@). No space is allowed at the beginning or end.

value

No

String

Parameter description: tag value, which can be an empty string or null. Use letters, digits, spaces, and special characters (_.:=+-@).

Table 6 AdditionalParams

Parameter

Mandatory

Type

Description

vpc_id

Yes

String

Parameter description: VPC ID of the instance of the enterprise edition.

subnet_id

Yes

String

Parameter description: subnet ID of the instance of the enterprise edition.

security_group_id

Yes

String

Parameter description: security group ID of the instance of the enterprise edition. Ensure that port 22 (Linux SSH login), port 3389 (Windows remote login), and ICMP (Ping) have been enabled for the selected security group.

smn_topic_urn

No

String

Parameter description: SMN topic URN. When an instance of the enterprise edition is successfully created, the platform sends notifications through this topic.

ciphering_algorithm

No

String

Parameter description: encryption algorithm supported by the instance.

Options:

  • COMMON_ALGORITHM: common encryption algorithm (international cryptographic algorithms such as RSA and SHA-256)

  • SM_ALGORITHM: SM series commercial encryption algorithms (Chinese cryptographic algorithms such as SM2, SM3, and SM4)

port_info

Yes

Port object

Port information of the enterprise edition. This parameter is mandatory when you create an enterprise instance.

Table 7 Port

Parameter

Mandatory

Type

Description

app_https_port

No

Integer

Parameter description: HTTPS port for application access. The default value is 443.

app_amqps_port

No

Integer

Parameter description: AMQP port for application access. The default value is 5671.

app_mqtts_port

No

Integer

Parameter description: MQTTS port for application access. The default value is 8883.

device_coap_port

No

Integer

Parameter description: CoAP port for device access. The default value is 5683.

device_coaps_port

No

Integer

Parameter description: CoAPS port for device access. The default value is 5684.

device_mqtt_port

No

Integer

Parameter description: MQTT port for device access. The default value is 1883.

device_mqtts_port

No

Integer

Parameter description: MQTTS port for device access. The default value is 8883.

device_https_port

No

Integer

Parameter description: HTTPS port for device access. The default value is 443.

Response Parameters

Status code: 200

Table 8 Response body parameters

Parameter

Type

Description

instance_type

String

Parameter description: instance type.

Options:

  • standard

  • enterprise

instance_id

String

Parameter description: instance ID.

Value: Enter up to 36 characters, including lowercase letters (a-f), digits, and hyphens (-).

name

String

Parameter description: instance name.

Value: Enter 1 to 64 characters, including letters, digits, underscores (_), and hyphens (-).

flavor

Flavor object

Parameter description: specifications of an IoTDA instance.

status

String

Parameter description: instance status.

Options:

  • CREATING: The instance is being created.

  • ACTIVE: The instance is normal.

  • FROZEN: The instance is frozen.

  • TRADING: The instance is in a transaction.

  • MODIFYING: The instance class is being changed.

  • MODIFY_FAILED: The instance modification failed.

  • FAILED: The instance fails to be created.

charge_info

ChargeInfo object

Parameter description: billing information of an IoTDA instance.

description

String

Parameter description: description of an IoTDA instance.

Value: The value can contain a maximum of 256 characters. Use only letters, digits, spaces, and special characters (_,.&-).

enterprise_project_id

String

Parameter description: enterprise project ID.

tags

Array of Tag objects

Parameter description: tag information of an IoTDA instance. This field has values if the instance has tags. Or, it is left empty.

order_id

String

Parameter description: order ID.

additional_params

AdditionalParams object

Additional parameter information of the enterprise edition.

Table 9 Flavor

Parameter

Type

Description

type

String

Parameter description : specification name of the IoTDA instance to create. For details, see Specifications.

size

Integer

Parameter description : unit number of the standard IoTDA instances to create. For details, see Specifications. This parameter is mandatory when instance_type is set to standard.

Table 10 ChargeInfo

Parameter

Type

Description

charge_mode

String

Parameter description: payment mode of the instance.

Options:

  • prePaid: yearly/monthly

  • postPaid: pay-per-use

period_type

String

Parameter description: period type of the subscribed IoTDA instance. This parameter is valid and mandatory only when charge_mode is set to prePaid.

Options:

  • month

  • year

period_num

Integer

Parameter description: number of periods for subscribing to an IoTDA instance. This parameter is valid and mandatory only when charge_mode is set to prePaid.

Value: If period_type is set to month, the value ranges from 1 to 9. If period_type is set to year, the value ranges from 1 to 3.

is_auto_renew

Boolean

Parameter description: whether to automatically renew the subscription, specified during yearly/monthly instance creation. The renewal period is the same as the original period, and the payment is automatically made during the renewal.

Options:

  • true

  • false (default value)

is_auto_pay

Boolean

Parameter description : whether to automatically pay from the customer's account. This parameter can be specified when a yearly/monthly instance is created. This parameter does not affect the payment mode of automatic renewal.

Value : true : automatic payment. Fees are automatically deducted from the account balance. false : default value. Orders are submitted but not paid. Pay for the order by referring to Paying Yearly/Monthly Product Orders.

promotion_infos

String

Parameter description: promotion information.

Table 11 Tag

Parameter

Type

Description

key

String

Parameter description: tag key. Use letters, digits, spaces, and special characters (_.:=+-@). No space is allowed at the beginning or end.

value

String

Parameter description: tag value, which can be an empty string or null. Use letters, digits, spaces, and special characters (_.:=+-@).

Table 12 AdditionalParams

Parameter

Type

Description

vpc_id

String

Parameter description: VPC ID of the instance of the enterprise edition.

subnet_id

String

Parameter description: subnet ID of the instance of the enterprise edition.

security_group_id

String

Parameter description: security group ID of the instance of the enterprise edition. Ensure that port 22 (Linux SSH login), port 3389 (Windows remote login), and ICMP (Ping) have been enabled for the selected security group.

smn_topic_urn

String

Parameter description: SMN topic URN. When an instance of the enterprise edition is successfully created, the platform sends notifications through this topic.

ciphering_algorithm

String

Parameter description: encryption algorithm supported by the instance.

Options:

  • COMMON_ALGORITHM: common encryption algorithm (international cryptographic algorithms such as RSA and SHA-256)

  • SM_ALGORITHM: SM series commercial encryption algorithms (Chinese cryptographic algorithms such as SM2, SM3, and SM4)

port_info

Port object

Port information of the enterprise edition. This parameter is mandatory when you create an enterprise instance.

Table 13 Port

Parameter

Type

Description

app_https_port

Integer

Parameter description: HTTPS port for application access. The default value is 443.

app_amqps_port

Integer

Parameter description: AMQP port for application access. The default value is 5671.

app_mqtts_port

Integer

Parameter description: MQTTS port for application access. The default value is 8883.

device_coap_port

Integer

Parameter description: CoAP port for device access. The default value is 5683.

device_coaps_port

Integer

Parameter description: CoAPS port for device access. The default value is 5684.

device_mqtt_port

Integer

Parameter description: MQTT port for device access. The default value is 1883.

device_mqtts_port

Integer

Parameter description: MQTTS port for device access. The default value is 8883.

device_https_port

Integer

Parameter description: HTTPS port for device access. The default value is 443.

Example Requests

  • Create an instance. Specifications: standard intermediate-frequency units, 2 units, and yearly billing.

    POST https://{endpoint}/v5/iot/{project_id}/iotda-instances
    
    {
      "instance_type" : "standard",
      "flavor" : {
        "type" : "iotda.standard.s1",
        "size" : 2
      },
      "name" : "iotda_instance",
      "charge_info" : {
        "charge_mode" : "prePaid",
        "period_type" : "year",
        "period_num" : 1,
        "is_auto_renew" : "true",
        "is_auto_pay" : "false"
      },
      "description" : "IoTDA instance for production.",
      "enterprise_project_id" : "d22e47e9-cfad-4254-8a29-d2a56a07681d",
      "tags" : [ {
        "key" : "testTagName",
        "value" : "testTagValue"
      } ]
    }
  • Create an instance. Specifications: standard intermediate-frequency units, 2 units, and pay-per-use billing.

    POST https://{endpoint}/v5/iot/{project_id}/iotda-instances
    
    {
      "instance_type" : "standard",
      "flavor" : {
        "type" : "iotda.standard.s2",
        "size" : 2
      },
      "name" : "iotda_instance",
      "charge_info" : {
        "charge_mode" : "postPaid"
      },
      "description" : "IoTDA instance for production.",
      "enterprise_project_id" : "d22e47e9-cfad-4254-8a29-d2a56a07681d"
    }
  • Create an instance. Specifications: enterprise edition and yearly billing.

    POST https://{endpoint}/v5/iot/{project_id}/iotda-instances
    
    {
      "instance_type" : "enterprise",
      "flavor" : {
        "type" : "iotda.enterprise.1000tps.10wonlinedevice"
      },
      "name" : "iotda_enterprise_instance",
      "charge_info" : {
        "charge_mode" : "postPaid"
      },
      "description" : "IoTDA instance for production.",
      "enterprise_project_id" : "d22e47e9-cfad-4254-8a29-d2a56a07681d",
      "additional_params" : {
        "vpc_id" : "40926909-d411-45dd-a8b4-1ebc36512345",
        "subnet_id" : "088c7d8a-f49e-4f5f-bd33-ce9b6b712345",
        "security_group_id" : "55980b43-f006-4dbf-ab58-9b0d9e712345",
        "smn_topic_urn" : "urn:smn:cn-north-7:08aaee8ae000d5182f26c00199812345:iotda_instance_create",
        "ciphering_algorithm" : "COMMON_ALGORITHM",
        "port_info" : {
          "app_https_port" : "443",
          "app_amqps_port" : "5671",
          "device_coap_port" : "5683",
          "device_coaps_port" : "5684",
          "device_mqtt_port" : "1883",
          "device_mqtts_port" : "8883",
          "device_https_port" : "443"
        }
      }
    }

Example Responses

Status code: 200

OK

{
  "instance_type" : "standard",
  "instance_id" : "8561675c-d8a3-4956-9884-9cf9cbdd3134",
  "flavor" : {
    "type" : "iotda.standard.s2",
    "size" : 2
  },
  "status" : "CREATING",
  "charge_info" : {
    "charge_mode" : "prePaid",
    "period_type" : "year",
    "period_num" : 1,
    "is_auto_renew" : true,
    "is_auto_pay" : false
  },
  "description" : "IoTDA instance for production.",
  "enterprise_project_id" : "d22e47e9-cfad-4254-8a29-d2a56a07681d",
  "tags" : [ {
    "key" : "testTagName",
    "value" : "testTagValue"
  } ],
  "order_id" : "CS22121614500ABCD",
  "additional_params" : null
}

SDK Sample Code

The SDK sample code is as follows.

Java

  • Create an instance. Specifications: standard intermediate-frequency units, 2 units, and yearly billing.

     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
    66
    67
    68
    69
    70
    71
    72
    73
    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.*;
    
    import java.util.List;
    import java.util.ArrayList;
    
    public class CreateInstanceSolution {
    
        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();
            CreateInstanceRequest request = new CreateInstanceRequest();
            CreateInstance body = new CreateInstance();
            List<Tag> listbodyTags = new ArrayList<>();
            listbodyTags.add(
                new Tag()
                    .withKey("testTagName")
                    .withValue("testTagValue")
            );
            ChargeInfo chargeInfobody = new ChargeInfo();
            chargeInfobody.withChargeMode("prePaid")
                .withPeriodType("year")
                .withPeriodNum(1)
                .withIsAutoRenew(true)
                .withIsAutoPay(false);
            Flavor flavorbody = new Flavor();
            flavorbody.withType("iotda.standard.s1")
                .withSize(2);
            body.withTags(listbodyTags);
            body.withEnterpriseProjectId("d22e47e9-cfad-4254-8a29-d2a56a07681d");
            body.withDescription("IoTDA instance for production.");
            body.withChargeInfo(chargeInfobody);
            body.withName("iotda_instance");
            body.withFlavor(flavorbody);
            body.withInstanceType("standard");
            request.withBody(body);
            try {
                CreateInstanceResponse response = client.createInstance(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());
            }
        }
    }
    
  • Create an instance. Specifications: standard intermediate-frequency units, 2 units, and pay-per-use billing.

     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
    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 CreateInstanceSolution {
    
        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();
            CreateInstanceRequest request = new CreateInstanceRequest();
            CreateInstance body = new CreateInstance();
            ChargeInfo chargeInfobody = new ChargeInfo();
            chargeInfobody.withChargeMode("postPaid");
            Flavor flavorbody = new Flavor();
            flavorbody.withType("iotda.standard.s2")
                .withSize(2);
            body.withEnterpriseProjectId("d22e47e9-cfad-4254-8a29-d2a56a07681d");
            body.withDescription("IoTDA instance for production.");
            body.withChargeInfo(chargeInfobody);
            body.withName("iotda_instance");
            body.withFlavor(flavorbody);
            body.withInstanceType("standard");
            request.withBody(body);
            try {
                CreateInstanceResponse response = client.createInstance(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());
            }
        }
    }
    
  • Create an instance. Specifications: enterprise edition and yearly billing.

     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
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    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 CreateInstanceSolution {
    
        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();
            CreateInstanceRequest request = new CreateInstanceRequest();
            CreateInstance body = new CreateInstance();
            Port portInfoAdditionalParams = new Port();
            portInfoAdditionalParams.withAppHttpsPort(443)
                .withAppAmqpsPort(5671)
                .withDeviceCoapPort(5683)
                .withDeviceCoapsPort(5684)
                .withDeviceMqttPort(1883)
                .withDeviceMqttsPort(8883)
                .withDeviceHttpsPort(443);
            AdditionalParams additionalParamsbody = new AdditionalParams();
            additionalParamsbody.withVpcId("40926909-d411-45dd-a8b4-1ebc36512345")
                .withSubnetId("088c7d8a-f49e-4f5f-bd33-ce9b6b712345")
                .withSecurityGroupId("55980b43-f006-4dbf-ab58-9b0d9e712345")
                .withSmnTopicUrn("urn:smn:cn-north-7:08aaee8ae000d5182f26c00199812345:iotda_instance_create")
                .withCipheringAlgorithm("COMMON_ALGORITHM")
                .withPortInfo(portInfoAdditionalParams);
            ChargeInfo chargeInfobody = new ChargeInfo();
            chargeInfobody.withChargeMode("postPaid");
            Flavor flavorbody = new Flavor();
            flavorbody.withType("iotda.enterprise.1000tps.10wonlinedevice");
            body.withAdditionalParams(additionalParamsbody);
            body.withEnterpriseProjectId("d22e47e9-cfad-4254-8a29-d2a56a07681d");
            body.withDescription("IoTDA instance for production.");
            body.withChargeInfo(chargeInfobody);
            body.withName("iotda_enterprise_instance");
            body.withFlavor(flavorbody);
            body.withInstanceType("enterprise");
            request.withBody(body);
            try {
                CreateInstanceResponse response = client.createInstance(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());
            }
        }
    }
    
  • Create an instance with the instance specification set to the enterprise edition and the billing mode set to pay-per-use.

     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
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    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 CreateInstanceSolution {
    
        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();
            CreateInstanceRequest request = new CreateInstanceRequest();
            CreateInstance body = new CreateInstance();
            Port portInfoAdditionalParams = new Port();
            portInfoAdditionalParams.withAppHttpsPort(443)
                .withAppAmqpsPort(5671)
                .withDeviceCoapPort(5683)
                .withDeviceCoapsPort(5684)
                .withDeviceMqttPort(1883)
                .withDeviceMqttsPort(8883)
                .withDeviceHttpsPort(443);
            AdditionalParams additionalParamsbody = new AdditionalParams();
            additionalParamsbody.withVpcId("40926909-d411-45dd-a8b4-1ebc36512345")
                .withSubnetId("088c7d8a-f49e-4f5f-bd33-ce9b6b712345")
                .withSecurityGroupId("55980b43-f006-4dbf-ab58-9b0d9e712345")
                .withSmnTopicUrn("urn:smn:cn-north-7:08aaee8ae000d5182f26c00199812345:iotda_instance_create")
                .withCipheringAlgorithm("COMMON_ALGORITHM")
                .withPortInfo(portInfoAdditionalParams);
            ChargeInfo chargeInfobody = new ChargeInfo();
            chargeInfobody.withChargeMode("prePaid")
                .withPeriodType("year")
                .withPeriodNum(1)
                .withIsAutoRenew(true)
                .withIsAutoPay(false);
            Flavor flavorbody = new Flavor();
            flavorbody.withType("iotda.enterprise.1000tps.10wonlinedevice");
            body.withAdditionalParams(additionalParamsbody);
            body.withEnterpriseProjectId("d22e47e9-cfad-4254-8a29-d2a56a07681d");
            body.withDescription("IoTDA instance for production.");
            body.withChargeInfo(chargeInfobody);
            body.withName("iotda_enterprise_instance");
            body.withFlavor(flavorbody);
            body.withInstanceType("enterprise");
            request.withBody(body);
            try {
                CreateInstanceResponse response = client.createInstance(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());
            }
        }
    }
    

Python

  • Create an instance. Specifications: standard intermediate-frequency units, 2 units, and yearly billing.

     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
    # 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 = CreateInstanceRequest()
            listTagsbody = [
                Tag(
                    key="testTagName",
                    value="testTagValue"
                )
            ]
            chargeInfobody = ChargeInfo(
                charge_mode="prePaid",
                period_type="year",
                period_num=1,
                is_auto_renew=True,
                is_auto_pay=False
            )
            flavorbody = Flavor(
                type="iotda.standard.s1",
                size=2
            )
            request.body = CreateInstance(
                tags=listTagsbody,
                enterprise_project_id="d22e47e9-cfad-4254-8a29-d2a56a07681d",
                description="IoTDA instance for production.",
                charge_info=chargeInfobody,
                name="iotda_instance",
                flavor=flavorbody,
                instance_type="standard"
            )
            response = client.create_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)
    
  • Create an instance. Specifications: standard intermediate-frequency units, 2 units, and pay-per-use billing.

     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
    # 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 = CreateInstanceRequest()
            chargeInfobody = ChargeInfo(
                charge_mode="postPaid"
            )
            flavorbody = Flavor(
                type="iotda.standard.s2",
                size=2
            )
            request.body = CreateInstance(
                enterprise_project_id="d22e47e9-cfad-4254-8a29-d2a56a07681d",
                description="IoTDA instance for production.",
                charge_info=chargeInfobody,
                name="iotda_instance",
                flavor=flavorbody,
                instance_type="standard"
            )
            response = client.create_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)
    
  • Create an instance. Specifications: enterprise edition and yearly billing.

     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
    # 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 = CreateInstanceRequest()
            portInfoAdditionalParams = Port(
                app_https_port=443,
                app_amqps_port=5671,
                device_coap_port=5683,
                device_coaps_port=5684,
                device_mqtt_port=1883,
                device_mqtts_port=8883,
                device_https_port=443
            )
            additionalParamsbody = AdditionalParams(
                vpc_id="40926909-d411-45dd-a8b4-1ebc36512345",
                subnet_id="088c7d8a-f49e-4f5f-bd33-ce9b6b712345",
                security_group_id="55980b43-f006-4dbf-ab58-9b0d9e712345",
                smn_topic_urn="urn:smn:cn-north-7:08aaee8ae000d5182f26c00199812345:iotda_instance_create",
                ciphering_algorithm="COMMON_ALGORITHM",
                port_info=portInfoAdditionalParams
            )
            chargeInfobody = ChargeInfo(
                charge_mode="postPaid"
            )
            flavorbody = Flavor(
                type="iotda.enterprise.1000tps.10wonlinedevice"
            )
            request.body = CreateInstance(
                additional_params=additionalParamsbody,
                enterprise_project_id="d22e47e9-cfad-4254-8a29-d2a56a07681d",
                description="IoTDA instance for production.",
                charge_info=chargeInfobody,
                name="iotda_enterprise_instance",
                flavor=flavorbody,
                instance_type="enterprise"
            )
            response = client.create_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)
    
  • Create an instance with the instance specification set to the enterprise edition and the billing mode set to pay-per-use.

     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
    66
    67
    # 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 = CreateInstanceRequest()
            portInfoAdditionalParams = Port(
                app_https_port=443,
                app_amqps_port=5671,
                device_coap_port=5683,
                device_coaps_port=5684,
                device_mqtt_port=1883,
                device_mqtts_port=8883,
                device_https_port=443
            )
            additionalParamsbody = AdditionalParams(
                vpc_id="40926909-d411-45dd-a8b4-1ebc36512345",
                subnet_id="088c7d8a-f49e-4f5f-bd33-ce9b6b712345",
                security_group_id="55980b43-f006-4dbf-ab58-9b0d9e712345",
                smn_topic_urn="urn:smn:cn-north-7:08aaee8ae000d5182f26c00199812345:iotda_instance_create",
                ciphering_algorithm="COMMON_ALGORITHM",
                port_info=portInfoAdditionalParams
            )
            chargeInfobody = ChargeInfo(
                charge_mode="prePaid",
                period_type="year",
                period_num=1,
                is_auto_renew=True,
                is_auto_pay=False
            )
            flavorbody = Flavor(
                type="iotda.enterprise.1000tps.10wonlinedevice"
            )
            request.body = CreateInstance(
                additional_params=additionalParamsbody,
                enterprise_project_id="d22e47e9-cfad-4254-8a29-d2a56a07681d",
                description="IoTDA instance for production.",
                charge_info=chargeInfobody,
                name="iotda_enterprise_instance",
                flavor=flavorbody,
                instance_type="enterprise"
            )
            response = client.create_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)
    

Go

  • Create an instance. Specifications: standard intermediate-frequency units, 2 units, and yearly billing.

     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
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    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, err := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            SafeBuild()
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        hcClient, err := iotdm.IoTDMClientBuilder().
             WithRegion(region.ValueOf("<YOUR REGION>")).
             WithCredential(auth).
             SafeBuild()
    
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        client := iotdm.NewIoTDMClient(hcClient)
    
        request := &model.CreateInstanceRequest{}
    	valueTags:= "testTagValue"
    	var listTagsbody = []model.Tag{
            {
                Key: "testTagName",
                Value: &valueTags,
            },
        }
    	periodTypeChargeInfo:= "year"
    	periodNumChargeInfo:= int32(1)
    	isAutoRenewChargeInfo:= true
    	isAutoPayChargeInfo:= false
    	chargeInfobody := &model.ChargeInfo{
    		ChargeMode: "prePaid",
    		PeriodType: &periodTypeChargeInfo,
    		PeriodNum: &periodNumChargeInfo,
    		IsAutoRenew: &isAutoRenewChargeInfo,
    		IsAutoPay: &isAutoPayChargeInfo,
    	}
    	sizeFlavor:= int32(2)
    	flavorbody := &model.Flavor{
    		Type: "iotda.standard.s1",
    		Size: &sizeFlavor,
    	}
    	enterpriseProjectIdCreateInstance:= "d22e47e9-cfad-4254-8a29-d2a56a07681d"
    	descriptionCreateInstance:= "IoTDA instance for production."
    	request.Body = &model.CreateInstance{
    		Tags: &listTagsbody,
    		EnterpriseProjectId: &enterpriseProjectIdCreateInstance,
    		Description: &descriptionCreateInstance,
    		ChargeInfo: chargeInfobody,
    		Name: "iotda_instance",
    		Flavor: flavorbody,
    		InstanceType: "standard",
    	}
    	response, err := client.CreateInstance(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • Create an instance. Specifications: standard intermediate-frequency units, 2 units, and pay-per-use billing.

     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
    66
    67
    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, err := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            SafeBuild()
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        hcClient, err := iotdm.IoTDMClientBuilder().
             WithRegion(region.ValueOf("<YOUR REGION>")).
             WithCredential(auth).
             SafeBuild()
    
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        client := iotdm.NewIoTDMClient(hcClient)
    
        request := &model.CreateInstanceRequest{}
    	chargeInfobody := &model.ChargeInfo{
    		ChargeMode: "postPaid",
    	}
    	sizeFlavor:= int32(2)
    	flavorbody := &model.Flavor{
    		Type: "iotda.standard.s2",
    		Size: &sizeFlavor,
    	}
    	enterpriseProjectIdCreateInstance:= "d22e47e9-cfad-4254-8a29-d2a56a07681d"
    	descriptionCreateInstance:= "IoTDA instance for production."
    	request.Body = &model.CreateInstance{
    		EnterpriseProjectId: &enterpriseProjectIdCreateInstance,
    		Description: &descriptionCreateInstance,
    		ChargeInfo: chargeInfobody,
    		Name: "iotda_instance",
    		Flavor: flavorbody,
    		InstanceType: "standard",
    	}
    	response, err := client.CreateInstance(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • Create an instance. Specifications: enterprise edition and yearly billing.

     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
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    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, err := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            SafeBuild()
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        hcClient, err := iotdm.IoTDMClientBuilder().
             WithRegion(region.ValueOf("<YOUR REGION>")).
             WithCredential(auth).
             SafeBuild()
    
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        client := iotdm.NewIoTDMClient(hcClient)
    
        request := &model.CreateInstanceRequest{}
    	appHttpsPortPortInfo:= int32(443)
    	appAmqpsPortPortInfo:= int32(5671)
    	deviceCoapPortPortInfo:= int32(5683)
    	deviceCoapsPortPortInfo:= int32(5684)
    	deviceMqttPortPortInfo:= int32(1883)
    	deviceMqttsPortPortInfo:= int32(8883)
    	deviceHttpsPortPortInfo:= int32(443)
    	portInfoAdditionalParams := &model.Port{
    		AppHttpsPort: &appHttpsPortPortInfo,
    		AppAmqpsPort: &appAmqpsPortPortInfo,
    		DeviceCoapPort: &deviceCoapPortPortInfo,
    		DeviceCoapsPort: &deviceCoapsPortPortInfo,
    		DeviceMqttPort: &deviceMqttPortPortInfo,
    		DeviceMqttsPort: &deviceMqttsPortPortInfo,
    		DeviceHttpsPort: &deviceHttpsPortPortInfo,
    	}
    	smnTopicUrnAdditionalParams:= "urn:smn:cn-north-7:08aaee8ae000d5182f26c00199812345:iotda_instance_create"
    	cipheringAlgorithmAdditionalParams:= "COMMON_ALGORITHM"
    	additionalParamsbody := &model.AdditionalParams{
    		VpcId: "40926909-d411-45dd-a8b4-1ebc36512345",
    		SubnetId: "088c7d8a-f49e-4f5f-bd33-ce9b6b712345",
    		SecurityGroupId: "55980b43-f006-4dbf-ab58-9b0d9e712345",
    		SmnTopicUrn: &smnTopicUrnAdditionalParams,
    		CipheringAlgorithm: &cipheringAlgorithmAdditionalParams,
    		PortInfo: portInfoAdditionalParams,
    	}
    	chargeInfobody := &model.ChargeInfo{
    		ChargeMode: "postPaid",
    	}
    	flavorbody := &model.Flavor{
    		Type: "iotda.enterprise.1000tps.10wonlinedevice",
    	}
    	enterpriseProjectIdCreateInstance:= "d22e47e9-cfad-4254-8a29-d2a56a07681d"
    	descriptionCreateInstance:= "IoTDA instance for production."
    	request.Body = &model.CreateInstance{
    		AdditionalParams: additionalParamsbody,
    		EnterpriseProjectId: &enterpriseProjectIdCreateInstance,
    		Description: &descriptionCreateInstance,
    		ChargeInfo: chargeInfobody,
    		Name: "iotda_enterprise_instance",
    		Flavor: flavorbody,
    		InstanceType: "enterprise",
    	}
    	response, err := client.CreateInstance(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • Create an instance with the instance specification set to the enterprise edition and the billing mode set to pay-per-use.

      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
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    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, err := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            SafeBuild()
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        hcClient, err := iotdm.IoTDMClientBuilder().
             WithRegion(region.ValueOf("<YOUR REGION>")).
             WithCredential(auth).
             SafeBuild()
    
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        client := iotdm.NewIoTDMClient(hcClient)
    
        request := &model.CreateInstanceRequest{}
    	appHttpsPortPortInfo:= int32(443)
    	appAmqpsPortPortInfo:= int32(5671)
    	deviceCoapPortPortInfo:= int32(5683)
    	deviceCoapsPortPortInfo:= int32(5684)
    	deviceMqttPortPortInfo:= int32(1883)
    	deviceMqttsPortPortInfo:= int32(8883)
    	deviceHttpsPortPortInfo:= int32(443)
    	portInfoAdditionalParams := &model.Port{
    		AppHttpsPort: &appHttpsPortPortInfo,
    		AppAmqpsPort: &appAmqpsPortPortInfo,
    		DeviceCoapPort: &deviceCoapPortPortInfo,
    		DeviceCoapsPort: &deviceCoapsPortPortInfo,
    		DeviceMqttPort: &deviceMqttPortPortInfo,
    		DeviceMqttsPort: &deviceMqttsPortPortInfo,
    		DeviceHttpsPort: &deviceHttpsPortPortInfo,
    	}
    	smnTopicUrnAdditionalParams:= "urn:smn:cn-north-7:08aaee8ae000d5182f26c00199812345:iotda_instance_create"
    	cipheringAlgorithmAdditionalParams:= "COMMON_ALGORITHM"
    	additionalParamsbody := &model.AdditionalParams{
    		VpcId: "40926909-d411-45dd-a8b4-1ebc36512345",
    		SubnetId: "088c7d8a-f49e-4f5f-bd33-ce9b6b712345",
    		SecurityGroupId: "55980b43-f006-4dbf-ab58-9b0d9e712345",
    		SmnTopicUrn: &smnTopicUrnAdditionalParams,
    		CipheringAlgorithm: &cipheringAlgorithmAdditionalParams,
    		PortInfo: portInfoAdditionalParams,
    	}
    	periodTypeChargeInfo:= "year"
    	periodNumChargeInfo:= int32(1)
    	isAutoRenewChargeInfo:= true
    	isAutoPayChargeInfo:= false
    	chargeInfobody := &model.ChargeInfo{
    		ChargeMode: "prePaid",
    		PeriodType: &periodTypeChargeInfo,
    		PeriodNum: &periodNumChargeInfo,
    		IsAutoRenew: &isAutoRenewChargeInfo,
    		IsAutoPay: &isAutoPayChargeInfo,
    	}
    	flavorbody := &model.Flavor{
    		Type: "iotda.enterprise.1000tps.10wonlinedevice",
    	}
    	enterpriseProjectIdCreateInstance:= "d22e47e9-cfad-4254-8a29-d2a56a07681d"
    	descriptionCreateInstance:= "IoTDA instance for production."
    	request.Body = &model.CreateInstance{
    		AdditionalParams: additionalParamsbody,
    		EnterpriseProjectId: &enterpriseProjectIdCreateInstance,
    		Description: &descriptionCreateInstance,
    		ChargeInfo: chargeInfobody,
    		Name: "iotda_enterprise_instance",
    		Flavor: flavorbody,
    		InstanceType: "enterprise",
    	}
    	response, err := client.CreateInstance(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    

More

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

OK

400

Bad Request

401

Unauthorized

403

Forbidden

Error Codes

See Error Codes.