This topic uses managing resources throughout the lifecycle of a virtual private cloud (VPC) to demonstrate how to call the Cloud Control API on OpenAPI Explorer.
Prerequisites
Log on to the OpenAPI Explorer. We recommend that you use a RAM user with the following permissions:
1. Permission to manage Cloud Control API. For more information, see Manage RAM users.
2. Permission to manage VPCs. For more information, see Use RAM to manage VPC permissions.
Procedure
You can call the Cloud Control API to create, access, update, list, and delete VPCs. If you need to integrate the Cloud Control API, refer to the sample codes in the OpenAPI Explorer.
1. Create a VPC
Log on to the OpenAPI Explorer as a RAM user. Click Resource creation under VPC, set regionId and body parameters, and then click Initiate Call. You can select a language for the sample code on the right. The system automatically generates code for your reference.
View the results after a call is initiated.
If an error is reported in the call, find the cause by referring to the log, API documentation, or common error codes in Diagnose. You can also contact us.
If the call is successful, record resourceId in the returned results. Status code 200 indicates that the resource creation task is synchronous, while status code 202 indicates that the task is asynchronous. Query the task by using the returned taskId.
NoteSynchronous and asynchronous operations are two modes of task execution. The difference is that a synchronous operation returns after the task is completed, while an asynchronous operation returns without waiting for the task to finish.
In this example, the returned status code is 202, which indicates an asynchronous operation. You must query the task status based on the taskId. Record taskId and click Query task to go to the Get Task page.
Enter taskId and click Initiate Call. View the call result. If the call is successful, the task status becomes Succeeded and the VPC is created.
View the created VPC in the Alibaba Cloud Console.
2. Access VPC resources
On the Get Resource page, enter Resource ID, select regionId, and click Initiate Call. The call is successful and the resource information is returned.
3. Update VPC resources
On the Update Resource page, enter the Resource ID, select regionId, enter the parameter to be updated, and click Initiate Call. You can view the updated resources in the Alibaba Cloud Console or by calling the CloudMonitor API.
4. Query VPCs
On the Get Resource page, select the regionId and click Initiate Call. View resources in the call results.
5. Delete a VPC
On the Delete Resource page, enter a Resource ID, select a regionId, and then click Initiate Call.
If the call is successful and status code 202 is returned, it indicates that the call is asynchronous.
Enter the taskId and click Initiate Call. If the task status is Succeeded, it indicates that the VPC resource has been deleted.
Sample code
Sample code repository: https://github.com/aliyun/cloud-control-api-demo
This repository provides sample codes of the Cloud Control API for you to query resource metadata and manage cloud resources.