获取指定函数的所有触发器
功能介绍
获取指定函数的所有触发器设置。
调用方法
请参见如何调用API。
URI
GET /v2/{project_id}/fgs/triggers/{function_urn}
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
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 |
响应参数
状态码: 200
参数 |
参数类型 |
描述 |
---|---|---|
[数组元素] |
Array of ListFunctionTriggerResult objects |
参数解释: 查询函数触发器列表返回体。 取值范围: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
trigger_id |
String |
参数解释: 触发器ID。 取值范围: 不涉及。 |
trigger_type_code |
String |
参数解释: 触发器类型。 取值范围: |
trigger_status |
String |
参数解释: 触发器状态。 取值范围: |
event_data |
TriggerEventDataResponseBody object |
参数解释: 触发器属性返回体。 取值范围: 不涉及。 |
last_updated_time |
String |
参数解释: 最后更新时间。 取值范围: 时间字符串。 |
created_time |
String |
参数解释: 触发器创建时间。 取值范围: 时间字符串。 |
参数 |
参数类型 |
描述 |
---|---|---|
name |
String |
参数解释: 触发器名称。 取值范围: 不涉及。 |
schedule_type |
String |
参数解释: 定时触发类型(TIMER触发器参数)。 取值范围: |
schedule |
String |
参数解释: 定时触发规则(TIMER触发器参数)。 取值范围: |
user_event |
String |
参数解释: 附加信息(TIMER触发器参数)。 当Timer触发器触发函数执行时,执行事件(函数的event参数)为: {"version": "v1.0", "time": "2018-06-01T08:30:00+08:00", "trigger_type": "TIMER", "trigger_name": "Timer_001", "user_event": "您输入的附加信息"} 取值范围: 不涉及。 |
triggerid |
String |
参数解释: APIG触发器id。(APIG触发器参数) 取值范围: 不涉及。 |
type |
Integer |
参数解释: API接口类型(APIG触发器参数)。 取值范围: |
path |
String |
参数解释: APIG接口PATH路径(APIG触发器参数)。 取值范围: 需要符合uri的命名规则。 |
protocol |
String |
参数解释: API的请求协议(APIG触发器参数)。 取值范围: |
req_method |
String |
参数解释: API的请求方式(APIG触发器参数)。 取值范围: |
group_id |
String |
参数解释: API所属的分组编号(APIG触发器参数)。 取值范围: 不涉及。 |
group_name |
String |
参数解释: API所属的分组名称(APIG触发器参数)。 取值范围: 不涉及。 |
match_mode |
String |
参数解释: API的匹配方式(APIG触发器参数)。 取值范围: |
env_name |
String |
参数解释: API的发布环境(APIG触发器参数)。 取值范围: 不涉及。 |
env_id |
String |
参数解释: API的发布环境id(APIG触发器参数)。 取值范围: 不涉及。 |
api_id |
String |
参数解释: API编号(APIG触发器参数)。 取值范围: 不涉及。 |
api_name |
String |
参数解释: API名称(APIG触发器参数)。 取值范围: 不涉及。 |
auth |
String |
参数解释: API的认证方式(APIG触发器参数)。 取值范围: |
invoke_url |
String |
参数解释: API调用地址(APIG触发器参数)。 取值范围: 不涉及。 |
func_info |
ApigTriggerFuncInfo object |
参数解释: apig触发器对应的函数后端信息。 取值范围: 不涉及。 |
sl_domain |
String |
参数解释: APIG系统默认分配的子域名(APIG触发器参数)。 取值范围: 不涉及。 |
backend_type |
String |
参数解释: API的后端类型(APIG触发器参数)。 取值范围: 目前固定为FUNCTION。 |
instance_id |
String |
参数解释: 实例id。DDS、KAFKA、RABBITMQ、ROCKETMQ触发器此参数必填。 取值范围: |
instance_ip |
String |
参数解释: 数据库ip地址(DYNAMODB触发器参数)。 取值范围: 不涉及。 |
table_name |
String |
参数解释: 数据库表名(DYNAMODB触发器参数)。 取值范围: 不涉及。 |
roma_app_id |
String |
参数解释: API归属的集成应用编号。(APIG触发器参数) 取值范围: 不涉及。 |
operations |
Array of strings |
参数解释: 自定义操作(CTS触发器参数)。 CTS云审计服务类型和操作订阅所需要的事件通知,当CTS云审计服务获取已订阅的操作记录后,通过CTS触发器将采集到的操作记录作为参数传递来调用FunctionGraph函数。 取值范围: 不涉及。 |
collection_name |
String |
参数解释: 集合名称(DDS触发器参数)。 取值范围: 不涉及。 |
db_name |
String |
参数解释: 文档数据库名称(DDS触发器参数)。 取值范围: 不涉及。 |
db_password |
String |
参数解释: 文档数据库密码(DDS触发器参数)。 取值范围: 不涉及。 |
db_user |
String |
参数解释: 文档数据库用户名(DDS触发器参数)。 取值范围: 不涉及。 |
instance_addrs |
Array of strings |
参数解释: 文档数据库实例地址(DDS触发器参数)。 取值范围: 不涉及。 |
mode |
String |
参数解释: 文档数据库实例类型(DDS触发器参数)。 取值范围: |
batch_size |
Integer |
参数解释: 批处理大小,单次函数执行处理的最大数据量。DIS、DDS、KAFKA、RABBITMQ、ROCKETMQ触发器此参数必填。 取值范围: |
queue_id |
String |
参数解释: 队列id(DMS触发器参数)。 取值范围: 不涉及。 |
consumer_group_id |
String |
参数解释: 消费组id(DMS触发器参数)。 取值范围: 不涉及。 |
polling_interval |
Integer |
参数解释: 拉取周期。 取值范围: 不涉及。 |
stream_name |
String |
参数解释: 通道名称(DIS触发器参数)。 取值范围: 不涉及。 |
sharditerator_type |
String |
参数解释: 起始位置(DIS/DYNAMODB触发器参数)。 取值范围: |
polling_unit |
String |
参数解释: 拉取周期单位(DIS触发器参数)。 取值范围: |
max_fetch_bytes |
Integer |
参数解释: 最大提取字节数(DIS触发器参数)。 取值范围: 不涉及。 |
is_serial |
String |
参数解释: 串行处理数据(DIS触发器参数)。 取值范围: |
log_group_id |
String |
参数解释: 日志组id(LTS触发器参数)。 取值范围: 不涉及。 |
log_topic_id |
String |
参数解释: 日志流id(LTS触发器参数)。 取值范围: 不涉及。 |
bucket |
String |
参数解释: 桶名称(OBS触发器参数),用作事件源的OBS存储桶,不能和本用户已有桶重名;不能和其他用户已有的桶重名;创建成功后不支持修改。 取值范围: 不涉及。 |
prefix |
String |
参数解释: 前缀(OBS触发器参数),输入一个可选性前缀来限制对以此关键字开头的对象的通知。 取值范围: 不涉及。 |
suffix |
String |
参数解释: 后缀(OBS触发器参数),输入一个可选性后缀来限制对以此关键字结尾的对象的通知。 取值范围: 不涉及。 |
events |
Array of strings |
参数解释: 触发事件(OBS触发器参数)。 取值范围: |
topic_urn |
String |
参数解释: 主题URN(SMN触发器参数)。 取值范围: 不涉及。 |
topic_ids |
Array of strings |
参数解释: KAFKA主题id列表(KAFKA触发器参数)。 取值范围: 不涉及。 |
kafka_user |
String |
参数解释: KAFKA账户名(KAFKA触发器参数)。 取值范围: 不涉及。 |
kafka_password |
String |
参数解释: KAFKA账户密码(KAFKA触发器参数)。 取值范围: 不涉及。 |
kafka_connect_address |
String |
参数解释: KAFKA实例连接IP地址(KAFKA触发器参数)。 取值范围: 不涉及。 |
kafka_ssl_enable |
Boolean |
参数解释: KAFKA连接是否开启安全认证(KAFKA触发器参数)。 取值范围: 不涉及。 |
access_password |
String |
参数解释: RABBITMQ账户密码(RABBITMQ触发器参数)。 取值范围: 不涉及。 |
access_user |
String |
参数解释: RABBITMQ账户名(RABBITMQ触发器参数)。 取值范围: 不涉及。 |
connect_address |
String |
参数解释: 实例连接IP地址(RABBITMQ触发器参数)。 取值范围: 不涉及。 |
exchange_name |
String |
参数解释: 交换机名称(RABBITMQ触发器参数)。 取值范围: 不涉及。 |
vhost |
String |
参数解释: 虚拟机名称(RABBITMQ触发器参数)。 取值范围: 不涉及。 |
ssl_enable |
Boolean |
参数解释: RABBITMQ连接是否开启安全认证(RABBITMQ触发器参数)。 取值范围: |
enable_acl |
Boolean |
参数解释: ROCKETMQ连接是否开启用户名密码认证(ROCKETMQ触发器参数)。 取值范围: -false:不开启。 |
access_key |
String |
参数解释: 连接用户名(ROCKETMQ触发器参数),enable_acl为true时此参数必填。 取值范围: 不涉及。 |
secret_key |
String |
参数解释: 连接密码(ROCKETMQ触发器参数),enable_acl为true时此参数必填。 取值范围: 不涉及。 |
Key_encode |
Boolean |
参数解释: EG obs触发器是否对对象加密(EVENTGRID触发器参数)。 取值范围: |
agency |
String |
参数解释: 使用的代理(EVENTGRID触发器参数)。 取值范围: 不涉及。 |
channel_name |
String |
参数解释: 通道名称(EVENTGRID触发器参数)。 取值范围: 不涉及。 |
channel_id |
String |
参数解释: 通道id(EVENTGRID触发器参数)。 取值范围: 不涉及。 |
source_name |
String |
参数解释: 事件源名称(EVENTGRID触发器参数)。 取值范围: 不涉及。 |
created_time |
String |
参数解释: 创建时间(EVENTGRID触发器参数)。 取值范围: 时间字符串。 |
status |
String |
参数解释: 触发器状态(EVENTGRID触发器参数)。 取值范围: |
trigger_name |
String |
参数解释: 触发器名称(EVENTGRID触发器参数)。 取值范围: 不涉及。 |
event_types |
Array of strings |
参数解释: 事件类型(EVENTGRID触发器参数)。 取值范围: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
function_urn |
String |
参数解释: 函数的URN,详细解释见FunctionGraph函数模型的描述。 取值范围: 不涉及。 |
invocation_type |
String |
参数解释: 调用函数执行方式。 取值范围: |
timeout |
Integer |
参数解释: API网关请求函数服务的超时时间(毫秒)。APIG触发器此参数必填。 取值范围: 1~60000秒。 |
version |
String |
参数解释: 函数版本信息。 取值范围: 不涉及。 |
状态码: 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 |
错误信息 |
请求示例
查询指定函数所有触发器。
GET https://{Endpoint}/v2/{project_id}/fgs/triggers/{function_urn}
响应示例
状态码: 200
OK
[ {
"trigger_id" : "1b3b264db3b849118d007884b9bc8a60",
"trigger_type_code" : "APIG",
"trigger_status" : "ACTIVE",
"event_data" : {
"api_id" : "4a59f6a7263c4d1dab3f69c34f98d949",
"api_name" : "API_test_triggers",
"auth" : "IAM",
"env_id" : "DEFAULT_ENVIRONMENT_RELEASE_ID",
"env_name" : "RELEASE",
"func_info" : {
"function_urn" : "urn:fss:xxxxx:46b6f338fc3445b8846c71dfb1fbxxxx:function:default:test_triggers",
"invocation_type" : "sync",
"timeout" : 5000,
"version" : "latest"
},
"group_id" : "9205f83fe721481eb490870d380cf31d",
"group_name" : "APIGroup_2mbe",
"invoke_url" : "https://ed94ae9494ba4f70ac24224747202140.{apig_endpoint}/test_triggers",
"match_mode" : "SWA",
"name" : "API_test_triggers",
"path" : "/test_triggers",
"protocol" : "HTTPS",
"req_method" : "ANY",
"triggerid" : "1b3b264db3b849118d007884b9bc8a60",
"type" : 1
},
"last_updated_time" : "2022-11-09 16:37:24",
"created_time" : "2022-11-09 16:37:24"
} ]
SDK代码示例
SDK代码示例如下。
Java
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 |
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 ListFunctionTriggersSolution {
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();
ListFunctionTriggersRequest request = new ListFunctionTriggersRequest();
try {
ListFunctionTriggersResponse response = client.listFunctionTriggers(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
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 |
# 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 = ListFunctionTriggersRequest()
response = client.list_function_triggers(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
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 |
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.ListFunctionTriggersRequest{}
response, err := client.ListFunctionTriggers(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 服务内部错误。 |
错误码
请参见错误码。