函数工作流 FunctionGraph-示例2:创建函数和APIG触发器获取静态页面:步骤2:创建APIG触发器

时间:2023-11-01 16:25:44

步骤2:创建APIG触发器

URI:POST /v2/{project_id}/fgs/triggers/{function_urn}

API文档详情请参见:创建触发器

  • 请求示例
    POST  https://{Endpoint}/v2/{project_id}/fgs/triggers/{function_urn}{ "event_data": {  "group_id": "a9ad0d5df4d7475c9bc35a7c17d89304",  "env_id": "DEFAULT_ENVIRONMENT_RELEASE_ID",  "auth": "NONE",  "protocol": "HTTP",  "name": "API_GetHtml",  "path": "/test",  "match_mode": "SWA",  "req_method": "ANY",  "backend_type": "FUNCTION",  "sl_domain": "a9ad0d5df4d7475c9bc35a7c17d89304.apig.xxx.xxxapis.com",  "type": 1,  "env_name": "RELEASE" }, "event_type_code": "APICreated", "trigger_status": "ACTIVE", "trigger_type_code": "APIG"}

    function_urn为步骤1:创建一个返回的静态页面函数中记录的函数URN,group_id为API分组的ID,sl_domain为APIG给API分组分配的子 域名

  • 响应示例
    { "trigger_id": "1b3ec74b86454aa39001a9f89cc70ee2", "trigger_type_code": "APIG", "trigger_status": "ACTIVE", "event_data": {  "api_id": "cbc698153d1f4265bdd8384b5cf6e581",  "api_name": "API_GetHtml",  "auth": "NONE",  "env_id": "",  "env_name": "",  "func_info": {   "function_urn": "urn:fss:{project_name}:{project_id}:function:default:get_html",   "invocation_type": "sync",   "timeout": 5000,   "version": "latest"  },  "group_id": "a9ad0d5df4d7475c9bc35a7c17d89304",  "group_name": "APIGroup_gethtml",  "invoke_url": "http://a9ad0d5df4d7475c9bc35a7c17d89304.apig.xxx.xxxapis.com/test",  "match_mode": "SWA",  "name": "API_GetHtml",  "path": "/test",  "protocol": "HTTP",  "req_method": "ANY",  "triggerid": "1b3ec74b86454aa39001a9f89cc70ee2",  "type": 1 }, "last_updated_time": "2020-06-04T17:14:32+08:00", "created_time": "2020-06-04T17:14:32+08:00"}

    记录“invoke_url”的值。

support.huaweicloud.com/api-functiongraph/functiongraph_06_0203.html