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