网络
虚拟私有云 VPC
弹性公网IP EIP
弹性负载均衡 ELB
NAT网关 NAT
云专线 DC
虚拟专用网络 VPN
云连接 CC
VPC终端节点 VPCEP
企业路由器 ER
企业交换机 ESW
全球加速 GA
企业连接 EC
云原生应用网络 ANC
安全与合规
安全技术与应用
Web应用防火墙 WAF
企业主机安全 HSS
云防火墙 CFW
安全云脑 SecMaster
DDoS防护 AAD
数据加密服务 DEW
数据库安全服务 DBSS
云堡垒机 CBH
数据安全中心 DSC
云证书管理服务 CCM
威胁检测服务 MTD
态势感知 SA
认证测试中心 CTC
边缘安全 EdgeSec
应用中间件
微服务引擎 CSE
分布式消息服务Kafka版
分布式消息服务RabbitMQ版
分布式消息服务RocketMQ版
API网关 APIG
分布式缓存服务 DCS
多活高可用服务 MAS
事件网格 EG
管理与监管
统一身份认证服务 IAM
消息通知服务 SMN
云监控服务 CES
应用运维管理 AOM
应用性能管理 APM
云日志服务 LTS
云审计服务 CTS
标签管理服务 TMS
配置审计 Config
应用身份管理服务 OneAccess
资源访问管理 RAM
组织 Organizations
资源编排服务 RFS
优化顾问 OA
IAM 身份中心
云运维中心 COC
资源治理中心 RGC
解决方案
高性能计算 HPC
SAP
混合云灾备
开天工业工作台 MIW
Haydn解决方案工厂
数字化诊断治理专家服务
云生态
云商店
合作伙伴中心
华为云开发者学堂
华为云慧通差旅
开发与运维
软件开发生产线 CodeArts
需求管理 CodeArts Req
流水线 CodeArts Pipeline
代码检查 CodeArts Check
编译构建 CodeArts Build
部署 CodeArts Deploy
测试计划 CodeArts TestPlan
制品仓库 CodeArts Artifact
移动应用测试 MobileAPPTest
CodeArts IDE Online
开源镜像站 Mirrors
性能测试 CodeArts PerfTest
应用管理与运维平台 ServiceStage
云应用引擎 CAE
开源治理服务 CodeArts Governance
华为云Astro轻应用
CodeArts IDE
Astro工作流 AstroFlow
代码托管 CodeArts Repo
漏洞管理服务 CodeArts Inspector
联接 CodeArtsLink
软件建模 CodeArts Modeling
Astro企业应用 AstroPro
CodeArts 盘古助手
华为云Astro大屏应用
计算
弹性云服务器 ECS
Flexus云服务
裸金属服务器 BMS
云手机服务器 CPH
专属主机 DeH
弹性伸缩 AS
镜像服务 IMS
函数工作流 FunctionGraph
云耀云服务器(旧版)
VR云渲游平台 CVR
Huawei Cloud EulerOS
网络
虚拟私有云 VPC
弹性公网IP EIP
弹性负载均衡 ELB
NAT网关 NAT
云专线 DC
虚拟专用网络 VPN
云连接 CC
VPC终端节点 VPCEP
企业路由器 ER
企业交换机 ESW
全球加速 GA
企业连接 EC
云原生应用网络 ANC
CDN与智能边缘
内容分发网络 CDN
智能边缘云 IEC
智能边缘平台 IEF
CloudPond云服务
安全与合规
安全技术与应用
Web应用防火墙 WAF
企业主机安全 HSS
云防火墙 CFW
安全云脑 SecMaster
DDoS防护 AAD
数据加密服务 DEW
数据库安全服务 DBSS
云堡垒机 CBH
数据安全中心 DSC
云证书管理服务 CCM
威胁检测服务 MTD
态势感知 SA
认证测试中心 CTC
边缘安全 EdgeSec
大数据
MapReduce服务 MRS
数据湖探索 DLI
表格存储服务 CloudTable
可信智能计算服务 TICS
推荐系统 RES
云搜索服务 CSS
数据可视化 DLV
数据接入服务 DIS
数据仓库服务 GaussDB(DWS)
数据治理中心 DataArts Studio
湖仓构建 LakeFormation
智能数据洞察 DataArts Insight
应用中间件
微服务引擎 CSE
分布式消息服务Kafka版
分布式消息服务RabbitMQ版
分布式消息服务RocketMQ版
API网关 APIG
分布式缓存服务 DCS
多活高可用服务 MAS
事件网格 EG
开天aPaaS
应用平台 AppStage
开天企业工作台 MSSE
开天集成工作台 MSSI
API中心 API Hub
云消息服务 KooMessage
交换数据空间 EDS
云地图服务 KooMap
云手机服务 KooPhone
组织成员账号 OrgID
云空间服务 KooDrive
管理与监管
统一身份认证服务 IAM
消息通知服务 SMN
云监控服务 CES
应用运维管理 AOM
应用性能管理 APM
云日志服务 LTS
云审计服务 CTS
标签管理服务 TMS
配置审计 Config
应用身份管理服务 OneAccess
资源访问管理 RAM
组织 Organizations
资源编排服务 RFS
优化顾问 OA
IAM 身份中心
云运维中心 COC
资源治理中心 RGC
区块链
区块链服务 BCS
数字资产链 DAC
华为云区块链引擎服务 HBS
解决方案
高性能计算 HPC
SAP
混合云灾备
开天工业工作台 MIW
Haydn解决方案工厂
数字化诊断治理专家服务
价格
成本优化最佳实践
专属云商业逻辑
云生态
云商店
合作伙伴中心
华为云开发者学堂
华为云慧通差旅
其他
管理控制台
消息中心
产品价格详情
系统权限
客户关联华为云合作伙伴须知
公共问题
宽限期保留期
奖励推广计划
活动
云服务信任体系能力说明
开发与运维
软件开发生产线 CodeArts
需求管理 CodeArts Req
流水线 CodeArts Pipeline
代码检查 CodeArts Check
编译构建 CodeArts Build
部署 CodeArts Deploy
测试计划 CodeArts TestPlan
制品仓库 CodeArts Artifact
移动应用测试 MobileAPPTest
CodeArts IDE Online
开源镜像站 Mirrors
性能测试 CodeArts PerfTest
应用管理与运维平台 ServiceStage
云应用引擎 CAE
开源治理服务 CodeArts Governance
华为云Astro轻应用
CodeArts IDE
Astro工作流 AstroFlow
代码托管 CodeArts Repo
漏洞管理服务 CodeArts Inspector
联接 CodeArtsLink
软件建模 CodeArts Modeling
Astro企业应用 AstroPro
CodeArts 盘古助手
华为云Astro大屏应用
存储
对象存储服务 OBS
云硬盘 EVS
云备份 CBR
高性能弹性文件服务 SFS Turbo
弹性文件服务 SFS
存储容灾服务 SDRS
云硬盘备份 VBS
云服务器备份 CSBS
数据快递服务 DES
云存储网关 CSG
专属分布式存储服务 DSS
数据工坊 DWR
地图数据 MapDS
键值存储服务 KVS
容器
云容器引擎 CCE
云容器实例 CCI
容器镜像服务 SWR
云原生服务中心 OSC
应用服务网格 ASM
华为云UCS
数据库
云数据库 RDS
数据复制服务 DRS
文档数据库服务 DDS
分布式数据库中间件 DDM
云数据库 GaussDB
云数据库 GeminiDB
数据管理服务 DAS
数据库和应用迁移 UGO
云数据库 TaurusDB
人工智能
AI开发平台ModelArts
华为HiLens
图引擎服务 GES
图像识别 Image
文字识别 OCR
自然语言处理 NLP
内容审核 Moderation
图像搜索 ImageSearch
医疗智能体 EIHealth
企业级AI应用开发专业套件 ModelArts Pro
人脸识别服务 FRS
对话机器人服务 CBS
语音交互服务 SIS
人证核身服务 IVS
视频智能分析服务 VIAS
城市智能体
自动驾驶云服务 Octopus
盘古大模型 PanguLargeModels
IoT物联网
设备接入 IoTDA
全球SIM联接 GSL
IoT数据分析 IoTA
路网数字化服务 DRIS
IoT边缘 IoTEdge
设备发放 IoTDP
企业应用
域名注册服务 Domains
云解析服务 DNS
企业门户 EWP
ICP备案
商标注册
华为云WeLink
华为云会议 Meeting
隐私保护通话 PrivateNumber
语音通话 VoiceCall
消息&短信 MSGSMS
云管理网络
SD-WAN 云服务
边缘数据中心管理 EDCM
云桌面 Workspace
应用与数据集成平台 ROMA Connect
ROMA资产中心 ROMA Exchange
API全生命周期管理 ROMA API
政企自服务管理 ESM
视频
实时音视频 SparkRTC
视频直播 Live
视频点播 VOD
媒体处理 MPC
视频接入服务 VIS
数字内容生产线 MetaStudio
迁移
主机迁移服务 SMS
对象存储迁移服务 OMS
云数据迁移 CDM
迁移中心 MGC
专属云
专属计算集群 DCC
开发者工具
SDK开发指南
API签名指南
DevStar
华为云命令行工具服务 KooCLI
Huawei Cloud Toolkit
CodeArts API
云化转型
云架构中心
云采用框架
用户服务
账号中心
费用中心
成本中心
资源中心
企业管理
工单管理
客户运营能力
国际站常见问题
支持计划
专业服务
合作伙伴支持计划
我的凭证
华为云公共事业服务云平台
工业软件
工业数字模型驱动引擎
硬件开发工具链平台云服务
工业数据转换引擎云服务
更新时间:2025-02-08 GMT+08:00
分享

