Cloud Firewall commerce API

更新时间:
复制 MD 格式

Cloud Firewall does not provide APIs for managing (including querying, creating, modifying, and renewing) instances. You can use the Alibaba Cloud Trading and Bill Management API to manage your Cloud Firewall instances. This topic describes the request methods and provides examples for doing so.

Background

The Alibaba Cloud Billing Management API provides a set of general-purpose APIs for managing Alibaba Cloud resources, allowing you to query service prices, manage instances, and retrieve billing information. For a list of all supported APIs, see the API overview.

You can use the Alibaba Cloud Trading and Bill Management API to query, create, modify, and renew Cloud Firewall instances. For information on how to call the API, see Request structure.

Query instances

Call QueryAvailableInstances to find available instances.

Debugging

You can run this API directly in OpenAPI Explorer without calculating a signature. On a successful call, it automatically generates an SDK code sample.

Request parameters

Parameter

Type

Required

Example value

Description

Region

String

No

cn-hangzhou

The ID of the region.

PageNum

Integer

No

1

The page number.

PageSize

Integer

No

20

The number of entries to return on each page.

ProductCode

String

Yes

cfw

The product code for Cloud Firewall. You can call the Query Product Information operation to query product codes or refer to the Alibaba Cloud Product Code Quick Reference. Valid value:

  • cfw

ProductType

String

No

cfw_sub_public_cn

The product type for Cloud Firewall. You can call the Query Product Information operation to query product types or refer to the Alibaba Cloud Product Code Quick Reference. Valid values:

  • cfw_sub_public_cn: subscription 2.0 for the China site

  • cfw_elasticity_public_cn: pay-as-you-go 2.0 for the China site

  • cfw_sub_public_intl: subscription 2.0 for the international site

  • cfw_elasticity_public_intl: pay-as-you-go 2.0 for the international site

SubscriptionType

String

No

Subscription

The billing method of the instance. Valid values:

  • Subscription: The subscription billing method.

  • PayAsYouGo: The pay-as-you-go billing method.

InstanceIDs

String

No

cfw_sub_public_cn-pe3xxxxxx

The IDs of the instances to query. You can specify up to 100 instance IDs, separated by commas.

EndTimeStart

String

No

2024-01-01T00:00:00Z

The start of the expiration time range to query. The time must be in the ISO 8601 format and in UTC.

EndTimeEnd

String

No

2024-01-01T00:00:00Z

The end of the expiration time range to query. The time must be in the ISO 8601 format and in UTC.

CreateTimeStart

String

No

2023-01-01T00:00:00Z

The start of the creation time range to query. The time must be in the ISO 8601 format and in UTC.

CreateTimeEnd

String

No

2023-01-01T00:00:00Z

The end of the creation time range to query. The time must be in the ISO 8601 format and in UTC.

RenewStatus

String

No

AutoRenewal

The renewal status. Valid values:

  • AutoRenewal: auto-renewal

  • ManualRenewal: manual renewal

  • NotRenewal: The instance will not be renewed upon expiration.

Response parameters

Parameter

Type

Example value

Description

Code

String

Success

The status code.

Message

String

Successful!

The response message.

RequestId

String

C7C15585-8349-4C62-BEE4-5A391841XXXX

The request ID.

Success

Boolean

TRUE

Specifies whether the request succeeded.

Data

Object

The response data. For details, see Data.

data

Parameter

Type

Value

Description

PageNum

Integer

1

The page number to return.

PageSize

Integer

10

The number of items to return on each page.

TotalCount

Integer

11

The total number of items found.

InstanceList

Object

The list of instances. For details, see InstanceList.

InstanceList

Parameter

Type

Example value

Description

SubStatus

String

Normal

The billing sub-status for a pay-as-you-go instance. Valid values:

  • Normal: The instance is operating normally.

  • WaitForLimit: The instance is about to be restricted due to an overdue payment.

  • BandwidthLimited: The instance is restricted due to an overdue payment.

Status

String

Normal

The status of the Cloud Firewall instance. Valid values:

  • Creating: The instance is being created.

  • WaitForExpire: The instance is about to expire.

  • Normal: The instance is operating normally.

  • Expired: The instance has expired.

ExpectedReleaseTime

