From fe406de6c89bbc7787d96c5e6eb16a48caceeaf2 Mon Sep 17 00:00:00 2001 From: Maxim Pertsov Date: Wed, 28 Feb 2024 13:30:44 -0500 Subject: [PATCH] RSDK-6664 Get cloud metadata client (#248) --- src/main.ts | 1 + src/robot.ts | 2 +- src/robot/client.ts | 12 ++++++++++++ src/robot/robot.ts | 9 +++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index cd363e02a..f79062b01 100644 --- a/src/main.ts +++ b/src/main.ts @@ -16,6 +16,7 @@ export { type DialDirectConf, type DialWebRTCConf, type RobotStatusStream, + type CloudMetadata, RobotClient, createRobotClient, } from './robot'; diff --git a/src/robot.ts b/src/robot.ts index ebd5ca687..de425fd6f 100644 --- a/src/robot.ts +++ b/src/robot.ts @@ -1,4 +1,4 @@ -export type { Robot, RobotStatusStream } from './robot/robot'; +export type { Robot, RobotStatusStream, CloudMetadata } from './robot/robot'; export { RobotClient } from './robot/client'; export { type DialConf, diff --git a/src/robot/client.ts b/src/robot/client.ts index 2ce3edd91..6b34f6d22 100644 --- a/src/robot/client.ts +++ b/src/robot/client.ts @@ -704,6 +704,18 @@ export class RobotClient extends EventDispatcher implements Robot { return response.getDiscoveryList(); } + // GET CLOUD METADATA + + async getCloudMetadata() { + const { robotService } = this; + const request = new proto.GetCloudMetadataRequest(); + const response = await promisify< + proto.GetCloudMetadataRequest, + proto.GetCloudMetadataResponse + >(robotService.getCloudMetadata.bind(robotService), request); + return response.toObject(); + } + // RESOURCES async resourceNames() { diff --git a/src/robot/robot.ts b/src/robot/robot.ts index a343e6933..c924cfccc 100644 --- a/src/robot/robot.ts +++ b/src/robot/robot.ts @@ -9,6 +9,7 @@ import type proto from '../gen/robot/v1/robot_pb'; import type { ResponseStream } from '../gen/robot/v1/robot_pb_service'; export type RobotStatusStream = ResponseStream; +export type CloudMetadata = proto.GetCloudMetadataResponse.AsObject; type Callback = (args: unknown) => void; @@ -164,4 +165,12 @@ export interface Robot { type: typeof RECONNECTED | typeof DISCONNECTED, listener: Callback ) => void; + + /** + * Get app-related information about the robot. + * + * @group App/Cloud + * @alpha + */ + getCloudMetadata(): Promise; }