修改函数的metadata信息

功能介绍

修改指定的函数的metadata信息。

调用方法

请参见如何调用API

URI

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

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

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

function_urn

String

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

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

用户Token。

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

Content-Type

String

消息体的类型(格式)

表3 请求Body参数

参数

是否必选

参数类型

描述

func_name

String

函数名称。

runtime

String

FunctionGraph函数的执行环境 Python2.7: Python语言2.7版本。 Python3.6: Pyton语言3.6版本。Python3.9: Python语言3.9版本。 Python3.10: Python语言3.10版本。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版本。Node.js16.17: Nodejs语言16.17版本。Node.js18.15: Nodejs语言18.15版本。C#(.NET Core 2.1): C#语言2.1版本。C#(.NET Core 3.1): C#语言3.1版本。Custom: 自定义运行时。PHP7.3: Php语言7.3版本。Cangjie1.0:仓颉语言1.0版本。http: HTTP函数。Custom Image: 自定义镜像函数。

枚举值:

  • Java8
  • Java11
  • Node.js6.10
  • Node.js8.10
  • Node.js10.16
  • Node.js12.13
  • Node.js14.18
  • Node.js16.17
  • Node.js18.15
  • Python2.7
  • Python3.6
  • Python3.10
  • Go1.x
  • C#(.NET Core 2.1)
  • C#(.NET Core 3.1)
  • Custom
  • PHP7.3
  • Python3.9
  • http
  • Custom Image
  • Cangjie1.0