String

2019-09-08T16:00:00Z

The time when the instance is scheduled to be released.

RenewStatus

String

ManualRenewal

The renewal status. Valid values:

  • AutoRenewal: auto-renewal

  • ManualRenewal: manual renewal

  • NotRenewal: The instance will not be renewed.

CreateTime

String

2019-09-08T16:00:00Z

The time when the instance was created.

SellerId

Long

123123123

The seller ID.

InstanceID

String

cfw_sub_public_cn-pe333nx****

The instance ID that corresponds to the order.

Seller

String

2****

The seller.

StopTime

String

2019-09-08T16:00:00Z

The time when the instance was stopped.

RenewalDurationUnit

String

M

The unit for the auto-renewal duration. Valid values:

  • M: Month

  • Y: Year

SubscriptionType

String

Subscription

The subscription type. Valid values:

  • Subscription: prepaid

  • PayAsYouGo: postpaid

OwnerId

Long

325352345

The owner ID.

EndTime

String

2019-09-08T16:00:00Z

The expiration time of the instance.

ProductType

String

cfw_sub_public_cn

The product type.

Region

String

cn-hangzhou

The region where the instance is located.

ReleaseTime

String

2019-09-08T16:00:00Z

The time when the instance was released.

RenewalDuration

Integer

1

The number of units in the auto-renewal period.

ProductCode

String

cfw

The product code.

Example

Example request

// 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. The default is 10 seconds.
                .responseTimeout(Duration.ofSeconds(10)) // Set the response timeout. The default is 20 seconds.
                .maxConnections(128) // Set the connection pool size.
                .maxIdleTimeOut(Duration.ofSeconds(50)) // Set the idle connection 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>"))
                // For HTTPS, configure a certificate or ignore SSL validation (for example, .ignoreSSL(true)).
                .x509TrustManagers(new X509TrustManager[]{})
                .keyManagers(new KeyManager[]{})
                .ignoreSSL(false)
                .build();*/

        // Configure credentials. Use an AccessKey pair or an STS token.
        StaticCredentialProvider provider = StaticCredentialProvider.create(Credential.builder()
                // Ensure that the ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables 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")) // Uncomment to use an STS token.
                .build());

        // Configure the client.
        AsyncClient client = AsyncClient.builder()
                .region("cn-shanghai") // Region ID
                //.httpClient(httpClient) // Uncomment to use the custom HttpClient. Otherwise, the SDK uses the default Apache HttpClient.
                .credentialsProvider(provider)
                //.serviceConfiguration(Configuration.create()) // Service-level configuration
                // Override client-level configuration to set the endpoint, HTTP request parameters, and more.
                .overrideConfiguration(
                        ClientOverrideConfiguration.create()
                                  // For the endpoint, see https://api.aliyun.com/product/BssOpenApi
                                .setEndpointOverride("business.aliyuncs.com")
                        //.setConnectTimeout(Duration.ofSeconds(30))
                )
                .build();

        // Configure the API request parameters.
        QueryAvailableInstancesRequest queryAvailableInstancesRequest = QueryAvailableInstancesRequest.builder()
                .productCode("cfw")
                .productType("cfw_sub_public_cn")
                // Request-level override for settings like HTTP request parameters.
                // .requestConfiguration(RequestConfiguration.create().setHttpHeaders(new HttpHeaders()))
                .build();

        // Call the API asynchronously.
        CompletableFuture<QueryAvailableInstancesResponse> response = client.queryAvailableInstances(queryAvailableInstancesRequest);
        // Get the response synchronously.
        QueryAvailableInstancesResponse resp = response.get();
        System.out.println(new Gson().toJson(resp));
        // Process the response asynchronously.
        /*response.thenAccept(resp -> {
            System.out.println(new Gson().toJson(resp));
        }).exceptionally(throwable -> { // Handle exceptions.
            System.out.println(throwable.getMessage());
            return null;
        });*/

        // Close the client to release resources.
        client.close();
    }

}

Sample response

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

Create an instance

Call CreateInstance to create an instance. This action also creates an order and completes the payment.

Debugging

You can run this API directly in OpenAPI Explorer without needing to calculate a signature. After a successful call, OpenAPI Explorer automatically generates an SDK code example.

