包年包月计费模式创建审计实例
功能介绍
包年包月计费模式创建审计实例
调用方法
请参见如何调用API。
URI
POST /v2/{project_id}/dbss/audit/charge/period/order
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
项目ID |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
用户Token。 通过调用IAM服务查询用户Token接口获取(响应消息头中X-Subject-Token的值)。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
name |
是 |
String |
实例名称。取值范围:
|
flavor_ref |
是 |
String |
云服务器使用的规格ID |
vpc_id |
是 |
String |
虚拟私有云的ID |
availability_zone |
是 |
String |
云服务器对应可用分区信息。(两个主备分区,中间用“,”分割,例如az1.dc1,az2.dc2)。 |
enterprise_project_id |
否 |
String |
企业项目ID。对接EPS必输。 |
nics |
是 |
Array of nics objects |
云服务器对应的网卡信息 |
security_groups |
是 |
Array of security_groups objects |
云服务器对应安全组信息 |
comment |
否 |
String |
备注信息 |
region |
是 |
String |
云服务器所在区域ID |
cloud_service_type |
是 |
String |
服务类型:
|
charging_mode |
是 |
Integer |
计费模式:
|
period_type |
是 |
Integer |
-订购周期类型
|
period_num |
是 |
Integer |
订购周期数 |
subscription_num |
是 |
Integer |
订购数量: DBSS只支持订购1套,不支持多套 |
product_infos |
是 |
Array of product_infos objects |
产品信息列表 |
tags |
否 |
Array of KeyValueBean objects |
资源标签 |
promotion_info |
否 |
String |
折扣信息 |
is_auto_renew |
否 |
Integer |
自动续费
|
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
product_id |
是 |
String |
产品ID |
cloud_service_type |
是 |
String |
服务类型:
|
resource_type |
是 |
String |
资源类型:
|
resource_spec_code |
是 |
String |
资源规格:- dbss.bypassaudit.low- dbss.bypassaudit.medium- dbss.bypassaudit.high |
product_spec_desc |
否 |
String |
产品规格的中英文描述,规格包含:主机名称、规格、虚拟私有云、子网。json字符串格式 :{"specDesc":{"zh-cn":{"主机名称":"value1","规格":"value2","虚拟私有云":"value3","子网":"value4"},"en-us":{"Instance Name":"value1","Edition":"value2","VPC":"value3","Subnet":"value4"}}} |
响应参数
状态码: 200
参数 |
参数类型 |
描述 |
---|---|---|
description |
String |
描述 |
code |
String |
返回码 |
order_id |
String |
订单ID |
状态码: 400
参数 |
参数类型 |
描述 |
---|---|---|
error |
Object |
错误信息返回体。 |
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
错误请求返回的错误码。 |
error_msg |
String |
错误请求返回的错误信息。 |
状态码: 403
参数 |
参数类型 |
描述 |
---|---|---|
error |
Object |
错误信息返回体。 |
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
错误请求返回的错误码。 |
error_msg |
String |
错误请求返回的错误信息。 |
状态码: 500
参数 |
参数类型 |
描述 |
---|---|---|
error |
Object |
错误信息返回体。 |
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
错误请求返回的错误码。 |
error_msg |
String |
错误请求返回的错误信息。 |
请求示例
/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" : "cn-north-7c", "comment" : "", "region" : "cn-north-7", "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" } ] }
响应示例
状态码: 200
成功
{ "description" : "Success", "code" : "0", "order_id" : "CS1710190909OGQIS" }
状态码: 400
失败
{ "error" : { "error_code" : "DBSS.XXXX", "error_msg" : "XXX" } }
SDK代码示例
SDK代码示例如下。
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("cn-north-7"); body.withComment(""); body.withSecurityGroups(listbodySecurityGroups); body.withNics(listbodyNics); body.withEnterpriseProjectId("0"); body.withAvailabilityZone("cn-north-7c"); 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="cn-north-7", comment="", security_groups=listSecurityGroupsbody, nics=listNicsbody, enterprise_project_id="0", availability_zone="cn-north-7c", 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: "cn-north-7", Comment: &commentCreateInstancePeriodRequest, SecurityGroups: listSecurityGroupsbody, Nics: listNicsbody, EnterpriseProjectId: "0", AvailabilityZone: "cn-north-7c", 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) } } |
更多
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
成功 |
400 |
失败 |
403 |
认证失败 |
500 |
服务端错误 |
错误码
请参见错误码。