Querying the Code of a Function

Function

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

URI

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

Table 1 Path parameters

Parameter

Mandatory

Type

Description

function_urn

Yes

String

Function URN.

project_id

Yes

String

Tenant's project ID.

Request Parameters

None

Response Parameters

Status code: 200

Table 2 Response body parameters

Parameter

Type

Description

func_code

FuncCode object

Function code.

func_urn

String

Function URN.

func_name

String

Function name.

domain_id

String

Tenant's domain ID.

runtime

String

Function runtime.

Enumeration values:

  • Python2.7

  • Python3.6

  • Go1.8

  • Go1.x

  • Java8

  • Node.js6.10

  • Node.js8.10

  • Node.js10.16

  • Node.js12.13

  • C#(.NET Core 2.0)

  • C#(.NET Core 2.1)

  • C#(.NET Core 3.1)

  • Custom

  • PHP7.3

concurrency

Long

0: The function is disabled. -1: The function is enabled.

Enumeration values:

  • 0

  • -1

code_type

String

Code entry mode. inline: Online editing. This mode is supported for Node.js*, PHP7.3, Python2.7, Python3.6, and custom runtimes. zip: Upload of a local ZIP package. This mode is supported for all runtimes. jar: Upload of a local JAR package. This mode is supported for the Java 8 runtime. obs: Upload of a file through the OBS console. This mode is supported for all runtimes.

Enumeration values:

  • inline

  • zip

  • obs

  • jar

code_url

String

When code_type is set to obs, this parameter indicates the address of a function code package in OBS. When code_type is set to inline, zip, or jar, this parameter is left blank.

code_filename

String

Function file name. When code_type is set to zip or jar, this parameter is required. When code_type is set to obs or inline, this parameter is not required.

code_size

Long

Code size. Unit: KB.

digest

String

Unique function hash value.

last_modified

String

Latest update time.

depend_list

Array of strings

Dependency list.

dependencies

Array of Dependency objects

Detailed information about the dependency list.

strategy_config

StrategyConfig object

Function policy configuration.

func_vpc

FuncVpc object

VPC configuration.

Table 3 FuncCode

Parameter

Type

Description

file

String

Function code. When code_type is set to inline, zip, or jar, this parameter is required. Moreover, the code must be encoded using Base64. When code_type is set to obs, this parameter is not required.

link

String

Function code. When code_type is set to obs, this parameter indicates the address of a function code package in OBS.

Table 4 Dependency

Parameter

Type

Description

id

String

Dependency ID.

owner

String

Dependency owner.

link

String

URL of the dependency in the OBS console.

runtime

String

Runtime.

etag

String

Unique ID of the dependency.

size

String

Size of the dependency.

name

String

Name of the dependency.

description

String

Description of the dependency.

file_name

String

File name of the dependency.

Table 5 StrategyConfig

Parameter

Type

Description

concurrency

Long

0: The function is disabled. -1: The function is enabled.

Enumeration values:

  • 0

  • -1

Table 6 FuncVpc

Parameter

Type

Description

vpc_name

String

VPC name.

vpc_id

String

VPC ID.

subnet_name

String

Subnet name.

subnet_id

String

Subnet ID.

cidr

String

Subnet mask.

gateway

String

Gateway.

Example Requests

GET https://{functiongraph_endpoint}/v2/7aad83af3e8d42e99ac194e8419e2c9b/fgs/functions/urn:fss:xxxxxxx:7aad83af3e8d42e99ac194e8419e2c9b:function:default:test:latest/code

Example Responses

Status code: 200

OK

{
  "func_urn" : "urn:fss:xxxxxxx:7aad83af3e8d42e99ac194e8419e2c9b:function:default:test:latest",
  "func_name" : "xxxxx",
  "domain_id" : "14ee2e35****a7998b******aa24cabf",
  "runtime" : "Python2.7",
  "code_type" : "inline",
  "code_filename" : "index.zip",
  "code_size" : 245,
  "digest" : "39d51ae334ffb239037e194159f4cc9cec31086719aa73db7d0a608343121a290f7115693e008bd01cb12b99a803856e83aa96173b26c528c41cfed18267e08f",
  "last_modified" : "2019-09-25T19:02:17+08:00",
  "func_code" : {
    "file" : "UEsDBAoAAAAIAAhYOU8ssPQsgwAAALYAAAAIAAAAaW5kZXgucHlVzbEOwjAMBNA9X2GVoQ1QZhSJvb8RNW4xSp3IcVDF1wOlCzee7ukO0B97GFMgnl3Vqb9+C0NLTqLwKImNCTgBMSn5SC+UbkysuKp1Bj7JQqxds+5p7La/ew4RBTp8IusZ/k2qmqvCDdoBY0ywYCl+RgctnLbTS6hLLj9sNyKoVXiXb1BLAQIeAwoAAAAIAAhYOU8ssPQsgwAAALYAAAAIAAAAAAAAAAAAAADzAgAAAABpbmRleC5weVBLBQYAAAAAAQABADYAAACpAAAAAAA=",
    "link" : "https://functionstorage.obs.cn-north-7.myhuaweicloud.com/functions/46b6f338fc3445b8846c71dfb1fbd9e8/default/xxxxx/latest/index.zip"
  },
  "strategy_config" : {
    "concurrency" : -1
  }
}

Status code: 404

Not Found

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

Status Codes

Status Code

Description

200

OK

404

Not Found

Error Codes

See Error Codes.