Request parameters

Parameter

Type

Required

Example

Description

ProductCode

String

Yes

cfw

The product code. To obtain product codes, call the Query product information operation or refer to the Alibaba Cloud Product Code Quick Reference. Valid value for Cloud Firewall:

  • cfw

ProductType

String

Yes

cfw_sub_public_cn

The product type. To obtain product types, call the Query product information operation or refer to the Alibaba Cloud Product Code Quick Reference. Valid values for Cloud Firewall:

  • cfw_sub_public_cn: subscription 2.0 for the China site

  • cfw_elasticity_public_cn: pay-as-you-go 2.0 for the China site

  • cfw_sub_public_intl: subscription 2.0 for the International site

  • cfw_elasticity_public_intl: pay-as-you-go 2.0 for the International site

SubscriptionType

String

Yes

Subscription

The billing method. Valid values:

  • Subscription: subscription

  • PayAsYouGo: pay-as-you-go

Parameter.N.Code

String

Yes

The code of the Nth module attribute, where N is an integer from 1 to 100. If you specify multiple module attributes, number the parameters consecutively as Parameter.1.Code, Parameter.2.Code, and so on. For more information, see Parameter.

Parameter.N.Value

String

Yes

The value of the Nth module attribute, where N is an integer from 1 to 100. For more information, see Parameter.

RenewPeriod

Integer

No

12

The auto-renewal period in months.

Note

This parameter is required if you set RenewalStatus to AutoRenewal.

Period

Integer

No

1

The subscription period in months. For annual subscriptions, enter a multiple of 12.

Note

This parameter is required for subscription instances.

RenewalStatus

String

No

ManualRenewal

The renewal status. Valid values:

  • AutoRenewal: Enables auto-renewal.

  • ManualRenewal (default): Requires manual renewal.

Parameter

Parameter

Type

Required

Example value

Description

cfw_spec

String

Required for subscription instances

2

The Cloud Firewall edition. Valid values:

  • 2: Advanced Edition

  • 3: Enterprise Edition

  • 4: Ultimate Edition

cfw_endpoint

Integer

No

0

The number of firewall extension instances. Valid range:

  • 0 to 1,000, in increments of 1

cfw_bandwidth

Integer

No

1000

The firewall extension bandwidth in Mbps. The valid range varies based on the edition:

  • Advanced Edition: 0 to 5,000, in increments of 10

  • Enterprise Edition: 0 to 10,000, in increments of 10

  • Ultimate Edition: 0 to 20,000, in increments of 10

cfw_ndlp_enable

String

No

false

Whether to enable sensitive data leak detection. Valid values:

  • true: Enables the feature.

  • false: Disables the feature.

cfw_log

String

No

false

Whether to enable log analysis. Valid values:

  • true: Enables the feature.

  • false: Disables the feature.

cfw_log_storage

Integer

No

100

The log storage capacity in TB. The valid range varies based on the edition:

  • Advanced Edition: 2 to 500, in increments of 1

  • Enterprise Edition: 4 to 500, in increments of 1

  • Ultimate Edition: 6 to 500, in increments of 1

Important

This parameter applies only when log analysis is enabled.

cfw_autoasset_protection

String

No

true

Specifies whether to enable automatic protection for internet assets. Valid values:

  • true: Automatically adds assets for protection.

  • false: Does not automatically add assets for protection.

Note

If you repurchase an instance within seven days of its release, the system automatically applies the previous configurations.

ndr_service

String

No

0

Whether to enable Agentic NDR. Valid values:

  • 1: Enables the feature.

  • 0: Disables the feature.

ndr_flow_storage

Integer

No

0

The Agentic NDR full traffic storage capacity in TB. Valid range:

  • 0 to 500, in increments of 1

Important

This parameter applies only when Agentic NDR is enabled.

ndr_bandwidth

Integer

No

0

The Agentic NDR extension bandwidth in Mbps. Valid range:

  • 0 to 10,000, in increments of 1

Important

This parameter applies only when Agentic NDR is enabled.

Return parameters

Parameter

Type

Value

Description

Code

String

Success

The status code.

InstanceId

String

cfw_sub_public_cn-************

The instance ID for the order.

