修改函数代码 -j9九游会登录
功能介绍
修改指定的函数的代码。
调用方法
请参见。
授权信息
账号具备所有api的调用权限,如果使用账号下的iam用户调用当前api,该iam用户需具备调用api所需的权限,具体权限要求请参见权限和授权项。
uri
put /v2/{project_id}/fgs/functions/{function_urn}/code
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
project_id |
是 |
string |
参数解释: 租户项目 id,获取方式请参见获取项目id。 约束限制: 不涉及。 取值范围: 只能由英文字母、数字组成,且长度为32个字符。 默认取值: 不涉及。 |
|
function_urn |
是 |
string |
参数解释: 函数的urn,详细解释见functiongraph函数模型的描述。 约束限制: 不涉及。 取值范围: 只能由英文字母、数字、下划线、中划线、冒号组成。 默认取值: 不涉及。 |
请求参数
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
x-auth-token |
是 |
string |
参数解释: 用户token。 通过调用iam服务获取用户token接口获取(响应消息头中x-subject-token的值)。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
|
content-type |
是 |
string |
参数解释: 消息体的类型(格式)。 约束限制: 不涉及。 取值范围: 只能为application/json。 默认取值: application/json |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
code_type |
是 |
string |
参数解释: 函数代码类型,取值有5种。 约束限制: 不涉及。 取值范围: inline: ui在线编辑代码。 zip: 函数代码为zip包。 obs: 函数代码来源于obs存储。 jar: 函数代码为jar包,主要针对java函数。 修改自定义镜像函数镜像配置请参考:修改自定义镜像类型函数的镜像配置。 默认取值: 不涉及。 |
|
code_url |
否 |
string |
参数解释: 当codetype为obs时,该值为函数代码包在obs上的地址,codetype为其他值时,该字段为空。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
|
code_filename |
否 |
string |
参数解释: 函数的文件名,当codetype为jar/zip时必须提供该字段,inline和obs不需要提供。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
|
func_code |
是 |
funccode object |
参数解释: funccode结构返回体。 取值范围: 不涉及。 |
|
depend_version_list |
否 |
array of strings |
参数解释: 依赖版本id列表 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
|
code_encrypt_kms_key_id |
否 |
string |
参数解释: 用于用户代码加密的kms主密钥id。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
file |
否 |
string |
参数解释: 函数代码,如果不为空必须进行base64编码,为空时使用默认的代码。 取值范围: base64编码的字符串 |
|
link |
否 |
string |
参数解释: 函数代码链接。 取值范围: obs链接地址 |
响应参数
状态码: 200
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
func_urn |
string |
参数解释: 函数的urn(uniform resource name),唯一标识函数。 取值范围: 不涉及。 |
|
func_name |
string |
参数解释: 函数名称。 取值范围: 不涉及。 |
|
domain_id |
string |
参数解释: 域名id。 取值范围: 不涉及。 |
|
runtime |
string |
参数解释: functiongraph函数的运行时,即函数执行环境。 取值范围:
|
|
code_type |
string |
参数解释: 函数代码类型,取值有5种。 取值范围:
|
|
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 |
参数解释: 函数策略配置。 取值范围: 不涉及。 |
|
status |
integer |
参数解释: 函数状态,常见取值有2种。 取值范围:
|
|
dependencies |
array of dependency objects |
参数解释: 函数状态,常见取值有2种。 取值范围:
|
|
code_encrypt_kms_key_id |
string |
参数解释: 用于用户代码加密的kms主密钥id。 取值范围: 不涉及。 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
file |
string |
参数解释: 函数代码,如果不为空必须进行base64编码,为空时使用默认的代码。 取值范围: base64编码的字符串。 |
|
link |
string |
参数解释: 函数代码链接。 取值范围: obs链接地址。 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
concurrency |
integer |
参数解释: 单函数最大实例数,-1代表该函数实例数无限制。 取值范围:
|
|
concurrent_num |
integer |
参数解释: 单实例并发数, v2版本支持。 取值范围: [1, 1000] |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
id |
string |
参数解释: 依赖包版本id。 取值范围: 不涉及。 |
|
owner |
string |
参数解释: 依赖包属主的domainid。 取值范围: 不涉及。 |
|
link |
string |
参数解释: 依赖包在obs上的链接。 取值范围: obs链接地址 |
|
runtime |
string |
参数解释: functiongraph函数的运行时,即函数执行环境。 取值范围:
|
|
etag |
string |
参数解释: 依赖包的md5值。 取值范围: 不涉及。 |
|
size |
long |
参数解释: 依赖包大小。 取值范围: 不涉及。 |
|
name |
string |
参数解释: 依赖包名称。 取值范围: 不涉及。 |
|
description |
string |
参数解释: 依赖包描述。 取值范围: 不涉及。 |
|
file_name |
string |
参数解释: 依赖包文件名,如果创建方式为zip时必填。 取值范围: 不涉及。 |
|
version |
long |
参数解释: 依赖包版本编号。 取值范围: 不涉及。 |
|
dep_id |
string |
参数解释: 依赖包id。 取值范围: 不涉及。 |
|
last_modified |
integer |
参数解释: 函数最后一次更新时间。 取值范围: 不涉及。 |
状态码: 400
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
error_code |
string |
错误码 |
|
error_msg |
string |
错误信息 |
状态码: 401
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
error_code |
string |
错误码 |
|
error_msg |
string |
错误信息 |
状态码: 403
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
error_code |
string |
错误码 |
|
error_msg |
string |
错误信息 |
状态码: 404
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
error_code |
string |
错误码 |
|
error_msg |
string |
错误信息 |
状态码: 500
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
error_code |
string |
错误码 |
|
error_msg |
string |
错误信息 |
请求示例
- 以inline方式修改指定函数代码。
put https://{endpoint}/v2/{project_id}/fgs/functions/{function_urn}/code { "code_filename" : "index.zip", "code_type" : "inline", "func_code" : { "file" : "uesdbaoaaaaiapq1m1gnimplraaaaaebaaaiaaaaaw5kzxguchlnjteogjamrd/5igvfxdalxhjdo0s/wb yrmgmdmvwgynh390wefru3nvb0xxjg85qlru sk8np0uhub3rltjtauwknkwvkduwba0vqmrdahk8ksstfsoceyvsmw2xukecvku0hlrk 6liz0u5s3bwpfwwueeg/yo6b4vexcshybg lb437kfnfpewhatrqmqgtkyvh0pit8fedcqm6vqtsgncxypppz5o3fgfuesbah4dcgaaaaga9duzwa0iy8usaaaaaqeaaagaaaaaaaaaaaaaapmcaaaaagluzgv4lnb5uesfbgaaaaabaaeangaaaniaaaaaaa==" } } - 以zip方式修改指定函数代码。
put https://{endpoint}/v2/{project_id}/fgs/functions/{function_urn}/code { "code_filename" : "index.zip", "code_type" : "zip", "func_code" : { "file" : "uesdbaoaaaaiapq1m1gnimplraaaaaebaaaiaaaaaw5kzxguchlnjteogjamrd/5igvfxdalxhjdo0s/wb yrmgmdmvwgynh390wefru3nvb0xxjg85qlru sk8np0uhub3rltjtauwknkwvkduwba0vqmrdahk8ksstfsoceyvsmw2xukecvku0hlrk 6liz0u5s3bwpfwwueeg/yo6b4vexcshybg lb437kfnfpewhatrqmqgtkyvh0pit8fedcqm6vqtsgncxypppz5o3fgfuesbah4dcgaaaaga9duzwa0iy8usaaaaaqeaaagaaaaaaaaaaaaaapmcaaaaagluzgv4lnb5uesfbgaaaaabaaeangaaaniaaaaaaa==" } }
响应示例
状态码: 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" : "39d51ae334ffb239037e194159f4cc9cec31086719aa73db7d0a608343121a290f7115693e008bd01cb12b99a803856e83aa96173b26c528c41cfed18267e08f",
"last_modified" : "2019-10-31 11:37:58",
"func_code" : {
"file" : "aw1wb3j0igpzb24kzgvmighhbmrszxiozxzlbnqsignvbnrlehqpogogicagb3v0chv0id0gj0hlbgxvie1zzybmb3igbw9kawz5oianicsgannvbi5kdw1wcyhldmvudckkicagigfrid0gy29udgv4dc5nzxrby2nlc3nlzxkokqogicagc2sgpsbjb250zxh0lmdldfnly3jldetlesgpciagicb0b2tlbia9ignvbnrlehquz2v0vg9rzw4okqogicagchjpbnqgj2froicgkybhawogicagchjpbnqgj3nroicgkybzawogicagchjpbnqgj3rva2vuoicgkyb0b2tlbgogicagcmv0dxjuig91dhb1dao c0nltqlwkimnctgbmsn5sc ubkysukp1bj7jqqxds 5p7la/ew4rbtp8iusz/k2qmqvcddoby0ywycl rgctnlbts6hllj9snykovxixb1blaqieawoaaaaiaahyou8sspqsgwaaalyaaaaiaaaaaaaaaaaaaadzagaaaabpbmrlec5wevblbqyaaaaaaqabadyaaacpaaaaaaa=",
"link" : ""
},
"status" : 0,
"strategy_config" : {
"concurrency" : -1
}
}
状态码: 404
not found 找不到资源。
{
"error_code" : "fss.1052",
"error_msg" : "not found the function version"
}
sdk代码示例
sdk代码示例如下。
java
- 以inline方式修改指定函数代码。
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 51 52
packagecom.huaweicloud.sdk.test; importcom.huaweicloud.sdk.core.auth.icredential; importcom.huaweicloud.sdk.core.auth.basiccredentials; importcom.huaweicloud.sdk.core.exception.connectionexception; importcom.huaweicloud.sdk.core.exception.requesttimeoutexception; importcom.huaweicloud.sdk.core.exception.serviceresponseexception; importcom.huaweicloud.sdk.functiongraph.v2.region.functiongraphregion; importcom.huaweicloud.sdk.functiongraph.v2.*; importcom.huaweicloud.sdk.functiongraph.v2.model.*; publicclass updatefunctioncodesolution{ publicstaticvoidmain(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 stringak=system.getenv("cloud_sdk_ak"); stringsk=system.getenv("cloud_sdk_sk"); icredentialauth=newbasiccredentials() .withak(ak) .withsk(sk); functiongraphclientclient=functiongraphclient.newbuilder() .withcredential(auth) .withregion(functiongraphregion.valueof("
" )) .build(); updatefunctioncoderequestrequest=newupdatefunctioncoderequest(); updatefunctioncoderequestbodybody=newupdatefunctioncoderequestbody(); funccodefunccodebody=newfunccode(); funccodebody.withfile("uesdbaoaaaaiapq1m1gnimplraaaaaebaaaiaaaaaw5kzxguchlnjteogjamrd/5igvfxdalxhjdo0s/wb yrmgmdmvwgynh390wefru3nvb0xxjg85qlru sk8np0uhub3rltjtauwknkwvkduwba0vqmrdahk8ksstfsoceyvsmw2xukecvku0hlrk 6liz0u5s3bwpfwwueeg/yo6b4vexcshybg lb437kfnfpewhatrqmqgtkyvh0pit8fedcqm6vqtsgncxypppz5o3fgfuesbah4dcgaaaaga9duzwa0iy8usaaaaaqeaaagaaaaaaaaaaaaaapmcaaaaagluzgv4lnb5uesfbgaaaaabaaeangaaaniaaaaaaa=="); body.withfunccode(funccodebody); body.withcodefilename("index.zip"); body.withcodetype(updatefunctioncoderequestbody.codetypeenum.fromvalue("inline")); request.withbody(body); try{ updatefunctioncoderesponseresponse=client.updatefunctioncode(request); system.out.println(response.tostring()); }catch(connectionexceptione){ e.printstacktrace(); }catch(requesttimeoutexceptione){ e.printstacktrace(); }catch(serviceresponseexceptione){ e.printstacktrace(); system.out.println(e.gethttpstatuscode()); system.out.println(e.getrequestid()); system.out.println(e.geterrorcode()); system.out.println(e.geterrormsg()); } } } - 以zip方式修改指定函数代码。
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 51 52
packagecom.huaweicloud.sdk.test; importcom.huaweicloud.sdk.core.auth.icredential; importcom.huaweicloud.sdk.core.auth.basiccredentials; importcom.huaweicloud.sdk.core.exception.connectionexception; importcom.huaweicloud.sdk.core.exception.requesttimeoutexception; importcom.huaweicloud.sdk.core.exception.serviceresponseexception; importcom.huaweicloud.sdk.functiongraph.v2.region.functiongraphregion; importcom.huaweicloud.sdk.functiongraph.v2.*; importcom.huaweicloud.sdk.functiongraph.v2.model.*; publicclass updatefunctioncodesolution{ publicstaticvoidmain(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 stringak=system.getenv("cloud_sdk_ak"); stringsk=system.getenv("cloud_sdk_sk"); icredentialauth=newbasiccredentials() .withak(ak) .withsk(sk); functiongraphclientclient=functiongraphclient.newbuilder() .withcredential(auth) .withregion(functiongraphregion.valueof("
" )) .build(); updatefunctioncoderequestrequest=newupdatefunctioncoderequest(); updatefunctioncoderequestbodybody=newupdatefunctioncoderequestbody(); funccodefunccodebody=newfunccode(); funccodebody.withfile("uesdbaoaaaaiapq1m1gnimplraaaaaebaaaiaaaaaw5kzxguchlnjteogjamrd/5igvfxdalxhjdo0s/wb yrmgmdmvwgynh390wefru3nvb0xxjg85qlru sk8np0uhub3rltjtauwknkwvkduwba0vqmrdahk8ksstfsoceyvsmw2xukecvku0hlrk 6liz0u5s3bwpfwwueeg/yo6b4vexcshybg lb437kfnfpewhatrqmqgtkyvh0pit8fedcqm6vqtsgncxypppz5o3fgfuesbah4dcgaaaaga9duzwa0iy8usaaaaaqeaaagaaaaaaaaaaaaaapmcaaaaagluzgv4lnb5uesfbgaaaaabaaeangaaaniaaaaaaa=="); body.withfunccode(funccodebody); body.withcodefilename("index.zip"); body.withcodetype(updatefunctioncoderequestbody.codetypeenum.fromvalue("zip")); request.withbody(body); try{ updatefunctioncoderesponseresponse=client.updatefunctioncode(request); system.out.println(response.tostring()); }catch(connectionexceptione){ e.printstacktrace(); }catch(requesttimeoutexceptione){ e.printstacktrace(); }catch(serviceresponseexceptione){ e.printstacktrace(); system.out.println(e.gethttpstatuscode()); system.out.println(e.getrequestid()); system.out.println(e.geterrorcode()); system.out.println(e.geterrormsg()); } } }
python
- 以inline方式修改指定函数代码。
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
# coding: utf-8 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 = __import__('os').getenv("cloud_sdk_ak") sk = __import__('os').getenv("cloud_sdk_sk") credentials = basiccredentials(ak, sk) \ client = functiongraphclient.new_builder() \ .with_credentials(credentials) \ .with_region(functiongraphregion.value_of("
" )) \ .build() try: request = updatefunctioncoderequest() funccodebody = funccode( file="uesdbaoaaaaiapq1m1gnimplraaaaaebaaaiaaaaaw5kzxguchlnjteogjamrd/5igvfxdalxhjdo0s/wb yrmgmdmvwgynh390wefru3nvb0xxjg85qlru sk8np0uhub3rltjtauwknkwvkduwba0vqmrdahk8ksstfsoceyvsmw2xukecvku0hlrk 6liz0u5s3bwpfwwueeg/yo6b4vexcshybg lb437kfnfpewhatrqmqgtkyvh0pit8fedcqm6vqtsgncxypppz5o3fgfuesbah4dcgaaaaga9duzwa0iy8usaaaaaqeaaagaaaaaaaaaaaaaapmcaaaaagluzgv4lnb5uesfbgaaaaabaaeangaaaniaaaaaaa==" ) request.body = updatefunctioncoderequestbody( func_code=funccodebody, code_filename="index.zip", code_type="inline" ) response = client.update_function_code(request) print(response) except exceptions.clientrequestexception as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) - 以zip方式修改指定函数代码。
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
# coding: utf-8 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 = __import__('os').getenv("cloud_sdk_ak") sk = __import__('os').getenv("cloud_sdk_sk") credentials = basiccredentials(ak, sk) \ client = functiongraphclient.new_builder() \ .with_credentials(credentials) \ .with_region(functiongraphregion.value_of("
" )) \ .build() try: request = updatefunctioncoderequest() funccodebody = funccode( file="uesdbaoaaaaiapq1m1gnimplraaaaaebaaaiaaaaaw5kzxguchlnjteogjamrd/5igvfxdalxhjdo0s/wb yrmgmdmvwgynh390wefru3nvb0xxjg85qlru sk8np0uhub3rltjtauwknkwvkduwba0vqmrdahk8ksstfsoceyvsmw2xukecvku0hlrk 6liz0u5s3bwpfwwueeg/yo6b4vexcshybg lb437kfnfpewhatrqmqgtkyvh0pit8fedcqm6vqtsgncxypppz5o3fgfuesbah4dcgaaaaga9duzwa0iy8usaaaaaqeaaagaaaaaaaaaaaaaapmcaaaaagluzgv4lnb5uesfbgaaaaabaaeangaaaniaaaaaaa==" ) request.body = updatefunctioncoderequestbody( func_code=funccodebody, code_filename="index.zip", code_type="zip" ) response = client.update_function_code(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
- 以inline方式修改指定函数代码。
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
packagemain 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" ) funcmain(){ // 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") auth:=basic.newcredentialsbuilder(). withak(ak). withsk(sk). build() client:=functiongraph.newfunctiongraphclient( functiongraph.functiongraphclientbuilder(). withregion(region.valueof("
" )). withcredential(auth). build()) request:=&model.updatefunctioncoderequest{} filefunccode:="uesdbaoaaaaiapq1m1gnimplraaaaaebaaaiaaaaaw5kzxguchlnjteogjamrd/5igvfxdalxhjdo0s/wb yrmgmdmvwgynh390wefru3nvb0xxjg85qlru sk8np0uhub3rltjtauwknkwvkduwba0vqmrdahk8ksstfsoceyvsmw2xukecvku0hlrk 6liz0u5s3bwpfwwueeg/yo6b4vexcshybg lb437kfnfpewhatrqmqgtkyvh0pit8fedcqm6vqtsgncxypppz5o3fgfuesbah4dcgaaaaga9duzwa0iy8usaaaaaqeaaagaaaaaaaaaaaaaapmcaaaaagluzgv4lnb5uesfbgaaaaabaaeangaaaniaaaaaaa==" funccodebody:=&model.funccode{ file:&filefunccode, } codefilenameupdatefunctioncoderequestbody:="index.zip" request.body=&model.updatefunctioncoderequestbody{ funccode:funccodebody, codefilename:&codefilenameupdatefunctioncoderequestbody, codetype:model.getupdatefunctioncoderequestbodycodetypeenum().inline, } response,err:=client.updatefunctioncode(request) iferr==nil{ fmt.printf("% v\n",response) }else{ fmt.println(err) } } - 以zip方式修改指定函数代码。
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
packagemain 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" ) funcmain(){ // 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") auth:=basic.newcredentialsbuilder(). withak(ak). withsk(sk). build() client:=functiongraph.newfunctiongraphclient( functiongraph.functiongraphclientbuilder(). withregion(region.valueof("
" )). withcredential(auth). build()) request:=&model.updatefunctioncoderequest{} filefunccode:="uesdbaoaaaaiapq1m1gnimplraaaaaebaaaiaaaaaw5kzxguchlnjteogjamrd/5igvfxdalxhjdo0s/wb yrmgmdmvwgynh390wefru3nvb0xxjg85qlru sk8np0uhub3rltjtauwknkwvkduwba0vqmrdahk8ksstfsoceyvsmw2xukecvku0hlrk 6liz0u5s3bwpfwwueeg/yo6b4vexcshybg lb437kfnfpewhatrqmqgtkyvh0pit8fedcqm6vqtsgncxypppz5o3fgfuesbah4dcgaaaaga9duzwa0iy8usaaaaaqeaaagaaaaaaaaaaaaaapmcaaaaagluzgv4lnb5uesfbgaaaaabaaeangaaaniaaaaaaa==" funccodebody:=&model.funccode{ file:&filefunccode, } codefilenameupdatefunctioncoderequestbody:="index.zip" request.body=&model.updatefunctioncoderequestbody{ funccode:funccodebody, codefilename:&codefilenameupdatefunctioncoderequestbody, codetype:model.getupdatefunctioncoderequestbodycodetypeenum().zip, } response,err:=client.updatefunctioncode(request) iferr==nil{ fmt.printf("% v\n",response) }else{ fmt.println(err) } }
更多
更多编程语言的sdk代码示例,请参见的代码示例页签,可生成自动对应的sdk代码示例。
状态码
|
状态码 |
描述 |
|---|---|
|
200 |
ok |
|
400 |
bad request 请求错误。 |
|
401 |
unauthorized 鉴权失败。 |
|
403 |
forbidden 没有操作权限。 |
|
404 |
not found 找不到资源。 |
|
500 |
internal server error 服务内部错误。 |
错误码
请参见错误码。
相关文档
意见反馈
文档内容是否对您有帮助?
如您有其它疑问,您也可以通过华为云社区问答频道来与我们联系探讨