timeout

Integer

函数执行超时时间,超时函数将被强行停止,范围3~259200秒。

handler

String

函数执行入口 规则:xx.xx,必须包含“. ” 举例:对于node.js函数:myfunction.handler,则表示函数的文件名为myfunction.js,执行的入口函数名为handler。长度不超过128个字符。

最小长度:3

最大长度:128

memory_size

Integer

函数消耗的内存。 单位M。 取值范围为:128、256、512、768、1024、1280、1536、1792、2048、2560、3072、3584、4096。 最小值为128,最大值为4096。

gpu_memory

Integer

函数消耗的显存,只支持自定义运行时与自定义镜像函数配置GPU。 单位MB。 取值范围为:1024、2048、3072、4096、5120、6144、7168、8192、9216、10240、11264、12288、13312、14336、15360、16384。 最小值为1024,最大值为16384。(目前只支持华东-上海一)

gpu_type

String

显卡类型。(目前只支持华东-上海一)

user_data

String

用户自定义的name/value信息。 在函数中使用的参数。 举例:如函数要访问某个主机,可以设置自定义参数:Host={host_ip},最多定义20个,总长度不超过4KB。

encrypted_user_data

String

用户自定义的name/value信息,用于需要加密的配置。

xrole

String

函数配置委托。需要IAM支持,并在IAM界面创建委托,当函数需要访问其他服务时,必须提供该字段。配置后用户可以通过函数执行入口方法中的context参数获取具有委托中权限的token、ak、sk,用于访问其他云服务。如果用户函数不访问任何云服务,则不用提供委托名称。

app_xrole

String

函数执行委托。可为函数执行单独配置执行委托,这将减小不必要的性能损耗;不单独配置执行委托时,函数执行和函数配置将使用同一委托。

description

String

函数描述。

func_vpc

FuncVpc object

函数vpc配置。需同时为函数配置具有vpc权限的委托。

mount_config

MountConfig object

函数挂载配置。

strategy_config

StrategyConfig object

函数策略配置。

custom_image

CustomImage object

用户容器镜像。

extend_config

String

函数扩展配置。

initializer_handler

String

函数初始化入口,规则:xx.xx,必须包含“. ”。当配置初始化函数时,此参数必填。 举例:对于node.js函数:myfunction.initializer,则表示函数的文件名为myfunction.js,初始化的入口函数名为initializer。

initializer_timeout

Integer

初始化超时时间,超时函数将被强行停止,范围1~300秒。当配置初始化函数时,此参数必填。

pre_stop_handler

String

函数预停止函数的入口,规则:xx.xx,必须包含“. ”。 举例:对于node.js函数:myfunction.pre_stop_handler,则表示函数的文件名为myfunction.js,初始化的入口函数名为pre_stop_handler。

pre_stop_timeout

Integer

初始化超时时间,超时函数将被强行停止,范围1~90秒。

ephemeral_storage

Integer

临时存储大小。默认情况下会为函数的/tmp目录分配512MB的空间。您可以通过临时存储设置将函数的/tmp目录大小调整为10G。

枚举值:

  • 512
  • 10240

enterprise_project_id

String

企业项目ID,在企业用户创建函数时必填。

log_config

FuncLogConfig object

函数绑定日志配置。

network_controller

NetworkControlConfig object

函数网络配置。

is_stateful_function

Boolean

是否支持有状态,如果需要支持,需要固定传参为true,v2版本支持

enable_dynamic_memory

Boolean

是否启动动态内存配置

enable_auth_in_header

Boolean

是否允许在请求头中添加鉴权信息

domain_names

String

内网域名配置。

restore_hook_handler

String

函数快照式冷启动Restore Hook入口,仅支持Java,规则:xx.xx,必须包含“. ”。如:com.xxx.demo.Test.restoreHook

restore_hook_timeout

Integer

快照冷启动Restore Hook的超时时间,超时函数将被强行停止,范围1~300秒。

heartbeat_handler

String

心跳函数函数的入口,规则:xx.xx,必须包含“. ”,只支持JAVA运行时配置。 心跳函数入口需要与函数执行入口在同一文件下。

