Create a Global Traffic Manager (GTM) instance by calling the CreateInstance operation of BSS OpenAPI.
Prerequisites
Instance creation and renewal of GTM instances use the Alibaba Cloud BSS API. When you call the operation, comply with the specifications of the BSS API. For more information, see CreateInstance.
SDK
Maven dependencies:
<dependencies>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-bssopenapi</artifactId>
<version>1.6.6</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.4.6</version>
</dependency>
</dependencies>For SDKs in other languages, see SDK list.
For client initialization, refer to Install latest Java SDK.
For the China site, set RegionId to cn-hangzhou. For the International site, set RegionId to ap-southeast-1.
CreateInstance operation
Description: Creates a GTM instance
API reference: CreateInstance
Request parameters:
Parameter | Type | Required | Description |
ProductCode | String | Yes | The product code. Set the value to |
ProductType | String | Yes | The product type (commodity code). Set the value to |
SubscriptionType | String | Yes | The billing method. Set the value to |
Period | Integer | Yes | The subscription duration. Unit: months. Required when you create a subscription instance. For products that are billed on a yearly basis, enter a multiple of 12. |
Parameter.1.Code | String | Yes | The code of the plan edition module. Set the value to |
Parameter.1.Value | String | Yes | The plan edition to order. Valid values: |
Parameter.2.Code | String | Yes | The code of the health check task package module. Set the value to |
Parameter.2.Value | String | Yes | The number of health check task packages to order. Default value: 0. Minimum value: 0. Step: 100. Maximum value: 100,000. |
Parameter.3.Code | String | Yes | The code of the domestic SMS notification package module. Set the value to |
Parameter.3.Value | String | Yes | The number of domestic SMS notification packages to order. Default value: 0. Minimum value: 0. Step: 1,000. Maximum value: 100,000. |
RenewalStatus | String | No | The auto-renewal status. Valid values: |
RenewPeriod | Integer | No | The auto-renewal period. Unit: months. Required when |
Request examples
https://business.aliyuncs.com/? Action=CreateInstance
&Parameter.1.Code=PackageEdition
&Parameter.1.Value=standard
&Parameter.2.Code=HealthcheckTaskCount
&Parameter.2.Value=0
&Period=1
&ProductCode=dns
&ProductType=dns_gtm_public_intl
&SubscriptionType=SubscriptionSample code
package alidnstest.domainmanager;
import com.alibaba.fastjson.JSON;
import com.aliyuncs.bssopenapi.model.v20171214.CreateInstanceRequest;
import com.aliyuncs.bssopenapi.model.v20171214.CreateInstanceResponse;
import com.aliyuncs.exceptions.ClientException;
import org.testng.annotations.Test;
import org.testng.collections.Lists;
import utils.AlidnsTestBase;
public class InstanceCreate extends AlidnsTestBase {
@Test
public void createInstanceTest() {
CreateInstanceRequest request = new CreateInstanceRequest();
request.setProductCode("dns");
request.setProductType("dns_gtm_public_intl");
request.setSubscriptionType("Subscription");
request.setPeriod(1);
CreateInstanceRequest.Parameter parameters1 = new CreateInstanceRequest.Parameter();
parameters1.setCode("PackageEdition");
parameters1.setValue("standard");
CreateInstanceRequest.Parameter parameters2 = new CreateInstanceRequest.Parameter();
parameters2.setCode("HealthcheckTaskCount");
parameters2.setValue("0");
request.setParameters(Lists.newArrayList(parameters1,parameters2,parameters3));
try {
CreateInstanceResponse response = client.getAcsResponse(request);
System.out.println(JSON.toJSON(response));
} catch (ClientException e) {
e.printStackTrace();
}
}
}