All Products
Search
Document Center

Alibaba Cloud SDK:Automatically generate SDK sample code

最終更新日:Jun 24, 2024

This topic describes how to automatically generate SDK sample code for API operations in OpenAPI Explorer.

Scenario

In this example, the sample code of the SDK for Java is generated for the DescribeRegions operation of Elastic Compute Service (ECS). This operation is used to query the available regions.

Procedure

  1. Visit OpenAPI Explorer.

  2. Perform the steps shown in the following figure to generate SDK sample code.

image

The following table describes the specific operations of each step in the preceding figure.

No.

Operation

1

On the OpenAPI Explorer homepage, move the pointer over Cloud Products in the top navigation bar. Then, enter the name of the cloud service that you want to manage in the search box. ECS is used in this example.

2

Check the version of the API. The API version is 2014-05-26 in this example.

3

Enter the name of the API operation that you want to call in the search box. Then, click the API operation in the search results.

DescribeRegions is used in this example.

4

Specify the request parameters of the DescribeRegions operation.

5

Optional. Click Initiate Call. You may be charged based on the billing rules of the API operation.

6

In the upper part of the rightmost pane, click the SDK Sample Code tab.

7

Select the SDK version and programming language based on your business requirements.

In this example, V2.0 is selected as the SDK version and Java is selected as the programming language.

8

Download the complete sample code for a sample SDK project.

9

Copy the sample code that is generated in the code editor.

10

View the SDK installation information, including the installation command and release report.

Note
  • In the upper-right corner of the code editor, you can click the 复制..png icon to copy the generated SDK sample code.

  • In the upper part of the SDK Sample Code tab, you can click Download Project to download the complete sample code for a sample SDK project.