هذه الصفحة غير متوفرة حاليًا بلغتك المحلية. نحن نعمل جاهدين على إضافة المزيد من اللغات. شاكرين تفهمك ودعمك المستمر لنا.
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
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
engine |
Yes |
String |
Definition: Message engine. Constraints: N/A Range: rabbitmq: RabbitMQ engine. Default Value: N/A |
project_id |
Yes |
String |
Definition: Project ID. For details, see Obtaining a Project ID. Constraints: N/A Range: N/A Default Value: N/A |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
Yes |
String |
Definition: Instance name. Constraints: A username must start with a letter. It can contain 4 to 64 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed. Range: N/A Default Value: N/A |
description |
No |
String |
Definition: Description of an instance. Constraints: 0–1,024 characters 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 \". Range: N/A Default Value: N/A |
engine |
Yes |
String |
Definition: Message engine. Constraints: N/A Range: rabbitmq: RabbitMQ engine. Default Value: N/A |
engine_version |
Yes |
String |
Definition: Message engine version. Constraints: N/A Range:
Default Value: N/A |
enable_acl |
No |
Boolean |
Definition: ACL Constraints: Available only for the AMQP version. Range:
Default Value: N/A |
storage_space |
Yes |
Integer |
Definition: Message storage space, in GB. Constraints: N/A Range:
Default Value: N/A |
access_user |
No |
String |
Definition: Authentication username. Constraints: Starts with a letter, consists of 4 to 64 characters, and contains only letters, digits, hyphens (-), and underscores (_). This parameter is mandatory when ssl_enable is set to true. This parameter is invalid when ssl_enable is set to false. Range: N/A Default Value: N/A |
password |
No |
String |
Definition: Instance password. Constraints:
Range: N/A Default Value: N/A |
vpc_id |
Yes |
String |
Definition: VPC ID. You can call the API for querying VPCs to obtain the VPC ID. The VPC ID is in the response body. For details, see Virtual Private Cloud API Reference. Constraints: N/A Range: N/A Default Value: N/A |
security_group_id |
Yes |
String |
Definition: Security group to which the instance belongs. You can call the API for querying security groups to obtain the security group ID. The security group ID is in the response body. For details, see Virtual Private Cloud API Reference. Constraints: N/A Range: N/A Default Value: N/A |
subnet_id |
Yes |
String |
Definition: Subnet information. You can call the API for querying subnets to obtain the subnet ID. The subnet ID is in the response body. For details, see Virtual Private Cloud API Reference. Constraints: N/A Range: N/A Default Value: N/A |
available_zones |
Yes |
Array of strings |
Definition: ID of the AZ where instance brokers reside and which has available resources. Obtain the AZ ID by referring to Listing AZ Information. Constraints: This parameter cannot be empty or null. A RabbitMQ instance should be deployed in 1 AZ or at least 3 AZs. If the instance is deployed in multiple AZs, separate the AZ IDs with commas (,). |
product_id |
Yes |
String |
Definition: Product ID. Obtain the product ID from Querying Product Specifications List. Constraints: N/A Range: N/A Default Value: N/A |
broker_num |
No |
Integer |
Definition: Number of brokers. Constraints: 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. Range:
Default Value: N/A |
maintain_begin |
No |
String |
Definition: Start time of the maintenance time window. Constraints: The value is in HH:mm format. Range: N/A Default Value: N/A |
maintain_end |
No |
String |
Definition: End time of the maintenance time window. Constraints: The value is in HH:mm format. Range: N/A Default Value: N/A |
enable_publicip |
No |
Boolean |
Definition: Whether to enable public access. Constraints: N/A Range:
Default Value: false |
publicip_id |
No |
String |
Definition: ID of the EIP bound to the instance. Constraints: Use commas (,) to separate multiple EIP IDs. This parameter is mandatory if public access is enabled (that is, enable_publicip is set to true). Range: N/A Default Value: N/A |
ssl_enable |
No |
Boolean |
Definition: Whether to enable SSL. Constraints: N/A Range:
Default Value: N/A |
storage_spec_code |
Yes |
String |
Definition: Storage I/O flavors. For details, see Disk Types and Disk Performance. Constraints: N/A Range:
Default Value: N/A |
enterprise_project_id |
No |
String |
Definition: Enterprise project ID. Constraints: This parameter is mandatory for an enterprise project account. Range: N/A Default Value: N/A |
tags |
No |
Array of TagEntity objects |
Definition: Tag list. Constraints: A maximum of 20 tags can be added to a RabbitMQ instance. |
bss_param |
No |
BssParam object |
Definition: Parameter related to the yearly/monthly billing mode. Constraints: N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
key |
No |
String |
Parameter description: Tag key. Value range: N/A |
value |
No |
String |
Parameter description: Tag value. Value range: N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
is_auto_renew |
No |
Boolean |
Definition: Indicates whether auto-renewal is enabled. Constraints: N/A Range:
Default Value: false |
charging_mode |
No |
String |
Definition: Billing mode. Constraints: N/A Range:
Default Value: postPaid |
is_auto_pay |
No |
Boolean |
Definition: Whether the order is automatically or manually paid. Constraints: N/A Range:
Default Value: false |
period_type |
No |
String |
Definition: Subscription period type. Constraints: This parameter is valid and mandatory only when chargingMode is set to prePaid. Range:
Default Value: N/A |
period_num |
No |
Integer |
Definition: Number of subscription periods. Constraints: This parameter is valid and mandatory only when chargingMode is set to prePaid. Range:
Default Value: N/A |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
instance_id |
String |
Definition: Instance ID. Range: N/A |
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 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("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.withEnableAcl(true); 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 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 = [ "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, enable_acl=True, 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 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{ "9f1c5806706d4c1fb0eb72f0a9b18c77", } enterpriseProjectIdCreateInstanceReq:= "0" sslEnableCreateInstanceReq:= false enablePublicipCreateInstanceReq:= false brokerNumCreateInstanceReq:= model.GetCreateInstanceReqBrokerNumEnum().E_1 enableAclCreateInstanceReq:= true 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), EnableAcl: &enableAclCreateInstanceReq, 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.
-
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 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("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.withEnableAcl(true); 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 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 = [ "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, enable_acl=True, 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 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{ "9f1c5806706d4c1fb0eb72f0a9b18c77", } enterpriseProjectIdCreateInstanceReq:= "0" sslEnableCreateInstanceReq:= false enablePublicipCreateInstanceReq:= false brokerNumCreateInstanceReq:= model.GetCreateInstanceReqBrokerNumEnum().E_1 enableAclCreateInstanceReq:= true 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), EnableAcl: &enableAclCreateInstanceReq, 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.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot