調(diào)用API開通PrivateZone后付費(fèi)服務(wù)
更新時間:
API接口名稱
通過調(diào)用本接口可以開通PrivateZone后付費(fèi)服務(wù),具體請參考實例創(chuàng)建服務(wù)。
接口參數(shù)和取值范圍
名稱 | 類型 | 是否必填 | 說明 | 枚舉值 |
ProductCode | String | 是 | 產(chǎn)品代碼 | pvtz |
ProductType | String | 是 | 產(chǎn)品類型 | pvtzpost |
SubscriptionType | String | 是 | 付費(fèi)類型 | PayAsYouGo:僅支持后付費(fèi) |
Parameter.1.Value | String | 是 | 取值 | pvtz |
Parameter.1.Code | String | 是 | 商品類型 | CommodityType |
請求示例
// This file is auto-generated, don't edit it. Thanks.
package com.aliyun.sample;
import com.aliyun.tea.*;
public class Sample {
/**
* <b>description</b> :
* <p>使用AK&SK初始化賬號Client</p>
* @return Client
*
* @throws Exception
*/
public static com.aliyun.bssopenapi20171214.Client createClient() throws Exception {
// 工程代碼泄露可能會導(dǎo)致 AccessKey 泄露,并威脅賬號下所有資源的安全性。以下代碼示例僅供參考。
// 建議使用更安全的 STS 方式,更多鑒權(quán)訪問方式請參見:http://bestwisewords.com/document_detail/378657.html。
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
// 必填,請確保代碼運(yùn)行環(huán)境設(shè)置了環(huán)境變量 ALIBABA_CLOUD_ACCESS_KEY_ID。
.setAccessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
// 必填,請確保代碼運(yùn)行環(huán)境設(shè)置了環(huán)境變量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
.setAccessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
// Endpoint 請參考 https://api.aliyun.com/product/BssOpenApi
config.endpoint = "business.aliyuncs.com";
return new com.aliyun.bssopenapi20171214.Client(config);
}
public static void main(String[] args_) throws Exception {
java.util.List<String> args = java.util.Arrays.asList(args_);
com.aliyun.bssopenapi20171214.Client client = Sample.createClient();
com.aliyun.bssopenapi20171214.models.CreateInstanceRequest.CreateInstanceRequestParameter parameter0 = new com.aliyun.bssopenapi20171214.models.CreateInstanceRequest.CreateInstanceRequestParameter()
.setValue("
pvtz")
.setCode("CommodityType");
com.aliyun.bssopenapi20171214.models.CreateInstanceRequest createInstanceRequest = new com.aliyun.bssopenapi20171214.models.CreateInstanceRequest()
.setProductCode("pvtz")
.setProductType("pvtzpost")
.setSubscriptionType("PayAsYouGo")
.setParameter(java.util.Arrays.asList(
parameter0
));
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
try {
// 復(fù)制代碼運(yùn)行請自行打印 API 的返回值
client.createInstanceWithOptions(createInstanceRequest, runtime);
} catch (TeaException error) {
// 此處僅做打印展示,請謹(jǐn)慎對待異常處理,在工程項目中切勿直接忽略異常。
// 錯誤 message
System.out.println(error.getMessage());
// 診斷地址
System.out.println(error.getData().get("Recommend"));
com.aliyun.teautil.Common.assertAsString(error.message);
} catch (Exception _error) {
TeaException error = new TeaException(_error.getMessage(), _error);
// 此處僅做打印展示,請謹(jǐn)慎對待異常處理,在工程項目中切勿直接忽略異常。
// 錯誤 message
System.out.println(error.getMessage());
// 診斷地址
System.out.println(error.getData().get("Recommend"));
com.aliyun.teautil.Common.assertAsString(error.message);
}
}
}
# -*- coding: utf-8 -*-
# This file is auto-generated, don't edit it. Thanks.
import os
import sys
from typing import List
from alibabacloud_bssopenapi20171214.client import Client as BssOpenApi20171214Client
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_bssopenapi20171214 import models as bss_open_api_20171214_models
from alibabacloud_tea_util import models as util_models
from alibabacloud_tea_util.client import Client as UtilClient
class Sample:
def __init__(self):
pass
@staticmethod
def create_client() -> BssOpenApi20171214Client:
"""
使用AK&SK初始化賬號Client
@return: Client
@throws Exception
"""
# 工程代碼泄露可能會導(dǎo)致 AccessKey 泄露,并威脅賬號下所有資源的安全性。以下代碼示例僅供參考。
# 建議使用更安全的 STS 方式,更多鑒權(quán)訪問方式請參見:http://bestwisewords.com/document_detail/378659.html。
config = open_api_models.Config(
# 必填,請確保代碼運(yùn)行環(huán)境設(shè)置了環(huán)境變量 ALIBABA_CLOUD_ACCESS_KEY_ID。,
access_key_id=os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID'],
# 必填,請確保代碼運(yùn)行環(huán)境設(shè)置了環(huán)境變量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。,
access_key_secret=os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET']
)
# Endpoint 請參考 https://api.aliyun.com/product/BssOpenApi
config.endpoint = f'business.aliyuncs.com'
return BssOpenApi20171214Client(config)
@staticmethod
def main(
args: List[str],
) -> None:
client = Sample.create_client()
parameter_0 = bss_open_api_20171214_models.CreateInstanceRequestParameter(
value='''
pvtz''',
code='CommodityType'
)
create_instance_request = bss_open_api_20171214_models.CreateInstanceRequest(
product_code='pvtz',
product_type='pvtzpost',
subscription_type='PayAsYouGo',
parameter=[
parameter_0
]
)
runtime = util_models.RuntimeOptions()
try:
# 復(fù)制代碼運(yùn)行請自行打印 API 的返回值
client.create_instance_with_options(create_instance_request, runtime)
except Exception as error:
# 此處僅做打印展示,請謹(jǐn)慎對待異常處理,在工程項目中切勿直接忽略異常。
# 錯誤 message
print(error.message)
# 診斷地址
print(error.data.get("Recommend"))
UtilClient.assert_as_string(error.message)
@staticmethod
async def main_async(
args: List[str],
) -> None:
client = Sample.create_client()
parameter_0 = bss_open_api_20171214_models.CreateInstanceRequestParameter(
value='''
pvtz''',
code='CommodityType'
)
create_instance_request = bss_open_api_20171214_models.CreateInstanceRequest(
product_code='pvtz',
product_type='pvtzpost',
subscription_type='PayAsYouGo',
parameter=[
parameter_0
]
)
runtime = util_models.RuntimeOptions()
try:
# 復(fù)制代碼運(yùn)行請自行打印 API 的返回值
await client.create_instance_with_options_async(create_instance_request, runtime)
except Exception as error:
# 此處僅做打印展示,請謹(jǐn)慎對待異常處理,在工程項目中切勿直接忽略異常。
# 錯誤 message
print(error.message)
# 診斷地址
print(error.data.get("Recommend"))
UtilClient.assert_as_string(error.message)
if __name__ == '__main__':
Sample.main(sys.argv[1:])
// This file is auto-generated, don't edit it. Thanks.
package main
import (
"encoding/json"
"strings"
"fmt"
"os"
bssopenapi20171214 "github.com/alibabacloud-go/bssopenapi-20171214/v5/client"
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
util "github.com/alibabacloud-go/tea-utils/v2/service"
"github.com/alibabacloud-go/tea/tea"
)
// Description:
//
// 使用AK&SK初始化賬號Client
//
// @return Client
//
// @throws Exception
func CreateClient () (_result *bssopenapi20171214.Client, _err error) {
// 工程代碼泄露可能會導(dǎo)致 AccessKey 泄露,并威脅賬號下所有資源的安全性。以下代碼示例僅供參考。
// 建議使用更安全的 STS 方式,更多鑒權(quán)訪問方式請參見:http://bestwisewords.com/document_detail/378661.html。
config := &openapi.Config{
// 必填,請確保代碼運(yùn)行環(huán)境設(shè)置了環(huán)境變量 ALIBABA_CLOUD_ACCESS_KEY_ID。
AccessKeyId: tea.String(os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_ID")),
// 必填,請確保代碼運(yùn)行環(huán)境設(shè)置了環(huán)境變量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
AccessKeySecret: tea.String(os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")),
}
// Endpoint 請參考 https://api.aliyun.com/product/BssOpenApi
config.Endpoint = tea.String("business.aliyuncs.com")
_result = &bssopenapi20171214.Client{}
_result, _err = bssopenapi20171214.NewClient(config)
return _result, _err
}
func _main (args []*string) (_err error) {
client, _err := CreateClient()
if _err != nil {
return _err
}
parameter0 := &bssopenapi20171214.CreateInstanceRequestParameter{
Value: tea.String("
pvtz"),
Code: tea.String("CommodityType"),
}
createInstanceRequest := &bssopenapi20171214.CreateInstanceRequest{
ProductCode: tea.String("pvtz"),
ProductType: tea.String("pvtzpost"),
SubscriptionType: tea.String("PayAsYouGo"),
Parameter: []*bssopenapi20171214.CreateInstanceRequestParameter{parameter0},
}
runtime := &util.RuntimeOptions{}
tryErr := func()(_e error) {
defer func() {
if r := tea.Recover(recover()); r != nil {
_e = r
}
}()
// 復(fù)制代碼運(yùn)行請自行打印 API 的返回值
_, _err = client.CreateInstanceWithOptions(createInstanceRequest, runtime)
if _err != nil {
return _err
}
return nil
}()
if tryErr != nil {
var error = &tea.SDKError{}
if _t, ok := tryErr.(*tea.SDKError); ok {
error = _t
} else {
error.Message = tea.String(tryErr.Error())
}
// 此處僅做打印展示,請謹(jǐn)慎對待異常處理,在工程項目中切勿直接忽略異常。
// 錯誤 message
fmt.Println(tea.StringValue(error.Message))
// 診斷地址
var data interface{}
d := json.NewDecoder(strings.NewReader(tea.StringValue(error.Data)))
d.Decode(&data)
if m, ok := data.(map[string]interface{}); ok {
recommend, _ := m["Recommend"]
fmt.Println(recommend)
}
_, _err = util.AssertAsString(error.Message)
if _err != nil {
return _err
}
}
return _err
}
func main() {
err := _main(tea.StringSlice(os.Args[1:]))
if err != nil {
panic(err)
}
}
文檔內(nèi)容是否對您有幫助?