Skip to content

Commit 1b23635

Browse files
authored
APP-8364: Implement getRobotPartByNameAndLocation (#566)
1 parent 36d720a commit 1b23635

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

src/app/app-client.spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,29 @@ describe('AppClient tests', () => {
793793
});
794794
});
795795

796+
describe('getRobotPartByNameAndLocation tests', () => {
797+
const expectedResponse = new pb.GetRobotPartByNameAndLocationResponse({
798+
part: robotPart,
799+
});
800+
beforeEach(() => {
801+
mockTransport = createRouterTransport(({ service }) => {
802+
service(AppService, {
803+
getRobotPartByNameAndLocation: () => {
804+
return expectedResponse;
805+
},
806+
});
807+
});
808+
});
809+
810+
it('getRobotPartByNameAndLocation', async () => {
811+
const response = await subject().getRobotPartByNameAndLocation(
812+
'name',
813+
'locationId'
814+
);
815+
expect(response).toEqual(expectedResponse);
816+
});
817+
});
818+
796819
describe('getRobotPartLogs tests', () => {
797820
const expectedResponse = new pb.GetRobotPartLogsResponse({
798821
logs: [logEntry],

src/app/app-client.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
GetAppContentResponse,
1616
GetRobotPartLogsResponse,
1717
GetRobotPartResponse,
18+
GetRobotPartByNameAndLocationResponse,
1819
ListOrganizationMembersResponse,
1920
Location,
2021
LocationAuth,
@@ -848,6 +849,32 @@ export class AppClient {
848849
return this.client.getRobotPart({ id });
849850
}
850851

852+
/**
853+
* Queries a specific robot part by name and location id.
854+
*
855+
* @example
856+
*
857+
* ```ts
858+
* const robotPart = await appClient.getRobotPartByNameAndLocation(
859+
* '<YOUR-ROBOT-PART-NAME>',
860+
* '<YOUR-LOCATION-ID>'
861+
* );
862+
* ```
863+
*
864+
* For more information, see [App
865+
* API](https://docs.viam.com/dev/reference/apis/fleet/#getrobotpartbynameandlocation).
866+
*
867+
* @param name The name of the requested robot part
868+
* @param locationId The ID of the location of the requested robot part
869+
* @returns The robot part
870+
*/
871+
async getRobotPartByNameAndLocation(
872+
name: string,
873+
locationId: string
874+
): Promise<GetRobotPartByNameAndLocationResponse> {
875+
return this.client.getRobotPartByNameAndLocation({ name, locationId });
876+
}
877+
851878
/**
852879
* Get a page of log entries for a specific robot part. Logs are sorted by
853880
* descending time (newest first).

0 commit comments

Comments
 (0)