Help Center/ FunctionGraph/ API Reference/ APIs/ Versions and Aliases/ Querying the Versions of a Function
Updated on 2026-10-27 GMT+08:00

Querying the Versions of a Function

Function

This API is used to query the versions of a function.

Calling Method

For details, see Calling APIs.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions. For details about the required permissions, see Permissions Policies and Supported Actions.

URI

GET /v2/{project_id}/fgs/functions/{function_urn}/versions

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Parameter description:

Project ID. For details, see Obtaining a Project ID.

Constraints:

None

Value range:

32 characters, including letters and digits.

Default value:

None

function_urn

Yes

String

Parameter description:

URN of the function. For details, see Function Model.

Constraints:

None

Value range:

Only letters, digits, underscores (_), hyphens (-), and colons (:) are allowed.

Default value:

None

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

marker

No

String

Parameter description:

Final record queried last time.

Constraints:

None

Value range:

The value must be an integer greater than or equal to 0.

Default value:

0

maxitems

No

String

Parameter description:

Final record queried last time.

Constraints:

None

Value range:

The value must be an integer greater than or equal to 0.

Default value:

0

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Parameter description:

User token.

The token can be obtained by calling the IAM API. The value of X-Subject-Token in the response header is the user token.

Constraints:

None

Value range:

None

Default value:

None

Content-Type

No

String

Parameter description:

Specifies the type (or format) of the message body.

Constraints:

None

Value range:

Only application/json is supported.

Default value:

application/json

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

versions

Array of ListFunctionVersionResult objects

Definition

Version list.

Value range:

None

next_marker

Long

Definition

Next record location.

Value range:

None

count

Long

Definition

Total number of versions.

Value range:

None

Table 5 ListFunctionVersionResult

Parameter

Type

Description

func_urn

String

Parameter description:

Function URN.

Value range:

None

func_name

String

Parameter description:

Function name.

Value range:

None

domain_id

String

Parameter description:

Tenant account ID.

Value range:

None

namespace

String

Parameter description:

Project ID.

Value range:

None

project_name

String

Parameter description:

Project name.

Value range:

None

package

String

Definition

Group to which the function belongs. This field is defined to group functions.

Value range

None

runtime

String

Parameter description:

Runtime of a function, that is, the environment where the function runs

Value range:

  • Java8: Java 8

  • Java11: Java 11

  • Java17: Java 17

  • Java21: Java 21

  • Python2.7: Python 2.7

  • Python3.6: Python 3.6

  • Python3.9: Python 3.9

  • Python3.10: Python 3.10

  • Python3.12: Python 3.12

  • Go1.x: Go 1.x

  • Node.js6.10: Nodejs 6.10

  • Node.js8.10: Nodejs 8.10

  • Node.js10.16: Nodejs 10.16

  • Node.js12.13: Nodejs 12.13

  • Node.js14.18: Nodejs 14.18

  • Node.js16.17: Nodejs 16.17

  • Node.js18.15: Nodejs 18.15

  • Node.js20.15: Nodejs 20.15

  • C#(.NET Core 2.1): C# 2.1

  • C#(.NET Core 3.1): C# 3.1

  • C#(.NET Core 6.0): C# 6.0

  • C#(.NET Core 8.0): C# 8.0

Custom

  • PHP7.3: Php 7.3

  • PHP8.3: Php 8.3

  • Cangjie1.0

  • Cangjie0.52.3

  • HTTP

Custom image-based functions

timeout

Integer

Parameter description:

Maximum duration the function can be executed.

Value range:

3–259,200 seconds

handler

String

Parameter description:

Handler

It is in the format of "xx.xx" and must contain a period (.). The handler of a custom image function is -.

For example, for Node.js function myfunction.handler, the file name is myfunction.js, and the handler function is handler. Can contain a maximum of 128 characters.

Value range:

3 to 128 characters

memory_size

Integer

Parameter description:

Memory (MB) consumed by the function.

Value range:

  • 128

  • 256

  • 512

  • 768

  • 1024

  • 1280

  • 1536

  • 1792

  • 2048

  • 2560

  • 3072

  • 3584

  • 4096

cpu

Integer

Parameter description:

GPU memory. This parameter is available only for functions created with a custom runtime or image.

Unit: MB.

