所有页面
由 GitBook 提供支持
1 / 6

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

use_git_repository 方法

命名空间和模块:tencent.cloud.serverless.functions.client.FunctionCode

简要

配置使用给定 Git 仓库作为无服务器云函数源代码来源。

参数

该方法具有以下参数,其参数、参数类型和参数描述如下:

返回值

该方法返回当前代表无服务器云函数源代码配置的 类实例本身。

异常

该方法可能会主动引发的异常类型如下:

ValueError

参数值或类型不符合预期。

示例

下面我们将通过一段 Python 代码向您演示如何使用该方法:

适用于

Tencent Cloud SDK for Python

产品软件包:tencent-cloud-sdk-serverless-functions >= 0.1.1

def use_git_repository(self,
    git_url: str,
    git_branch_name: str = None,
    git_directory_name: str = None,
    git_commit_id: str = None,
    git_username: str = None,
    git_password: str = None
)

否

Git 仓库中包含用于无服务器云函数源代码的目录名称。

git_commit_id

str

否

Git 仓库中包含用于无服务器云函数源代码的提交 ID。

git_username

str

否

拥有给定 Git 仓库访问权限的用户名。

git_password

str

否

拥有给定 Git 仓库访问权限用户的密码。

参数

类型

必选

描述

git_url

str

是

Git 仓库 URL 字符串。

git_branch_name

str

否

Git 仓库中已创建的分支名称。

git_directory_name

FunctionCode

str

functions.FunctionCode.use_git_repository(
    git_url = 'https://github.com/tencentyun/scf-demo-repo.git',
    git_directory_name = 'Python3.6-helloworld'
)

get_code_source 方法

命名空间和模块:tencent.cloud.serverless.functions.client.FunctionCode

简要

获取无服务器云函数源代码来源类型。

参数

该方法没有参数。

返回值

该方法返回无服务器云函数源代码来源类型,与受支持的触发器种类名称相对应的是 枚举器。

异常

该方法不会主动引发任何异常。

示例

下面我们将通过一段 Python 代码向您演示如何使用该方法:

适用于

Tencent Cloud SDK for Python

产品软件包:tencent-cloud-sdk-serverless-functions >= 0.1.1

def get_code_source(self) -> int
FunctionCodeSource
functions.FunctionCode().get_code_source()

get_code_context 方法

命名空间和模块:tencent.cloud.serverless.functions.client.FunctionCode

简要

获取包含无服务器云函数源代码配置描述结构上下文的字典实例。

参数

该方法没有参数。

返回值

该方法返回包含无服务器云函数源代码描述结构上下文的字典实例。如果当前尚未配置源代码来源,该方法将始终返回 None。

异常

该方法不会主动引发任何异常。

示例

下面我们将通过一段 Python 代码向您演示如何使用该方法:

适用于

Tencent Cloud SDK for Python

产品软件包:tencent-cloud-sdk-serverless-functions >= 0.1.1

def get_code_context(self) -> dict
functions.FunctionCode().get_code_context()

FunctionCode 类

命名空间和模块:tencent.cloud.serverless.functions.client

简要

代表无服务器云函数源代码配置的类。通过利用该类,您可以快速指定无服务器云函数的源代码,而无需关注源代码数据类型。

class FunctionCode

构造

该类仅支持构造类实例后使用,其构造实例方法签名如下:

示例

在下文中我们将向您演示如何构造一个无服务器云函数源代码类实例并使用它。

适用于

Tencent Cloud SDK for Python

产品软件包:tencent-cloud-sdk-serverless-functions >= 0.1.1

def __init__(self)
from tencent.cloud.serverless import functions

# The method will return itself.

functions.FunctionCode().use_object_storage_bucket(
    region_id = 'ap-shanghai-1',
    bucket_name = 'scf-code',
    object_name = 'source.zip'
)

use_local_zip_archive 方法

命名空间和模块:tencent.cloud.serverless.functions.client.FunctionCode

简要

配置使用本机硬盘上的 ZIP 压缩档案文件作为无服务器云函数源代码来源。

参数

该方法具有以下参数,其参数、参数类型和参数描述如下:

返回值

该方法返回当前代表无服务器云函数源代码配置的 类实例本身。

异常

该方法可能会主动引发的异常类型如下:

ValueError

参数值或类型不符合预期。

IOError

给定 ZIP 压缩档案文件不存在或无法读取。

示例

下面我们将通过一段 Python 代码向您演示如何使用该方法:

适用于

Tencent Cloud SDK for Python

产品软件包:tencent-cloud-sdk-serverless-functions >= 0.1.1

use_object_storage_bucket 方法

命名空间和模块:tencent.cloud.serverless.functions.client.FunctionCode

简要

配置使用对象存储桶作为无服务器云函数源代码来源。

参数

该方法具有以下参数,其参数、参数类型和参数描述如下:

返回值

该方法返回当前代表无服务器云函数源代码配置的 类实例本身。

异常

该方法可能会主动引发的异常类型如下:

ValueError

参数值或类型不符合预期。

示例

下面我们将通过一段 Python 代码向您演示如何使用该方法:

适用于

Tencent Cloud SDK for Python

产品软件包:tencent-cloud-sdk-serverless-functions >= 0.1.1

def use_local_zip_archive(self,
    local_file_path: str
)
def use_object_storage_bucket(self,
    region_id: str,
    bucket_name: str,
    object_name: str
)

参数

类型

必选

描述

local_file_path

str

是

本机硬盘上的 ZIP 压缩档案文件路径。

FunctionCode

是

对象存储桶中用于作为无服务器云函数源代码 ZIP 档案文件的对象名称。

参数

类型

必选

描述

region_id

str

是

对象存储桶所在数据中心园区的可用区唯一标识符。

bucket_name

str

是

对象存储桶的完全名称,例如 scf-code-1000000000。

object_name

FunctionCode

str

functions.FunctionCode.use_local_zip_archive(
    local_file_path = './source.zip'
)
functions.FunctionCode.use_object_storage_bucket(
    region_id = 'ap-shanghai',
    bucket_name = 'scf-code-1000000000',
    object_name = 'source.zip'
)