Buying a DataArts Studio Instance
Function
This API is used to buy a DataArts Studio instance.
Calling Method
For details, see Calling APIs.
URI
POST /v1/{project_id}/instances/onekey-purchase
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
project_id |
Yes |
String |
Project ID. For details about how to obtain the project ID, see Project ID and Account ID. |
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
X-Auth-Token |
Yes |
String |
User token. This parameter is mandatory when token authentication is used. You can obtain it from the value of X-Subject-Token in the response message header returned by the "Obtaining a User Token" API of the IAM service. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
region_id |
Yes |
String |
Region ID. You can obtain it from the response message of the "Querying the Region List" API of the IAM service. |
|
commodity_id |
No |
String |
Order ID |
|
product_id |
No |
String |
Product ID |
|
period_type |
Yes |
Integer |
Period type, which can be 2 (month) or 3 (year) |
|
period_num |
Yes |
Integer |
Number of subscription periods. The value is greater than 0. |
|
availability_zone |
Yes |
String |
AZ |
|
vpc_id |
Yes |
String |
Virtual NIC ID |
|
security_group_id |
Yes |
String |
Security group ID, which can be obtained from the current security group list |
|
net_id |
Yes |
String |
Subnet ID, which can be obtained from the VPC list |
|
instance_name |
Yes |
String |
Instance name |
|
eps_id |
Yes |
String |
Enterprise project ID. For details about how to obtain the enterprise project ID, see Project ID and Account ID. |
|
is_auto_renew |
Yes |
Integer |
Whether to enable auto renewal |
|
promotion_info |
No |
String |
Promotion information |
|
extesion_package_type |
No |
String |
Incremental package type |
|
binding_instance_id |
No |
String |
DataArts Studio instance ID. For details about how to obtain the instance ID, see Instance ID and Workspace ID. |
|
cdm_version |
No |
String |
CDM version |
|
resource_spec_code |
Yes |
String |
Instance specifications code |
|
cloud_service_type |
No |
String |
Cloud service type |
|
resource_type |
No |
String |
Resource type |
|
tags |
No |
Array of TmsTagDTO objects |
TMS tags |
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
order_id |
String |
Order ID |
|
resource_id |
String |
Instance ID |
Status code: 400
|
Parameter |
Type |
Description |
|---|---|---|
|
error_msg |
String |
Returned error information. |
|
error_code |
String |
Returned error code. |
Status code: 500
|
Parameter |
Type |
Description |
|---|---|---|
|
error_msg |
String |
Returned error information. |
|
error_code |
String |
Returned error code. |
Example Requests
{
"region_id" : "xxxxxx",
"period_type" : 2,
"period_num" : 1,
"availability_zone" : "xxxxxx",
"vpc_id" : "000aaa00-8ece-44c0-963c-b6ed0e105c34",
"net_id" : "5a6411c1-1487-420c-8c97-c264a6dae12e",
"security_group_id" : "01263337-b511-4de3-ab2d-f57d9af67d1e",
"eps_id" : "9dc0e37c-c117-48c7-8c6d-ac4b27cfc8a8",
"instance_name" : "DGC-0722",
"resource_spec_code" : "dayu.nb.professional",
"is_auto_renew" : 0,
"promotion_info" : ""
}
Example Responses
Status code: 400
Bad request.
{
"error_code" : "DAYU.4402",
"error_msg" : "The operation failed, detail msg {0}."
}
Status code: 500
Internal server error.
{
"error_code" : "DAYU.3531",
"error_msg" : "Internal server error: {0}"
}
SDK Sample Code
The SDK sample code is as follows.
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 |
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.dataartsstudio.v1.region.DataArtsStudioRegion; import com.huaweicloud.sdk.dataartsstudio.v1.*; import com.huaweicloud.sdk.dataartsstudio.v1.model.*; public class PayForDgcOneKeySolution { 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); DataArtsStudioClient client = DataArtsStudioClient.newBuilder() .withCredential(auth) .withRegion(DataArtsStudioRegion.valueOf("<YOUR REGION>")) .build(); PayForDgcOneKeyRequest request = new PayForDgcOneKeyRequest(); OrderReq body = new OrderReq(); request.withBody(body); try { PayForDgcOneKeyResponse response = client.payForDgcOneKey(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()); } } } |
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 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkdataartsstudio.v1.region.dataartsstudio_region import DataArtsStudioRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkdataartsstudio.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 = DataArtsStudioClient.new_builder() \ .with_credentials(credentials) \ .with_region(DataArtsStudioRegion.value_of("<YOUR REGION>")) \ .build() try: request = PayForDgcOneKeyRequest() request.body = OrderReq( ) response = client.pay_for_dgc_one_key(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
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 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" dataartsstudio "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/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 := dataartsstudio.NewDataArtsStudioClient( dataartsstudio.DataArtsStudioClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.PayForDgcOneKeyRequest{} request.Body = &model.OrderReq{ } response, err := client.PayForDgcOneKey(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 |
The instance ID and order ID are returned. |
|
400 |
Bad request. |
|
500 |
Internal server error. |
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