Syntax Overview

ResourceQL provides SQL-like functions, allowing you to flexibly query your cloud resources.

SELECT name, created, updated FROM resources WHERE region_id = 'cn-north-4'

The statement is case insensitive. That is, SELECT COUNT(*)... and select CoUnT(*)... are the same. Use single quotation marks to represent the literal of a string.

ResourceQL supports the following data types: For the array type, [] is used to index a position, and the number starts from 1.

Table 1 Supported data types

Type Name

Type

Integer

int/integer

Float

float/double

Boolean

boolean

Array

array

String

string

Dictionary

object

Timestamp

date

All your cloud resources form a table. The table name is fixed to resources. Each row in the table records a piece of data. The conventions of each column are as follows:

Table 2 Parameter descriptions in table resources

Parameter

Type

Description

id

String

Specifies the resource ID.

name

String

Specifies the resource name.

provider

String

Specifies the cloud service name.

type

String

Specifies the resource type.

region_id

String

Specifies the region ID.

project_id

String

Specifies the project ID.

ep_id

String

Specifies the enterprise project ID.

checksum

String

Specifies the resource checksum.

created

Date

Specifies the time when the resource was created.

updated

Date

Specifies the time when the resource was updated.

provisioning_state

String

Specifies the status of the operation that causes the resource change.

tag

Array(Map<String,String>)

Specifies the resource tag.

properties

Map<String,Object>

Specifies the detailed properties of the resource.

Different types of resources can be distinguished by provider and type, and structures of their properties field are different. For example, cloudservers of an ECS has properties that contain 23 fields, and a VPC has properties that contain only three fields.

For a specific resource type, you can use commas (.), a nesting method, to query the specific fields in properties. For example, if properties of an ECS contain the status and addresses fields, you can run the following statement to query the running ECS and its address:

SELECT name, created, updated, properties.addresses FROM resources 
	WHERE provider = 'ecs' AND type = 'cloudservers' AND properties.status = 'ACTIVE'