Value range:

  • 1024

  • 2048

  • 3072

  • 4096

  • 5120

  • 6144

  • 7168

  • 8192

  • 9216

  • 10240

  • 11264

  • 12288

  • 13312,

  • 14336

  • 15360

  • 16384

Range: 1024 to 16,384.

code_type

String

Parameter description:

Function code type

Value range:

The options are as follows:

inline: inline code

zip: ZIP file

obs: function code stored in an OBS bucket

jar: JAR file, mainly for Java functions

Custom-Image-Swr: The function code comes from the SWR custom image.

code_url

String

Parameter description:

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.

Value range:

OBS path

code_filename

String

Parameter description:

Name of a function file. This parameter is mandatory only when CodeType is set to jar or zip.

Value range:

None

code_size

Long

Parameter description:

Code size in bytes.

Value range:

None

user_data

String

Parameter description:

Name/Value information defined for the function. These are parameters used in the function. For example, if a function needs to access a host, you can set a custom parameter as follows: Host={host_ip}. The total length cannot exceed 4 KB.

Value range:

json indicates a character string in JSON format.

encrypted_user_data

String

Parameter description:

Name/value information to be encrypted.

Value range:

Message structure, which is a JSON string.

digest

String

Parameter description:

SHA512 hash value of function code, which is used to determine whether the function is changed.

Value range:

None

version

String

Parameter description:

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).

Value range:

None

image_name

String

Parameter description:

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).

Value range:

None

xrole

String

Parameter description:

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).

Value range:

None

app_xrole

String

Parameter description:

Execution agency. You can optimize performance by configuring a separate agency for function execution, otherwise, the same agency is used for both execution and configuration.

Value range:

None

last_modified

String

Parameter description:

Execution agency. You can optimize performance by configuring a separate agency for function execution, otherwise, the same agency is used for both execution and configuration.

Value range:

None

func_vpc_id

String

Parameter description:

VPC ID.

Value range:

None

concurrency

Integer

Parameter description:

Max. Instances per Function

Range

The value of v1 ranges from 0 to -1, and the value of v2 ranges from -1 to 1000.

-1: The function has unlimited instances.

0: The function is disabled.

concurrent_num

Integer

Parameter description:

Number of concurrent requests for a single instance

Range

Supported only in v2. The value ranges from 1 to 1000.

strategy_config

StrategyConfig object

Parameter description:

Function policy configuration.

status

Integer

Parameter description:

Function status.

Value range:

  • 0: The function is enabled.

  • 1: The function is disabled.

initializer_handler

String

Parameter description:

Initializer of the function in the format of "xx.xx". It must contain a period (.). ". This parameter is mandatory when the initialization function is configured.

For example, for the Node.js function myfunction.initializer, the file name is myfunction.js, and the initialization input is

The interface function name is initializer.

Value range:

None

initializer_timeout

Integer

Parameter description:

Initialization timeout interval. The timeout function will be forcibly stopped. This parameter is mandatory when the initialization function is configured.

Value range:

[1, 300]

pre_stop_handler

String

Parameter description:

The pre-stop handler of a function. The value must contain a period (.) in the format of xx.xx. ".

For example, for Node.js function myfunction.pre_stop_handler, the file name is myfunction.js, and the initialization function is pre_stop_handler.

Value range:

None

pre_stop_timeout

Integer

Parameter description:

Timeout interval of initialization. If the timeout interval is reached, the function will be forcibly stopped.

Value range:

1 to 90 seconds

long_time

Boolean

Parameter description:

Whether to allow a long timeout.

Value range:

true: Long timeout settings are allowed.

false: Long timeout settings are not allowed.

function_async_config

FunctionAsyncConfig object

Parameter description:

Response for configuring asynchronous execution notification.

type

String

Parameter description:

Function Version

Value range:

v2: indicates the official version.

v1: indicates the discarded version.

enable_dynamic_memory

Boolean

Parameter description:

Whether to enable dynamic memory allocation.

Value range:

true: The dynamic memory function is enabled.

false: The dynamic memory function is disabled.

enterprise_project_id

String

Parameter description:

Enterprise project ID. This parameter is mandatory if you create a function as an enterprise user.

Value range:

None

is_stateful_function

Boolean

Parameter description:

Whether stateful functions are supported. This parameter is supported in FunctionGraph v2.

