bosdyn-scout 3.3.2__py3-none-any.whl → 4.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bosdyn/scout/client.py +708 -331
- bosdyn/scout/exceptions.py +3 -11
- bosdyn/scout/utils.py +161 -139
- {bosdyn_scout-3.3.2.dist-info → bosdyn_scout-4.0.1.dist-info}/METADATA +2 -1
- bosdyn_scout-4.0.1.dist-info/RECORD +9 -0
- {bosdyn_scout-3.3.2.dist-info → bosdyn_scout-4.0.1.dist-info}/WHEEL +1 -1
- bosdyn_scout-3.3.2.dist-info/RECORD +0 -9
- {bosdyn_scout-3.3.2.dist-info → bosdyn_scout-4.0.1.dist-info}/top_level.txt +0 -0
bosdyn/scout/client.py
CHANGED
|
@@ -4,34 +4,43 @@
|
|
|
4
4
|
# is subject to the terms and conditions of the Boston Dynamics Software
|
|
5
5
|
# Development Kit License (20191101-BDSDK-SL).
|
|
6
6
|
|
|
7
|
-
""" Scout Client is a client for a single Scout instance. The client uses the Scout web API
|
|
7
|
+
""" Scout Client is a client for a single Scout instance. The client uses the Scout web API
|
|
8
8
|
to send HTTPs requests to a number of REStful endpoints using the Requests library.
|
|
9
9
|
"""
|
|
10
|
+
from collections.abc import Iterable
|
|
11
|
+
from typing import Dict
|
|
12
|
+
|
|
10
13
|
import requests
|
|
14
|
+
from deprecated.sphinx import deprecated
|
|
11
15
|
|
|
16
|
+
import bosdyn.scout.utils
|
|
12
17
|
from bosdyn.scout.exceptions import UnauthenticatedScoutClientError
|
|
13
|
-
from bosdyn.scout.utils import get_credentials
|
|
14
18
|
|
|
15
19
|
DEFAULT_HEADERS = {'Accept': 'application/json'}
|
|
20
|
+
OCTET_HEADER = {'Content-type': 'application/octet-stream', 'Accept': 'application/octet-stream'}
|
|
16
21
|
|
|
17
22
|
|
|
23
|
+
@deprecated(
|
|
24
|
+
reason=
|
|
25
|
+
'Scout has been renamed to Orbit. Please, use bosdyn-orbit package instead of bosdyn-scout.',
|
|
26
|
+
version='4.0.0', action="always")
|
|
18
27
|
class ScoutClient():
|
|
19
28
|
"""Client for Scout web API"""
|
|
20
29
|
|
|
21
|
-
def __init__(self, hostname, verify=True, cert=None):
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
def __init__(self, hostname: str, verify: bool = True, cert: str = None):
|
|
31
|
+
""" Initializes the attributes of the ScoutClient object.
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
hostname: the IP address associated with the Scout instance
|
|
35
|
+
verify(path to a CA bundle or Boolean): controls whether we verify the server’s TLS certificate
|
|
36
|
+
Note that verify=False makes your application vulnerable to man-in-the-middle (MitM) attacks
|
|
37
|
+
Defaults to True
|
|
38
|
+
cert(.pem file or a tuple with ('cert', 'key') pair): a local cert to use as client side certificate
|
|
39
|
+
Note that the private key to your local certificate must be unencrypted because Requests does not support using encrypted keys.
|
|
40
|
+
Defaults to None. For additional configurations, use the member Session object "_session" in accordance with Requests library
|
|
41
|
+
Raises:
|
|
42
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
43
|
+
"""
|
|
35
44
|
# The hostname of the Scout instance
|
|
36
45
|
self._hostname = hostname
|
|
37
46
|
# Set a Session object to persist certain parameters across requests
|
|
@@ -49,23 +58,26 @@ class ScoutClient():
|
|
|
49
58
|
# Flag indicating that the ScoutClient is authenticated
|
|
50
59
|
self._is_authenticated = False
|
|
51
60
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
@deprecated(reason='Please, use authenticate_with_api_token.', version='4.0.0', action="always")
|
|
62
|
+
def authenticate_with_password(self, username: str = None,
|
|
63
|
+
password: str = None) -> requests.Response:
|
|
64
|
+
""" Authorizes the client with username and password. Must call before using other client functions.
|
|
65
|
+
If username and password are not provided, the function obtains credentials from
|
|
66
|
+
either environment variables or terminal inputs.
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
username: the username for the Scout instance
|
|
70
|
+
password: the password for the Scout instance
|
|
71
|
+
Raises:
|
|
72
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
73
|
+
Returns::
|
|
74
|
+
requests.Response: the response associated with the login request
|
|
75
|
+
"""
|
|
64
76
|
if username and password:
|
|
65
77
|
username = username
|
|
66
78
|
password = password
|
|
67
79
|
else:
|
|
68
|
-
input_user, input_pass = get_credentials()
|
|
80
|
+
input_user, input_pass = bosdyn.scout.utils.get_credentials()
|
|
69
81
|
username = input_user
|
|
70
82
|
password = input_pass
|
|
71
83
|
login_response = self.post_resource("login", data={
|
|
@@ -78,411 +90,776 @@ class ScoutClient():
|
|
|
78
90
|
print('ScoutClient: Login failed: {}'.format(login_response.text))
|
|
79
91
|
return login_response
|
|
80
92
|
|
|
81
|
-
def
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
def authenticate_with_api_token(self, api_token: str = None) -> requests.Response:
|
|
94
|
+
""" Authorizes the client using the provided API token obtained from the Scout instance.
|
|
95
|
+
Must call before using other client functions.
|
|
96
|
+
|
|
97
|
+
Args:
|
|
98
|
+
api_token: the API token obtained from the Scout instance
|
|
99
|
+
Raises:
|
|
100
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
101
|
+
"""
|
|
102
|
+
if not api_token:
|
|
103
|
+
api_token = bosdyn.scout.utils.get_api_token()
|
|
104
|
+
# Set API token for self._session
|
|
105
|
+
self._session.headers.update({'Authorization': 'Bearer ' + api_token})
|
|
106
|
+
# Check the validity of the API token
|
|
107
|
+
authenticate_response = self._session.get(
|
|
108
|
+
f'https://{self._hostname}/api/v0/api_token/authenticate')
|
|
109
|
+
if authenticate_response.ok:
|
|
110
|
+
self._is_authenticated = True
|
|
111
|
+
else:
|
|
112
|
+
print(
|
|
113
|
+
'ScoutClient: Login failed: {} Please, obtain a valid API token from the Scout instance!'
|
|
114
|
+
.format(authenticate_response.text))
|
|
115
|
+
# Remove the invalid API token from session headers
|
|
116
|
+
self._session.headers.pop('Authorization')
|
|
117
|
+
return authenticate_response
|
|
118
|
+
|
|
119
|
+
def get_resource(self, path: str, **kwargs) -> requests.Response:
|
|
120
|
+
""" Base function for getting a resource in /api/v0/
|
|
121
|
+
|
|
122
|
+
Args:
|
|
123
|
+
path: the path appended to /api/v0/
|
|
124
|
+
kwargs(**): a variable number of keyword arguments for the get request
|
|
125
|
+
Raises:
|
|
126
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
127
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
128
|
+
Returns:
|
|
129
|
+
requests.Response: the response associated with the get request
|
|
130
|
+
"""
|
|
92
131
|
if not self._is_authenticated:
|
|
93
132
|
raise UnauthenticatedScoutClientError()
|
|
94
133
|
return self._session.get(f'https://{self._hostname}/api/v0/{path}/', **kwargs)
|
|
95
134
|
|
|
96
|
-
def post_resource(self, path, **kwargs):
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
135
|
+
def post_resource(self, path: str, **kwargs) -> requests.Response:
|
|
136
|
+
""" Base function for posting a resource in /api/v0/
|
|
137
|
+
|
|
138
|
+
Args:
|
|
139
|
+
path: the path appended to /api/v0/
|
|
140
|
+
kwargs(**): a variable number of keyword arguments for the post request
|
|
141
|
+
Raises:
|
|
142
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
143
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
144
|
+
Returns:
|
|
145
|
+
The response associated with the post request
|
|
146
|
+
"""
|
|
107
147
|
if not self._is_authenticated and path != "login":
|
|
108
148
|
raise UnauthenticatedScoutClientError()
|
|
109
149
|
return self._session.post(f'https://{self._hostname}/api/v0/{path}', **kwargs)
|
|
110
150
|
|
|
111
|
-
def delete_resource(self, path, **kwargs):
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
151
|
+
def delete_resource(self, path: str, **kwargs) -> requests.Response:
|
|
152
|
+
""" Base function for deleting a resource in /api/v0/
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
path: the path appended to /api/v0/
|
|
156
|
+
kwargs(**): a variable number of keyword arguments for the delete request
|
|
157
|
+
Raises:
|
|
158
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
159
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
160
|
+
Returns:
|
|
161
|
+
The response associated with the delete request
|
|
162
|
+
"""
|
|
122
163
|
if not self._is_authenticated:
|
|
123
164
|
raise UnauthenticatedScoutClientError()
|
|
124
165
|
return self._session.delete(f'https://{self._hostname}/api/v0/{path}', **kwargs)
|
|
125
166
|
|
|
126
|
-
def get_scout_version(self, **kwargs):
|
|
127
|
-
""" Retrieves info about a scout .
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
167
|
+
def get_scout_version(self, **kwargs) -> requests.Response:
|
|
168
|
+
""" Retrieves info about a scout .
|
|
169
|
+
|
|
170
|
+
Args:
|
|
171
|
+
kwargs(**): a variable number of keyword arguments for the get request
|
|
172
|
+
Raises:
|
|
173
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
174
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
175
|
+
Returns:
|
|
176
|
+
requests.Response: the response associated with the get request
|
|
135
177
|
"""
|
|
136
178
|
return self.get_resource("version", **kwargs)
|
|
137
179
|
|
|
138
|
-
def get_scout_system_time(self, **kwargs):
|
|
139
|
-
""" Returns scout's current system time.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
180
|
+
def get_scout_system_time(self, **kwargs) -> requests.Response:
|
|
181
|
+
""" Returns scout's current system time.
|
|
182
|
+
|
|
183
|
+
Args:
|
|
184
|
+
kwargs(**): a variable number of keyword arguments for the get request
|
|
185
|
+
Raises:
|
|
186
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
187
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
188
|
+
Returns:
|
|
189
|
+
requests.Response: the response associated with the get request
|
|
147
190
|
"""
|
|
148
191
|
return self.get_resource("settings/system-time", **kwargs)
|
|
149
192
|
|
|
150
|
-
def get_robots(self, **kwargs):
|
|
151
|
-
""" Returns robots on the specified scout instance.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
193
|
+
def get_robots(self, **kwargs) -> requests.Response:
|
|
194
|
+
""" Returns robots on the specified scout instance.
|
|
195
|
+
|
|
196
|
+
Args:
|
|
197
|
+
kwargs(**): a variable number of keyword arguments for the get request
|
|
198
|
+
Raises:
|
|
199
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
200
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
201
|
+
Returns:
|
|
202
|
+
requests.Response: the response associated with the get request
|
|
159
203
|
"""
|
|
160
204
|
return self.get_resource("robots", **kwargs)
|
|
161
205
|
|
|
162
|
-
def get_robot_by_hostname(self, hostname, **kwargs):
|
|
163
|
-
""" Returns a robot on given a hostname of a specific robot.
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
206
|
+
def get_robot_by_hostname(self, hostname: str, **kwargs) -> requests.Response:
|
|
207
|
+
""" Returns a robot on given a hostname of a specific robot.
|
|
208
|
+
|
|
209
|
+
Args:
|
|
210
|
+
hostname: the IP address associated with the desired robot on the Scout instance
|
|
211
|
+
kwargs(**): a variable number of keyword arguments for the get request
|
|
212
|
+
Raises:
|
|
213
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
214
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
215
|
+
Returns:
|
|
216
|
+
requests.Response: the response associated with the get request
|
|
172
217
|
"""
|
|
173
218
|
return self.get_resource(f'robots/{hostname}', **kwargs)
|
|
174
219
|
|
|
175
|
-
def get_site_walks(self, **kwargs):
|
|
220
|
+
def get_site_walks(self, **kwargs) -> requests.Response:
|
|
176
221
|
""" Returns site walks on the specified scout instance
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
222
|
+
|
|
223
|
+
Args:
|
|
224
|
+
kwargs(**): a variable number of keyword arguments for the get request
|
|
225
|
+
Raises:
|
|
226
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
227
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
228
|
+
Returns:
|
|
229
|
+
requests.Response: the response associated with the get request
|
|
184
230
|
"""
|
|
185
231
|
return self.get_resource("site_walks", **kwargs)
|
|
186
232
|
|
|
187
|
-
def get_site_walk_by_id(self, uuid):
|
|
233
|
+
def get_site_walk_by_id(self, uuid: str, **kwargs) -> requests.Response:
|
|
188
234
|
""" Given a site walk uuid, returns a site walk on the specified scout instance
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
235
|
+
|
|
236
|
+
Args:
|
|
237
|
+
uuid: the ID associated with the site walk
|
|
238
|
+
kwargs(**): a variable number of keyword arguments for the get request
|
|
239
|
+
Raises:
|
|
240
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
241
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
242
|
+
Returns:
|
|
243
|
+
requests.Response: the response associated with the get request
|
|
244
|
+
"""
|
|
245
|
+
return self.get_resource(f'site_walks/{uuid}', **kwargs)
|
|
246
|
+
|
|
247
|
+
def get_site_elements(self, **kwargs) -> requests.Response:
|
|
201
248
|
""" Returns site elements on the specified scout instance
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
249
|
+
|
|
250
|
+
Args:
|
|
251
|
+
kwargs(**): a variable number of keyword arguments for the get request
|
|
252
|
+
Raises:
|
|
253
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
254
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
255
|
+
Returns:
|
|
256
|
+
requests.Response: the response associated with the get request
|
|
209
257
|
"""
|
|
210
258
|
return self.get_resource("site_elements", **kwargs)
|
|
211
259
|
|
|
212
|
-
def get_site_element_by_id(self, uuid, **kwargs):
|
|
260
|
+
def get_site_element_by_id(self, uuid: str, **kwargs) -> requests.Response:
|
|
213
261
|
""" Given a site element uuid, returns a site element on the specified scout instance
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
262
|
+
|
|
263
|
+
Args:
|
|
264
|
+
uuid: the ID associated with the site element
|
|
265
|
+
kwargs(**): a variable number of keyword arguments for the get request
|
|
266
|
+
Raises:
|
|
267
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
268
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
269
|
+
Returns:
|
|
270
|
+
requests.Response: the response associated with the get request
|
|
222
271
|
"""
|
|
223
272
|
return self.get_resource(f'site_elements/{uuid}', **kwargs)
|
|
224
273
|
|
|
225
|
-
def get_site_docks(self, **kwargs):
|
|
274
|
+
def get_site_docks(self, **kwargs) -> requests.Response:
|
|
226
275
|
""" Returns site docks on the specified scout instance
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
276
|
+
|
|
277
|
+
Args:
|
|
278
|
+
kwargs(**): a variable number of keyword arguments for the get request
|
|
279
|
+
Raises:
|
|
280
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
281
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
282
|
+
Returns:
|
|
283
|
+
requests.Response: the response associated with the get request
|
|
234
284
|
"""
|
|
235
285
|
return self.get_resource("site_docks", **kwargs)
|
|
236
286
|
|
|
237
|
-
def get_site_dock_by_id(self, uuid, **kwargs):
|
|
287
|
+
def get_site_dock_by_id(self, uuid: str, **kwargs) -> requests.Response:
|
|
238
288
|
""" Given a site dock uuid, returns a site dock on the specified scout instance
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
289
|
+
|
|
290
|
+
Args:
|
|
291
|
+
uuid: the ID associated with the site dock
|
|
292
|
+
kwargs(**): a variable number of keyword arguments for the get request
|
|
293
|
+
Raises:
|
|
294
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
295
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
296
|
+
Returns:
|
|
297
|
+
requests.Response: the response associated with the get request
|
|
247
298
|
"""
|
|
248
299
|
return self.get_resource(f'site_docks/{uuid}', **kwargs)
|
|
249
300
|
|
|
250
|
-
def get_calendar(self, **kwargs):
|
|
301
|
+
def get_calendar(self, **kwargs) -> requests.Response:
|
|
251
302
|
""" Returns calendar events on the specified scout instance
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
303
|
+
|
|
304
|
+
Args:
|
|
305
|
+
kwargs(**): a variable number of keyword arguments for the get request
|
|
306
|
+
Raises:
|
|
307
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
308
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
309
|
+
Returns:
|
|
310
|
+
requests.Response: the response associated with the get request
|
|
259
311
|
"""
|
|
260
312
|
return self.get_resource("calendar/schedule", **kwargs)
|
|
261
313
|
|
|
262
|
-
def get_run_events(self, **kwargs):
|
|
263
|
-
""" Given a dictionary of query params, returns run events
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
314
|
+
def get_run_events(self, **kwargs) -> requests.Response:
|
|
315
|
+
""" Given a dictionary of query params, returns run events
|
|
316
|
+
|
|
317
|
+
Args:
|
|
318
|
+
kwargs(**): a variable number of keyword arguments for the get request
|
|
319
|
+
Raises:
|
|
320
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
321
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
322
|
+
Returns:
|
|
323
|
+
requests.Response: the response associated with the get request
|
|
271
324
|
"""
|
|
272
325
|
return self.get_resource("run_events", **kwargs)
|
|
273
326
|
|
|
274
|
-
def get_run_event_by_id(self, uuid, **kwargs):
|
|
275
|
-
""" Given a runEventUuid, returns a run event
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
327
|
+
def get_run_event_by_id(self, uuid: str, **kwargs) -> requests.Response:
|
|
328
|
+
""" Given a runEventUuid, returns a run event
|
|
329
|
+
|
|
330
|
+
Args:
|
|
331
|
+
uuid: the ID associated with the run event
|
|
332
|
+
kwargs(**): a variable number of keyword arguments for the get request
|
|
333
|
+
Raises:
|
|
334
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
335
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
336
|
+
Returns:
|
|
337
|
+
requests.Response: the response associated with the get request
|
|
284
338
|
"""
|
|
285
339
|
return self.get_resource(f'run_events/{uuid}', **kwargs)
|
|
286
340
|
|
|
287
|
-
def get_run_captures(self, **kwargs):
|
|
288
|
-
""" Given a dictionary of query params, returns run captures
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
341
|
+
def get_run_captures(self, **kwargs) -> requests.Response:
|
|
342
|
+
""" Given a dictionary of query params, returns run captures
|
|
343
|
+
|
|
344
|
+
Args:
|
|
345
|
+
kwargs(**): a variable number of keyword arguments for the get request
|
|
346
|
+
Raises:
|
|
347
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
348
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
349
|
+
Returns:
|
|
350
|
+
requests.Response: the response associated with the get request
|
|
296
351
|
"""
|
|
297
352
|
return self.get_resource("run_captures", **kwargs)
|
|
298
353
|
|
|
299
|
-
def get_run_capture_by_id(self, uuid, **kwargs):
|
|
300
|
-
""" Given a runCaptureUuid, returns a run capture
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
354
|
+
def get_run_capture_by_id(self, uuid: str, **kwargs) -> requests.Response:
|
|
355
|
+
""" Given a runCaptureUuid, returns a run capture
|
|
356
|
+
|
|
357
|
+
Args:
|
|
358
|
+
uuid: the ID associated with the run capture
|
|
359
|
+
kwargs(**): a variable number of keyword arguments for the get request
|
|
360
|
+
Raises:
|
|
361
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
362
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
363
|
+
Returns:
|
|
364
|
+
requests.Response: the response associated with the get request
|
|
309
365
|
"""
|
|
310
366
|
return self.get_resource(f'run_captures/{uuid}', **kwargs)
|
|
311
367
|
|
|
312
|
-
def get_runs(self, **kwargs):
|
|
313
|
-
""" Given a dictionary of query params, returns runs
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
368
|
+
def get_runs(self, **kwargs) -> requests.Response:
|
|
369
|
+
""" Given a dictionary of query params, returns runs
|
|
370
|
+
|
|
371
|
+
Args:
|
|
372
|
+
kwargs(**): a variable number of keyword arguments for the get request
|
|
373
|
+
Raises:
|
|
374
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
375
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
376
|
+
Returns:
|
|
377
|
+
requests.Response: the response associated with the get request
|
|
321
378
|
"""
|
|
322
379
|
return self.get_resource("runs", **kwargs)
|
|
323
380
|
|
|
324
|
-
def get_run_by_id(self, uuid, **kwargs):
|
|
325
|
-
""" Given a runUuid, returns a run
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
381
|
+
def get_run_by_id(self, uuid: str, **kwargs) -> requests.Response:
|
|
382
|
+
""" Given a runUuid, returns a run
|
|
383
|
+
|
|
384
|
+
Args:
|
|
385
|
+
uuid: the ID associated with the run
|
|
386
|
+
kwargs(**): a variable number of keyword arguments for the get request
|
|
387
|
+
Raises:
|
|
388
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
389
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
390
|
+
Returns:
|
|
391
|
+
requests.Response: the response associated with the get request
|
|
334
392
|
"""
|
|
335
393
|
return self.get_resource(f'runs/{uuid}', **kwargs)
|
|
336
394
|
|
|
337
|
-
def get_run_archives_by_id(self, uuid, **kwargs):
|
|
338
|
-
""" Given a runUuid, returns run archives
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
395
|
+
def get_run_archives_by_id(self, uuid: str, **kwargs) -> requests.Response:
|
|
396
|
+
""" Given a runUuid, returns run archives
|
|
397
|
+
|
|
398
|
+
Args:
|
|
399
|
+
uuid: the ID associated with the run
|
|
400
|
+
kwargs(**): a variable number of keyword arguments for the get request
|
|
401
|
+
Raises:
|
|
402
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
403
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
404
|
+
Returns:
|
|
405
|
+
requests.Response: the response associated with the get request
|
|
347
406
|
"""
|
|
348
407
|
return self.get_resource(f'run_archives/{uuid}', **kwargs)
|
|
349
408
|
|
|
350
|
-
def get_image(self, url, **kwargs):
|
|
351
|
-
""" Given a data capture url, returns a
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
409
|
+
def get_image(self, url: str, **kwargs) -> 'urllib3.response.HTTPResponse':
|
|
410
|
+
""" Given a data capture url, returns a decoded image
|
|
411
|
+
|
|
412
|
+
Args:
|
|
413
|
+
url: the url associated with the data capture in the form of https://hostname + RunCapture["dataUrl"]
|
|
414
|
+
kwargs(**): a variable number of keyword arguments for the get request
|
|
415
|
+
Raises:
|
|
416
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
417
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
418
|
+
Returns:
|
|
419
|
+
urllib3.response.HTTPResponse: the decoded response associated with the get request
|
|
360
420
|
"""
|
|
361
421
|
if not self._is_authenticated:
|
|
362
422
|
raise UnauthenticatedScoutClientError()
|
|
363
423
|
response = self._session.get(url, stream=True, **kwargs)
|
|
424
|
+
response.raise_for_status()
|
|
364
425
|
response.raw.decode_content = True
|
|
365
426
|
return response.raw
|
|
366
427
|
|
|
367
|
-
def
|
|
428
|
+
def get_image_response(self, url: str, **kwargs) -> requests.Response:
|
|
429
|
+
""" Given a data capture url, returns an image response
|
|
430
|
+
|
|
431
|
+
Args:
|
|
432
|
+
url: the url associated with the data capture in the form of https://hostname + RunCapture["dataUrl"]
|
|
433
|
+
kwargs(**): a variable number of keyword arguments for the get request
|
|
434
|
+
Raises:
|
|
435
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
436
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
437
|
+
Returns:
|
|
438
|
+
requests.Response: the image response associated with the get request
|
|
439
|
+
"""
|
|
440
|
+
if not self._is_authenticated:
|
|
441
|
+
raise UnauthenticatedScoutClientError()
|
|
442
|
+
response = self._session.get(url, stream=True, **kwargs)
|
|
443
|
+
return response
|
|
444
|
+
|
|
445
|
+
def get_webhook(self, **kwargs) -> requests.Response:
|
|
446
|
+
""" Returns webhook on the specified scout instance
|
|
447
|
+
|
|
448
|
+
Args:
|
|
449
|
+
kwargs(**): a variable number of keyword arguments for the get request
|
|
450
|
+
Raises:
|
|
451
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
452
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
453
|
+
Returns:
|
|
454
|
+
requests.Response: the response associated with the get request
|
|
455
|
+
"""
|
|
456
|
+
return self.get_resource("webhooks", **kwargs)
|
|
457
|
+
|
|
458
|
+
def get_webhook_by_id(self, uuid: str, **kwargs) -> requests.Response:
|
|
459
|
+
""" Given a uuid, returns a specific webhook instance
|
|
460
|
+
|
|
461
|
+
Args:
|
|
462
|
+
uuid: the ID associated with the webhook
|
|
463
|
+
kwargs(**): a variable number of keyword arguments for the get request
|
|
464
|
+
Raises:
|
|
465
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
466
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
467
|
+
Returns:
|
|
468
|
+
requests.Response: the response associated with the get request
|
|
469
|
+
"""
|
|
470
|
+
return self.get_resource(f'webhooks/{uuid}', **kwargs)
|
|
471
|
+
|
|
472
|
+
def get_robot_info(self, robot_nickname: str, **kwargs) -> requests.Response:
|
|
473
|
+
""" Given a robot nickname, returns information about the robot
|
|
474
|
+
|
|
475
|
+
Args:
|
|
476
|
+
robot_nickname: the nickname of the robot
|
|
477
|
+
kwargs(**): a variable number of keyword arguments for the get request
|
|
478
|
+
Raises:
|
|
479
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
480
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
481
|
+
Returns:
|
|
482
|
+
requests.Response: the response associated with the post request
|
|
483
|
+
"""
|
|
484
|
+
return self.get_resource(f'robot-session/{robot_nickname}/session', **kwargs)
|
|
485
|
+
|
|
486
|
+
def post_export_as_walk(self, site_walk_uuid: str, **kwargs) -> requests.Response:
|
|
368
487
|
""" Given a site walk uuid, it exports the walks_pb2.Walk equivalent
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
488
|
+
|
|
489
|
+
Args:
|
|
490
|
+
site_walk_uuid: the ID associated with the site walk
|
|
491
|
+
kwargs(**): a variable number of keyword arguments for the get request
|
|
492
|
+
Raises:
|
|
493
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
494
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
495
|
+
Returns:
|
|
496
|
+
requests.Response: the response associated with the post request
|
|
377
497
|
"""
|
|
378
498
|
return self.post_resource(f'site_walks/export_as_walk/{site_walk_uuid}', **kwargs)
|
|
379
499
|
|
|
380
|
-
def post_import_from_walk(self, **kwargs):
|
|
500
|
+
def post_import_from_walk(self, **kwargs) -> requests.Response:
|
|
381
501
|
""" Given a walk data, imports it to the specified scout instance
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
502
|
+
|
|
503
|
+
Args:
|
|
504
|
+
kwargs(**): a variable number of keyword arguments for the post request
|
|
505
|
+
Raises:
|
|
506
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
507
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
508
|
+
Returns:
|
|
509
|
+
requests.Response: the response associated with the post request
|
|
389
510
|
"""
|
|
390
511
|
return self.post_resource("site_walks/import_from_walk", **kwargs)
|
|
391
512
|
|
|
392
|
-
def post_site_element(self, **kwargs):
|
|
393
|
-
""" Create a site element
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
513
|
+
def post_site_element(self, **kwargs) -> requests.Response:
|
|
514
|
+
""" Create a site element. It also updates a pre-existing Site Element using the associated UUID.
|
|
515
|
+
|
|
516
|
+
Args:
|
|
517
|
+
kwargs(**): a variable number of keyword arguments for the post request
|
|
518
|
+
Raises:
|
|
519
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
520
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
521
|
+
Returns:
|
|
522
|
+
requests.Response: the response associated with the post request
|
|
401
523
|
"""
|
|
402
524
|
return self.post_resource("site_elements", **kwargs)
|
|
403
525
|
|
|
404
|
-
def post_site_walk(self, **kwargs):
|
|
405
|
-
""" Create a site walk
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
526
|
+
def post_site_walk(self, **kwargs) -> requests.Response:
|
|
527
|
+
""" Create a site walk. It also updates a pre-existing Site Walk using the associated UUID.
|
|
528
|
+
|
|
529
|
+
Args:
|
|
530
|
+
kwargs(**): a variable number of keyword arguments for the post request
|
|
531
|
+
Raises:
|
|
532
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
533
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
534
|
+
Returns:
|
|
535
|
+
requests.Response: the response associated with the post request
|
|
413
536
|
"""
|
|
414
537
|
return self.post_resource("site_walks", **kwargs)
|
|
415
538
|
|
|
416
|
-
def post_site_dock(self, **kwargs):
|
|
417
|
-
""" Create a site element
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
539
|
+
def post_site_dock(self, **kwargs) -> requests.Response:
|
|
540
|
+
""" Create a site element. It also updates a pre-existing Site Dock using the associated UUID.
|
|
541
|
+
|
|
542
|
+
Args:
|
|
543
|
+
kwargs(**): a variable number of keyword arguments for the post request
|
|
544
|
+
Raises:
|
|
545
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
546
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
547
|
+
Returns:
|
|
548
|
+
requests.Response: the response associated with the post request
|
|
425
549
|
"""
|
|
426
550
|
return self.post_resource("site_docks", **kwargs)
|
|
427
551
|
|
|
428
|
-
def post_robot(self, **kwargs):
|
|
552
|
+
def post_robot(self, **kwargs) -> requests.Response:
|
|
429
553
|
""" Add a robot to the specified scout instance
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
554
|
+
|
|
555
|
+
Args:
|
|
556
|
+
kwargs(**): a variable number of keyword arguments for the post request
|
|
557
|
+
Raises:
|
|
558
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
559
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
560
|
+
Returns:
|
|
561
|
+
requests.Response: the response associated with the post request
|
|
437
562
|
"""
|
|
438
563
|
return self.post_resource("robots", **kwargs)
|
|
439
564
|
|
|
440
|
-
def post_calendar_event(self,
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
565
|
+
def post_calendar_event(self, nickname: str = None, time_ms: int = None, repeat_ms: int = None,
|
|
566
|
+
mission_id: str = None, force_acquire_estop: bool = None,
|
|
567
|
+
require_docked: bool = None, schedule_name: str = None,
|
|
568
|
+
blackout_times: Iterable[Dict[str,
|
|
569
|
+
int]] = None, disable_reason: str = None,
|
|
570
|
+
event_id: str = None, **kwargs) -> requests.Response:
|
|
571
|
+
""" This function serves two purposes. It creates a new calendar event on Scout using the following arguments
|
|
572
|
+
when Event ID is not specified. When the Event ID associated with a pre-existing calendar event is specified,
|
|
573
|
+
the function overwrites the attributes of the pre-existing calendar event.
|
|
574
|
+
|
|
575
|
+
Args:
|
|
576
|
+
nickname: the name associated with the robot
|
|
577
|
+
time_ms: the first kickoff time in terms of milliseconds since epoch
|
|
578
|
+
repeat_ms:the delay time in milliseconds for repeating calendar events
|
|
579
|
+
mission_id: the UUID associated with the mission( also known as Site Walk)
|
|
580
|
+
force_acquire_estop: instructs the system to force acquire the estop when the mission kicks off
|
|
581
|
+
require_docked: determines whether the event will require the robot to be docked to start
|
|
582
|
+
schedule_name: the desired name of the calendar event
|
|
583
|
+
blackout_times: a specification for a time period over the course of a week when a schedule should not run
|
|
584
|
+
specified as list of a dictionary defined as {"startMs": <int>, "endMs" : <int>}
|
|
585
|
+
with startMs (inclusive) being the millisecond offset from the beginning of the week (Sunday) when this blackout period starts
|
|
586
|
+
and endMs (exclusive) being the millisecond offset from beginning of the week(Sunday) when this blackout period ends
|
|
587
|
+
disable_reason: (optional) a reason for disabling the calendar event
|
|
588
|
+
event_id: the auto-generated ID for a calendar event that is already posted on the Scout instance.
|
|
589
|
+
This is only useful when editing a pre-existing calendar event.
|
|
590
|
+
kwargs(**): a variable number of keyword arguments for the post request
|
|
591
|
+
Raises:
|
|
592
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
593
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
594
|
+
Returns:
|
|
595
|
+
requests.Response: the response associated with the post request
|
|
449
596
|
"""
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
597
|
+
# Check if the input contains the json param that is constructed outside the function
|
|
598
|
+
if 'json' in kwargs:
|
|
599
|
+
return self.post_resource("calendar/schedule", **kwargs)
|
|
600
|
+
# Construct payload based on provided inputs
|
|
601
|
+
payload = {
|
|
602
|
+
"agent": {
|
|
603
|
+
"nickname": nickname
|
|
604
|
+
},
|
|
605
|
+
"schedule": {
|
|
606
|
+
"timeMs": time_ms,
|
|
607
|
+
"repeatMs": repeat_ms,
|
|
608
|
+
"blackouts": blackout_times,
|
|
609
|
+
"disableReason": disable_reason,
|
|
610
|
+
},
|
|
611
|
+
"task": {
|
|
612
|
+
"missionId": mission_id,
|
|
613
|
+
"forceAcquireEstop": force_acquire_estop,
|
|
614
|
+
"requireDocked": require_docked,
|
|
615
|
+
},
|
|
616
|
+
"eventMetadata": {
|
|
617
|
+
"name": schedule_name,
|
|
618
|
+
"eventId": event_id
|
|
619
|
+
},
|
|
620
|
+
}
|
|
621
|
+
return self.post_resource("calendar/schedule", json=payload, **kwargs)
|
|
622
|
+
|
|
623
|
+
def post_calendar_events_disable_all(self, disable_reason: str, **kwargs) -> requests.Response:
|
|
624
|
+
""" Disable all scheduled missions
|
|
625
|
+
|
|
626
|
+
Args:
|
|
627
|
+
disable_reason: Reason for disabling all scheduled missions
|
|
628
|
+
kwargs(**): a variable number of keyword arguments for the post request
|
|
629
|
+
Raises:
|
|
630
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
631
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
632
|
+
Returns:
|
|
633
|
+
requests.Response: the response associated with the post request
|
|
634
|
+
"""
|
|
635
|
+
return self.post_resource("calendar/disable-enable", json={"disableReason": disable_reason},
|
|
636
|
+
**kwargs)
|
|
637
|
+
|
|
638
|
+
def post_calendar_event_disable_by_id(self, event_id: str, disable_reason: str,
|
|
639
|
+
**kwargs) -> requests.Response:
|
|
640
|
+
""" Disable specific scheduled mission by event ID
|
|
641
|
+
|
|
642
|
+
Args:
|
|
643
|
+
event_id: eventId associated with a mission to disable
|
|
644
|
+
disable_reason: Reason for disabling a scheduled mission
|
|
645
|
+
kwargs(**): a variable number of keyword arguments for the post request
|
|
646
|
+
Raises:
|
|
647
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
648
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
649
|
+
Returns:
|
|
650
|
+
requests.Response: the response associated with the post request
|
|
651
|
+
"""
|
|
652
|
+
return self.post_resource("calendar/disable-enable", json={
|
|
653
|
+
"disableReason": disable_reason,
|
|
654
|
+
"eventId": event_id
|
|
655
|
+
}, **kwargs)
|
|
656
|
+
|
|
657
|
+
def post_calendar_events_enable_all(self, **kwargs) -> requests.Response:
|
|
658
|
+
""" Enable all scheduled missions
|
|
659
|
+
|
|
660
|
+
Args:
|
|
661
|
+
kwargs(**): a variable number of keyword arguments for the post request
|
|
662
|
+
Raises:
|
|
663
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
664
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
665
|
+
Returns:
|
|
666
|
+
requests.Response: the response associated with the post request
|
|
667
|
+
"""
|
|
668
|
+
return self.post_resource("calendar/disable-enable", json={"disableReason": ""}, **kwargs)
|
|
669
|
+
|
|
670
|
+
def post_calendar_event_enable_by_id(self, event_id: str, **kwargs) -> requests.Response:
|
|
671
|
+
""" Enable specific scheduled mission by event ID
|
|
672
|
+
|
|
673
|
+
Args:
|
|
674
|
+
event_id: eventId associated with a mission to enable
|
|
675
|
+
kwargs(**): a variable number of keyword arguments for the post request
|
|
676
|
+
Raises:
|
|
677
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
678
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
679
|
+
Returns:
|
|
680
|
+
requests.Response: the response associated with the post request
|
|
681
|
+
"""
|
|
682
|
+
return self.post_resource("calendar/disable-enable", json={
|
|
683
|
+
"disableReason": "",
|
|
684
|
+
"eventId": event_id
|
|
685
|
+
}, **kwargs)
|
|
686
|
+
|
|
687
|
+
def post_webhook(self, **kwargs) -> requests.Response:
|
|
688
|
+
""" Create a webhook instance
|
|
689
|
+
|
|
690
|
+
Args:
|
|
691
|
+
kwargs(**): a variable number of keyword arguments for the post request
|
|
692
|
+
Raises:
|
|
693
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
694
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
695
|
+
Returns:
|
|
696
|
+
requests.Response: the response associated with the post request
|
|
697
|
+
"""
|
|
698
|
+
return self.post_resource("webhooks", **kwargs)
|
|
699
|
+
|
|
700
|
+
def post_webhook_by_id(self, uuid: str, **kwargs) -> requests.Response:
|
|
701
|
+
""" Update an existing webhook instance
|
|
702
|
+
|
|
703
|
+
Args:
|
|
704
|
+
uuid: the ID associated with the desired webhook instance
|
|
705
|
+
kwargs(**): a variable number of keyword arguments for the post request
|
|
706
|
+
Raises:
|
|
707
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
708
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
709
|
+
Returns:
|
|
710
|
+
requests.Response: the response associated with the post request
|
|
711
|
+
"""
|
|
712
|
+
return self.post_resource(f'webhooks/{uuid}', **kwargs)
|
|
713
|
+
|
|
714
|
+
def post_return_to_dock_mission(self, robot_nickname: str, site_dock_uuid: str,
|
|
715
|
+
**kwargs) -> requests.Response:
|
|
716
|
+
""" Generate a mission to send the robot back to the dock
|
|
717
|
+
|
|
718
|
+
Args:
|
|
719
|
+
robot_nickname: the nickname of the robot
|
|
720
|
+
site_dock_uuid: the uuid of the dock to send robot to
|
|
721
|
+
kwargs(**): a variable number of keyword arguments for the post request
|
|
722
|
+
Raises:
|
|
723
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
724
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
725
|
+
Returns:
|
|
726
|
+
requests.Response: the response associated with the post request
|
|
727
|
+
"""
|
|
728
|
+
return self.post_resource('graph/send-robot', json={
|
|
729
|
+
"nickname": robot_nickname,
|
|
730
|
+
"siteDockUuid": site_dock_uuid
|
|
731
|
+
}, **kwargs)
|
|
732
|
+
|
|
733
|
+
def post_dispatch_mission_to_robot(self, robot_nickname: str, driver_id: str, mission_uuid: str,
|
|
734
|
+
delete_mission: bool, force_acquire_estop: bool,
|
|
735
|
+
**kwargs) -> requests.Response:
|
|
736
|
+
""" Dispatch the robot to a mission given a mission uuid
|
|
737
|
+
|
|
738
|
+
Args:
|
|
739
|
+
robot_nickname: the nickname of the robot
|
|
740
|
+
driver_id: the current driver ID of the mission
|
|
741
|
+
mission_uuid: uuid of the mission(also known as Site Walk) to dispatch
|
|
742
|
+
delete_mission: whether to delete the mission after playback
|
|
743
|
+
force_acquire_estop: whether to force acquire E-stop from the previous client
|
|
744
|
+
kwargs(**): a variable number of keyword arguments for the post request
|
|
745
|
+
Raises:
|
|
746
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
747
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
748
|
+
Returns:
|
|
749
|
+
requests.Response: the response associated with the post request
|
|
750
|
+
"""
|
|
751
|
+
# Payload required for dispatching a mission
|
|
752
|
+
payload = {
|
|
753
|
+
"agent": {
|
|
754
|
+
"nickname": robot_nickname
|
|
755
|
+
},
|
|
756
|
+
"schedule": {
|
|
757
|
+
"timeMs": {
|
|
758
|
+
"low": 1,
|
|
759
|
+
"high": 0,
|
|
760
|
+
"unsigned": False
|
|
761
|
+
},
|
|
762
|
+
"repeatMs": {
|
|
763
|
+
"low": 0,
|
|
764
|
+
"high": 0,
|
|
765
|
+
"unsigned": False
|
|
766
|
+
}
|
|
767
|
+
},
|
|
768
|
+
"task": {
|
|
769
|
+
"missionId": mission_uuid,
|
|
770
|
+
"forceAcquireEstop": force_acquire_estop,
|
|
771
|
+
"deleteMission": delete_mission,
|
|
772
|
+
"requireDocked": False
|
|
773
|
+
},
|
|
774
|
+
"eventMetadata": {
|
|
775
|
+
"name": "Scout API Triggered Mission"
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
return self.post_resource(
|
|
779
|
+
f'calendar/mission/dispatch/{robot_nickname}?currentDriverId={driver_id}', json=payload,
|
|
780
|
+
**kwargs)
|
|
781
|
+
|
|
782
|
+
def delete_site_walk(self, uuid: str, **kwargs) -> requests.Response:
|
|
453
783
|
""" Given a site walk uuid, deletes the site walk associated with the uuid on the specified scout instance
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
784
|
+
|
|
785
|
+
Args:
|
|
786
|
+
uuid: the ID associated with the desired site walk
|
|
787
|
+
kwargs(**): a variable number of keyword arguments for the delete request
|
|
788
|
+
Raises:
|
|
789
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
790
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
791
|
+
Returns:
|
|
792
|
+
requests.Response: the response associated with the delete request
|
|
462
793
|
"""
|
|
463
794
|
return self.delete_resource(f'site_walks/{uuid}', **kwargs)
|
|
464
795
|
|
|
465
|
-
def delete_robot(self,
|
|
466
|
-
""" Given a
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
796
|
+
def delete_robot(self, robot_hostname: str, **kwargs) -> requests.Response:
|
|
797
|
+
""" Given a robot hostname, deletes the robot associated with the hostname on the specified scout instance
|
|
798
|
+
|
|
799
|
+
Args:
|
|
800
|
+
robot_hostname: the IP address associated with the robot
|
|
801
|
+
kwargs(**): a variable number of keyword arguments for the delete request
|
|
802
|
+
Raises:
|
|
803
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
804
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
805
|
+
Returns:
|
|
806
|
+
requests.Response: the response associated with the delete request
|
|
475
807
|
"""
|
|
476
|
-
return self.delete_resource(f'robots/{
|
|
808
|
+
return self.delete_resource(f'robots/{robot_hostname}', **kwargs)
|
|
477
809
|
|
|
478
|
-
def delete_calendar_event(self, **kwargs):
|
|
810
|
+
def delete_calendar_event(self, event_id: str, **kwargs) -> requests.Response:
|
|
479
811
|
""" Delete the specified calendar event on the specified scout instance
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
812
|
+
|
|
813
|
+
Args:
|
|
814
|
+
event_id(string): the ID associated with the calendar event
|
|
815
|
+
kwargs(**): a variable number of keyword arguments for the delete request
|
|
816
|
+
Raises:
|
|
817
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
818
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
819
|
+
Returns:
|
|
820
|
+
requests.Response: the response associated with the delete request
|
|
821
|
+
"""
|
|
822
|
+
return self.delete_resource(f'calendar/schedule/{event_id}', **kwargs)
|
|
823
|
+
|
|
824
|
+
def delete_webhook(self, uuid: str, **kwargs) -> requests.Response:
|
|
825
|
+
""" Delete the specified webhook instance on the specified scout instance
|
|
826
|
+
|
|
827
|
+
Args:
|
|
828
|
+
uuid: the ID associated with the desired webhook
|
|
829
|
+
kwargs(**): a variable number of keyword arguments for the delete request
|
|
830
|
+
Raises:
|
|
831
|
+
RequestExceptions: exceptions thrown by the Requests library
|
|
832
|
+
UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
|
|
833
|
+
Returns:
|
|
834
|
+
requests.Response: the response associated with the delete request
|
|
835
|
+
"""
|
|
836
|
+
return self.delete_resource(f'webhooks/{uuid}', **kwargs)
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
def create_scout_client(options: 'argparse.Namespace') -> 'bosdyn.scout.client.ScoutClient':
|
|
840
|
+
""" Creates a Scout client object.
|
|
841
|
+
|
|
842
|
+
Args:
|
|
843
|
+
options: User input containing Scout hostname, verification, and certification info.
|
|
844
|
+
Returns:
|
|
845
|
+
scout_client: Scout client object.
|
|
846
|
+
"""
|
|
847
|
+
# Determine the value for the argument "verify"
|
|
848
|
+
if options.verify in ["True", "False"]:
|
|
849
|
+
verify = options.verify == "True"
|
|
850
|
+
else:
|
|
851
|
+
print(
|
|
852
|
+
"The provided value for the argument verify [%s] is not either 'True' or 'False'. Assuming verify is set to 'path/to/CA bundle'"
|
|
853
|
+
.format(options.verify))
|
|
854
|
+
verify = options.verify
|
|
855
|
+
|
|
856
|
+
# A Scout client object represents a single Scout instance.
|
|
857
|
+
scout_client = ScoutClient(hostname=options.hostname, verify=verify, cert=options.cert)
|
|
858
|
+
|
|
859
|
+
# The Scout client needs to be authenticated before using its functions
|
|
860
|
+
if options.use_api_token:
|
|
861
|
+
scout_client.authenticate_with_api_token()
|
|
862
|
+
else:
|
|
863
|
+
scout_client.authenticate_with_password()
|
|
864
|
+
|
|
865
|
+
return scout_client
|