This article shows you how to use OpenAPI Explorer to call the Cloud Control API and manage the lifecycle of a Virtual Private Cloud (VPC).
Prerequisites
Log on to OpenAPI Explorer. We recommend that you use a RAM user with the following permissions:
1. Permission to manage the Cloud Control API. For more information, see Manage RAM users.
2. Permission to manage the VPC service. For more information, see Use RAM to manage VPC permissions.
Procedure
Use OpenAPI Explorer to call the Cloud Control API to create, retrieve, update, list, and delete a VPC resource. To integrate the Cloud Control API into your application, use the sample code automatically generated in OpenAPI Explorer.
Step 1: Create a VPC resource
-
Log on to OpenAPI Explorer as a RAM user. On the VPC resource creation page, select a regionId, specify the parameters in the body, and then click Initiate Call. On the right, select a language to view the auto-generated sample code.
The body includes resource properties such as IsDefault, Description (for example,
vpctest), ResourceGroupId, and ClassicLinkEnabled. In the sample code, the endpoint iscloudcontrol.aliyuncs.com, and theCreateResourcemethod initiates the call. -
After you initiate the call, view the result.
If an error occurs, use the log information in Diagnose, the API documentation, or the common error codes to troubleshoot. You can also contact us.
If the call is successful, record the resource ID from the response. A status code of 200 indicates a synchronous operation, which means the resource creation task is complete. A status code of 202 indicates an asynchronous operation. For an asynchronous operation, use the returned taskId to query the task status.
NoteA synchronous operation returns a result only after the task completes, while an asynchronous operation returns a result immediately and the task finishes in the background.
This example returns a status code of 202. In addition to
resourceIdandtaskId, the response body also containsresourcePathwith a value ofVPC/vpc-2zej5wah22u2d. In the response header,x-acs-cloudcontrol-timeout: 600indicates a 600-second timeout for the asynchronous task. -
The status code 202 indicates an asynchronous operation. Use the taskId to check the task status. Record the taskId and click Query task to go to the query page.
-
Enter the taskId and click Initiate Call. View the result. A task status of Succeeded indicates the VPC resource was created.
-
View the created VPC in the VPC console.
In the navigation pane on the left, click Virtual Private Cloud. In the VPC list, find the VPC instance you created and confirm its status is Available.
Step 2: Get a VPC resource
On the Get a VPC resource page, enter the resource ID, select a regionId, and click Initiate Call. A successful call returns the resource information.
In this example, regionId is set to cn-beijing. The call returns a status code of 200. The resourceAttributes in the response body contains fields such as IsDefault: false, Status: Available, Description: vpctest, and CidrBlock: 172.16.0.0/12. The request endpoint is cloudcontrol.aliyuncs.com.
Step 3: Update a VPC resource
On the Update a VPC resource page, enter the resource ID, select a regionId, specify the parameters to update, and then click Initiate Call. To verify the update, check the resource information in the VPC console or by calling the Cloud Control API.
In this example, enter vpc-2zej5wah22u2d for the resource ID in the requestPath, select cn-beijing for regionId, and enter vpctest update for Description in the body. After you initiate the call, a status code of 200 is returned, indicating a successful update.
Step 4: List VPC resources
On the List VPC resources page, select a regionId and click Initiate Call. The result shows the resource information.
For example, if you select cn-beijing as the regionId, a successful call returns a status code of 200. The returned JSON response contains the resource ID (such as vpc-2zej5wah22u2d) and resource properties such as IsDefault, Status, and Description.
Step 5: Delete a VPC resource
-
On the Delete a VPC resource page, enter the resource ID, select a regionId, and click Initiate Call. Then, view the result.
A successful call returns a status code of
202. The response body contains therequestIdandtaskIdfields. ThetaskId, such astask-5057a4fbef2bcda286c8ba5c1f, is used to track the status of the asynchronous deletion task. -
On the task query page, enter the taskId, and click Initiate Call. View the result. A task status of Succeeded indicates the VPC resource was deleted.
Sample code
Code repository: https://github.com/aliyun/cloud-control-api-demo
This repository contains Cloud Control API sample code to query resource metadata and manage cloud resources.