This document describes the steps of accessing EDAS APIs, including instructions on how to obtain the SDK and descriptions of initialization parameters. It also provides an example of a specific API call.
Obtain the SDK
For Maven users
Add the following openAPI SDK dependency to the pom.xml file:
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-edas</artifactId>
<version>2.16.2-SNAPSHOT</version>
</dependency>
NOTE: If you cannot obtain the SDK after the dependency is added, add the following profile to the setting.xml file of the local repository (the file is in .m2 of the user directory).If you still cannot obtain the SDK after the profile is added, open a ticket to consult with us.
<profiles>
<profile>
<id>allow-snapshots</id>
<activation><activeByDefault>true</activeByDefault></activation>
<repositories>
<repository>
<id>snapshots-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>allow-snapshots</activeProfile>
</activeProfiles>
For non-Maven users
Download the JAR package from the following version list and add the package to the project:
Version 2.16.0-SNAPSHOT: http://edas.oss-cn-hangzhou.aliyuncs.com/edas-pop-api/2.16.0-SNAPSHOT/aliyun-java-sdk-edas-2.16.0-snapshot.jar
Common request parameters
Parameter | Description |
---|---|
regionId | Unique ID of the region where the API gateway is located. For details, see the list of EDAS supported regions. |
accessKeyId/accessKeySecret | Access Key ID and Access Key Secret that you obtain on Alibaba Cloud website, which are different for the primary account and subaccount. |
productName | OpenAPI product name. Set this parameter to EDAS. |
domain | Domain of the endpoint for OpenAPI access, in the format of edas.${RegionId}.aliyuncs.com. For details about the list of regions with support for EDAS OpenAPIs, see the following section. |
Use of a subaccount
Currently, APIs can be called by subaccounts. In this case, enter the Access Key ID and Access Key Secret of each subaccount. In addition, subaccounts must be authorized by the primary accounts to use the corresponding resources. For more information, see [Authorize permissions to subaccounts] in subaccount management documentation(44023).
Supported regions
Region | RegionId | Domain | Domain (VPC environment) | Remarks |
---|---|---|---|---|
China (Beijing) | cn-beijing | edas.cn-beijing.aliyuncs.com | edas-vpc.cn-beijing.aliyuncs.com | This endpoint is recommended for users in China (Beijing). |
China (Qingdao) | cn-qingdao | edas.cn-qingdao.aliyuncs.com | Not supported | This endpoint is recommended for users in China (Qingdao). |
China (Shenzhen) | cn-shenzhen | edas.cn-shenzhen.aliyuncs.com | edas-vpc.cn-shenzhen.aliyuncs.com | This endpoint is recommended for users in China (Shenzhen). |
China (Hangzhou) | cn-hangzhou | edas.cn-hangzhou.aliyuncs.com | edas-vpc.cn-hangzhou.aliyuncs.com | This endpoint is recommended for users in China (Hangzhou). |
China (Shanghai) | cn-shanghai | edas.cn-shanghai.aliyuncs.com | edas-vpc.cn-shanghai.aliyuncs.com | This endpoint is recommended for users in China (Shanghai). |
Singapore | ap-southeast-1 | edas.ap-southeast-1.aliyuncs.com | Not supported | This endpoint is recommended for users in Singapore. |
Request example
To use OpenAPIs, launch the OpenAPI client, configure an endpoint, and set public parameters such as regionId and accessKeyId.Here is a sample API request.
public static void main(String[] args) throws ClientException{
/**
*Endpoint used to access the OpenAPI. Set it based on the list of EDAS supported regions and the region where your instance is located.
*/
String regionId = "XXXXX";
/**
*Access Key ID used for authentication. Obtain it in the Alibaba Cloud console.
*/
String accessKeyId = "XXXXXXXXXXXXXXXXX";
/**
*Access Key Secret used for authentication. Obtain it in the Alibaba Cloud console.
*/
String accessKeySecret = "XXXXXXXXXXXXXXXXX";
/**
* Name of the cloud product that you access using the OpenAPI. Set it to EDAS.
*/
String productName ="Edas";
/**
*Domain of the endpoint. For details, see the domains in the list of EDAS supported regions.
*/
String domain ="edas.XXXXX.aliyuncs.com";
// Construct the OpenAPI client
DefaultProfile.addEndpoint(regionId,regionId,productName,domain);
DefaultProfile defaultProfile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret);
DefaultAcsClient defaultAcsClient = new DefaultAcsClient(defaultProfile);
defaultAcsClient.setAutoRetry(false);
// Construct the API request for listing application deployment groups. For details about the input parameters, see API description.
String appId = "xxxxxxxxx";
ListDeployGroupRequest request = new ListDeployGroupRequest();
// For details about the input parameters, see API description.
request.setAppId(appId);
ListDeployGroupResponse response = defaultAcsClient.getAcsResponse(request);
// Result parsing (If Code 200 is returned, the API call is successful; if any other code is returned, the API call fails. For details, see the error code list.)
if (response.getCode() == 200) {
// Parse the returned result (For details, see the return value description of the API.)
List<DeployGroup> deployGroups = response.getDeployGroupList();
if (CollectionUtils.isNotEmpty(deployGroups)) {
for (DeployGroup deployGroup : deployGroups) {
System.out.println(deployGroup.getGroupName());
System.out.println(deployGroup.getGroupId());
}
}
} else {
// Print the cause of the error
System.out.println(response.getMessage());
}
}