Modifying the Code of a Function
Function
This API is used to modify the code of a function.
URI
PUT /v2/{project_id}/fgs/functions/{function_urn}/code
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| function_urn | Yes | String | Function URN. |
| project_id | Yes | String | Tenant's project ID. |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| code_type | Yes | 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:
|
| depend_list | No | Array of strings | Function code dependency. |
| code_url | No | String | Path of the function code package. This parameter is mandatory when you upload code from the OBS console. |
| code_filename | No | String | Function file name, which consists of a file name and file type. |
| func_code | Yes | FuncCode object | Function code. |
| dependencies | No | Array of Dependency objects | Function dependency list. |
| handler | No | String | Entry point of the function. It is in the format of "xx.xx" and must contain a period (.). For example, for Node.js function myfunction.handler, the file name is myfunction.js, and the entry point function is handler. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| file | No | 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 | No | String | Function code. When code_type is set to obs, this parameter indicates the address of a function code package in OBS. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| id | Yes | String | Dependency ID. |
| owner | Yes | String | Dependency owner. |
| link | Yes | String | URL of the dependency in the OBS console. |
| runtime | Yes | String | Runtime. |
| etag | Yes | String | Unique ID of the dependency. |
| size | Yes | String | Size of the dependency. |
| name | Yes | String | Name of the dependency. |
| description | No | String | Description of the dependency. |
| file_name | No | String | File name of the dependency. |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| func_urn | String | Function URN. |
| func_name | String | Function name. |
| domain_id | String | Tenant's domain ID. |
| runtime | String | Function runtime. Enumeration values:
|
| concurrency | Long | 0: The function is disabled. -1: The function is enabled. Enumeration values:
|
| 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:
|
| 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. |
| func_code | FuncCode object | Function code. |
| 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. |
| 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. |
| 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. |
Example Requests
PUT https://{functiongraph_endpoint}/v2/7aad83af3e8d42e99ac194e8419e2c9b/fgs/functions/urn:fss:xxxxxxxx:7aad83af3e8d42e99ac194e8419e2c9b:function:default:test:latest/code
{
"code_type" : "inline",
"code_filename" : "index.zip",
"func_code" : {
"file" : "UEsDBAoAAAAAAGIXhk0Ac1L2tgAAALYAAAAIAAAAaW5kZXguanNleHBvcnRzLmhhbmRsZXIgPSBmdW5jdGlvbiAoZXZlbnQsIGNvbnRleHQsIGNhbGxiYWNrKSB7DQogICAgY29uc3QgZXJyb3IgPSBudWxsOw0KICAgIGNvbnN0IG91dHB1dCA9IGBIZWxsbyB3b3JsZCBtZXNzYWdlOiAke0pTT04uc3RyaW5naWZ5KGV2ZW50KX1gOw0KICAgIGNhbGxiYWNrKGVycm9yLCBvdXRwdXQpOw0KfVBLAQIeAwoAAAAAAGIXhk0Ac1L2tgAAALYAAAAIAAAAAAAAAAAAAAC0gQAAAABpbmRleC5qc1BLBQYAAAAAAQABADYAAADcAAAAAAA="
}
} Example Responses
Status code: 200
OK
{
"func_urn" : "urn:fss:cn-north-7:46b6f338fc3445b8846c71dfb1fbd9e8:function:default:xxxxx: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.
Last Article: Querying the Code of a Function
Next Article: Querying the Metadata of a Function
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.