在开启心跳函数配置时,此参数必填。

enable_class_isolation

Boolean

类隔离开关,只支持JAVA运行时配置。

开启类隔离后可以支持Kafka转储并提升类加载效率,但也可能会导致某些兼容性问题,请谨慎开启。

peering_cidr

String

VPC对等连接网段。

您可以声明代码中使用到的VPC网段,用以检测是否与服务使用VPC网段冲突。网段间使用分号分隔且不能超过5个。

lts_custom_tag

Map<String,String>

自定义日志标签。

函数执行时,可以按照自定义标签配置上报标签到云日志服务(LTS),用户可以通过标签对日志进行过滤筛选。

表4 FuncVpc

参数

是否必选

参数类型

描述

domain_id

String

域名id。

namespace

String

租户的project id。

vpc_name

String

虚拟私有云名称。

vpc_id

String

虚拟私有云唯一标识。

subnet_name

String

子网名称。

subnet_id

String

子网编号。

cidr

String

子网掩码。

gateway

String

网关。

security_groups

Array of strings

安全组

表5 MountConfig

参数

是否必选

参数类型

描述

mount_user

MountUser object

挂载用户信息。

func_mounts

Array of FuncMount objects

函数挂载列表。

表6 MountUser

参数

是否必选

参数类型

描述

user_id

String

用户ID(-1~65534的非0整数)

user_group_id

String

用户组ID(-1~65534的非0整数)

表7 FuncMount

参数

是否必选

参数类型

描述

mount_type

String

挂载类型(sfs/sfsTurbo/ecs),func_mounts非空时必选。

mount_resource

String

挂载资源ID(对应云服务ID),func_mounts非空时必选。

mount_share_path

String

远端挂载路径(例如192.168.0.12:/data),如果mount_type为ecs,必选。

local_mount_path

String

函数访问路径,func_mounts非空时必选。

表8 StrategyConfig

参数

是否必选

参数类型

描述

concurrency

Integer

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

concurrent_num

Integer

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

表9 CustomImage

参数

是否必选

参数类型

描述

enabled

Boolean

是否启用

image

String

镜像地址

command

String

启动容器镜像的命令

args

String

启动容器镜像的命令行参数

working_dir

String

镜像容器工作目录

uid

String

镜像容器的用户id

gid

String

镜像容器的用户组id

表10 FuncLogConfig

参数

是否必选

参数类型

描述

group_name

String

函数绑定日志组名。

group_id

String

函数绑定日志组ID。

stream_name

String

函数绑定日志流名。

stream_id

String

函数绑定日志流ID。

表11 NetworkControlConfig

参数

是否必选

参数类型

描述

disable_public_network

Boolean

禁止公网访问开关。

trigger_access_vpcs

Array of VpcConfig objects

指定触发函数vpc配置。

表12 VpcConfig

参数

是否必选

参数类型

描述

vpc_name

String

vpc名称。

vpc_id

String

vpc ID。

响应参数

状态码: 200

表13 响应Body参数

参数

参数类型

描述

func_id

String

函数id,唯一标识函数。

resource_id

String

函数资源id。

func_urn

String

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

func_name

String

函数名称。

domain_id

String

域名id。

namespace

String

租户的project id。

project_name

String

租户的project name。

package

String

函数所属的分组Package,用于用户针对函数的自定义分组。

runtime

String

FunctionGraph函数的执行环境 Python2.7: Python语言2.7版本。 Python3.6: Pyton语言3.6版本。Python3.9: Python语言3.9版本。 Python3.10: Python语言3.10版本。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版本。Node.js16.17: Nodejs语言16.17版本。Node.js18.15: Nodejs语言18.15版本。C#(.NET Core 2.1): C#语言2.1版本。C#(.NET Core 3.1): C#语言3.1版本。Custom: 自定义运行时。PHP7.3: Php语言7.3版本。Cangjie1.0:仓颉语言1.0版本。http: HTTP函数。Custom Image: 自定义镜像函数。

枚举值:

  • Java8
  • Java11
  • Node.js6.10
  • Node.js8.10
  • Node.js10.16
  • Node.js12.13
  • Node.js14.18
  • Node.js16.17
  • Node.js18.15
  • Python2.7
  • Python3.6
  • Python3.10
  • Go1.x
  • C#(.NET Core 2.1)
  • C#(.NET Core 3.1)
  • Custom
  • PHP7.3
  • Python3.9
  • http
  • Custom Image
  • Cangjie1.0

timeout

Integer

函数执行超时时间,超时函数将被强行停止,范围3~259200秒。

handler

String

函数执行入口 规则:xx.xx,必须包含“. ” 举例:对于node.js函数:myfunction.handler,则表示函数的文件名为myfunction.js,执行的入口函数名为handler。长度不超过128个字符。

最小长度:3

最大长度:128

memory_size

Integer

函数消耗的内存。 单位M。 取值范围为:128、256、512、768、1024、1280、1536、1792、2048、2560、3072、3584、4096。 最小值为128,最大值为4096。

gpu_memory

Integer

