更新时间:2024-11-12 GMT+08:00
java模板
package com.huawei.demo; import com.huawei.services.runtime.Context; import com.huawei.services.runtime.entity.apig.APIGTriggerEvent; import com.huawei.services.runtime.entity.apig.APIGTriggerResponse; import com.huawei.services.runtime.entity.dis.DISTriggerEvent; import com.huawei.services.runtime.entity.dms.DMSTriggerEvent; import com.huawei.services.runtime.entity.lts.LTSTriggerEvent; import com.huawei.services.runtime.entity.smn.SMNTriggerEvent; import com.huawei.services.runtime.entity.timer.TimerTriggerEvent; import java.io.UnsupportedEncodingException; import java.util.HashMap; import java.util.Map; public class TriggerTests { public APIGTriggerResponse apigTest(APIGTriggerEvent event, Context context) { System.out.println(event); Map<String, String> headers = new HashMap<>(); headers.put("Content-Type", "application/json"); return new APIGTriggerResponse(200, headers, event.toString()); } public String smnTest(SMNTriggerEvent event, Context context) { System.out.println(event); return "ok"; } public String dmsTest(DMSTriggerEvent event, Context context) { System.out.println(event); return "ok"; } public String timerTest(TimerTriggerEvent event, Context context) { System.out.println(event); return "ok"; } public String disTest(DISTriggerEvent event, Context context) throws UnsupportedEncodingException { System.out.println(event); System.out.println(event.getMessage().getRecords()[0].getRawData()); return "ok"; } public String ltsTest(LTSTriggerEvent event, Context context) throws UnsupportedEncodingException { System.out.println(event); System.out.println("raw data: " + event.getLts().getRawData()); return "ok"; } }
父主题: Java