OrderId

String

22165938636****

The ID of the created order.

Message

String

Successful!

The response message.

RequestId

String

13B1DCF7-0B7C-5426-BC08-************

The request ID.

Success

Boolean

true

Indicates whether the request was successful.

Example

This code creates a prepaid Cloud Firewall instance in mainland China for one month with manual renewal.

Example request

// This file is auto-generated. Do not edit.
package com.aliyun.sample;

import com.aliyun.tea.*;

public class Sample {

    /**
     * <b>description</b> :
     * <p>Initializes a client with a credential.</p>
     * @return Client
     * 
     * @throws Exception
     */
    public static com.aliyun.bssopenapi20171214.Client createClient() throws Exception {
        // For production environments, we recommend a more secure credential method than using an access key. For more information about configuring credentials, see 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);
        // For endpoint details, see 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 {
            // Call the API operation.
            client.createInstanceWithOptions(createInstanceRequest, runtime);
        } catch (TeaException error) {
            // This exception handling is for demonstration only. Implement proper exception handling in production code.
            System.out.println(error.getMessage());
            // The recommendation.
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // This exception handling is for demonstration only. Implement proper exception handling in production code.
            System.out.println(error.getMessage());
            // The recommendation.
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }        
    }
}

Successful response

Creating a Cloud Firewall instance returns an instance ID (InstanceId). This ID is required for subsequent operations, such as specification changes and renewals.

{
  "RequestId": "13B1DCF7-0B7C-5426-BC08-************",
  "Message": "Successful!",
  "Data": {
    "InstanceId": "cfw_sub_public_cn-***********",
    "OrderId": 22165938636****
  },
  "Code": "Success",
  "Success": true
}

Modify instance

Use the ModifyInstance API to modify an instance's configuration. This creates an order and automatically processes the payment.

Note

After you downgrade your configuration, no refund will be issued for the current billing cycle. You will be billed at the new rate starting from the next billing cycle.

Debugging

You can run this API directly in OpenAPI Explorer without having to calculate a signature. After a successful call, OpenAPI Explorer automatically generates an SDK code sample.

Parameters

Parameter

Type

Required

Example value

Description

Action

String

Yes

ModifyInstance

A system parameter. Set this to ModifyInstance.

Parameter.N.Code

String

Yes

The code for the Nth module attribute, where N is an integer from 1 to 100. To specify multiple attributes, use the format Parameter.1.Code, Parameter.2.Code, and so on. For more information, see Parameter.

Parameter.N.Value

String

Yes

The value of the Nth module attribute, where N is an integer from 1 to 100. For more information, see Parameter.

ProductCode

String

Yes

cfw

The product code. To obtain product codes, call the Query Product Information operation or refer to the Alibaba Cloud Product Code Quick Reference. The product code for Cloud Firewall is:

  • cfw

SubscriptionType

String

Yes

Subscription

The billing method. Valid values:

  • Subscription: prepaid

  • PayAsYouGo: pay-as-you-go

ModifyType

Upgrade

The modification type. Valid values:

  • Upgrade: upgrade

  • Downgrade: downgrade

InstanceId

String

No

vipcloudfw-cn-pe333nx****

The instance ID associated with the order.

Parameter

Parameter.N.Code

Type

Required

Example

Description

cfw_spec

String

Required for subscription instances.

2

The edition of the Cloud Firewall instance. Valid values:

  • 2: Advanced Edition

  • 3: Enterprise Edition

  • 4: Ultimate Edition

cfw_endpoint

Integer

No

0

The number of additional firewall instances. The value must be an integer from 0 to 1,000.

  • 0 to 1000, with a step of 1

cfw_bandwidth

Integer

No

1000

The additional bandwidth in Mbps. The valid range varies based on the edition:

  • Advanced Edition: 0 to 5,000, in increments of 10

  • Enterprise Edition: 0 to 10,000, in increments of 10

  • Ultimate Edition: 0 to 20,000, in increments of 10

cfw_ndlp_enable

String

No

false

Specifies whether to enable sensitive data leakage detection. Valid values:

  • true

  • false

cfw_log

String

No

false

Specifies whether to enable log analysis. Valid values:

  • true

  • false

cfw_log_storage

