触发器操作
更新时间:2024-07-05
各接口的请求参数和响应参数说明请参考触发器操作。
获取触发器列表
如下代码用于获取触发器列表:
Plain Text
1public void testListTrigger(CfcClient cfcClient) {
2 String functionBrn = "brn:bce:cfc:bj:7c83a9530352900ef3e38db05f1c10e9:function:test-1557900680300:$LATEST";
3 ListTriggersResponse response = cfcClient.listTriggers(functionBrn);
4 System.out.println(response);
5 }
创建触发器
如下代码用于创建触发器:
Plain Text
1public void testCreateTrigger(CfcClient cfcClient) {
2 String target = "brn:bce:cfc:bj:7c83a9530352900ef3e38db05f1c10e9:function:test-1557900680300:$LATEST";
3 String source = "cfc-http-trigger/v1/CFCAPI";
4 HashMap<String, String> data = new HashMap<String, String>();
5 data.put("AuthType", "anonymous");
6 data.put("Method", "GET");
7 data.put("ResourcePath", "hello002");
8
9 CreateTriggerResponse response = cfcClient.createTrigger(target, source, data);
10 System.out.println(response);
11
12 }
更新触发器
如下代码用于更新触发器:
Plain Text
1public void testUpdateTrigger(CfcClient cfcClient) {
2 String relationId = "brn:bce:cfc-http-trigger:bj:7c83a9530352900ef3e38db05f1c10e9:ece4c25ee836060f84d60fcc4a5477fd/cfc/GET/hello002";
3 String source = "cfc-http-trigger/v1/CFCAPI";
4 String target = "brn:bce:cfc:bj:7c83a9530352900ef3e38db05f1c10e9:function:test-1557900680300:$LATEST";
5 HashMap<String, String> data = new HashMap<String, String>();
6 data.put("AuthType", "anonymous");
7 data.put("Method", "GET");
8 data.put("ResourcePath", "hello1");
9
10 UpdateTriggerResponse response = cfcClient.updateTrigger(relationId, target, source, data);
11 System.out.println(response);
12 }
删除触发器
如下代码用于删除触发器:
Plain Text
1public void testDeleteTrigger(CfcClient cfcClient) {
2 String relationId = "brn:bce:cfc-http-trigger:bj:7c83a9530352900ef3e38db05f1c10e9:ece4c25ee836060f84d60fcc4a5477fd/cfc/GET/hello1";
3 String source = "cfc-http-trigger/v1/CFCAPI";
4 String target = "brn:bce:cfc:bj:7c83a9530352900ef3e38db05f1c10e9:function:test-1557387367523:$LATEST";
5 cfcClient.deleteTrigger(target, source, relationId);
6 }