函数消耗的显存,只支持自定义运行时与自定义镜像函数配置GPU。 单位MB。 取值范围为:1024、2048、3072、4096、5120、6144、7168、8192、9216、10240、11264、12288、13312、14336、15360、16384。 最小值为1024,最大值为16384。

cpu

Integer

函数占用的cpu资源。 单位为millicore(1 core=1000 millicores)。 取值与MemorySize成比例,默认是128M内存占0.1个核(100 millicores)。

code_type

String

函数代码类型,取值有5种。 inline: UI在线编辑代码。 zip: 函数代码为zip包。 obs: 函数代码来源于obs存储。 jar: 函数代码为jar包,主要针对Java函数。 Custom-Image-Swr: 函数代码来源于SWR自定义镜像。

枚举值:

  • inline
  • zip
  • obs
  • jar
  • Custom-Image-Swr

code_url

String

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

code_filename

String

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

code_size

Long

函数大小,单位:字节。

user_data

String

用户自定义的name/value信息。 在函数中使用的参数。 举例:如函数要访问某个主机,可以设置自定义参数:Host={host_ip},最多定义20个,总长度不超过4KB。

encrypted_user_data

String

用户自定义的name/value信息,用于需要加密的配置。

digest

String

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

version

String

函数版本号,由系统自动生成,规则:vYYYYMMDD-HHMMSS(v+年月日-时分秒)。

image_name

String

函数版本的内部标识。

xrole

String

函数配置委托。需要IAM支持,并在IAM界面创建委托,当函数需要访问其他服务时,必须提供该字段。配置后用户可以通过函数执行入口方法中的context参数获取具有委托中权限的token、ak、sk,用于访问其他云服务。如果用户函数不访问任何云服务,则不用提供委托名称。

app_xrole

String

函数执行委托。可为函数执行单独配置执行委托,这将减小不必要的性能损耗;不单独配置执行委托时,函数执行和函数配置将使用同一委托。

description

String

函数描述。

last_modified

String

函数最后一次更新时间。

ephemeral_storage

Integer

临时存储大小。默认情况下会为函数的/tmp目录分配512MB的空间。您可以通过临时存储设置将函数的/tmp目录大小调整为10G。

枚举值:

  • 512
  • 10240

func_vpc

FuncVpc object

函数vpc配置。需同时为函数配置具有vpc权限的委托。

mount_config

MountConfig object

函数挂载配置。

strategy_config

StrategyConfig object

函数策略配置。

dependencies

Array of Dependency objects

函数依赖代码包列表。

initializer_handler

String

函数初始化入口,规则:xx.xx,必须包含“. ”。当配置初始化函数时,此参数必填。 举例:对于node.js函数:myfunction.initializer,则表示函数的文件名为myfunction.js,初始化的入口函数名为initializer。

initializer_timeout

Integer

初始化超时时间,超时函数将被强行停止,范围1~300秒。当配置初始化函数时,此参数必填。

pre_stop_handler

String

函数预停止函数的入口,规则:xx.xx,必须包含“. ”。 举例:对于node.js函数:myfunction.pre_stop_handler,则表示函数的文件名为myfunction.js,初始化的入口函数名为pre_stop_handler。

pre_stop_timeout

Integer

初始化超时时间,超时函数将被强行停止,范围1~90秒。

enterprise_project_id

String

企业项目ID,在企业用户创建函数时必填。

long_time

Boolean

是否允许进行长时间超时设置。

log_group_id

String

自定义日志查询组id。

log_stream_id

String

自定义日志查询流id。

type

String

v2表示为正式版本,v1为废弃版本。

枚举值:

  • v1
  • v2

enable_cloud_debug

String

适配CloudDebug场景,是否开启云调试(已废弃)。

enable_dynamic_memory

Boolean

是否启动动态内存配置。

enable_auth_in_header

Boolean

是否允许在请求头中添加鉴权信息,只支持自定义镜像函数。

is_stateful_function

Boolean

是否支持有状态,v2版本支持。

domain_names

String

函数配置的需要支持域名解析的内网域名。

enable_auth_in_header

Boolean

是否允许在请求头中添加鉴权信息。

custom_image

CustomImage object

用户容器镜像。

is_return_stream

Boolean

是否返回流式数据(已废弃)。

peering_cidr

String

VPC对等连接网段。

您可以声明代码中使用到的VPC网段,用以检测是否与服务使用VPC网段冲突。网段间使用分号分隔且不能超过5个。

lts_custom_tag

Map<String,String>

自定义日志标签。

函数执行时,可以按照自定义标签配置上报标签到云日志服务(LTS),用户可以通过标签对日志进行过滤筛选。

表14 FuncVpc

参数

参数类型

描述

domain_id

String

域名id。

namespace

String

租户的project id。

vpc_name

String

虚拟私有云名称。

vpc_id

String

虚拟私有云唯一标识。

subnet_name

String

子网名称。

subnet_id

String

子网编号。

cidr

String

子网掩码。

gateway

String

网关。

security_groups

Array of strings

安全组

表15 MountConfig

参数

参数类型

描述

mount_user

MountUser object

挂载用户信息。

func_mounts

Array of FuncMount objects

函数挂载列表。

表16 MountUser

参数

参数类型

描述

user_id

String

