Skip to content

Commit 3b05c5d

Browse files
[APP-8687] Add ListMachineSummaries (#580)
Co-authored-by: Naveed Jooma <[email protected]>
1 parent 98999c4 commit 3b05c5d

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

src/app/app-client.spec.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,47 @@ describe('AppClient tests', () => {
11051105
});
11061106
});
11071107

1108+
describe('listMachineSummaries tests', () => {
1109+
const locSummary1 = new pb.LocationSummary({});
1110+
const locSummary2 = new pb.LocationSummary({});
1111+
const locationSummaries = [locSummary1, locSummary2];
1112+
let capturedReq: pb.ListMachineSummariesRequest | undefined;
1113+
1114+
beforeEach(() => {
1115+
mockTransport = createRouterTransport(({ service }) => {
1116+
service(AppService, {
1117+
listMachineSummaries: (req: pb.ListMachineSummariesRequest) => {
1118+
capturedReq = req;
1119+
return new pb.ListMachineSummariesResponse({ locationSummaries });
1120+
},
1121+
});
1122+
});
1123+
});
1124+
1125+
it('returns location summaries with only organizationId', async () => {
1126+
const response = await subject().listMachineSummaries('orgId');
1127+
expect(response).toEqual(locationSummaries);
1128+
expect(capturedReq?.organizationId).toEqual('orgId');
1129+
expect(capturedReq?.fragmentIds).toEqual([]);
1130+
expect(capturedReq?.locationIds).toEqual([]);
1131+
expect(capturedReq?.limit).toBeUndefined();
1132+
});
1133+
1134+
it('returns location summaries with all filters', async () => {
1135+
const response = await subject().listMachineSummaries(
1136+
'orgId',
1137+
['frag1', 'frag2'],
1138+
['loc1'],
1139+
5
1140+
);
1141+
expect(response).toEqual(locationSummaries);
1142+
expect(capturedReq?.organizationId).toEqual('orgId');
1143+
expect(capturedReq?.fragmentIds).toEqual(['frag1', 'frag2']);
1144+
expect(capturedReq?.locationIds).toEqual(['loc1']);
1145+
expect(capturedReq?.limit).toEqual(5);
1146+
});
1147+
});
1148+
11081149
describe('newRobot tests', () => {
11091150
beforeEach(() => {
11101151
mockTransport = createRouterTransport(({ service }) => {

src/app/app-client.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ import {
3434
RotateKeyResponse,
3535
RoverRentalRobot,
3636
Visibility,
37+
ListMachineSummariesRequest,
38+
LocationSummary,
3739
} from '../gen/app/v1/app_pb';
3840
import type { LogEntry } from '../gen/common/v1/common_pb';
3941

@@ -2240,4 +2242,41 @@ export class AppClient {
22402242
): Promise<GetAppBrandingResponse> {
22412243
return this.client.getAppBranding({ publicNamespace, name });
22422244
}
2245+
2246+
/**
2247+
* Lists machine summaries for an organization, optionally filtered by
2248+
* fragment IDs, location IDs, and limit.
2249+
*
2250+
* @example
2251+
*
2252+
* ```ts
2253+
* const summaries = await appClient.listMachineSummaries(
2254+
* 'orgId',
2255+
* ['frag1'],
2256+
* ['loc1'],
2257+
* 10
2258+
* );
2259+
* ```
2260+
*
2261+
* @param organizationId The ID of the organization
2262+
* @param fragmentIds Optional list of fragment IDs to filter machines
2263+
* @param locationIds Optional list of location IDs to filter machines
2264+
* @param limit Optional max number of machines to return
2265+
* @returns The list of location summaries
2266+
*/
2267+
async listMachineSummaries(
2268+
organizationId: string,
2269+
fragmentIds?: string[],
2270+
locationIds?: string[],
2271+
limit?: number
2272+
): Promise<LocationSummary[]> {
2273+
const req: ListMachineSummariesRequest = new ListMachineSummariesRequest({
2274+
organizationId,
2275+
fragmentIds,
2276+
locationIds,
2277+
limit,
2278+
});
2279+
const resp = await this.client.listMachineSummaries(req);
2280+
return resp.locationSummaries;
2281+
}
22432282
}

0 commit comments

Comments
 (0)