Integer

No

100

The log storage capacity in TB. The valid range varies based on the edition:

  • Advanced Edition: 2 to 500, in increments of 1

  • Enterprise Edition: 4 to 500, in increments of 1

  • Ultimate Edition: 6 to 500, in increments of 1

Important

This parameter takes effect only when cfw_log is set to true.

cfw_autoasset_protection

String

No

true

Specifies whether to automatically protect internet assets. Valid values:

  • true: Automatically adds new assets.

  • false: Does not automatically add new assets.

ndr_service

String

No

0

Specifies whether to enable Agentic NDR. Valid values:

  • 1: Enables the feature.

  • 0: Disables the feature.

ndr_flow_storage

Integer

No

0

The storage capacity in TB for Agentic NDR full-traffic analysis. The value must be an integer from 0 to 500.

  • 0 to 500, in increments of 1

Important

This parameter takes effect only when ndr_service is set to 1.

ndr_bandwidth

Integer

No

0

The additional bandwidth in Mbps for Agentic NDR. The value must be an integer from 0 to 10,000.

  • 0 to 10,000, with a step of 1

Important

This parameter takes effect only when ndr_service is set to 1.

Response parameters

Parameter

Type

Value

Description

Code

String

Success

The response status code.

HostId

String

cn****

The host ID.

OrderId

String

22165938810****

The ID of the created order.

Message

String

Successful!

The response message.

RequestId

String

3EC4C157-46E3-5341-82B0-************

The request ID.

Success

Boolean

true

Indicates whether the request was successful.

Example

The following code upgrades the edition from Advanced to Enterprise.

Request example

// This file is auto-generated. Do not edit.
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)) // Sets the connection timeout. Default: 10s.
                .responseTimeout(Duration.ofSeconds(10)) // Sets the response timeout. Default: 20s.
                .maxConnections(128) // Sets the connection pool size.
                .maxIdleTimeOut(Duration.ofSeconds(50)) // Sets the idle connection timeout. Default: 30s.
                // Configure the proxy.
                .proxy(new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress("", 9001))
                        .setCredentials("", ""))
                // For an HTTPS connection, configure a certificate or ignore certificate validation.
                .x509TrustManagers(new X509TrustManager[]{})
                .keyManagers(new KeyManager[]{})
                .ignoreSSL(false)
                .build();*/

        // Configure credentials. Use an AccessKey pair or an STS token.
        StaticCredentialProvider provider = StaticCredentialProvider.create(Credential.builder()
                // Ensure the ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables 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")) // Uncomment to use an STS token.
                .build());

        // Configure the client.
        AsyncClient client = AsyncClient.builder()
                .region("cn-hangzhou") // Region ID
                //.httpClient(httpClient) // Specify the HTTP client. If omitted, the default Apache HttpClient is used.
                .credentialsProvider(provider)
                //.serviceConfiguration(Configuration.create()) // Service-level configuration
                // Override client-level configurations, such as the endpoint and HTTP request parameters.
                .overrideConfiguration(
                        ClientOverrideConfiguration.create()
                                  // Set the endpoint. For a list of endpoints, see https://api.aliyun.com/product/BssOpenApi
                                .setEndpointOverride("business.aliyuncs.com")
                        //.setConnectTimeout(Duration.ofSeconds(30))
                )
                .build();

        // Configure the API request parameters.
        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
                ))
                // Override request-level configurations, such as HTTP request parameters.
                // .requestConfiguration(RequestConfiguration.create().setHttpHeaders(new HttpHeaders()))
                .build();

        // Call the API asynchronously.
        CompletableFuture response = client.modifyInstance(modifyInstanceRequest);
        // Get the response synchronously.
        ModifyInstanceResponse resp = response.get();
        System.out.println(new Gson().toJson(resp));
        // Process the response asynchronously.
        /*response.thenAccept(resp -> {
            System.out.println(new Gson().toJson(resp));
        }).exceptionally(throwable -> { // Handle exceptions.
            System.out.println(throwable.getMessage());
            return null;
        });*/

        // Close the client.
        client.close();
    }

}

Sample success response

