[Service] Add edge orchestration interface 44/245644/10
authorYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 13 Oct 2020 09:35:00 +0000 (02:35 -0700)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Nov 2020 06:53:36 +0000 (22:53 -0800)
This provides initial edge orchestration interface.

Change-Id: I44df11d7769e9ed692790cd9efd6735a97de94c5
Signed-off-by: Youngsoo Choi <kenshin.choi@samsung.com>
wrt_app/service/device_api_router.ts

index 7cb70cb..a7e3563 100644 (file)
@@ -52,9 +52,34 @@ export class DeviceAPIRouter {
     global.webapis.getPackageId = () => {
       return this.packageId;
     }
+    this.initEdgeWebapis();
     this.initProductWebapis();
   }
 
+  initEdgeWebapis() {
+    if (wrt['edge'] && !global.webapis.edge) {
+      let edge = wrt.edge as NativeWRTjs.EdgeExtension;
+      global.webapis.edge = {
+        orchestrationGetDevicelist: (service_name: string, exec_type: string) => {
+          return edge.orchestrationGetDevicelist(service_name, exec_type);
+        },
+        orchestrationReadCapability: (ip: string) => {
+          return edge.orchestrationReadCapability(ip);
+        },
+        orchestrationRequestService: (app_name: string, self_select: boolean, exec_type: string, exec_parameter: string) => {
+          return edge.orchestrationRequestService(app_name, self_select, exec_type, exec_parameter);
+        },
+        orchestrationRequestServiceOnDevice: (app_name: string, self_select: boolean, exec_type: string, exec_parameter: string, ip: string) => {
+          return edge.orchestrationRequestServiceOnDevice(app_name, self_select, exec_type, exec_parameter, ip);
+        },
+        orchestrationWriteCapability: (json: string) => {
+          return edge.orchestrationWriteCapability(json);
+        },
+      }
+      Object.defineProperty(global.webapis, 'edge', { writable: false, enumerable: true });
+    }
+  }
+
   initProductWebapis() {
     // for TV profile
     if (wrt.tv && !global.webapis.productinfo) {