Skip to content

Commit

Permalink
RSDK-6664 Get cloud metadata client (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximpertsov authored Feb 28, 2024
1 parent 99bea13 commit fe406de
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export {
type DialDirectConf,
type DialWebRTCConf,
type RobotStatusStream,
type CloudMetadata,
RobotClient,
createRobotClient,
} from './robot';
Expand Down
2 changes: 1 addition & 1 deletion src/robot.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
12 changes: 12 additions & 0 deletions src/robot/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
9 changes: 9 additions & 0 deletions src/robot/robot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<proto.Status[]>;
export type CloudMetadata = proto.GetCloudMetadataResponse.AsObject;

type Callback = (args: unknown) => void;

Expand Down Expand Up @@ -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<CloudMetadata>;
}

0 comments on commit fe406de

Please sign in to comment.