华为云计算 云知识 修改函数代码UpdateFunctionCode
修改函数代码UpdateFunctionCode

 

功能介绍

修改指定的函数的代码。

调试

您可以在API Explorer中调试该接口,支持自动认证鉴权。API Explorer可以自动生成SDK代码示例,并提供SDK代码示例调试功能。

URI

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

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

租户项目 ID,获取方式请参见获取项目ID

function_urn

String

函数的URN,详细解释见FunctionGraph函数模型的描述。

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

用户Token。

通过调用 IAM 服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。

表3 请求Body参数

参数

是否必选

参数类型

描述

code_type

String

函数代码类型,取值有4种。 inline: UI在线编辑代码。 zip: 函数代码为zip包。 obs: 函数代码来源于obs存储。 jar: 函数代码为jar包,主要针对Java函数。

枚举值:

  • inline

  • zip

  • obs

  • jar

code_url

String

当CodeType为obs时,该值为函数代码包在OBS上的地址,CodeType为其他值时,该字段为空。

code_filename

String

函数的文件名,当CodeType为jar/zip时必须提供该字段,inline和obs不需要提供。

func_code

FuncCode object

FuncCode结构返回体。

depend_list

Array of strings

依赖id列表

depend_version_list

Array of strings

依赖版本id列表

表4 FuncCode

参数

是否必选

参数类型

描述

file

String

函数代码,如果不为空必须进行base64编码,为空时使用默认的代码。

link

String

函数代码链接。

响应参数

状态码: 200

表5 响应Body参数

参数

参数类型

描述

func_urn

String

函数的URN(Uniform Resource Name),唯一标识函数。

func_name

String

函数名称。

domain_id

String

域名id。

runtime

String

FunctionGraph函数的执行环境 Python2.7: Python语言2.7版本。 Python3.6: Pyton语言3.6版本。 Python3.9: Python语言3.9版本。 Go1.8: Go语言1.8版本。 Go1.x: Go语言1.x版本。 Java8: Java语言8版本。 Java11: Java语言11版本。 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版本。 C#(.NET Core 2.0): C#语言2.0版本。 C#(.NET Core 2.1): C#语言2.1版本。 C#(.NET Core 3.1): C#语言3.1版本。 Custom: 自定义运行时。 PHP7.3: Php语言7.3版本。 http: HTTP函数。

枚举值:

  • 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

code_type

String

函数代码类型,取值有4种。 inline: UI在线编辑代码。 zip: 函数代码为zip包。 obs: 函数代码来源于obs存储。 jar: 函数代码为jar包,主要针对Java函数。

枚举值:

  • inline

  • zip

  • obs

  • jar

code_url

String

当CodeType为obs时,该值为函数代码包在OBS上的地址,CodeType为其他值时,该字段为空。

code_filename

String

函数的文件名,当CodeType为jar/zip时必须提供该字段,inline和obs不需要提供。

code_size

Long

函数大小,单位:字节。

digest

String

函数代码SHA512 hash值,用于判断函数是否变化。

last_modified

String

函数最后一次更新时间。

func_code

FuncCode object

FuncCode结构返回体。

depend_list

Array of strings

依赖id列表

depend_version_list

Array of strings

依赖版本id列表

strategy_config

StrategyConfig object

函数策略配置。

dependencies

Array of Dependency objects

函数依赖代码包列表。

表6 FuncCode

参数

参数类型

描述

file

String

函数代码,如果不为空必须进行base64编码,为空时使用默认的代码。

link

String

函数代码链接。

表7 StrategyConfig

参数

参数类型

描述

concurrency

Integer

单函数最大实例数,v1取值0和-1,v2取值-1到1000 -1代表该函数实例数无限制 0代表该函数被禁用

concurrent_num

Integer

单实例最大并发数,v2版本才支持,取值-1到1000

表8 Dependency

参数

参数类型

描述

owner

String

依赖包属主的domainId。

link

String

依赖包在OBS上的链接。

runtime

String

FunctionGraph函数的执行环境 Python2.7: Python语言2.7版本。 Python3.6: Pyton语言3.6版本。 Python3.9: Python语言3.9版本。 Go1.8: Go语言1.8版本。 Go1.x: Go语言1.x版本。 Java8: Java语言8版本。 Java11: Java语言11版本。 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版本。 C#(.NET Core 2.0): C#语言2.0版本。 C#(.NET Core 2.1): C#语言2.1版本。 C#(.NET Core 3.1): C#语言3.1版本。 Custom: 自定义运行时。 PHP7.3: Php语言7.3版本。 http: HTTP函数。

枚举值:

  • 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值

size

Long

依赖包大小。

name

String

依赖包名称。

description

String

依赖包描述。

file_name

String

依赖包文件名,如果创建方式为zip时。

状态码: 400

表9 响应Body参数

参数

参数类型

描述

error_code

String

错误码

error_msg

String

错误信息

状态码: 401

表10 响应Body参数

参数

参数类型

描述

error_code

String

错误码

error_msg

String

错误信息

状态码: 403

表11 响应Body参数

参数

参数类型

描述

error_code

String

错误码

error_msg

String

错误信息

状态码: 404

表12 响应Body参数

参数

参数类型

描述

error_code

String

错误码

error_msg

String

错误信息

状态码: 500

表13 响应Body参数

参数

参数类型

描述

error_code

String

错误码

error_msg

String

错误信息

请求示例

修改指定函数代码,。

PUT https://{Endpoint}/v2/{project_id}/fgs/functions/{function_urn}/code

{
  "code_filename" : "index.zip",
  "code_type" : "inline",
  "func_code" : {
  }
}

响应示例

状态码: 200

OK

{
  "func_urn" : "urn:fss:xxxxxxxxxxxx:7aad83af3e8d42e99ac194e8419e2c9b:function:default:test:latest",
  "func_name" : "test",
  "domain_id" : "14ee2e3501124efcbca7998baa24xxxx",
  "runtime" : "Node.js6.10",
  "code_type" : "inline",
  "code_filename" : "index.js",
  "code_size" : 245,
  "digest" : "",
  "last_modified" : "2019-10-31 11:37:58",
  "func_code" : {
    "link" : ""
  },
  "strategy_config" : {
    "concurrency" : -1
  }
}

状态码: 404

Not Found 找不到资源。

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

状态码

状态码

描述

200

OK

400

Bad Request 请求错误。

401

Unauthorized 鉴权失败。

403

Forbidden 没有操作权限。

404

Not Found 找不到资源。

500

Internal Server Error 服务内部错误。

错误码

请参见错误码

 

 

上一篇:开启流日志EnableFlowLoger 下一篇:企业OA上云靠谱最重要,多年业务推进为何华为云成为我的首选?

函数工作流 FunctionGraph

函数工作流(FunctionGraph)是一项基于事件驱动的函数托管计算服务。通过函数工作流,只需编写业务函数代码并设置运行的条件,无需配置和管理服务器等基础设施,函数以弹性、免运维、高可靠的方式运行。此外,按函数实际执行资源计费,不执行不产生费用