Updated on 2024-11-12 GMT+08:00
Java Template
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"; } }
Parent topic: Java
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.
The system is busy. Please try again later.