用户ID(-1~65534的非0整数)

user_group_id

String

用户组ID(-1~65534的非0整数)

表17 FuncMount

参数

参数类型

描述

mount_type

String

挂载类型(sfs/sfsTurbo/ecs),func_mounts非空时必选。

mount_resource

String

挂载资源ID(对应云服务ID),func_mounts非空时必选。

mount_share_path

String

远端挂载路径(例如192.168.0.12:/data),如果mount_type为ecs,必选。

local_mount_path

String

函数访问路径,func_mounts非空时必选。

表18 StrategyConfig

参数

参数类型

描述

concurrency

Integer

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

concurrent_num

Integer

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

表19 Dependency

参数

参数类型

描述

id

String

依赖包版本ID。

owner

String

依赖包属主的domainId。

link

String

依赖包在OBS上的链接。

runtime

String

FunctionGraph函数的执行环境 Python2.7: Python语言2.7版本。 Python3.6: Pyton语言3.6版本。Python3.9: Python语言3.9版本。 Python3.10: Python语言3.10版本。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版本。Node.js16.17: Nodejs语言16.17版本。Node.js18.15: Nodejs语言18.15版本。C#(.NET Core 2.1): C#语言2.1版本。C#(.NET Core 3.1): C#语言3.1版本。Custom: 自定义运行时。PHP7.3: Php语言7.3版本。Cangjie1.0:仓颉语言1.0版本。http: HTTP函数。Custom Image: 自定义镜像函数。

枚举值:

  • Java8
  • Java11
  • Node.js6.10
  • Node.js8.10
  • Node.js10.16
  • Node.js12.13
  • Node.js14.18
  • Node.js16.17
  • Node.js18.15
  • Python2.7
  • Python3.6
  • Python3.10
  • Go1.x
  • C#(.NET Core 2.1)
  • C#(.NET Core 3.1)
  • Custom
  • PHP7.3
  • Python3.9
  • http
  • Custom Image
  • Cangjie1.0

etag

String

依赖包的md5值

size

Long

依赖包大小。

name

String

依赖包名称。

description

String

依赖包描述。

file_name

String

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

version

Long

依赖包版本编号。

dep_id

String

依赖包ID

last_modified

Integer

函数最后一次更新时间。

表20 CustomImage

参数

参数类型

描述

enabled

Boolean

是否启用

image

String

镜像地址

command

String

启动容器镜像的命令

args

String

启动容器镜像的命令行参数

working_dir

String

镜像容器工作目录

uid

String

镜像容器的用户id

gid

String

镜像容器的用户组id

状态码: 400

表21 响应Body参数

参数

参数类型

描述

error_code

String

错误码

error_msg

String

错误信息

状态码: 401

表22 响应Body参数

参数

参数类型

描述

error_code

String

错误码

error_msg

String

错误信息

状态码: 403

表23 响应Body参数

参数

参数类型

描述

error_code

String

错误码

error_msg

String

错误信息

状态码: 404

表24 响应Body参数

参数

参数类型

描述

error_code

String

错误码

error_msg

String

错误信息

状态码: 500

表25 响应Body参数

参数

参数类型

描述

error_code

String

错误码

error_msg

String

错误信息

请求示例

  • 修改名为fgsTest的Nodejs函数配置信息,将内存大小改为768MB,超时时间设为40s,添加环境变量host,添加磁盘挂载。
    PUT https://{Endpoint}/v2/{project_id}/fgs/functions/{function_urn}/config
    
    {
      "func_name" : "fgsTest",
      "handler" : "index.handler",
      "memory_size" : 768,
      "user_data" : "{\"host\":\"192.168.0.1\"}",
      "runtime" : "Node.js6.10",
      "mount_config" : {
        "mount_user" : {
          "user_id" : -1,
          "user_group_id" : -1
        },
        "func_mounts" : [ {
          "mount_resource" : "268xxx-d3xx-4cxx-98xx-d1dbxxx",
          "local_mount_path" : "/mnt",
          "mount_type" : "sfsTurbo"
        } ]
      },
      "timeout" : 40
    }
  • 修改自定义运行时函数GPU配置,将GPU显存设置为1GB,内存大小设置为4GB。
    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
    }
  • 修改自定义镜像类型函数的镜像配置。
    {
      "func_name": "test_function",
      "handler": "-",
      "memory_size": 128,
      "runtime": "Custom Image",
      "timeout": 3,
      "xrole": "xxx",
      "custom_image": {
          "enabled": true,
          "image": "swr.xxx.example.com/xxx/xxx:xxx",
          "working_dir": "/"
      }
    }

响应示例

状态码: 200

OK

