All Products
Search
Document Center

ENS:Java SDK call example

Last Updated:Sep 09, 2026

This topic describes how to call the DescribeEnsRegions operation using the OpenAPI to query available Edge Node Service (ENS) edge zones.

Step 1: Review API documentation

Read the API documentation before you call an operation. To learn about the request parameters and permissions that are required to call the DescribeEnsRegions operation, see DescribeEnsRegions. For more information, see API overview.

  1. On the Stacks page, click Create Stack. In the Specify Template section, click Select an Existing Template.

    Note
    • If you select Create Template or ROS Infrastructure Composer, you are redirected to the corresponding page.

  2. For Template Import Method, select Enter Template Content. For Template Content, select ROS and enter the code.

Step 2: Create a RAM user and grant permissions

Important

Your Alibaba Cloud account has full permissions for all API operations. For security, we recommend using a RAM user for API calls and routine O&M.

You can call this operation by using an Alibaba Cloud account (root account), a RAM user, or a RAM role. For more information about the differences between these identities, see identity.

This topic uses a RAM user to call the API operation.

  1. Create a RAM user.

    1. Log on to the Resource Access Management (RAM) console.

    2. In the left-side navigation pane, choose .

    3. On the Users page, click Create User.

    4. On the Create User page, set the logon name and display name. For access mode, select console access.

    5. Click OK.

      After you create the RAM user, record the logon name and password. You will use these credentials for console access.

  2. Grant permissions to the RAM user.

    Note

    AliyunENSFullAccess: Grants the permissions to manage Edge Node Service (ENS) resources.

    AliyunENSReadOnlyAccess: Grants the read-only permissions on ENS resources.

    To create a custom policy, see Authorization information.

    1. Go to the Users list.

    2. Find the target RAM user and click Add Permissions in the Actions column.

    3. In the search box, enter ENS and select the AliyunENSFullAccess policy.

    4. Click OK.

  3. Go to the details page of the RAM user. On the Authentication tab, click Create AccessKey.

    For more information, see Create an AccessKey pair.

Step 3: Call the API

This topic provides an example of how to call an OpenAPI by using the Java SDK. The usage is similar for SDKs in other languages. For more information, see Edge Node Service SDK. You can also select other calling methods based on your business requirements. For more information, see Calling method.

Configure environment variables

Environment variables are system-level parameters that contain names and values to specify the runtime environment for applications. For information about how to configure an AccessKey pair as environment variables on different operating systems, see Configure environment variables on Linux, macOS, and Windows.

Download the sample code

  1. Go to DescribeEnsRegions.

  2. On the Parameters tab on the left, specify the required parameters.

  3. On the SDK sample tab on the right, set SDK Version to v2.0 and Language to Java. Click Download sample project to download the sample project.

  4. Decompress the package and go to the alibabacloud_sample directory.

Open the project

Use IntelliJ IDEA to open the project. After the dependencies finish loading, open the src/main/java/com/aliyun/sample/Sample.java file. Add code to print the response based on the comments in the file.

Run the project

Click Run in the upper-right corner of the IDE to view the output log. A sample response is shown below:

{
  "headers": {
    "access-control-allow-origin": "*",
    "date": "Tue, 18 Jul 2023 15:26:50 GMT",
    "content-length": "92",
    "keep-alive": "timeout=25",
    "x-acs-request-id": "1589E192-A47E-5224-95E2-A18F2D1ED186",
    "connection": "keep-alive",
    "content-type": "application/json;charset=utf-8",
    "etag": "9fcxMGIK+zckvQOS1NfD6GA2",
    "access-control-expose-headers": "*",
    "x-acs-trace-id": "bdfecedff57c1e8fc1b7970e909bca31"
  },
  "statusCode": 200,
  "body": {
    "code": 0,
    "ensRegions": {
      "ensRegions": [
        {
          "Area": "SouthWestChina",
          "EnName": "",
          "EnsRegionId": "cn-chongqing-unicom",
          "Province": "Chongqing",
          "Name": "China Unicom (Chongqing)"
        }
      ]
    },
    "requestId": "1589E192-A47E-5224-95E2-A18F2D1ED186"
  }
}