云防火墙服务不提供管理(包含查询、创建、变更、续费)实例的接口。您可以通过调用阿里云交易和账单管理API提供的接口来管理云防火墙实例。文本介绍调用API管理云防火墙实例的请求方法和示例。
背景信息
阿里云交易和账单管理API是一套通用的管理阿里云资源的接口,可以用于查询服务价格、管理实例、获取账单信息等。关于阿里云交易和账单管理API支持的所有接口,请参见API概览。
您可以调用阿里云交易和账单管理API提供的接口,查询、创建、变更、续费云防火墙实例。关于该接口的调用方式,请参见请求结构。
查询实例
调用QueryAvailableInstances查询实例资源。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
请求参数
名称 | 类型 | 必填 | 示例值 | 描述 |
Region | String | 否 | cn-hangzhou | 地域。 |
PageNum | Integer | 否 | 1 | 页码。 |
PageSize | Integer | 否 | 20 | 每页条数。 |
ProductCode | String | 是 | cfw | 产品代码。可通过接口查询产品信息查询产品代码,或查看阿里云产品Code速查手册。云防火墙的产品代码。取值:
|
ProductType | String | 否 | cfw_sub_public_cn | 产品类型。可通过接口查询产品信息查询产品类型,或查看阿里云产品Code速查手册。云防火墙的产品类型。取值:
|
SubscriptionType | String | 否 | Subscription | 付费类型。取值:
|
InstanceIDs | String | 否 | cfw_sub_public_cn-pe3xxxxxx | 实例ID。多个ID用英文逗号分隔,最大不超过100个。 |
EndTimeStart | String | 否 | 2024-01-01T00:00:00Z | 结束时间段起。符合ISO8601标准的utc时间格式。 |
EndTimeEnd | String | 否 | 2024-01-01T00:00:00Z | 结束时间段止。符合ISO8601标准的utc时间格式。 |
CreateTimeStart | String | 否 | 2023-01-01T00:00:00Z | 创建时间段起。符合ISO8601标准的utc时间格式。 |
CreateTimeEnd | String | 否 | 2023-01-01T00:00:00Z | 创建时间段止。符合ISO8601标准的utc时间格式。 |
RenewStatus | String | 否 | AutoRenewal | 续费状态。取值:
|
响应参数
名称 | 类型 | 示例值 | 描述 |
Code | String | Success | 状态码。 |
Message | String | Successful! | 错误信息。 |
RequestId | String | C7C15585-8349-4C62-BEE4-5A391841XXXX | 请求ID。 |
Success | Boolean | TRUE | 是否成功。 |
Data | Object | 返回数据。关于Data的详细信息,请参见Data。 |
Data
名称 | 类型 | 示例值 | 描述 |
PageNum | Integer | 1 | 页码。 |
PageSize | Integer | 10 | 每页条数。 |
TotalCount | Integer | 11 | 总记录数。 |
InstanceList | Object | 实例信息的列表。关于InstanceList的详细介绍,请参见InstanceList。 |
InstanceList
名称 | 类型 | 示例值 | 描述 |
SubStatus | String | Normal | 续费的子状态。取值:
|
Status | String | Normal | 购买的云防火墙状态。取值:
|
ExpectedReleaseTime | String | 2019-09-08T16:00:00Z | 期望释放时间。 |
RenewStatus | String | ManualRenewal | 续费状态。取值:
|
CreateTime | String | 2019-09-08T16:00:00Z | 创建时间。 |
SellerId | Long | 123123123 | 卖方ID。 |
InstanceID | String | cfw_sub_public_cn-pe333nx**** | 订单对应的实例ID。 |
Seller | String | 2**** | 卖方。 |
StopTime | String | 2019-09-08T16:00:00Z | 停止时间。 |
RenewalDurationUnit | String | M | 自动续费周期单位。取值:
|
SubscriptionType | String | Subscription | 订阅类型。取值:
|
OwnerId | Long | 325352345 | 所有者ID。 |
EndTime | String | 2019-09-08T16:00:00Z | 结束时间。 |
ProductType | String | cfw_sub_public_cn | 产品类型。 |
Region | String | cn-hangzhou | 地域。 |
ReleaseTime | String | 2019-09-08T16:00:00Z | 释放时间。 |
RenewalDuration | Integer | 1 | 自动续费周期数量。 |
ProductCode | String | cfw | 产品代码。 |
示例
请求示例
// This file is auto-generated, don't edit it. Thanks.
package demo;
import com.aliyun.auth.credentials.Credential;
import com.aliyun.auth.credentials.provider.StaticCredentialProvider;
import com.aliyun.core.http.HttpClient;
import com.aliyun.core.http.HttpMethod;
import com.aliyun.core.http.ProxyOptions;
import com.aliyun.httpcomponent.httpclient.ApacheAsyncHttpClientBuilder;
import com.aliyun.sdk.service.bssopenapi20171214.models.*;
import com.aliyun.sdk.service.bssopenapi20171214.*;
import com.google.gson.Gson;
import darabonba.core.RequestConfiguration;
import darabonba.core.client.ClientOverrideConfiguration;
import darabonba.core.utils.CommonUtil;
import darabonba.core.TeaPair;
//import javax.net.ssl.KeyManager;
//import javax.net.ssl.X509TrustManager;
import java.net.InetSocketAddress;
import java.time.Duration;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.io.*;
public class QueryAvailableInstances {
public static void main(String[] args) throws Exception {
// HttpClient Configuration
/*HttpClient httpClient = new ApacheAsyncHttpClientBuilder()
.connectionTimeout(Duration.ofSeconds(10)) // Set the connection timeout time, the default is 10 seconds
.responseTimeout(Duration.ofSeconds(10)) // Set the response timeout time, the default is 20 seconds
.maxConnections(128) // Set the connection pool size
.maxIdleTimeOut(Duration.ofSeconds(50)) // Set the connection pool timeout, the default is 30 seconds
// Configure the proxy
.proxy(new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress("<your-proxy-hostname>", 9001))
.setCredentials("<your-proxy-username>", "<your-proxy-password>"))
// If it is an https connection, you need to configure the certificate, or ignore the certificate(.ignoreSSL(true))
.x509TrustManagers(new X509TrustManager[]{})
.keyManagers(new KeyManager[]{})
.ignoreSSL(false)
.build();*/
// Configure Credentials authentication information, including ak, secret, token
StaticCredentialProvider provider = StaticCredentialProvider.create(Credential.builder()
// Please ensure that the environment variables ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set.
.accessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
.accessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"))
//.securityToken(System.getenv("ALIBABA_CLOUD_SECURITY_TOKEN")) // use STS token
.build());
// Configure the Client
AsyncClient client = AsyncClient.builder()
.region("cn-shanghai") // Region ID
//.httpClient(httpClient) // Use the configured HttpClient, otherwise use the default HttpClient (Apache HttpClient)
.credentialsProvider(provider)
//.serviceConfiguration(Configuration.create()) // Service-level configuration
// Client-level configuration rewrite, can set Endpoint, Http request parameters, etc.
.overrideConfiguration(
ClientOverrideConfiguration.create()
// Endpoint 请参考 https://api.aliyun.com/product/BssOpenApi
.setEndpointOverride("business.aliyuncs.com")
//.setConnectTimeout(Duration.ofSeconds(30))
)
.build();
// Parameter settings for API request
QueryAvailableInstancesRequest queryAvailableInstancesRequest = QueryAvailableInstancesRequest.builder()
.productCode("cfw")
.productType("cfw_sub_public_cn")
// Request-level configuration rewrite, can set Http request parameters, etc.
// .requestConfiguration(RequestConfiguration.create().setHttpHeaders(new HttpHeaders()))
.build();
// Asynchronously get the return value of the API request
CompletableFuture<QueryAvailableInstancesResponse> response = client.queryAvailableInstances(queryAvailableInstancesRequest);
// Synchronously get the return value of the API request
QueryAvailableInstancesResponse resp = response.get();
System.out.println(new Gson().toJson(resp));
// Asynchronous processing of return values
/*response.thenAccept(resp -> {
System.out.println(new Gson().toJson(resp));
}).exceptionally(throwable -> { // Handling exceptions
System.out.println(throwable.getMessage());
return null;
});*/
// Finally, close the client
client.close();
}
}正常返回示例
{
"Message": "Successful!",
"RequestId": "4A028827-4D32-5EAD-8771-************",
"Data": {
"TotalCount": 1,
"PageNum": 1,
"PageSize": 20,
"InstanceList": [
{
"Status": "Normal",
"SubscriptionType": "Subscription",
"OwnerId": 13206399********,
"EndTime": "2026-01-03T16:00:00Z",
"InstanceID": "cfw_sub_public_cn-***********",
"ProductCode": "cfw",
"CreateTime": "2025-12-03T06:55:44Z",
"ProductType": "cfw_sub_public_cn",
"RenewalDurationUnit": "M",
"Seller": "26842",
"SubStatus": "Normal",
"RenewStatus": "ManualRenewal"
}
]
},
"Code": "Success",
"Success": true
}创建实例
调用CreateInstance创建一个实例资源,调用接口会自动创建一个新购实例资源的订单,并自动支付。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
请求参数
名称 | 类型 | 是否必选 | 示例值 | 描述 |
ProductCode | String | 是 | cfw | 产品代码。可通过接口查询产品信息查询产品代码,或查看阿里云产品Code速查手册。云防火墙的产品代码。取值:
|
ProductType | String | 是 | cfw_sub_public_cn | 产品类型。可通过接口查询产品信息查询产品类型,或查看阿里云产品Code速查手册。云防火墙的产品类型。取值:
|
SubscriptionType | String | 是 | Subscription | 付费类型。取值:
|
Parameter.N.Code | String | 是 | | 第n个模块属性code配置,n的取值范围为(1~100),如有多个模块属性参数,按照n=1,2,3…n的形式拼接多个参数。具体信息,请参见Parameter。 |
Parameter.N.Value | String | 是 | | 第n个模块属性value配置,n的取值范围为(1~100)。具体信息,请参见Parameter。 |
RenewPeriod | Integer | 否 | 12 | 自动续费周期。单位为月。 说明 当设置RenewalStatus为AutoRenewal时,必须设置。 |
Period | Integer | 否 | 1 | 预付费周期。单位为月,按年付费产品请输入12的整数倍。 说明 当创建预付费实例时,必须设置。 |
RenewalStatus | String | 否 | ManualRenewal | 自动续费状态。取值:
|
Parameter
Parameter.N.Code | 类型 | 是否必选 | 示例值 | 描述 |
cfw_spec | String | 包年包月实例必选 | 2 | 云防火墙版本。取值:
|
cfw_endpoint | Integer | 否 | 0 | 防火墙扩展实例数。单位:个。支持取值范围:
|
cfw_bandwidth | Integer | 否 | 1000 | 防火墙扩展带宽。单位:Mbps。各版本取值范围:
|
cfw_ndlp_enable | String | 否 | false | 敏感数据泄露检测。取值:
|
cfw_log | String | 否 | false | 日志分析。取值:
|
cfw_log_storage | Integer | 否 | 100 | 日志存储容量。单位:TB。各版本取值范围:
重要 必须打开日志分析,日志存储容量设置才会生效。 |
cfw_autoasset_protection | String | 否 | true | 互联网资产自动接入防护。取值:
说明 原实例释放后7天内重新购买实例时,会按照历史保留配置生效。 |
ndr_service | String | 否 | 0 | 全流量威胁检测与响应NDR。取值:
|
ndr_flow_storage | Integer | 否 | 0 | NDR全流量存储容量。单位:TB。取值范围:
重要 必须打开全流量威胁检测与响应NDR,NDR全流量存储容量设置才会生效。 |
ndr_bandwidth | Integer | 否 | 0 | NDR扩展带宽。单位:Mbps。取值:
重要 必须打开全流量威胁检测与响应NDR,NDR扩展带宽设置才会生效。 |
返回参数
名称 | 类型 | 示例值 | 描述 |
Code | String | Success | 状态码。 |
InstanceId | String | cfw_sub_public_cn-************ | 订单对应的实例ID。 |
OrderId | String | 22165938636**** | 创建成功的订单ID。 |
Message | String | Successful! | 错误信息。 |
RequestId | String | 13B1DCF7-0B7C-5426-BC08-************ | 请求ID。 |
Success | Boolean | true | 是否成功。 |
示例
下面代码创建了预付费中国站云防火墙,使用手动续费,且预付费用1个月。
请求示例
// 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>使用凭据初始化账号Client</p>
* @return Client
*
* @throws Exception
*/
public static com.aliyun.bssopenapi20171214.Client createClient() throws Exception {
// 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378657.html。
com.aliyun.credentials.Client credential = new com.aliyun.credentials.Client();
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
.setCredential(credential);
// 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 {
com.aliyun.bssopenapi20171214.Client client = Sample.createClient();
com.aliyun.bssopenapi20171214.models.CreateInstanceRequest.CreateInstanceRequestParameter parameter0 = new com.aliyun.bssopenapi20171214.models.CreateInstanceRequest.CreateInstanceRequestParameter()
.setValue("cfw_spec")
.setCode("2");
com.aliyun.bssopenapi20171214.models.CreateInstanceRequest createInstanceRequest = new com.aliyun.bssopenapi20171214.models.CreateInstanceRequest()
.setProductCode("cfw")
.setProductType("cfw_sub_public_cn")
.setSubscriptionType("Subscription")
.setPeriod(1)
.setRenewalStatus("ManualRenewal")
.setParameter(java.util.Arrays.asList(
parameter0
));
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
try {
// 复制代码运行请自行打印 API 的返回值
client.createInstanceWithOptions(createInstanceRequest, runtime);
} catch (TeaException error) {
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
// 错误 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);
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
// 错误 message
System.out.println(error.getMessage());
// 诊断地址
System.out.println(error.getData().get("Recommend"));
com.aliyun.teautil.Common.assertAsString(error.message);
}
}
}正常返回示例
云防火墙创建成功会返回实例ID(InstanceId),实例ID在后续变配和续费中将用到。
{
"RequestId": "13B1DCF7-0B7C-5426-BC08-************",
"Message": "Successful!",
"Data": {
"InstanceId": "cfw_sub_public_cn-***********",
"OrderId": 22165938636****
},
"Code": "Success",
"Success": true
}变更实例
调用ModifyInstance对实例资源配置进行变更。调用接口会创建一个变配实例资源的订单,并自动支付。
降低配置后,已经开始的收费周期内不支持退费,会从下一个收费周期开始按照降配后的最新规格计费。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
请求参数
名称 | 类型 | 是否必选 | 示例值 | 描述 |
Action | String | 是 | ModifyInstance | 系统规定参数。取值:ModifyInstance。 |
Parameter.N.Code | String | 是 | | 第n个模块属性code配置,n的取值范围为(1~100),如有多个模块属性参数,按照n=1,2,3…n的形式拼接多个参数。具体信息,请参见Parameter。 |
Parameter.N.Value | String | 是 | | 第n个模块属性value配置,n的取值范围为(1~100)。具体信息,请参见Parameter。 |
ProductCode | String | 是 | cfw | 产品代码。可通过接口查询产品信息查询产品代码,或查看阿里云产品Code速查手册。云防火墙的产品代码。取值:
|
SubscriptionType | String | 是 | Subscription | 付费类型。取值:
|
ModifyType | Upgrade | 变配类型。取值:
| ||
InstanceId | String | 否 | vipcloudfw-cn-pe333nx**** | 订单对应的实例ID。 |
Parameter
Parameter.N.Code | 类型 | 是否必选 | 示例值 | 描述 |
cfw_spec | String | 包年包月实例必选 | 2 | 云防火墙版本。取值:
|
cfw_endpoint | Integer | 否 | 0 | 防火墙扩展实例数。单位:个。支持取值范围:
|
cfw_bandwidth | Integer | 否 | 1000 | 防火墙扩展带宽。单位:Mbps。各版本取值范围:
|
cfw_ndlp_enable | String | 否 | false | 敏感数据泄露检测。取值:
|
cfw_log | String | 否 | false | 日志分析。取值:
|
cfw_log_storage | Integer | 否 | 100 | 日志存储容量。单位:TB。各版本取值范围:
重要 必须打开日志分析,日志存储容量设置才会生效。 |
cfw_autoasset_protection | String | 否 | true | 互联网资产自动接入防护。取值:
|
ndr_service | String | 否 | 0 | 全流量威胁检测与响应NDR。取值:
|
ndr_flow_storage | Integer | 否 | 0 | NDR全流量存储容量。单位:TB。取值范围:
重要 必须打开全流量威胁检测与响应NDR,NDR全流量存储容量设置才会生效。 |
ndr_bandwidth | Integer | 否 | 0 | NDR扩展带宽。单位:Mbps。取值:
重要 必须打开全流量威胁检测与响应NDR,NDR扩展带宽设置才会生效。 |
响应参数
名称 | 类型 | 示例值 | 描述 |
Code | String | Success | 状态码。 |
HostId | String | cn**** | 主机ID。 |
OrderId | String | 22165938810**** | 创建成功的订单ID。 |
Message | String | Successful! | 错误信息。 |
RequestId | String | 3EC4C157-46E3-5341-82B0-************ | 请求ID。 |
Success | Boolean | true | 是否成功。 |
示例
下面代码为您实现将版本从高级版改为企业版。
请求示例
// This file is auto-generated, don't edit it. Thanks.
package demo;
import com.aliyun.auth.credentials.Credential;
import com.aliyun.auth.credentials.provider.StaticCredentialProvider;
import com.aliyun.core.http.HttpClient;
import com.aliyun.core.http.HttpMethod;
import com.aliyun.core.http.ProxyOptions;
import com.aliyun.httpcomponent.httpclient.ApacheAsyncHttpClientBuilder;
import com.aliyun.sdk.service.bssopenapi20171214.models.*;
import com.aliyun.sdk.service.bssopenapi20171214.*;
import com.google.gson.Gson;
import darabonba.core.RequestConfiguration;
import darabonba.core.client.ClientOverrideConfiguration;
import darabonba.core.utils.CommonUtil;
import darabonba.core.TeaPair;
//import javax.net.ssl.KeyManager;
//import javax.net.ssl.X509TrustManager;
import java.net.InetSocketAddress;
import java.time.Duration;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.io.*;
public class ModifyInstance {
public static void main(String[] args) throws Exception {
// HttpClient Configuration
/*HttpClient httpClient = new ApacheAsyncHttpClientBuilder()
.connectionTimeout(Duration.ofSeconds(10)) // Set the connection timeout time, the default is 10 seconds
.responseTimeout(Duration.ofSeconds(10)) // Set the response timeout time, the default is 20 seconds
.maxConnections(128) // Set the connection pool size
.maxIdleTimeOut(Duration.ofSeconds(50)) // Set the connection pool timeout, the default is 30 seconds
// Configure the proxy
.proxy(new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress("<your-proxy-hostname>", 9001))
.setCredentials("<your-proxy-username>", "<your-proxy-password>"))
// If it is an https connection, you need to configure the certificate, or ignore the certificate(.ignoreSSL(true))
.x509TrustManagers(new X509TrustManager[]{})
.keyManagers(new KeyManager[]{})
.ignoreSSL(false)
.build();*/
// Configure Credentials authentication information, including ak, secret, token
StaticCredentialProvider provider = StaticCredentialProvider.create(Credential.builder()
// Please ensure that the environment variables ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set.
.accessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
.accessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"))
//.securityToken(System.getenv("ALIBABA_CLOUD_SECURITY_TOKEN")) // use STS token
.build());
// Configure the Client
AsyncClient client = AsyncClient.builder()
.region("cn-hangzhou") // Region ID
//.httpClient(httpClient) // Use the configured HttpClient, otherwise use the default HttpClient (Apache HttpClient)
.credentialsProvider(provider)
//.serviceConfiguration(Configuration.create()) // Service-level configuration
// Client-level configuration rewrite, can set Endpoint, Http request parameters, etc.
.overrideConfiguration(
ClientOverrideConfiguration.create()
// Endpoint 请参考 https://api.aliyun.com/product/BssOpenApi
.setEndpointOverride("business.aliyuncs.com")
//.setConnectTimeout(Duration.ofSeconds(30))
)
.build();
// Parameter settings for API request
ModifyInstanceRequest.Parameter parameter0 = ModifyInstanceRequest.Parameter.builder()
.value("cfw_spec")
.build();
ModifyInstanceRequest modifyInstanceRequest = ModifyInstanceRequest.builder()
.productCode("cfw")
.subscriptionType("Subscription")
.modifyType("Upgrade")
.parameter(java.util.Arrays.asList(
parameter0
))
// Request-level configuration rewrite, can set Http request parameters, etc.
// .requestConfiguration(RequestConfiguration.create().setHttpHeaders(new HttpHeaders()))
.build();
// Asynchronously get the return value of the API request
CompletableFuture<ModifyInstanceResponse> response = client.modifyInstance(modifyInstanceRequest);
// Synchronously get the return value of the API request
ModifyInstanceResponse resp = response.get();
System.out.println(new Gson().toJson(resp));
// Asynchronous processing of return values
/*response.thenAccept(resp -> {
System.out.println(new Gson().toJson(resp));
}).exceptionally(throwable -> { // Handling exceptions
System.out.println(throwable.getMessage());
return null;
});*/
// Finally, close the client
client.close();
}
}正常返回示例
{
"Message": "Successful!",
"RequestId": "3EC4C157-46E3-5341-82B0-************",
"Data": {
"OrderId": 22165938810****,
"HostId": "cn****"
},
"Code": "Success",
"Success": true
}实例续费
调用RenewInstance对相关实例进行续费。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
请求参数
名称 | 类型 | 是否必选 | 示例值 | 描述 |
Action | String | 是 | RenewInstance | 系统规定参数。取值:RenewInstance。 |
ProductCode | String | 是 | cfw | 产品代码。可通过接口查询产品信息查询产品代码,或查看阿里云产品Code速查手册。云防火墙的产品代码。取值:
|
RenewPeriod | Integer | 是 | 6 | 预付费续费时长。单位:月。取值:
|
InstanceId | String | 否 | vipcloudfw-cn-pe333nx**** | 订单对应的实例ID。 |
响应参数
错误码 | 类型 | 示例值 | 描述 |
Code | String | Success | 状态码。 |
OrderId | String | 22165938810**** | 创建成功的订单ID。 |
Message | String | Successful! | 错误信息。 |
RequestId | String | E15FB71F-7FF8-5272-80B1-************ | 请求ID。 |
Success | Boolean | true | 是否成功。 |
示例
以下是实现续费6个月的代码示例。
请求示例
// This file is auto-generated, don't edit it. Thanks.
package demo;
import com.aliyun.auth.credentials.Credential;
import com.aliyun.auth.credentials.provider.StaticCredentialProvider;
import com.aliyun.core.http.HttpClient;
import com.aliyun.core.http.HttpMethod;
import com.aliyun.core.http.ProxyOptions;
import com.aliyun.httpcomponent.httpclient.ApacheAsyncHttpClientBuilder;
import com.aliyun.sdk.service.bssopenapi20171214.models.*;
import com.aliyun.sdk.service.bssopenapi20171214.*;
import com.google.gson.Gson;
import darabonba.core.RequestConfiguration;
import darabonba.core.client.ClientOverrideConfiguration;
import darabonba.core.utils.CommonUtil;
import darabonba.core.TeaPair;
//import javax.net.ssl.KeyManager;
//import javax.net.ssl.X509TrustManager;
import java.net.InetSocketAddress;
import java.time.Duration;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.io.*;
public class RenewInstance {
public static void main(String[] args) throws Exception {
// HttpClient Configuration
/*HttpClient httpClient = new ApacheAsyncHttpClientBuilder()
.connectionTimeout(Duration.ofSeconds(10)) // Set the connection timeout time, the default is 10 seconds
.responseTimeout(Duration.ofSeconds(10)) // Set the response timeout time, the default is 20 seconds
.maxConnections(128) // Set the connection pool size
.maxIdleTimeOut(Duration.ofSeconds(50)) // Set the connection pool timeout, the default is 30 seconds
// Configure the proxy
.proxy(new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress("<your-proxy-hostname>", 9001))
.setCredentials("<your-proxy-username>", "<your-proxy-password>"))
// If it is an https connection, you need to configure the certificate, or ignore the certificate(.ignoreSSL(true))
.x509TrustManagers(new X509TrustManager[]{})
.keyManagers(new KeyManager[]{})
.ignoreSSL(false)
.build();*/
// Configure Credentials authentication information, including ak, secret, token
StaticCredentialProvider provider = StaticCredentialProvider.create(Credential.builder()
// Please ensure that the environment variables ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set.
.accessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
.accessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"))
//.securityToken(System.getenv("ALIBABA_CLOUD_SECURITY_TOKEN")) // use STS token
.build());
// Configure the Client
AsyncClient client = AsyncClient.builder()
.region("cn-hangzhou") // Region ID
//.httpClient(httpClient) // Use the configured HttpClient, otherwise use the default HttpClient (Apache HttpClient)
.credentialsProvider(provider)
//.serviceConfiguration(Configuration.create()) // Service-level configuration
// Client-level configuration rewrite, can set Endpoint, Http request parameters, etc.
.overrideConfiguration(
ClientOverrideConfiguration.create()
// Endpoint 请参考 https://api.aliyun.com/product/BssOpenApi
.setEndpointOverride("business.aliyuncs.com")
//.setConnectTimeout(Duration.ofSeconds(30))
)
.build();
// Parameter settings for API request
RenewInstanceRequest renewInstanceRequest = RenewInstanceRequest.builder()
.productCode("cfw")
.instanceId("********")
.renewPeriod(6)
// Request-level configuration rewrite, can set Http request parameters, etc.
// .requestConfiguration(RequestConfiguration.create().setHttpHeaders(new HttpHeaders()))
.build();
// Asynchronously get the return value of the API request
CompletableFuture<RenewInstanceResponse> response = client.renewInstance(renewInstanceRequest);
// Synchronously get the return value of the API request
RenewInstanceResponse resp = response.get();
System.out.println(new Gson().toJson(resp));
// Asynchronous processing of return values
/*response.thenAccept(resp -> {
System.out.println(new Gson().toJson(resp));
}).exceptionally(throwable -> { // Handling exceptions
System.out.println(throwable.getMessage());
return null;
});*/
// Finally, close the client
client.close();
}
}正常返回示例
{
"Message": "Successful!",
"RequestId": "E15FB71F-7FF8-5272-80B1-*************",
"Data": {
"OrderId": 22167752456****
},
"Code": "Success",
"Success": true
}