{
  "func_id" : "0d075978-5a54-4ee1-8e24-ff5bd070xxxx",
  "resource_id" : "0d075978-5a54-4ee1-8e24-ff5bd070xxxx:test",
  "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,
  "user_data" : "{\"host\":\"192.168.0.1\"}",
  "mount_config" : {
    "mount_user" : {
      "user_id" : -1,
      "user_group_id" : -1
    },
    "func_mounts" : [ {
      "mount_resource" : "268xxx-d3xx-4cxx-98xx-d1dbxxx",
      "local_mount_path" : "/mnt",
      "mount_type" : "sfsTurbo"
    } ]
  },
  "digest" : "faa825575c45437cddd4e369bea69893bcbe195d478178462ad90984fe72993f3f59d15f41c5373f807f3e05fb9af322c55dabeb16565c386e402413458e6068",
  "version" : "latest",
  "ephemeral_storage" : 512,
  "image_name" : "latest-191025153727@zehht",
  "last_modified" : "2019-10-25 15:37:27",
  "strategy_config" : {
    "concurrency" : 0
  }
}

SDK代码示例

SDK代码示例如下。

Java

  • 修改名为fgsTest的Nodejs函数配置信息,将内存大小改为768MB,超时时间设为40s,添加环境变量host,添加磁盘挂载。
     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
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    package com.huaweicloud.sdk.test;
    
    import com.huaweicloud.sdk.core.auth.ICredential;
    import com.huaweicloud.sdk.core.auth.BasicCredentials;
    import com.huaweicloud.sdk.core.exception.ConnectionException;
    import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
    import com.huaweicloud.sdk.core.exception.ServiceResponseException;
    import com.huaweicloud.sdk.functiongraph.v2.region.FunctionGraphRegion;
    import com.huaweicloud.sdk.functiongraph.v2.*;
    import com.huaweicloud.sdk.functiongraph.v2.model.*;
    
    import java.util.List;
    import java.util.ArrayList;
    
    public class UpdateFunctionConfigSolution {
    
        public static void main(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
            String ak = System.getenv("CLOUD_SDK_AK");
            String sk = System.getenv("CLOUD_SDK_SK");
    
            ICredential auth = new BasicCredentials()
                    .withAk(ak)
                    .withSk(sk);
    
            FunctionGraphClient client = FunctionGraphClient.newBuilder()
                    .withCredential(auth)
                    .withRegion(FunctionGraphRegion.valueOf("<YOUR REGION>"))
                    .build();
            UpdateFunctionConfigRequest request = new UpdateFunctionConfigRequest();
            UpdateFunctionConfigRequestBody body = new UpdateFunctionConfigRequestBody();
            List<FuncMount> listMountConfigFuncMounts = new ArrayList<>();
            listMountConfigFuncMounts.add(
                new FuncMount()
                    .withMountType("sfsTurbo")
                    .withMountResource("268xxx-d3xx-4cxx-98xx-d1dbxxx")
                    .withLocalMountPath("/mnt")
            );
            MountUser mountUserMountConfig = new MountUser();
            mountUserMountConfig.withUserId("-1")
                .withUserGroupId("-1");
            MountConfig mountConfigbody = new MountConfig();
            mountConfigbody.withMountUser(mountUserMountConfig)
                .withFuncMounts(listMountConfigFuncMounts);
            body.withMountConfig(mountConfigbody);
            body.withUserData("{"host":"192.168.0.1"}");
            body.withMemorySize(768);
            body.withHandler("index.handler");
            body.withTimeout(40);
            body.withRuntime(UpdateFunctionConfigRequestBody.RuntimeEnum.fromValue("Node.js6.10"));
            body.withFuncName("fgsTest");
            request.withBody(body);
            try {
                UpdateFunctionConfigResponse response = client.updateFunctionConfig(request);
                System.out.println(response.toString());
            } catch (ConnectionException e) {
                e.printStackTrace();
            } catch (RequestTimeoutException e) {
                e.printStackTrace();
            } catch (ServiceResponseException e) {
                e.printStackTrace();
                System.out.println(e.getHttpStatusCode());
                System.out.println(e.getRequestId());
                System.out.println(e.getErrorCode());
                System.out.println(e.getErrorMsg());
            }
        }
    }
    
  • 修改自定义运行时函数GPU配置,将GPU显存设置为1GB,内存大小设置为4GB。
     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
    53
    package com.huaweicloud.sdk.test;
    
    import com.huaweicloud.sdk.core.auth.ICredential;
    import com.huaweicloud.sdk.core.auth.BasicCredentials;
    import com.huaweicloud.sdk.core.exception.ConnectionException;
    import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
    import com.huaweicloud.sdk.core.exception.ServiceResponseException;
    import com.huaweicloud.sdk.functiongraph.v2.region.FunctionGraphRegion;
    import com.huaweicloud.sdk.functiongraph.v2.*;
    import com.huaweicloud.sdk.functiongraph.v2.model.*;
    
    
    public class UpdateFunctionConfigSolution {
    
        public static void main(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
            String ak = System.getenv("CLOUD_SDK_AK");
            String sk = System.getenv("CLOUD_SDK_SK");
    
            ICredential auth = new BasicCredentials()
                    .withAk(ak)
                    .withSk(sk);
    
            FunctionGraphClient client = FunctionGraphClient.newBuilder()
                    .withCredential(auth)
                    .withRegion(FunctionGraphRegion.valueOf("<YOUR REGION>"))
                    .build();
            UpdateFunctionConfigRequest request = new UpdateFunctionConfigRequest();
            UpdateFunctionConfigRequestBody body = new UpdateFunctionConfigRequestBody();
            body.withGpuMemory(1024);
            body.withMemorySize(4096);
            body.withHandler("bootstrap");
            body.withTimeout(40);
            body.withRuntime(UpdateFunctionConfigRequestBody.RuntimeEnum.fromValue("Custom"));
            body.withFuncName("test_GPU");
            request.withBody(body);
            try {
                UpdateFunctionConfigResponse response = client.updateFunctionConfig(request);
                System.out.println(response.toString());
            } catch (ConnectionException e) {
                e.printStackTrace();
            } catch (RequestTimeoutException e) {
                e.printStackTrace();
            } catch (ServiceResponseException e) {
                e.printStackTrace();
                System.out.println(e.getHttpStatusCode());
                System.out.println(e.getRequestId());
                System.out.println(e.getErrorCode());
                System.out.println(e.getErrorMsg());
            }
        }
    }
    

