Install and configure the Alibaba Cloud Developer Toolkit plugin to browse APIs, debug calls, and generate SDK sample code in your JetBrains IDE.
Install the plugin
Prerequisites
-
A JetBrains IDE, such as IntelliJ IDEA, PyCharm, or GoLand, is installed.
-
The IDE version must be 2022.2 or later.
The following examples use IntelliJ IDEA for Windows.
Method 1: Install from the marketplace
-
In the IntelliJ IDEA top menu bar, choose , or choose .
-
On the Plugins page, click the Marketplace tab.
-
Search for Alibaba Cloud Developer Toolkit and click Install.
-
Click Apply, and then click OK.
Method 2: Install from a downloaded package
-
Download the plugin package from the JetBrains Marketplace.
-
In the IntelliJ IDEA top menu bar, choose , or choose .
-
On the Plugins page, click the gear icon , select Install Plugin from Disk..., and then select the downloaded package. Do not decompress the package.
Verify the installation
After the installation is complete, the Alibaba Cloud API tree appears in the left-hand tool window bar of IntelliJ IDEA and lists service categories such as Application Security, Big Data, Application Services, Cloud Communication, Networking, Storage and CDN, Video Services, and Artificial Intelligence. Alibaba Cloud: is displayed on the right side of the status bar at the bottom, which indicates that the Alibaba Cloud Developer Toolkit plugin is ready.
Configure a profile
Configure a profile with valid AccessKey credentials to make API calls. The plugin supports only AccessKey credentials.
Method 1
-
In the top toolbar of IntelliJ IDEA, click the user icon to open the Alibaba Cloud Developer Tools panel, and then select New Profile from the drop-down list at the top of the left pane to create a profile. You can also click the
icon. -
Enter the Profile Name, RegionId, Access Key ID, and Secret Access Key. Use an existing AccessKey pair or create one. View the AccessKey information of a RAM user. The Secret Access Key is displayed only once — store it securely.
ImportantA root account AccessKey grants full permissions to all resources and poses a significant security risk if compromised. We recommend using a RAM user AccessKey instead.
-
Click Add Configurations.
-
A Profile added. message appears. Select the new profile from the drop-down list in the left pane.
-
Click a profile name to switch the active profile.
Method 2
-
If Alibaba Cloud CLI is installed and configured, the plugin reuses its credential configuration. Configure credentials for Alibaba Cloud CLI.
-
Use the drop-down list in the left pane or the status bar to switch between profiles.
-
Click a profile name in the drop-down list to activate it.
Features
The plugin lets you browse Alibaba Cloud APIs, debug API calls, generate SDKs, and insert SDK sample code in your projects.
Search for services and APIs
The left pane lists services in a tree view. Search by service name in English or Chinese, then click a service to browse its APIs.
In the left pane of the Alibaba Cloud Developer Toolkit plugin, use the Profile selector to switch the account configuration, enter a service keyword such as ecs in the search box, and then select the service that you want, such as Elastic Compute Service (ECS), from the service tree. After you select a service, the right pane displays the API list of the service. You can search for APIs by keyword — for example, entering run matches RunInstances and RunCommand. The complete API catalog is displayed below, grouped by feature category such as Resource Assurance, Block Storage, Images, Security Groups, and Cloud Assistant.
View API reference
Click an API to view its reference, including description, request parameters, response parameters, and error codes.
In the API navigation pane on the left of the Alibaba Cloud Developer Toolkit plugin, search for and select the service that you want, such as Elastic Compute Service (ECS). The corresponding API page, such as DescribeRegions, opens in the right pane. The page provides three tabs: API reference, Sample Code, and Debug. On the API reference tab, you can view the request parameters of the API, including parameter names, types, and valid values. You can select an endpoint from the drop-down list at the bottom of the page, or click Debug in the upper-right corner to start debugging the API.
API debugging
-
API debugging requires authentication.
-
Fill in the API parameters to view results in the IDE, or click Debug to open the API in OpenAPI Explorer.
In the search box of the navigation tree on the left, enter a keyword such as ecs and select the service that you want, such as Elastic Compute Service (ECS). The right pane displays the details of the selected API on three tabs: API reference, Sample Code, and Debug. Enter the request parameters in the parameter form, such as RegionId, ImageId, and InstanceType, select an endpoint, and then click Debug at the bottom to start debugging in the IDE. You can also click Clear Parameters or Generate Sample to assist with the operation.
View and insert SDK sample code
View SDK sample code
The plugin can generate SDKSDK sample code.
-
The plugin generates sample code based on your parameters. Open and edit the code directly in the IDE.
-
Automatic dependency import is supported for Maven only.
-
Use the Installation Method and View Source Code buttons to manage dependencies and view source code.
Select a language such as Java in the plugin panel, and then click Generate Sample. The plugin generates the SDK sample code of RunInstances and imports it into the editor. The generated sample code is as follows:
// This file is auto-generated, don't edit it. Thanks.
package com.aliyun.sample;
import com.aliyun.tea.*;
public class Sample {
/**
* Initialize the account Client with an AccessKey pair
* @param accessKeyId
* @param accessKeySecret
* @return Client
* @throws Exception
*/
public static com.aliyun.ecs20140526.Client createClient() throws xxx {
// Leaked project code may expose your AccessKey pair and threaten all resources under the account xxx
// We recommend the more secure STS method. For more authentication methods, see: https://hexxx
com.aliyun.teaopenapi.models.Config config = new com.aliyuxxx
// Required. Make sure that the ALIBABA_CLOUD_xxx environment variable is set in the code runtime environment
.setAccessKeyId(System.getenv("ALIBABA_CLOUDxxx
// Required. Make sure that the ALIBABA_CLOUD_Axxx environment variable is set in the code runtime environment
.setAccessKeySecret(System.getenv("ALIBABA_Cxxx
// For the endpoint, see https://api.alibabacloud.com/product/Ecs
config.endpoint = "ecs-cn-hangzhou.aliyuncs.com";
return new com.aliyun.ecs20140526.Client(config);
}
public static void main(String[] args_) throws Exception {
java.util.List<String> args = java.util.Arrays.asList(args_xxx
com.aliyun.ecs20140526.Client client = Sample.createClientxxx
com.aliyun.ecs20140526.models.RunInstancesRequest runInstaxxx
Insert code snippets
Insert Java or async Java SDK sample code with a single click. The plugin adds the Maven dependency to your pom.xml automatically. Toggle this feature by right-clicking and selecting Alibaba Cloud Developer Toolkit > Disable/Enable Alibaba Cloud SDK auto-completion, or press ctrl+cmd+p.
public class Test1 {
public static void main(String[] args) {
run
After you enter run in the editor, the plugin displays a code completion list with Alibaba Cloud API suggestions, such as RunInstances::Ecs::2014-05-26 (creates ECS instances) and RunCommand::cloudphone::2020-12-30 (runs a command on a cloud phone).
Search for ecs in the Alibaba Cloud Developer Toolkit panel, expand the Elastic Computing category, and then select Elastic Compute Service (ECS). The editor automatically generates the following SDK code. A dialog box appears in the lower-right corner and asks whether to automatically import the ecs20140526 dependency. Click Yes to import it.
public class Test1 {
public static void main(String[] args) {
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
// Make sure that the ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables are set in the code runtime environment
.setAccessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
.setAccessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"))
// For the endpoint, see https://api.alibabacloud.com/product/Ecs
.setEndpoint("ecs.cn-qingdao.aliyuncs.com");
com.aliyun.ecs20140526.Client client = new com.aliyun.ecs20140526.Client(config);
com.aliyun.ecs20140526.models.RunInstancesRequest runInstancesRequest = new com.aliyun.ecs20140526.models.RunInstancesRequest();
com.aliyun.ecs20140526.models.RunInstancesResponse runInstancesResponse = client.runInstances(runInstancesRequest);
}
}
public class Test1 {
public static void main(String[] args) throws Exception {
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
// Make sure that the ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables are set in the code runtime environment
.setAccessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
.setAccessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"))
// For the endpoint, see https://api.alibabacloud.com/product/Ecs
.setEndpoint("ecs.cn-qingdao.aliyuncs.com");
com.aliyun.ecs20140526.Client client = new com.aliyun.ecs20140526.Client(config);
com.aliyun.ecs20140526.models.RunInstancesRequest runInstancesRequest = new com.aliyun.ecs20140526.models.RunInstancesRequest();
com.aliyun.ecs20140526.models.RunInstancesResponse runInstancesResponse = client.runInstances(runInstancesRequest);
}
}