更新时间:2024-07-05 GMT+08:00
分享

DataArtsStudio实例一键购买接口

功能介绍

DataArtsStudio实例一键购买接口

调用方法

请参见如何调用API

URI

POST /v1/{project_id}/instances/onekey-purchase

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

项目ID,获取方法请参见项目ID和账号ID

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

用户的token

表3 请求Body参数

参数

是否必选

参数类型

描述

region_id

String

通过调用ManageOne平台的IAM服务的“查询区域列表”接口获取响应消息中的区域ID。

commodity_id

String

订单Id。

product_id

String

产品Id

period_type

Integer

购买周期类型,2:月,3:年

period_num

Integer

购买周期数,大于0

availability_zone

String

可用区

vpc_id

String

虚拟网卡Id

security_group_id

String

安全组id,可在当前安全组列表中获取

net_id

String

子网id,可在当前虚拟私有云列表中获取

instance_name

String

实例名

eps_id

String

企业项目ID,获取方法请参见项目ID和账号ID

is_auto_renew

Integer

是否续订

promotion_info

String

促销信息

extesion_package_type

String

实例附加增量包类型

binding_instance_id

String

DataArts Studio实例ID,获取方法请参见实例ID和工作空间ID

cdm_version

String

cdm版本号

resource_spec_code

String

产品规格编码(即实例类型编码),例如dayu.starter,dayu.basic,dayu.advanced等。可通过查询其他实例信息进行获取。

cloud_service_type

String

云服务类型

resource_type

String

资源类型

tags

Array of TmsTagDTO objects

tms标签

表4 TmsTagDTO

参数

是否必选

参数类型

描述

key

String

key值

value

String

value值

响应参数

状态码: 200

表5 响应Body参数

参数

参数类型

描述

order_id

String

订单Id

resource_id

String

实例Id

状态码: 400

表6 响应Body参数

参数

参数类型

描述

error_msg

String

返回的错误信息。

error_code

String

返回的错误码。

状态码: 500

表7 响应Body参数

参数

参数类型

描述

error_msg

String

返回的错误信息。

error_code

String

返回的错误码。

请求示例

{
  "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" : ""
}

响应示例

状态码: 400

{
  "error_code" : "DAYU.4402",
  "error_msg" : "The operation failed, detail msg {0}."
}

状态码: 500

{
  "error_code" : "DAYU.3531",
  "error_msg" : "Internal server error: {0}"
}

SDK代码示例

SDK代码示例如下。

 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)
    }
}

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

200

返回实例Id和订单Id

400

BadRequest

500

Internal Server Error

相关文档