Querying Resources
Function
This API is used to query resources.
URI
POST /v2/{project_id}/{resource_type}/resource-instances/{action}
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Project ID. For details, see Obtaining a Project ID. |
resource_type |
Yes |
String |
Resource type. |
action |
Yes |
String |
Filter or count. Enumeration values:
|
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
User token. It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
without_any_tag |
No |
Boolean |
Whether to use tag-based filtering. |
limit |
No |
String |
Number of records displayed on each page. |
offset |
No |
String |
Query offset. |
action |
No |
String |
Query an action. Enumeration values:
|
matches |
No |
Array of KvItem objects |
Query a key-value pair. |
sys_tags |
No |
Array of TagItem objects |
Query system tags. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
resources |
Array of ListEnterpriseResourceResult objects |
Enterprise projects. |
total_count |
Long |
Number of resources. |
Parameter |
Type |
Description |
---|---|---|
resource_id |
String |
Resource ID. |
resource_detail |
ListFunctionResult object |
Function attribute struct. |
tags |
Array of KvItem objects |
Tag list. |
sys_tags |
Array of KvItem objects |
System tags. |
resource_name |
String |
Resource name. |
Parameter |
Type |
Description |
---|---|---|
func_urn |
String |
Function URN. |
func_name |
String |
Function name. |
domain_id |
String |
Domain ID. |
namespace |
String |
Project ID. |
project_name |
String |
Project name. |
package |
String |
Group to which the function belongs. This field is defined to group functions. |
runtime |
String |
Environment in which a FunctionGraph function is executed. Options:
Enumeration values:
|
timeout |
Integer |
Maximum duration the function can be executed. Value range: 3s–900s. The value can be up to 12 hours for whitelisted users. For details, contact FunctionGraph personnel. |
handler |
String |
Handler of a function in the format of "xx.xx". It must contain a period (.). For example, for Node.js function myfunction.handler, the file name is myfunction.js, and the handler function is handler. |
memory_size |
Integer |
Memory consumed by a function. Unit: MB. The value can be 128, 256, 512, 768, 1024, 1280, 1536, 1792, 2048, 2560, 3072, 3584 or 4096. The value ranges from 128 to 4096. |
gpu_memory |
Integer |
GPU memory. This parameter is available only for functions created with a custom runtime or image. Unit: MB. Options: 1024, 2048, 3072, 4096, 5120, 6144, 7168, 8192, 9216, 10,240, 11,264, 12,288, 13,312, 14,336, 15,360, and 16,384. Range: 1024 to 16,384. |
cpu |
Integer |
CPU resources of a function. Unit: millicore (1 core = 1000 millicores). The value of this field is proportional to that of MemorySize. By default, 100 CPU millicores are required for 128 MB memory. The value is calculated as follows: Memory/128 x 100 + 200 (basic CPU millicores) |
code_type |
String |
Function code type. Options:
Enumeration values:
|
code_url |
String |
If CodeType is set to obs, enter the OBS URL of the function code package. If CodeType is not set to obs, leave this parameter blank. |
code_filename |
String |
Name of a function file. This parameter is mandatory only when CodeType is set to jar or zip. |
code_size |
Long |
Code size in bytes. |
user_data |
String |
Name/Value information defined for the function. These are parameters used in the function. For example, if a function needs to access a host, define Host={host_ip}. You can define a maximum of 20 such parameters, and their total length cannot exceed 4 KB. |
encrypted_user_data |
String |
User-defined name/value to be encrypted. |
digest |
String |
SHA512 hash value of function code, which is used to determine whether the function has changed. |
version |
String |
Function version, which is automatically generated by the system. The version name is in the format of "vYYYYMMDD-HHMMSS" (v+year/month/day-hour/minute/second). |
image_name |
String |
Internal identifier of a function version. |
xrole |
String |
Agency used by the function. You need to create an agency on the IAM console. This field is mandatory when a function needs to access other services. |
app_xrole |
String |
Agency used by the function app. You need to create an agency on the IAM console. This field is mandatory when a function needs to access other services. |
description |
String |
Function description. |
last_modified |
String |
Time when the function was last updated. |
func_vpc_id |
String |
VPC ID. |
strategy_config |
StrategyConfig object |
Function policy configuration. |
extend_config |
String |
Extended configuration. |
initializer_handler |
String |
Initializer of the function. It is in the format of "xx.xx" and must contain a period (.). For example, for Node.js function myfunction.initializer, the file name is myfunction.js, and the initialization function is initializer. |
initializer_timeout |
Integer |
Maximum duration the function can be initialized. Value range: 1s–300s. |
enterprise_project_id |
String |
Enterprise project ID. This parameter is mandatory if you create a function as an enterprise user. |
long_time |
Boolean |
Whether to allow a long timeout. |
log_group_id |
String |
Log group ID. |
log_stream_id |
String |
Log stream ID. |
type |
String |
v2 indicates the OBT version and v1 indicates the original version. Enumeration values:
|
fail_count |
Integer |
Number of times that a function failed to be executed in the last day. |
is_bridge_function |
Boolean |
Whether this is a bridge function. |
bind_bridge_funcUrns |
Array of strings |
URNs bound to the bridge function. |
Parameter |
Type |
Description |
---|---|---|
concurrency |
Integer |
Maximum number of instances for a single function. For v1, the value can be 0 or –1; for v2, it ranges from –1 to 1000.
|
concurrent_num |
Integer |
Maximum number of concurrent requests per instance. This parameter is supported only by v2. The value ranges from –1 to 1000. |
Status code: 400
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. |
error_msg |
String |
Error message. |
Status code: 401
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. |
error_msg |
String |
Error message. |
Status code: 403
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. |
error_msg |
String |
Error message. |
Status code: 404
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. |
error_msg |
String |
Error message. |
Status code: 500
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. |
error_msg |
String |
Error message. |
Example Requests
Query resources.
POST https://{Endpoint}/v2/{project_id}/{resource_type}/resource-instances/{action} { "without_any_tag" : true, "limit" : 5, "matches" : [ { "key" : "resource_name", "value" : "test_function" } ] }
Example Responses
Status code: 200
ok
-
Example 1
{ "resources" : [ { "resource_id" : "34e4516e-e324-412b-914e-c4e568c7d813", "resource_detail" : { "func_urn" : "", "func_name" : "test_v2_1", "domain_id" : "f0a16ead2b344414a5ff053409c4xxxx", "namespace" : "e3e37049e339493d996313d658f7xxxx", "project_name" : "{region}", "package" : "default", "runtime" : "Node.js6.10", "timeout" : 3, "handler" : "index.handler", "memory_size" : 128, "cpu" : 300, "code_type" : "inline", "code_filename" : "index.zip", "code_size" : "247", "digest" : "608239783ff8efe2cd8b623530c5afdcfed38fca66beb99c26d7ff4dcb872e091d4976bc8b0e5986d8f185d55fdf92ff7c55980f8c91d01cd36402763c0d1d13", "version" : "latest", "image_name" : "latest-191211192124@po1lk", "strategy_config" : { } }, "tags" : [ ], "sys_tags" : [ { "key" : "_sys_enterprise_project_id", "value" : "df5edab8-c458-4a4c-b87b-a4d3b0a757ce" } ], "resource_name" : "test_v2_1" } ] }
-
Example 2
1
Status Codes
Status Code |
Description |
---|---|
200 |
ok |
400 |
Bad request. |
401 |
Unauthorized. |
403 |
Forbidden. |
404 |
Not found. |
500 |
Internal server error. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot