Updated on 2023-07-06 GMT+08:00

Modifying the Metadata of a Function

Function

This API is used to modify the metadata of a function.

URI

PUT /v2/{project_id}/fgs/functions/{function_urn}/config

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

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

function_urn

Yes

String

Function URN. For details, see the function model description.

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

func_name

Yes

String

Function name.

runtime

Yes

String

Environment in which a FunctionGraph function is executed. Options:

  • Python 2.7

  • Python 3.6

  • Python 3.9

  • Go 1.8

  • Go 1.x

  • Java 8

  • Java 11

  • Node.js 6.10

  • Node.js 8.10

  • Node.js 10.16

  • Node.js 12.13

  • Node.js 14.18

  • C# (.NET Core 2.0)

  • C# (.NET Core 2.1)

  • C# (.NET Core 3.1)

  • Custom

  • PHP 7.3

  • HTTP

Enumeration values:

  • Java8

  • Java11

  • Node.js6.10

  • Node.js8.10

  • Node.js10.16

  • Node.js12.13

  • Node.js14.18

  • Python2.7

  • Python3.6

  • Go1.8

  • Go1.x

  • C#(.NET Core 2.0)

  • C#(.NET Core 2.1)

  • C#(.NET Core 3.1)

  • Custom

  • PHP7.3

  • Python3.9

  • http

timeout

Yes

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

Yes

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

Yes

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

No

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.

user_data

No

String

Name/Value information defined for the function.

These are parameters used in a 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

No

String

User-defined name/value to be encrypted.

xrole

No

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

No

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

No

String

Function description.

func_vpc

No

FuncVpc object

VPC configuration.

mount_config

No

MountConfig object

Mounting configuration.

strategy_config

No

StrategyConfig object

Function policy configuration.

custom_image

No

CustomImage object

Container image.

extend_config

No

String

Extended configuration.

initializer_handler

No

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

No

Integer

Maximum duration the function can be initialized. Value range: 1s–300s.

ephemeral_storage

No

Integer

Ephemeral storage size. Max.: 10 GB. Default: 512 MB.

Enumeration values:

  • 512

  • 10240

enterprise_project_id

No

String

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

log_config

No

FuncLogConfig object

Function log configuration.

network_controller

No

NetworkControlConfig object

Network configuration.

is_stateful_function

No

Boolean

Whether stateful functions are supported. If they are supported, set this parameter to true. This parameter is supported in FunctionGraph v2.

enable_dynamic_memory

No

Boolean

Whether to enable dynamic memory allocation.

enable_auth_in_header

No

Boolean

Whether to allow authentication information in the request header.

domain_names

No

String

Private domain name.

restore_hook_handler

No

String

Restore Hook entry point for snapshot-based cold start in the format "xx.xx". The period (.) must be included. For example, com.huawei.demo.Test.restoreHook. This parameter is available only for Java functions.

restore_hook_timeout

No

Integer

Restore Hook timeout of snapshot-based cold start. Range: 1s to 300s.

Table 3 FuncVpc

Parameter

Mandatory

Type

Description

vpc_name

Yes

String

VPC name.

vpc_id

Yes

String

VPC ID.

subnet_name

Yes

String

Subnet name.

subnet_id

Yes

String

Subnet ID.

cidr

Yes

String

Subnet mask.

gateway

Yes

String

Gateway.

security_groups

No

Array of strings

Security group.

Table 4 MountConfig

Parameter

Mandatory

Type

Description

mount_user

Yes

MountUser object

User information.

func_mounts

Yes

Array of FuncMount objects

Mounted resources.

Table 5 MountUser

Parameter

Mandatory

Type

Description

user_id

Yes

String

User ID, a non-0 integer from –1 to 65534.

user_group_id

Yes

String

User group ID, a non-0 integer from –1 to 65534.

Table 6 FuncMount

Parameter

Mandatory

Type

Description

mount_type

Yes

String

Mount type. The value can be sfs, sfsTurbo, or ecs. This parameter is mandatory when func_mounts is not empty.

mount_resource

Yes

String

ID of the mounted resource (cloud service ID). This parameter is mandatory when func_mounts is not empty.

mount_share_path

No

String

Remote mount path. For example, 192.168.0.12:/data. This parameter is mandatory if mount_type is set to ecs.

local_mount_path

Yes

String

Function access path. This parameter is mandatory when func_mounts is not empty.

Table 7 StrategyConfig

Parameter

Mandatory

Type

Description

concurrency

Yes

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.

  • -1: The function has unlimited instances.

  • 0: The function is disabled.

concurrent_num

Yes

Integer

Maximum number of concurrent requests per instance. This parameter is supported only by v2. The value ranges from –1 to 1000.

Table 8 CustomImage

Parameter

Mandatory

Type

Description

enabled

No

Boolean

Whether to enable this feature.

image

No

String

Image address.

command

No

String

Command for starting a container image.

args

No

String

Command line parameter for starting a container image.

working_dir

No

String

Working directory of an image container.

uid

No

String

User ID of an image container.

gid

No

String

User group ID of an image container.

Table 9 FuncLogConfig

Parameter

Mandatory

Type

Description

group_name

No

String

Name of the log group bound to the function.

group_id

No

String

ID of the log group bound to the function.

stream_name

No

String

Name of the log stream bound to the function.

stream_id

No

String

ID of the log stream bound to the function.

Table 10 NetworkControlConfig

Parameter

Mandatory

Type

Description

disable_public_network

No

Boolean

Disable public access.

trigger_access_vpcs

No

Array of VpcConfig objects

VPC access restriction.

Table 11 VpcConfig

Parameter

Mandatory

Type

Description

vpc_name

No

String

VPC name.

vpc_id

No

String

VPC ID.

Response Parameters

Status code: 200

Table 12 Response body parameters

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:

  • Python 2.7

  • Python 3.6

  • Python 3.9

  • Go 1.8

  • Go 1.x

  • Java 8

  • Java 11

  • Node.js 6.10

  • Node.js 8.10

  • Node.js 10.16

  • Node.js 12.13

  • Node.js 14.18

  • C# (.NET Core 2.0)

  • C# (.NET Core 2.1)

  • C# (.NET Core 3.1)

  • Custom

  • PHP 7.3

  • HTTP

Enumeration values:

  • Java8

  • Java11

  • Node.js6.10

  • Node.js8.10

  • Node.js10.16

  • Node.js12.13

  • Node.js14.18

  • Python2.7

  • Python3.6

  • Go1.8

  • Go1.x

  • C#(.NET Core 2.0)

  • C#(.NET Core 2.1)

  • C#(.NET Core 3.1)

  • Custom

  • PHP7.3

  • Python3.9

  • http

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:

  • inline: inline code.

  • zip: ZIP file.

  • obs: function code stored in an OBS bucket.

  • jar: JAR file, for Java functions.

Enumeration values:

  • inline

  • zip

  • obs

  • jar

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

ephemeral_storage

Integer

Ephemeral storage.

Enumeration values:

  • 512

  • 10240

func_vpc

FuncVpc object

VPC configuration.

mount_config

MountConfig object

Mounting configuration.

strategy_config

StrategyConfig object

Function policy configuration.

dependencies

Array of Dependency objects

Dependency packages.

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:

  • v1

  • v2

enable_dynamic_memory

Boolean

Whether to enable dynamic memory allocation.

is_stateful_function

Boolean

Whether stateful functions are supported. If they are supported, set this parameter to true. This parameter is supported in FunctionGraph v2.

domain_names

String

Private domain name configured for resolution.

enable_auth_in_header

Boolean

Whether to allow authentication information in the request header.

custom_image

CustomImage object

Container image.

Table 13 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.

security_groups

Array of strings

Security group.

Table 14 MountConfig

Parameter

Type

Description

mount_user

MountUser object

User information.

func_mounts

Array of FuncMount objects

Mounted resources.

Table 15 MountUser

Parameter

Type

Description

user_id

String

User ID, a non-0 integer from –1 to 65534.

user_group_id

String

User group ID, a non-0 integer from –1 to 65534.

Table 16 FuncMount

Parameter

Type

Description

mount_type

String

Mount type. The value can be sfs, sfsTurbo, or ecs. This parameter is mandatory when func_mounts is not empty.

mount_resource

String

ID of the mounted resource (cloud service ID). This parameter is mandatory when func_mounts is not empty.

mount_share_path

String

Remote mount path. For example, 192.168.0.12:/data. This parameter is mandatory if mount_type is set to ecs.

local_mount_path

String

Function access path. This parameter is mandatory when func_mounts is not empty.

Table 17 StrategyConfig

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.

  • -1: The function has unlimited instances.

  • 0: The function is disabled.

concurrent_num

Integer

Maximum number of concurrent requests per instance. This parameter is supported only by v2. The value ranges from –1 to 1000.

Table 18 Dependency

Parameter

Type

Description

owner

String

Domain ID of the dependency owner.

link

String

URL of the dependency on OBS.

runtime

String

Environment in which a FunctionGraph function is executed. Options:

  • Python 2.7

  • Python 3.6

  • Python 3.9

  • Go 1.8

  • Go 1.x

  • Java 8

  • Java 11

  • Node.js 6.10

  • Node.js 8.10

  • Node.js 10.16

  • Node.js 12.13

  • Node.js 14.18

  • C# (.NET Core 2.0)

  • C# (.NET Core 2.1)

  • C# (.NET Core 3.1)

  • Custom

  • PHP 7.3

  • HTTP

Enumeration values:

  • Java8

  • Java11

  • Node.js6.10

  • Node.js8.10

  • Node.js10.16

  • Node.js12.13

  • Node.js14.18

  • Python2.7

  • Python3.6

  • Go1.8

  • Go1.x

  • C#(.NET Core 2.0)

  • C#(.NET Core 2.1)

  • C#(.NET Core 3.1)

  • Custom

  • PHP7.3

  • Python3.9

  • http

etag

String

MD5 value of a dependency.

size

Long

Dependency size.

name

String

Dependence name.

description

String

Dependency description.

file_name

String

File name of a dependency package (ZIP).

Table 19 CustomImage

Parameter

Type

Description

enabled

Boolean

Whether to enable this feature.

image

String

Image address.

command

String

Command for starting a container image.

args

String

Command line parameter for starting a container image.

working_dir

String

Working directory of an image container.

uid

String

User ID of an image container.

gid

String

User group ID of an image container.

Status code: 400

Table 20 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 401

Table 21 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 403

Table 22 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 404

Table 23 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 500

Table 24 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Example Requests

  • Modify the metadata of a function.

    PUT https://{Endpoint}/v2/{project_id}/fgs/functions/{function_urn}/config
    
    {
      "func_name" : "fgsSdkTest-20220831080525",
      "handler" : "index.handler",
      "memory_size" : 768,
      "runtime" : "Node.js6.10",
      "timeout" : 40
    }
  • Modify GPU configuration of a custom runtime function.

    PUT https://{Endpoint}/v2/{project_id}/fgs/functions/{function_urn}/config
    
    {
      "func_name" : "test_GPU",
      "handler" : "bootstrap",
      "memory_size" : 4096,
      "runtime" : "Custom",
      "timeout" : 40,
      "gpu_memory" : 1024
    }

Example Responses

Status code: 200

OK

{
  "func_urn" : "urn:fss:xxxxxxxx:7aad83af3e8d42e99ac194e8419e2c9b:function:default:test",
  "func_name" : "test",
  "domain_id" : "14ee2e3501124efcbca7998baa24xxxx",
  "namespace" : "46b6f338fc3445b8846c71dfb1fbxxxx",
  "project_name" : "xxxxxx",
  "package" : "default",
  "runtime" : "Node.js6.10",
  "timeout" : 3,
  "handler" : "fssExampleCsharp2.1::fssExampleCsharp21.Program::MyFunc",
  "memory_size" : 128,
  "cpu" : 300,
  "code_type" : "inline",
  "code_filename" : "index.js",
  "code_size" : 272,
  "digest" : "faa825575c45437cddd4e369bea69893bcbe195d478178462ad90984fe72993f3f59d15f41c5373f807f3e05fb9af322c55dabeb16565c386e402413458e6068",
  "version" : "latest",
  "ephemeral_storage" : 512,
  "image_name" : "latest-191025153727@zehht",
  "last_modified" : "2019-10-25 15:37:27",
  "strategy_config" : {
    "concurrency" : 0
  }
}

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.