Value range:

true: Stateful functions are supported.

false: Stateful functions are not supported.

enable_auth_in_header

Boolean

Parameter description:

Whether to allow authentication information in the request header.

Value range:

true: Authentication information can be added to the request header.

false: Authentication information cannot be added to the request header.

custom_image

CustomImage object

Parameter description:

Container image.

reserved_instance_idle_mode

Boolean

Parameter description:

Whether to enable idle mode for reserved instances.

Value range:

Enabling Idle Mode for Reserved Instances

false: The reserved instance idle mode is disabled.

enable_cloud_debug

String

Definition

Whether to enable cloud debugging to adapt to the CloudDebug scenario.

Range

N/A

is_bridge_function

Boolean

Definition

Whether this is a bridge function.

Range

  • true: yes

  • false: no

enable_custom_rpc

Boolean

Definition

Whether to enable custom RPC.

Range

  • true: yes

  • false: no

is_return_stream

Boolean

Definition

Whether to return streaming data.

Range

N/A

stream_response

Boolean

Definition

Streaming response switch.

Range

N/A

is_websocket_function

Boolean

Definition

Whether this is a WebSocket function.

Range

  • true: yes

  • false: no

enable_snapshot

Boolean

Definition

Whether to enable the snapshot function.

Range

  • true: yes

  • false: no

ephemeral_storage

Integer

Definition

Ephemeral storage.

Range

  • 512: 512 MB.

  • 10240: 10 GB.

is_shared

Boolean

Definition

Whether it is a shared function.

Range

N/A

enable_class_isolation

Boolean

Definition

Class isolation switch.

Range

  • true: class isolation enabled

  • false: class isolation disabled

resource_id

String

Definition

Unique ID of a function resource.

Range

N/A

edge_support

Object

Definition

Edge support configuration.

Range

N/A

edge_logs_collect

Boolean

Definition

Whether to collect edge logs.

Range

  • true: yes

  • false: no

disable_insecure_ak_sk

Boolean

Definition

Whether to disable insecure methods for obtaining the AK/SK.

Range

  • true: yes

  • false: no

enable_lts_log

Boolean

Definition

Whether to enable LTS.

Range

  • true: yes

  • false: no

is_safety

Boolean

Definition

Whether the function can access the VPC in a secure manner.

Range

  • true: yes

  • false: no

func_code

Object

Definition

Function code object.

Range

N/A

FuncCode

Object

Definition

Function code object (deprecated).

Range

N/A

Table 6 StrategyConfig

Parameter

Type

Description

concurrency

Integer

Parameter description:

Specifies the maximum number of instances for a function. The value -1 indicates that the number of instances is not limited.

Value range:

v1: 0 and -1

v2: [–1, 1000]

concurrent_num

Integer

Parameter description:

Specifies the number of concurrent requests per instance. This parameter is supported in v2.

Value range:

[1, 1000]

Table 7 FunctionAsyncConfig

Parameter

Type

Description

max_async_event_age_in_seconds

Integer

Parameter description:

Maximum duration for which a message can survive.

Range

60 to 86400 Unit: second.

max_async_retry_attempts

Integer

Parameter description:

Maximum number of retry attempts to be made if asynchronous invocation fails. Default value: 3.

Range

Value range: 0–8.

destination_config

FuncAsyncDestinationConfig object

Parameter description:

Asynchronous invocation target.

Range:

None

created_time

String

Parameter description:

Time when asynchronous execution notification was configured.

Range:

None

last_modified

String

Parameter description:

Time when the asynchronous execution notification settings were last modified.

Range:

None

Table 8 FuncAsyncDestinationConfig

Parameter

Type

Description

on_success

FuncDestinationConfig object

Parameter description:

Target to be invoked when a function is successfully executed.

Range:

None

on_failure

FuncDestinationConfig object

Parameter description:

Target to be invoked when a function fails to be executed due to a system error or an internal error.

Range:

None

Table 9 FuncDestinationConfig

Parameter

Type

Description

destination

String

Parameter description:

Object type.

Range

  • OBS

  • SMN

  • DIS

  • FunctionGraph

param

String

Parameter description:

Parameters (in JSON format) corresponding to the target service.

