tencent-serverless-python
腾讯云云函数SDK,集成云函数业务流接口
Install
pip install tencentserverless
Example01
本地测试:
from tencentserverless import scf
from tencentserverless.exception import TencentServerlessSDKException
try:
data = scf.invoke('test',secret_id="your secret id",
secret_key="your secret key", data={"a":"b"})
print data
except TencentServerlessSDKException as e:
print e
except TencentCloudSDKException as e:
print e
except Exception as e:
print e
云函数环境测试:
from tencentserverless.scf import invoke
from tencentserverless.exception import TencentServerlessSDKException
try:
data = invoke('test', data={"a":"b"})
print data
except TencentServerlessSDKException as e:
print e
except TencentCloudSDKException as e:
print e
except Exception as e:
print e
Example02
本地测试:
from tencentserverless.scf import client
from tencentserverless.exception import TencentServerlessSDKException
scf = client(secret_id="your secret id",
secret_key="your secret key")
try:
data = scf.invoke('test',data={"a":"b"})
print data
except TencentServerlessSDKException as e:
print e
except TencentCloudSDKException as e:
print e
except Exception as e:
print e
云函数环境测试:
from tencentserverless.scf import client
from tencentserverless.exception import TencentServerlessSDKException
scf = client()
try:
data = scf.invoke('test',data={"a":"b"})
print data
except TencentServerlessSDKException as e:
print e
except TencentCloudSDKException as e:
print e
except Exception as e:
print e
API Reference
client
- [init]
Params:
| 参数名 | 是否必填 | 类型 | 描述 |
|---|---|---|---|
| region | 否 | string | 地域信息,默认与调用接口的函数所属地域相同,本地调用默认是广州 |
| secret_id | 否 | string | 用户 secret_id, 默认是从云函数环境变量中获取,本地调试必填 |
| secret_key | 否 | string | 用户 secret_key, 默认是从云函数环境变量中获取,本地调试必填 |
| token | 否 | string | 用户 token,默认是从云函数环境变量中获取 |
- [invoke]
Params:
| 参数名 | 是否必填 | 类型 | 描述 |
|---|---|---|---|
| function_name | 是 | string | 函数名称 |
| qualifier | 否 | string | 函数版本,默认为$LATEST |
| data | 否 | 对象 | 函数运行入参,必须可以被json.dumps的对象 |
| namespace | 否 | string | 命名空间,默认为default |
Invoke
调用函数。暂时只支持同步调用。
Params:
| 参数名 | 是否必填 | 类型 | 描述 |
|---|---|---|---|
| region | 否 | string | 地域信息,默认与调用接口的函数所属地域相同,本地调用默认是广州 |
| secret_id | 否 | string | 用户 secret_id, 默认是从云函数环境变量中获取,本地调试必填 |
| secret_key | 否 | string | 用户 secret_key, 默认是从云函数环境变量中获取,本地调试必填 |
| token | 否 | string | 用户 token,默认是从云函数环境变量中获取 |
| function_name | 是 | string | 函数名称 |
| qualifier | 否 | string | 函数版本,默认为$LATEST |
| data | 否 | string | 函数运行入参,必须可以被json.dumps的对象 |
| namespace | 否 | string | 命名空间,默认为default |
TencentServerlessSDKException
属性
- [code]
- [message]
- [request_id]
- [response]
- [stack_trace]
方法
- [get_code]
返回错误码信息
- [get_message]
返回错误信息
- [get_request_id]
返回request_id信息
- [get_response]
返回response信息
- [get_stack_trace]
返回stack_trace信息
TODO List
- 支持管理流接口
Licence
Metadata
Release files for tencentserverless 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tencentserverless-0.1.7.tar.gz | 4.9 kB | Without provenance | Details for tencentserverless-0.1.7.tar.gz |
Release files / tencentserverless-0.1.7.tar.gz
| Download URL | tencentserverless-0.1.7.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2db7880c64a1b8cdd607b0560d895c68117173afc54bc7434a5133d64671b51c
|
|
BLAKE2b-256 checksum How to use checksums |
9ae01a190567e94a9dddb66d9257918b89691f4c4c53716fa12af85dbe8cb5e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.5
|
Security for tencentserverless 0.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.