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