函数工作流 FunctionGraph-创建触发器:请求示例

时间:2025-02-12 15:14:29

请求示例

  • 创建名为obs-event-1ec7的obs触发器,触发事件为input-picture2桶中有新文件上传。
    POST https://{Endpoint}/v2/{project_id}/fgs/triggers/{function_urn}{  "trigger_type_code" : "OBS",  "trigger_status" : "ACTIVE",  "event_data" : {    "bucket" : "input-picture2",    "events" : [ "s3:ObjectCreated:*" ],    "name" : "obs-event-1ec7"  }}
  • 创建名为API_test_function的apig共享版触发器,创建无认证方式的临时 域名 ,超时时间为5000s。
    POST https://{Endpoint}/v2/{project_id}/fgs/triggers/{function_urn}{  "trigger_type_code" : "APIG",  "trigger_status" : "ACTIVE",  "event_data" : {    "func_info" : {      "timeout" : 5000    },    "name" : "API_test_function",    "env_id" : "DEFAULT_ENVIRONMENT_RELEASE_ID",    "env_name" : "RELEASE",    "protocol" : "HTTPS",    "auth" : "NONE",    "group_id" : "318b09eb214a41488c667ecd51667e3x",    "sl_domain" : "318b09eb214a41488c667ecd51667e3x.apig.{region}.example.com",    "match_mode" : "SWA",    "req_method" : "ANY",    "backend_type" : "FUNCTION",    "type" : 1,    "path" : "/test_gxz_v1_billing"  }}
  • 创建名为API_test_function的apig专享版触发器,创建无认证方式的临时域名,超时时间为5000s。
    POST https://{Endpoint}/v2/{project_id}/fgs/triggers/{function_urn}{  "trigger_type_code" : "DEDICATEDGATEWAY",  "trigger_status" : "ACTIVE",  "event_data" : {    "func_info" : {      "timeout" : 5000    },    "name" : "API_test_function",    "env_id" : "DEFAULT_ENVIRONMENT_RELEASE_ID",    "env_name" : "RELEASE",    "protocol" : "HTTPS",    "auth" : " IAM ",    "group_id" : "5106210cf79e4xxxx",    "sl_domain" : "5106210cf79e4xxxx.apic.{region_id}.example.com",    "match_mode" : "SWA",    "req_method" : "ANY",    "backend_type" : "FUNCTION",    "type" : 1,    "path" : "/test_gxz_v1_billing"  }}
  • 创建86ad3efcxx实例的kafka触发器,从PUSH_TOKEN_RECORD消费组中拉取消息触发函数执行。
    POST https://{Endpoint}/v2/{project_id}/fgs/triggers/{function_urn}{  "trigger_type_code" : "KAFKA",  "trigger_status" : "DISABLED",  "event_data" : {    "instance_id" : "86ad3efc-c019-460e-91e7-317b1a89f95x",    "topic_ids" : [ "PUSH_TOKEN_RECORD" ],    "batch_size" : 100  }}
  • 创建timer触发器,每3分钟触发一次函数执行。
    POST https://{Endpoint}/v2/{project_id}/fgs/triggers/{function_urn}{  "trigger_type_code" : "TIMER",  "trigger_status" : "ACTIVE",  "event_data" : {    "name" : "Timer-l8v2",    "schedule" : "3m",    "schedule_type" : "Rate"  }}
  • 创建指定lts触发器(需配置访问LTS服务权限的委托)。
    POST https://{Endpoint}/v2/{project_id}/fgs/triggers/{function_urn}{  "trigger_type_code" : "LTS",  "trigger_status" : "ACTIVE",  "event_data" : {    "log_group_id" : "ccd3fa30-7c86-4590-8a9d-XXX",    "log_topic_id" : "5b4944dd-9603-481d-9b91-XXX"  }}
  • 创建指定smn触发器。
    POST https://{Endpoint}/v2/{project_id}/fgs/triggers/{function_urn}{  "trigger_type_code" : " SMN ",  "trigger_status" : "ACTIVE",  "event_data" : {    "topic_urn" : "urn:smn:{region}:{project_id}:Failed_times"  }}
support.huaweicloud.com/api-functiongraph/functiongraph_06_0122.html