@@ -2,59 +2,71 @@ import 'dart:async';
2
2
3
3
import '../gen/app/v1/app.pbgrpc.dart' ;
4
4
5
+ /// gRPC client for connecting to Viam's App Service
6
+ ///
7
+ /// All calls must be authenticated.
5
8
class AppClient {
6
9
final AppServiceClient _client;
7
10
8
11
AppClient (this ._client);
9
12
13
+ /// List all the [Organization] the currently authenticated user has access to
10
14
Future <List <Organization >> listOrganizations () async {
11
15
final listOrganizationsRequest = ListOrganizationsRequest ();
12
16
final ListOrganizationsResponse response = await _client.listOrganizations (listOrganizationsRequest);
13
17
return response.organizations;
14
18
}
15
19
20
+ /// Get a specific [Organization] by ID
16
21
Future <Organization > getOrganization (String organizationId) async {
17
22
final getOrganizationRequest = GetOrganizationRequest ()..organizationId = organizationId;
18
23
final GetOrganizationResponse response = await _client.getOrganization (getOrganizationRequest);
19
24
return response.organization;
20
25
}
21
26
27
+ /// List the [Location] of a specific [Organization] that the currently authenticated user has access to
22
28
Future <List <Location >> listLocations (Organization organization) async {
23
29
final listLocationsRequest = ListLocationsRequest ()..organizationId = organization.id;
24
30
final ListLocationsResponse response = await _client.listLocations (listLocationsRequest);
25
31
return response.locations;
26
32
}
27
33
34
+ /// Get a specific [Location] by ID
28
35
Future <Location > getLocation (String locationId) async {
29
36
final getLocationRequest = GetLocationRequest ()..locationId = locationId;
30
37
final GetLocationResponse response = await _client.getLocation (getLocationRequest);
31
38
return response.location;
32
39
}
33
40
41
+ /// List the [Robot] of a specific [Location] that the currently authenticated user has access to
34
42
Future <List <Robot >> listRobots (Location location) async {
35
43
final listRobotsRequest = ListRobotsRequest ()..locationId = location.id;
36
44
final ListRobotsResponse response = await _client.listRobots (listRobotsRequest);
37
45
return response.robots;
38
46
}
39
47
48
+ /// Get a specific [Robot] by ID
40
49
Future <Robot > getRobot (String robotId) async {
41
50
final getRobotRequest = GetRobotRequest ()..id = robotId;
42
51
final GetRobotResponse response = await _client.getRobot (getRobotRequest);
43
52
return response.robot;
44
53
}
45
54
55
+ /// List the [RobotPart] of a specific [Robot] that the currently authenticated user has access to
46
56
Future <List <RobotPart >> listRobotParts (Robot robot) async {
47
57
final getRobotPartsRequest = GetRobotPartsRequest ()..robotId = robot.id;
48
58
final response = await _client.getRobotParts (getRobotPartsRequest);
49
59
return response.parts;
50
60
}
51
61
62
+ /// Get a specific [RobotPart] by ID
52
63
Future <RobotPart > getRobotPart (String partId) async {
53
64
final getRobotPartRequest = GetRobotPartRequest ()..id = partId;
54
65
final response = await _client.getRobotPart (getRobotPartRequest);
55
66
return response.part;
56
67
}
57
68
69
+ /// Get a stream of [LogEntry] for a specific [RobotPart] . Logs are sorted by descending time (newest first)
58
70
Stream <List <LogEntry >> tailLogs (RobotPart part, {bool errorsOnly = false }) {
59
71
final request = TailRobotPartLogsRequest ()
60
72
..id = part.id
0 commit comments