{
  "Message": "Successful!",
  "RequestId": "3EC4C157-46E3-5341-82B0-************",
  "Data": {
    "OrderId": 22165938810****,
    "HostId": "cn****"
  },
  "Code": "Success",
  "Success": true
}

Instance renewal

Call RenewInstance to renew the instance.

Debugging

You can run this API directly in OpenAPI Explorer without having to calculate a signature. Upon a successful call, OpenAPI Explorer automatically generates an SDK code sample.

Parameters

Parameter

Type

Required

Example

Description

Action

String

Yes

RenewInstance

A system parameter. The value must be RenewInstance.

ProductCode

String

Yes

cfw

The product code for the service. You can call the Query product information operation or refer to the Alibaba Cloud Product Code Quick Reference to find the product code. The product code for Cloud Firewall is cfw.

  • Cloud Firewall (CFW)

RenewPeriod

Integer

Yes

6

The renewal period for the subscription. Unit: months. Valid values:

  • 1-9

  • 12

  • 24

  • 36

InstanceId

String

No

vipcloudfw-cn-pe333nx****

The ID of the instance that you want to renew.

Response parameters

Parameter

Type

Example value

Description

Code

String

Success

The status code.

OrderId

String

22165938810****

The ID of the order.

Message

String

Successful!

The response message.

RequestId

String

E15FB71F-7FF8-5272-80B1-************

The request ID.

Success

Boolean

true

Indicates whether the request was successful.

Example

Here is a code sample for a 6-month renewal.

Example request

// This file is auto-generated. Do not edit.
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)) // Connection timeout (default: 10s).
                .responseTimeout(Duration.ofSeconds(10)) // Response timeout (default: 20s).
                .maxConnections(128) // Connection pool size.
                .maxIdleTimeOut(Duration.ofSeconds(50)) // Idle connection timeout (default: 30s).
                // Configure a proxy.
                .proxy(new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress("<your-proxy-hostname>", 9001))
                        .setCredentials("<your-proxy-username>", "<your-proxy-password>"))
                // For HTTPS, configure a certificate or ignore certificate validation.
                .x509TrustManagers(new X509TrustManager[]{})
                .keyManagers(new KeyManager[]{})
                .ignoreSSL(false)
                .build();*/

        // Configure authentication credentials.
        StaticCredentialProvider provider = StaticCredentialProvider.create(Credential.builder()
                // Ensure the ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables 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 an STS token.
                .build());

        // Configure the client.
        AsyncClient client = AsyncClient.builder()
                .region("cn-hangzhou") // region ID
                //.httpClient(httpClient) // Specify the HTTP client. Defaults to Apache HttpClient.
                .credentialsProvider(provider)
                //.serviceConfiguration(Configuration.create()) // Service-level configuration
                // Override client-level settings, such as endpoint and HTTP parameters.
                .overrideConfiguration(
                        ClientOverrideConfiguration.create()
                                  // For endpoints, see https://api.aliyun.com/product/BssOpenApi
                                .setEndpointOverride("business.aliyuncs.com")
                        //.setConnectTimeout(Duration.ofSeconds(30))
                )
                .build();

        // Set API request parameters.
        RenewInstanceRequest renewInstanceRequest = RenewInstanceRequest.builder()
                .productCode("cfw")
                .instanceId("********")
                .renewPeriod(6)
                // Override request-level settings, such as HTTP headers.
                // .requestConfiguration(RequestConfiguration.create().setHttpHeaders(new HttpHeaders()))
                .build();

        // Call the API asynchronously.
        CompletableFuture<RenewInstanceResponse> response = client.renewInstance(renewInstanceRequest);
        // Fetch the response synchronously.
        RenewInstanceResponse resp = response.get();
        System.out.println(new Gson().toJson(resp));
        // Process the response asynchronously.
        /*response.thenAccept(resp -> {
            System.out.println(new Gson().toJson(resp));
        }).exceptionally(throwable -> { // Handle exceptions.
            System.out.println(throwable.getMessage());
            return null;
        });*/

        // Close the client.
        client.close();
    }

}

Successful response

{
  "Message": "Successful!",
  "RequestId": "E15FB71F-7FF8-5272-80B1-*************",
  "Data": {
    "OrderId": 22167752456****
  },
  "Code": "Success",
  "Success": true
}