Range

  • OBS: Parameters related to the bucket name, object directory prefix, and object expiration time are included. The object expiration time ranges from 0 to 365 days. If the value is 0, the object will not expire.

  • SMN: The topic_urn parameter is included.

  • DIS: The stream_name parameter is included.

FunctionGraph: The func_urn parameter is included.

Table 10 CustomImage

Parameter

Type

Description

enabled

Boolean

Parameter description:

Whether to use an image. If no image is used, the following parameters do not take effect.

Value range:

true: An image is used.

false: No image is used.

image

String

Parameter description:

Image address.

Value range:

None

command

String

Parameter description:

Command for starting a container image.

Value range:

None

args

String

Parameter description:

Command line parameter for starting a container image.

Value range:

None

working_dir

String

Parameter description:

Working directory of an image container.

Value range:

None

uid

String

Parameter description:

User ID of an image container.

Value range:

None

gid

String

Parameter description:

User group ID of an image container.

Value range:

None

is_public

Boolean

Parameter description:

Whether the image is a public image.

Value range:

None

Status code: 400

Table 11 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 401

Table 12 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 403

Table 13 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 404

Table 14 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 500

Table 15 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Example Requests

Query functions.

GET https://{Endpoint}/v2/{project_id}/fgs/functions/{function_urn}/versions

Example Responses

Status code: 200

{
  "versions" : [ {
    "func_urn" : "urn:fss:xxxxxxxxxxx:7aad83af3e8d42e99ac194e8419e2c9b:function:default:test",
    "func_name" : "test",
    "domain_id" : "14ee2e3501124efcbca7998baa24xxxx",
    "namespace" : "46b6f338fc3445b8846c71dfb1fbxxxx",
    "project_name" : "xxxxx",
    "package" : "default",
    "runtime" : "Node.js6.10",
    "timeout" : 3,
    "handler" : "test.handler",
    "memory_size" : 128,
    "cpu" : 1024,
    "code_type" : "inline",
    "code_filename" : "index.js",
    "code_size" : 272,
    "digest" : "faa825575c45437cddd4e369bea69893bcbe195d478178462ad90984fe72993f3f59d15f41c5373f807f3e05fb9af322c55dabeb16565c386e402413458e6068",
    "version" : "latest",
    "image_name" : "latest-191025153727@zehht",
    "last_modified" : "2019-10-25 15:37:27",
    "strategy_config" : {
      "concurrency" : 0
    }
  } ],
  "next_marker" : 5
}

Status code: 404

{
  "error_code" : "FSS.1051",
  "error_msg" : "Not found the function"
}

SDK Sample Code

The SDK sample code is as follows.

Java

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.functiongraph.v2.region.FunctionGraphRegion;
import com.huaweicloud.sdk.functiongraph.v2.*;
import com.huaweicloud.sdk.functiongraph.v2.model.*;


public class ListFunctionVersionsSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");
        String projectId = "{project_id}";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);

        FunctionGraphClient client = FunctionGraphClient.newBuilder()
                .withCredential(auth)
                .withRegion(FunctionGraphRegion.valueOf("<YOUR REGION>"))
                .build();
        ListFunctionVersionsRequest request = new ListFunctionVersionsRequest();
        request.withFunctionUrn("{function_urn}");
        try {
            ListFunctionVersionsResponse response = client.listFunctionVersions(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}

Python

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkfunctiongraph.v2.region.functiongraph_region import FunctionGraphRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkfunctiongraph.v2 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId)

    client = FunctionGraphClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(FunctionGraphRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ListFunctionVersionsRequest()
        request.function_urn = "{function_urn}"
        response = client.list_function_versions(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Go

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    functiongraph "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/functiongraph/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/functiongraph/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/functiongraph/v2/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")
    projectId := "{project_id}"

    auth, err := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        SafeBuild()

    if err != nil {
        fmt.Println(err)
        return
    }

    hcClient, err := functiongraph.FunctionGraphClientBuilder().
         WithRegion(region.ValueOf("<YOUR REGION>")).
         WithCredential(auth).
         SafeBuild()


    if err != nil {
        fmt.Println(err)
        return
    }

    client := functiongraph.NewFunctionGraphClient(hcClient)

    request := &model.ListFunctionVersionsRequest{}
	request.FunctionUrn = "{function_urn}"
	response, err := client.ListFunctionVersions(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

More

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

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.