Python

  • 修改名为fgsTest的Nodejs函数配置信息,将内存大小改为768MB,超时时间设为40s,添加环境变量host,添加磁盘挂载。
     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
    53
    # 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("<YOUR REGION>")) \
            .build()
    
        try:
            request = UpdateFunctionConfigRequest()
            listFuncMountsMountConfig = [
                FuncMount(
                    mount_type="sfsTurbo",
                    mount_resource="268xxx-d3xx-4cxx-98xx-d1dbxxx",
                    local_mount_path="/mnt"
                )
            ]
            mountUserMountConfig = MountUser(
                user_id="-1",
                user_group_id="-1"
            )
            mountConfigbody = MountConfig(
                mount_user=mountUserMountConfig,
                func_mounts=listFuncMountsMountConfig
            )
            request.body = UpdateFunctionConfigRequestBody(
                mount_config=mountConfigbody,
                user_data="{"host":"192.168.0.1"}",
                memory_size=768,
                handler="index.handler",
                timeout=40,
                runtime="Node.js6.10",
                func_name="fgsTest"
            )
            response = client.update_function_config(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • 修改自定义运行时函数GPU配置,将GPU显存设置为1GB,内存大小设置为4GB。
     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("<YOUR REGION>")) \
            .build()
    
        try:
            request = UpdateFunctionConfigRequest()
            request.body = UpdateFunctionConfigRequestBody(
                gpu_memory=1024,
                memory_size=4096,
                handler="bootstrap",
                timeout=40,
                runtime="Custom",
                func_name="test_GPU"
            )
            response = client.update_function_config(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

  • 修改名为fgsTest的Nodejs函数配置信息,将内存大小改为768MB,超时时间设为40s,添加环境变量host,添加磁盘挂载。
     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
    53
    54
    55
    56
    57
    58
    59
    60
    package main
    
    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"
    )
    
    func 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 := 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("<YOUR REGION>")).
                WithCredential(auth).
                Build())
    
        request := &model.UpdateFunctionConfigRequest{}
    	var listFuncMountsMountConfig = []model.FuncMount{
            {
                MountType: "sfsTurbo",
                MountResource: "268xxx-d3xx-4cxx-98xx-d1dbxxx",
                LocalMountPath: "/mnt",
            },
        }
    	mountUserMountConfig := &model.MountUser{
    		UserId: "-1",
    		UserGroupId: "-1",
    	}
    	mountConfigbody := &model.MountConfig{
    		MountUser: mountUserMountConfig,
    		FuncMounts: listFuncMountsMountConfig,
    	}
    	userDataUpdateFunctionConfigRequestBody:= "{"host":"192.168.0.1"}"
    	request.Body = &model.UpdateFunctionConfigRequestBody{
    		MountConfig: mountConfigbody,
    		UserData: &userDataUpdateFunctionConfigRequestBody,
    		MemorySize: int32(768),
    		Handler: "index.handler",
    		Timeout: int32(40),
    		Runtime: model.GetUpdateFunctionConfigRequestBodyRuntimeEnum().NODE_JS6_10,
    		FuncName: "fgsTest",
    	}
    	response, err := client.UpdateFunctionConfig(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • 修改自定义运行时函数GPU配置,将GPU显存设置为1GB,内存大小设置为4GB。
     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
    package main
    
    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"
    )
    
    func 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 := 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("<YOUR REGION>")).
                WithCredential(auth).
                Build())
    
        request := &model.UpdateFunctionConfigRequest{}
    	gpuMemoryUpdateFunctionConfigRequestBody:= int32(1024)
    	request.Body = &model.UpdateFunctionConfigRequestBody{
    		GpuMemory: &gpuMemoryUpdateFunctionConfigRequestBody,
    		MemorySize: int32(4096),
    		Handler: "bootstrap",
    		Timeout: int32(40),
    		Runtime: model.GetUpdateFunctionConfigRequestBodyRuntimeEnum().CUSTOM,
    		FuncName: "test_GPU",
    	}
    	response, err := client.UpdateFunctionConfig(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    

更多

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

200

OK

400

Bad Request 请求错误。

401

Unauthorized 鉴权失败。

403

Forbidden 没有操作权限。

404

Not Found 找不到资源。

500

Internal Server Error 服务内部错误。

错误码

请参见错误码

相关文档