Updated on 2024-08-08 GMT+08:00

Creating an Instance

Function

This API is used to create an instance in the pay-per-use or yearly/monthly mode.

Calling Method

For details, see Calling APIs.

URI

POST /v2/{engine}/{project_id}/instances

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

engine

Yes

String

Message engine.

project_id

Yes

String

Project ID. For details, see Obtaining a Project ID.

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

name

Yes

String

Instance name.

An instance name can contain 4 to 64 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed.

description

No

String

Description of an instance.

The description supports up to 1024 characters.

NOTE:

The backslash () and quotation mark (") are special characters for JSON messages. When using these characters in a parameter value, add the escape character () before the characters, for example, \ and ".

engine

Yes

String

Message engine. Value: rabbitmq.

engine_version

Yes

String

Version of the message engine.

  • 3.8.35 and AMQP-0-9-1.

storage_space

Yes

Integer

Message storage space in GB. Value range:

  • Single-node RabbitMQ instance: 100–90,000 GB

  • Cluster RabbitMQ instance: 100 GB × Number of nodes to 90,000 GB, 200 GB × Number of nodes to 90,000 GB, and 300 GB × Number of nodes to 90,000 GB

access_user

No

String

A username must start with a letter and only letters, digits, hyphens (-), and underscores (_) are allowed. It can contain 4 to 64 characters.

password

No

String

Instance password.

The password must meet the following complexity requirements:

  • Contains 8 to 32 characters.

  • Contains at least two of the following character types:

    • Lowercase letters

    • Uppercase letters

    • Digits

    • Special characters `~!@#$%^&*()-_=+|[{}]:'",<.>/?

vpc_id

Yes

String

VPC ID.

To obtain it, log in to the VPC console and view the VPC ID on the VPC details page.

security_group_id

Yes

String

Security group ID.

To obtain it, log in to the VPC console and view the security group ID on the security group details page.

subnet_id

Yes

String

Subnet ID.

To obtain it, log in to VPC console and click the target subnet on the Subnets page. You can view the network ID on the displayed page.

available_zones

Yes

Array of strings

ID of the AZ where instance brokers reside and which has available resources. Obtain the AZ ID by referring to Listing AZ Information.

This parameter cannot be empty or null.

product_id

Yes

String

Product ID.

Obtain a product ID from Querying Product Specifications List.

If the product is of the cluster type (that is, type is set to cluster), the broker_num field is mandatory.

broker_num

No

Integer

Number of brokers.

If the product is of the single-node type, there can be only 1 broker. If the product is of the cluster type, there can be 3, 5, or 7 brokers.

If the product type is single:

  • 1

If the product type is cluster:

  • 3

  • 5

  • 7

maintain_begin

No

String

Indicates the time at which a maintenance time window starts. Format: HH:mm.

  • The start time and end time of the maintenance time window must indicate the time segment of a supported maintenance time window.

  • The start time must be set to 22:00, 02:00, 06:00, 10:00, 14:00, or 18:00.

  • The start time and end time must be set in pairs. If the start time is left blank, the end time must also be left blank. In this case, the system automatically sets the start time to 02:00.

maintain_end

No

String

Indicates the time at which a maintenance time window ends. Format: HH:mm.

  • The start time and end time of the maintenance time window must indicate the time segment of a supported maintenance time window.

  • The end time is four hours later than the start time. For example, if the start time is 22:00, the end time is 02:00.

  • The start time and end time must be set in pairs. If the end time is left blank, the start time is also left blank. In this case, the system automatically sets the end time to 06:00.

enable_publicip

No

Boolean

Whether to enable public access for the RabbitMQ instance.

  • true: enable

  • false: disable

publicip_id

No

String

ID of the EIP bound to the RabbitMQ instance.

This parameter is mandatory if public access is enabled (that is, enable_publicip is set to true).

ssl_enable

No

Boolean

Whether to enable SSL encryption for access.

  • true: enable

  • false: disable

storage_spec_code

Yes

String

Storage I/O specification.

For details, see Disk Types and Disk Performance.

Value range:

  • dms.physical.storage.high.v2

  • dms.physical.storage.ultra.v2

  • dms.physical.storage.high.dss.v2 (DeC)

  • dms.physical.storage.ultra.dss.v2 (DeC)

enterprise_project_id

No

String

Enterprise project ID. This parameter is mandatory for an enterprise project account.

tags

No

Array of TagEntity objects

Tag list.

bss_param

No

BssParam object

Parameter related to the yearly/monthly billing mode.

If this parameter is left blank, the billing mode is pay-per-use by default. If this parameter is not left blank, the billing mode is yearly/monthly.

Table 3 TagEntity

Parameter

Mandatory

Type

Description

key

No

String

Tag key.

  • Must be specified.

  • Must be unique for the same instance.

  • Can contain 1 to 128 characters.

  • Can contain letters, digits, spaces, and special characters _.:=+-@

  • Cannot start with _sys_

  • Cannot start or end with a space.

value

No

String

Tag value.

  • Can contain 0 to 255 characters.

  • Can contain letters, digits, spaces, and special characters _.:=+-@

Table 4 BssParam

Parameter

Mandatory

Type

Description

is_auto_renew

No

Boolean

Whether auto renewal is enabled.

Options:

  • true: Auto renewal is enabled.

  • false: Auto renewal is not enabled.

By default, auto renewal is disabled.

charging_mode

No

String

Billing mode.

This parameter specifies a payment mode.

Options:

  • prePaid: yearly/monthly billing.

  • postPaid: pay-per-use billing.

The default value is postPaid.

is_auto_pay

No

Boolean

Specifies whether the order is automatically or manually paid.

Options:

  • true: The order will be automatically paid.

  • false: The order must be manually paid.

The default payment mode is manual.

period_type

No

String

Subscription period type.

Options:

  • month

  • year:

**This parameter is valid and mandatory only when chargingMode is set to prePaid. **

period_num

No

Integer

Subscribed periods.

Options:

  • If periodType is month, the value ranges from 1 to 9.

  • If periodType is year, the value ranges from 1 to 3.

**This parameter is valid and mandatory only when chargingMode is set to prePaid. **

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

instance_id

String

Instance ID.

Example Requests

  • Creating a pay-per-use RabbitMQ instance whose version is 3.8.35, specifications are 2 vCPUs | 4 GB x 1, and storage space is 100 GB

    POST https://{endpoint}/v2/{engine}/{project_id}/instances
    
    {
      "name" : "rabbitmq-demo",
      "description" : "",
      "engine" : "RabbitMQ",
      "engine_version" : "3.8.35",
      "storage_space" : 100,
      "access_user" : "******",
      "password" : "******",
      "vpc_id" : "1e93f86e-13af-46c8-97d6-d40fa62b76c2",
      "security_group_id" : "0aaa0033-bf7f-4c41-a6c2-18cd04cad2c8",
      "subnet_id" : "b5fa806c-35e7-4299-b659-b39398dd4718",
      "available_zones" : [ "d573142f24894ef3bd3664de068b44b0" ],
      "product_id" : "c6.2u4g.single",
      "ssl_enable" : false,
      "enable_publicip" : false,
      "publicip_id" : "",
      "storage_spec_code" : "dms.physical.storage.high.v2"
    }
  • Creating a yearly/monthly RabbitMQ instance whose version is 3.8.35, specifications are 2 vCPUs | 4 GB x 1, and storage space is 100 GB

    POST https://{endpoint}/v2/{engine}/{project_id}/instances
    
    {
      "name" : "rabbitmq-demo",
      "description" : "",
      "engine" : "RabbitMQ",
      "engine_version" : "3.8.35",
      "storage_space" : 100,
      "access_user" : "******",
      "password" : "******",
      "vpc_id" : "1e93f86e-13af-46c8-97d6-d40fa62b76c2",
      "security_group_id" : "0aaa0033-bf7f-4c41-a6c2-18cd04cad2c8",
      "subnet_id" : "b5fa806c-35e7-4299-b659-b39398dd4718",
      "available_zones" : [ "d573142f24894ef3bd3664de068b44b0" ],
      "product_id" : "c6.2u4g.single",
      "ssl_enable" : false,
      "enable_publicip" : false,
      "publicip_id" : "",
      "storage_spec_code" : "dms.physical.storage.high.v2",
      "bss_param" : {
        "charging_mode" : "prePaid",
        "period_type" : "month",
        "period_num" : 1,
        "is_auto_pay" : true
      }
    }
  • Creating a RabbitMQ instance with AMQP-0-9-1, amqp.b1.large.1, and 100 GB

    POST https://{endpoint}/v2/{engine}/{project_id}/instances
    
    {
      "name" : "rabbitmq-aor-demo",
      "description" : "",
      "engine" : "RabbitMQ",
      "engine_version" : "AMQP-0-9-1",
      "storage_space" : 100,
      "vpc_id" : "05590544-f553-4158-be38-c791589ad303",
      "security_group_id" : "030f635d-b407-4ffb-b530-6b4eaf8edc03",
      "subnet_id" : "89c1cb26-787b-4d66-a6e4-1bd887f19183",
      "available_zones" : [ "9f1c5806706d4c1fb0eb72f0a9b18c77" ],
      "product_id" : "amqp.b1.large.1",
      "broker_num" : 1,
      "ssl_enable" : false,
      "enable_publicip" : false,
      "storage_spec_code" : "dms.physical.storage.high.v2",
      "enable_acl" : true,
      "enterprise_project_id" : 0
    }

Example Responses

Status code: 200

Instance created successfully.

{
  "instance_id" : "8959ab1c-7n1a-yyb1-a05t-93dfc361b32d"
}

SDK Sample Code

The SDK sample code is as follows.

  • Creating a pay-per-use RabbitMQ instance whose version is 3.8.35, specifications are 2 vCPUs | 4 GB x 1, and storage space is 100 GB

     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
    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.*;
    
    import java.util.List;
    import java.util.ArrayList;
    
    public class CreatePostPaidInstanceByEngineSolution {
    
        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();
            CreatePostPaidInstanceByEngineRequest request = new CreatePostPaidInstanceByEngineRequest();
            request.withEngine(CreatePostPaidInstanceByEngineRequest.EngineEnum.fromValue("{engine}"));
            CreateInstanceReq body = new CreateInstanceReq();
            List<String> listbodyAvailableZones = new ArrayList<>();
            listbodyAvailableZones.add("d573142f24894ef3bd3664de068b44b0");
            body.withStorageSpecCode(CreateInstanceReq.StorageSpecCodeEnum.fromValue("dms.physical.storage.high.v2"));
            body.withSslEnable(false);
            body.withPublicipId("");
            body.withEnablePublicip(false);
            body.withProductId("c6.2u4g.single");
            body.withAvailableZones(listbodyAvailableZones);
            body.withSubnetId("b5fa806c-35e7-4299-b659-b39398dd4718");
            body.withSecurityGroupId("0aaa0033-bf7f-4c41-a6c2-18cd04cad2c8");
            body.withVpcId("1e93f86e-13af-46c8-97d6-d40fa62b76c2");
            body.withPassword("******");
            body.withAccessUser("******");
            body.withStorageSpace(100);
            body.withEngineVersion("3.8.35");
            body.withEngine(CreateInstanceReq.EngineEnum.fromValue("RabbitMQ"));
            body.withDescription("");
            body.withName("rabbitmq-demo");
            request.withBody(body);
            try {
                CreatePostPaidInstanceByEngineResponse response = client.createPostPaidInstanceByEngine(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());
            }
        }
    }
    
  • Creating a yearly/monthly RabbitMQ instance whose version is 3.8.35, specifications are 2 vCPUs | 4 GB x 1, and storage space is 100 GB

     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
    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.*;
    
    import java.util.List;
    import java.util.ArrayList;
    
    public class CreatePostPaidInstanceByEngineSolution {
    
        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();
            CreatePostPaidInstanceByEngineRequest request = new CreatePostPaidInstanceByEngineRequest();
            request.withEngine(CreatePostPaidInstanceByEngineRequest.EngineEnum.fromValue("{engine}"));
            CreateInstanceReq body = new CreateInstanceReq();
            BssParam bssParambody = new BssParam();
            bssParambody.withChargingMode(BssParam.ChargingModeEnum.fromValue("prePaid"))
                .withIsAutoPay(true)
                .withPeriodType(BssParam.PeriodTypeEnum.fromValue("month"))
                .withPeriodNum(1);
            List<String> listbodyAvailableZones = new ArrayList<>();
            listbodyAvailableZones.add("d573142f24894ef3bd3664de068b44b0");
            body.withBssParam(bssParambody);
            body.withStorageSpecCode(CreateInstanceReq.StorageSpecCodeEnum.fromValue("dms.physical.storage.high.v2"));
            body.withSslEnable(false);
            body.withPublicipId("");
            body.withEnablePublicip(false);
            body.withProductId("c6.2u4g.single");
            body.withAvailableZones(listbodyAvailableZones);
            body.withSubnetId("b5fa806c-35e7-4299-b659-b39398dd4718");
            body.withSecurityGroupId("0aaa0033-bf7f-4c41-a6c2-18cd04cad2c8");
            body.withVpcId("1e93f86e-13af-46c8-97d6-d40fa62b76c2");
            body.withPassword("******");
            body.withAccessUser("******");
            body.withStorageSpace(100);
            body.withEngineVersion("3.8.35");
            body.withEngine(CreateInstanceReq.EngineEnum.fromValue("RabbitMQ"));
            body.withDescription("");
            body.withName("rabbitmq-demo");
            request.withBody(body);
            try {
                CreatePostPaidInstanceByEngineResponse response = client.createPostPaidInstanceByEngine(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());
            }
        }
    }
    
  • Creating a RabbitMQ instance with AMQP-0-9-1, amqp.b1.large.1, and 100 GB

     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
    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.*;
    
    import java.util.List;
    import java.util.ArrayList;
    
    public class CreatePostPaidInstanceByEngineSolution {
    
        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();
            CreatePostPaidInstanceByEngineRequest request = new CreatePostPaidInstanceByEngineRequest();
            request.withEngine(CreatePostPaidInstanceByEngineRequest.EngineEnum.fromValue("{engine}"));
            CreateInstanceReq body = new CreateInstanceReq();
            List<String> listbodyAvailableZones = new ArrayList<>();
            listbodyAvailableZones.add("9f1c5806706d4c1fb0eb72f0a9b18c77");
            body.withEnterpriseProjectId("0");
            body.withStorageSpecCode(CreateInstanceReq.StorageSpecCodeEnum.fromValue("dms.physical.storage.high.v2"));
            body.withSslEnable(false);
            body.withEnablePublicip(false);
            body.withBrokerNum(CreateInstanceReq.BrokerNumEnum.NUMBER_1);
            body.withProductId("amqp.b1.large.1");
            body.withAvailableZones(listbodyAvailableZones);
            body.withSubnetId("89c1cb26-787b-4d66-a6e4-1bd887f19183");
            body.withSecurityGroupId("030f635d-b407-4ffb-b530-6b4eaf8edc03");
            body.withVpcId("05590544-f553-4158-be38-c791589ad303");
            body.withStorageSpace(100);
            body.withEngineVersion("AMQP-0-9-1");
            body.withEngine(CreateInstanceReq.EngineEnum.fromValue("RabbitMQ"));
            body.withDescription("");
            body.withName("rabbitmq-aor-demo");
            request.withBody(body);
            try {
                CreatePostPaidInstanceByEngineResponse response = client.createPostPaidInstanceByEngine(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());
            }
        }
    }
    
  • Creating a pay-per-use RabbitMQ instance whose version is 3.8.35, specifications are 2 vCPUs | 4 GB x 1, and storage space is 100 GB

     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
    # 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 = CreatePostPaidInstanceByEngineRequest()
            request.engine = "{engine}"
            listAvailableZonesbody = [
                "d573142f24894ef3bd3664de068b44b0"
            ]
            request.body = CreateInstanceReq(
                storage_spec_code="dms.physical.storage.high.v2",
                ssl_enable=False,
                publicip_id="",
                enable_publicip=False,
                product_id="c6.2u4g.single",
                available_zones=listAvailableZonesbody,
                subnet_id="b5fa806c-35e7-4299-b659-b39398dd4718",
                security_group_id="0aaa0033-bf7f-4c41-a6c2-18cd04cad2c8",
                vpc_id="1e93f86e-13af-46c8-97d6-d40fa62b76c2",
                password="******",
                access_user="******",
                storage_space=100,
                engine_version="3.8.35",
                engine="RabbitMQ",
                description="",
                name="rabbitmq-demo"
            )
            response = client.create_post_paid_instance_by_engine(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • Creating a yearly/monthly RabbitMQ instance whose version is 3.8.35, specifications are 2 vCPUs | 4 GB x 1, and storage space is 100 GB

     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
    # 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 = CreatePostPaidInstanceByEngineRequest()
            request.engine = "{engine}"
            bssParambody = BssParam(
                charging_mode="prePaid",
                is_auto_pay=True,
                period_type="month",
                period_num=1
            )
            listAvailableZonesbody = [
                "d573142f24894ef3bd3664de068b44b0"
            ]
            request.body = CreateInstanceReq(
                bss_param=bssParambody,
                storage_spec_code="dms.physical.storage.high.v2",
                ssl_enable=False,
                publicip_id="",
                enable_publicip=False,
                product_id="c6.2u4g.single",
                available_zones=listAvailableZonesbody,
                subnet_id="b5fa806c-35e7-4299-b659-b39398dd4718",
                security_group_id="0aaa0033-bf7f-4c41-a6c2-18cd04cad2c8",
                vpc_id="1e93f86e-13af-46c8-97d6-d40fa62b76c2",
                password="******",
                access_user="******",
                storage_space=100,
                engine_version="3.8.35",
                engine="RabbitMQ",
                description="",
                name="rabbitmq-demo"
            )
            response = client.create_post_paid_instance_by_engine(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • Creating a RabbitMQ instance with AMQP-0-9-1, amqp.b1.large.1, and 100 GB

     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
    # 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 = CreatePostPaidInstanceByEngineRequest()
            request.engine = "{engine}"
            listAvailableZonesbody = [
                "9f1c5806706d4c1fb0eb72f0a9b18c77"
            ]
            request.body = CreateInstanceReq(
                enterprise_project_id="0",
                storage_spec_code="dms.physical.storage.high.v2",
                ssl_enable=False,
                enable_publicip=False,
                broker_num=1,
                product_id="amqp.b1.large.1",
                available_zones=listAvailableZonesbody,
                subnet_id="89c1cb26-787b-4d66-a6e4-1bd887f19183",
                security_group_id="030f635d-b407-4ffb-b530-6b4eaf8edc03",
                vpc_id="05590544-f553-4158-be38-c791589ad303",
                storage_space=100,
                engine_version="AMQP-0-9-1",
                engine="RabbitMQ",
                description="",
                name="rabbitmq-aor-demo"
            )
            response = client.create_post_paid_instance_by_engine(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • Creating a pay-per-use RabbitMQ instance whose version is 3.8.35, specifications are 2 vCPUs | 4 GB x 1, and storage space is 100 GB

     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
    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.CreatePostPaidInstanceByEngineRequest{}
    	request.Engine = model.GetCreatePostPaidInstanceByEngineRequestEngineEnum().ENGINE
    	var listAvailableZonesbody = []string{
            "d573142f24894ef3bd3664de068b44b0",
        }
    	sslEnableCreateInstanceReq:= false
    	publicipIdCreateInstanceReq:= ""
    	enablePublicipCreateInstanceReq:= false
    	passwordCreateInstanceReq:= "******"
    	accessUserCreateInstanceReq:= "******"
    	descriptionCreateInstanceReq:= ""
    	request.Body = &model.CreateInstanceReq{
    		StorageSpecCode: model.GetCreateInstanceReqStorageSpecCodeEnum().DMS_PHYSICAL_STORAGE_HIGH,
    		SslEnable: &sslEnableCreateInstanceReq,
    		PublicipId: &publicipIdCreateInstanceReq,
    		EnablePublicip: &enablePublicipCreateInstanceReq,
    		ProductId: "c6.2u4g.single",
    		AvailableZones: listAvailableZonesbody,
    		SubnetId: "b5fa806c-35e7-4299-b659-b39398dd4718",
    		SecurityGroupId: "0aaa0033-bf7f-4c41-a6c2-18cd04cad2c8",
    		VpcId: "1e93f86e-13af-46c8-97d6-d40fa62b76c2",
    		Password: &passwordCreateInstanceReq,
    		AccessUser: &accessUserCreateInstanceReq,
    		StorageSpace: int32(100),
    		EngineVersion: "3.8.35",
    		Engine: model.GetCreateInstanceReqEngineEnum().RABBIT_MQ,
    		Description: &descriptionCreateInstanceReq,
    		Name: "rabbitmq-demo",
    	}
    	response, err := client.CreatePostPaidInstanceByEngine(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • Creating a yearly/monthly RabbitMQ instance whose version is 3.8.35, specifications are 2 vCPUs | 4 GB x 1, and storage space is 100 GB

     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
    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.CreatePostPaidInstanceByEngineRequest{}
    	request.Engine = model.GetCreatePostPaidInstanceByEngineRequestEngineEnum().ENGINE
    	chargingModeBssParam:= model.GetBssParamChargingModeEnum().PRE_PAID
    	isAutoPayBssParam:= true
    	periodTypeBssParam:= model.GetBssParamPeriodTypeEnum().MONTH
    	periodNumBssParam:= int32(1)
    	bssParambody := &model.BssParam{
    		ChargingMode: &chargingModeBssParam,
    		IsAutoPay: &isAutoPayBssParam,
    		PeriodType: &periodTypeBssParam,
    		PeriodNum: &periodNumBssParam,
    	}
    	var listAvailableZonesbody = []string{
            "d573142f24894ef3bd3664de068b44b0",
        }
    	sslEnableCreateInstanceReq:= false
    	publicipIdCreateInstanceReq:= ""
    	enablePublicipCreateInstanceReq:= false
    	passwordCreateInstanceReq:= "******"
    	accessUserCreateInstanceReq:= "******"
    	descriptionCreateInstanceReq:= ""
    	request.Body = &model.CreateInstanceReq{
    		BssParam: bssParambody,
    		StorageSpecCode: model.GetCreateInstanceReqStorageSpecCodeEnum().DMS_PHYSICAL_STORAGE_HIGH,
    		SslEnable: &sslEnableCreateInstanceReq,
    		PublicipId: &publicipIdCreateInstanceReq,
    		EnablePublicip: &enablePublicipCreateInstanceReq,
    		ProductId: "c6.2u4g.single",
    		AvailableZones: listAvailableZonesbody,
    		SubnetId: "b5fa806c-35e7-4299-b659-b39398dd4718",
    		SecurityGroupId: "0aaa0033-bf7f-4c41-a6c2-18cd04cad2c8",
    		VpcId: "1e93f86e-13af-46c8-97d6-d40fa62b76c2",
    		Password: &passwordCreateInstanceReq,
    		AccessUser: &accessUserCreateInstanceReq,
    		StorageSpace: int32(100),
    		EngineVersion: "3.8.35",
    		Engine: model.GetCreateInstanceReqEngineEnum().RABBIT_MQ,
    		Description: &descriptionCreateInstanceReq,
    		Name: "rabbitmq-demo",
    	}
    	response, err := client.CreatePostPaidInstanceByEngine(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • Creating a RabbitMQ instance with AMQP-0-9-1, amqp.b1.large.1, and 100 GB

     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
    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.CreatePostPaidInstanceByEngineRequest{}
    	request.Engine = model.GetCreatePostPaidInstanceByEngineRequestEngineEnum().ENGINE
    	var listAvailableZonesbody = []string{
            "9f1c5806706d4c1fb0eb72f0a9b18c77",
        }
    	enterpriseProjectIdCreateInstanceReq:= "0"
    	sslEnableCreateInstanceReq:= false
    	enablePublicipCreateInstanceReq:= false
    	brokerNumCreateInstanceReq:= model.GetCreateInstanceReqBrokerNumEnum().E_1
    	descriptionCreateInstanceReq:= ""
    	request.Body = &model.CreateInstanceReq{
    		EnterpriseProjectId: &enterpriseProjectIdCreateInstanceReq,
    		StorageSpecCode: model.GetCreateInstanceReqStorageSpecCodeEnum().DMS_PHYSICAL_STORAGE_HIGH,
    		SslEnable: &sslEnableCreateInstanceReq,
    		EnablePublicip: &enablePublicipCreateInstanceReq,
    		BrokerNum: &brokerNumCreateInstanceReq,
    		ProductId: "amqp.b1.large.1",
    		AvailableZones: listAvailableZonesbody,
    		SubnetId: "89c1cb26-787b-4d66-a6e4-1bd887f19183",
    		SecurityGroupId: "030f635d-b407-4ffb-b530-6b4eaf8edc03",
    		VpcId: "05590544-f553-4158-be38-c791589ad303",
    		StorageSpace: int32(100),
    		EngineVersion: "AMQP-0-9-1",
    		Engine: model.GetCreateInstanceReqEngineEnum().RABBIT_MQ,
    		Description: &descriptionCreateInstanceReq,
    		Name: "rabbitmq-aor-demo",
    	}
    	response, err := client.CreatePostPaidInstanceByEngine(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

200

Instance created successfully.

Error Codes

See Error Codes.