Creating an Audit Instance in Yearly/Monthly Billing Mode
Function
This API is used to create an audit instance in yearly/monthly billing mode.
Calling Method
For details, see Calling APIs.
URI
POST /v2/{project_id}/dbss/audit/charge/period/order
Parameter |
Mandatory |
Parameter Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Project ID. |
Request Parameter
Parameter |
Mandatory |
Parameter Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
User token. The token can be queried by calling the IAM API. (The token is the value of X-Subject-Token in the response header.) |
Parameter |
Mandatory |
Parameter Type |
Description |
---|---|---|---|
name |
Yes |
String |
Instance name. The options are as follows:
|
flavor_ref |
Yes |
String |
Specifies the ID of the specifications used by the ECS. |
vpc_id |
Yes |
String |
VPC ID |
availability_zone |
Yes |
String |
Availability zone to which the ECS belongs. (Primary and secondary AZs are separated by commas. Example: az1.dc1,az2.dc2) |
enterprise_project_id |
No |
String |
Specifies the ID of the enterprise project Mandatory for interconnecting with EPS. |
nics |
Yes |
Array of nics objects |
NIC of the ECS |
security_groups |
Yes |
Array of security_groups objects |
Information about the security group to which the ECS belongs. |
comment |
No |
String |
Indicates the remarks. |
region |
Yes |
String |
ID of the region where the ECS is located. |
cloud_service_type |
Yes |
String |
Service type:
|
charging_mode |
Yes |
Integer |
Billing mode:
|
period_type |
Yes |
Integer |
Subscription period type. The value can be:
|
period_num |
Yes |
Integer |
Number of subscription periods |
subscription_num |
Yes |
Integer |
Number of subscriptions. Only one set of DBSS can be subscribed to. |
product_infos |
Yes |
Array of product_infos objects |
Product list. |
tags |
No |
Array of KeyValueBean objects |
Resource tag |
promotion_info |
No |
String |
Discount information |
is_auto_renew |
No |
Integer |
Auto-Renewal
|
Parameter |
Mandatory |
Parameter Type |
Description |
---|---|---|---|
subnet_id |
Yes |
String |
ID of the subnet on which the NIC works. |
ip_address |
No |
String |
IP address. If the value of this parameter is left blank or is set to an empty string, an IP address is automatically assigned. |
Parameter |
Mandatory |
Parameter Type |
Description |
---|---|---|---|
id |
Yes |
String |
Specifies the ID of the security group corresponding to the ECS. This ID takes effect for the NIC configured on the ECS. |
Parameter |
Mandatory |
Parameter Type |
Description |
---|---|---|---|
product_id |
Yes |
String |
Product ID. |
cloud_service_type |
Yes |
String |
Service Type:
|
resource_type |
Yes |
String |
Resource type:
|
resource_spec_code |
Yes |
String |
Resource specifications: - dbss.bypassaudit.low-dbss.bypassaudit.medium-dbss.bypassaudit.high |
product_spec_desc |
No |
String |
Product specification description, including the host name, specifications, VPC, and subnet. JSON string format: {"specDesc":{"zh-cn":{" Host name ":"value1"," Specification ":"value2"," VPC ":"value3"," Subnet ":"value4"},"en-us":{"Instance Name":"value1","Edition":"value2","VPC":"value3","Subnet":"value4"}}} |
Response Parameters
Status code: 200
Parameter |
Parameter Type |
Description |
---|---|---|
description |
String |
Description |
code |
String |
Returned code |
order_id |
String |
Specifies an order ID. |
Status code: 400
Parameter |
Parameter Type |
Description |
---|---|---|
error |
Object |
Error message. |
Parameter |
Parameter Type |
Description |
---|---|---|
error_code |
String |
Error code |
error_msg |
String |
Error message |
Status code: 403
Parameter |
Parameter Type |
Description |
---|---|---|
error |
Object |
Error message. |
Parameter |
Parameter Type |
Description |
---|---|---|
error_code |
String |
Error code |
error_msg |
String |
Error message |
Status code: 500
Parameter |
Parameter Type |
Description |
---|---|---|
error |
Object |
Error message. |
Parameter |
Parameter Type |
Description |
---|---|---|
error_code |
String |
Error code |
error_msg |
String |
Error message |
Example request
/v2/{project_id}/dbss/audit/charge/period/order { "flavor_ref" : "st6.xlarge.4", "name" : "DBSS-acc3", "vpc_id" : "4c035747-f77b-4c6d-b23b-cb3a2b96c7e6", "availability_zone" : "xx-xx", "comment" : "", "region" : "xx-xx", "nics" : [ { "subnet_id" : "6201dcf2-1374-43ec-ae8b-78b4081572d3" } ], "security_groups" : [ { "id" : "04088976-9c63-4e6b-9070-84e6a30c782b" } ], "cloud_service_type" : "hws.service.type.dbss", "charging_mode" : 0, "period_type" : 2, "period_num" : 1, "subscription_num" : 1, "is_auto_renew" : 0, "product_infos" : [ { "product_id" : "00301-xxxxxxx-0--0", "cloud_service_type" : "hws.service.type.dbss", "resource_type" : "hws.resource.type.dbss", "resource_spec_code" : "dbss.bypassaudit.low", "product_spec_desc" : "{\"specDesc\":{\"zh-cn\":{},\"en-us\":{\"instance Name\":\"DBSS-test\",\"VPC\":\"default_vpc\",\"Subnet\":\"subnet-af32\"}}}" } ], "promotion_info" : "", "enterprise_project_id" : "0", "tags" : [ { "key" : "key_test", "value" : "1" } ] }
Response Examples
Status code: 200
Success
{ "description" : "Success", "code" : "0", "order_id" : "CS1710190909OGQIS" }
Status code: 400
Failed
{ "error" : { "error_code" : "DBSS.XXXX", "error_msg" : "XXX" } }
Example SDK Code
The sample code is as follows.
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
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.dbss.v1.region.DbssRegion; import com.huaweicloud.sdk.dbss.v1.*; import com.huaweicloud.sdk.dbss.v1.model.*; import java.util.List; import java.util.ArrayList; public class CreateInstancesPeriodOrderSolution { 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); DbssClient client = DbssClient.newBuilder() .withCredential(auth) .withRegion(DbssRegion.valueOf("<YOUR REGION>")) .build(); CreateInstancesPeriodOrderRequest request = new CreateInstancesPeriodOrderRequest(); CreateInstancePeriodRequest body = new CreateInstancePeriodRequest(); List<KeyValueBean> listbodyTags = new ArrayList<>(); listbodyTags.add( new KeyValueBean() .withKey("key_test") .withValue("1") ); List<CreateInstancePeriodRequestProductInfos> listbodyProductInfos = new ArrayList<>(); listbodyProductInfos.add( new CreateInstancePeriodRequestProductInfos() .withProductId("00301-xxxxxxx-0--0") .withCloudServiceType("hws.service.type.dbss") .withResourceType("hws.resource.type.dbss") .withResourceSpecCode("dbss.bypassaudit.low") .withProductSpecDesc("{"specDesc":{"zh-cn":{},"en-us":{"instance Name":"DBSS-test","VPC":"default_vpc","Subnet":"subnet-af32"}}}") ); List<CreateInstancePeriodRequestSecurityGroups> listbodySecurityGroups = new ArrayList<>(); listbodySecurityGroups.add( new CreateInstancePeriodRequestSecurityGroups() .withId("04088976-9c63-4e6b-9070-84e6a30c782b") ); List<CreateInstancePeriodRequestNics> listbodyNics = new ArrayList<>(); listbodyNics.add( new CreateInstancePeriodRequestNics() .withSubnetId("6201dcf2-1374-43ec-ae8b-78b4081572d3") ); body.withIsAutoRenew(0); body.withPromotionInfo(""); body.withTags(listbodyTags); body.withProductInfos(listbodyProductInfos); body.withSubscriptionNum(1); body.withPeriodNum(1); body.withPeriodType(2); body.withChargingMode(0); body.withCloudServiceType("hws.service.type.dbss"); body.withRegion("xx-xx"); body.withComment(""); body.withSecurityGroups(listbodySecurityGroups); body.withNics(listbodyNics); body.withEnterpriseProjectId("0"); body.withAvailabilityZone("xx-xx"); body.withVpcId("4c035747-f77b-4c6d-b23b-cb3a2b96c7e6"); body.withName("DBSS-acc3"); body.withFlavorRef("st6.xlarge.4"); request.withBody(body); try { CreateInstancesPeriodOrderResponse response = client.createInstancesPeriodOrder(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
Python
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 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkdbss.v1.region.dbss_region import DbssRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkdbss.v1 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 = DbssClient.new_builder() \ .with_credentials(credentials) \ .with_region(DbssRegion.value_of("<YOUR REGION>")) \ .build() try: request = CreateInstancesPeriodOrderRequest() listTagsbody = [ KeyValueBean( key="key_test", value="1" ) ] listProductInfosbody = [ CreateInstancePeriodRequestProductInfos( product_id="00301-xxxxxxx-0--0", cloud_service_type="hws.service.type.dbss", resource_type="hws.resource.type.dbss", resource_spec_code="dbss.bypassaudit.low", product_spec_desc="{"specDesc":{"zh-cn":{},"en-us":{"instance Name":"DBSS-test","VPC":"default_vpc","Subnet":"subnet-af32"}}}" ) ] listSecurityGroupsbody = [ CreateInstancePeriodRequestSecurityGroups( id="04088976-9c63-4e6b-9070-84e6a30c782b" ) ] listNicsbody = [ CreateInstancePeriodRequestNics( subnet_id="6201dcf2-1374-43ec-ae8b-78b4081572d3" ) ] request.body = CreateInstancePeriodRequest( is_auto_renew=0, promotion_info="", tags=listTagsbody, product_infos=listProductInfosbody, subscription_num=1, period_num=1, period_type=2, charging_mode=0, cloud_service_type="hws.service.type.dbss", region="xx-xx", comment="", security_groups=listSecurityGroupsbody, nics=listNicsbody, enterprise_project_id="0", availability_zone="xx-xx", vpc_id="4c035747-f77b-4c6d-b23b-cb3a2b96c7e6", name="DBSS-acc3", flavor_ref="st6.xlarge.4" ) response = client.create_instances_period_order(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
Go
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" dbss "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dbss/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dbss/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dbss/v1/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 := dbss.NewDbssClient( dbss.DbssClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.CreateInstancesPeriodOrderRequest{} var listTagsbody = []model.KeyValueBean{ { Key: "key_test", Value: "1", }, } var listProductInfosbody = []model.CreateInstancePeriodRequestProductInfos{ { ProductId: "00301-xxxxxxx-0--0", CloudServiceType: "hws.service.type.dbss", ResourceType: "hws.resource.type.dbss", ResourceSpecCode: "dbss.bypassaudit.low", ProductSpecDesc: "{"specDesc":{"zh-cn":{},"en-us":{"instance Name":"DBSS-test","VPC":"default_vpc","Subnet":"subnet-af32"}}}", }, } var listSecurityGroupsbody = []model.CreateInstancePeriodRequestSecurityGroups{ { Id: "04088976-9c63-4e6b-9070-84e6a30c782b", }, } var listNicsbody = []model.CreateInstancePeriodRequestNics{ { SubnetId: "6201dcf2-1374-43ec-ae8b-78b4081572d3", }, } isAutoRenewCreateInstancePeriodRequest:= int32(0) promotionInfoCreateInstancePeriodRequest:= "" commentCreateInstancePeriodRequest:= "" request.Body = &model.CreateInstancePeriodRequest{ IsAutoRenew: &isAutoRenewCreateInstancePeriodRequest, PromotionInfo: &promotionInfoCreateInstancePeriodRequest, Tags: &listTagsbody, ProductInfos: listProductInfosbody, SubscriptionNum: int32(1), PeriodNum: int32(1), PeriodType: int32(2), ChargingMode: int32(0), CloudServiceType: "hws.service.type.dbss", Region: "xx-xx", Comment: &commentCreateInstancePeriodRequest, SecurityGroups: listSecurityGroupsbody, Nics: listNicsbody, EnterpriseProjectId: "0", AvailabilityZone: "xx-xx", VpcId: "4c035747-f77b-4c6d-b23b-cb3a2b96c7e6", Name: "DBSS-acc3", FlavorRef: "st6.xlarge.4", } response, err := client.CreateInstancesPeriodOrder(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
More
For more SDK code examples in various programming languages, see the Sample Code tab on the right of the API Explorer page, which can automatically generate the corresponding SDK code examples.
Status Code
Status Code |
Description |
---|---|
200 |
Success |
400 |
Failed |
403 |
Authentication failed. |
500 |
Server error. |
Error Codes
For details, 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