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 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
- ''' Initializes the attributes of the ScoutClient object.
23
- - Args:
24
- - hostname(str): the IP address associated with the Scout instance
25
- - verify(path to a CA bundle or Boolean): controls whether we verify the server’s TLS certificate
26
- - Note that verify=False makes your application vulnerable to man-in-the-middle (MitM) attacks
27
- - Defaults to True
28
- - cert(.pem file or a tuple with ('cert', 'key') pair): a local cert to use as client side certificate
29
- - Note that the private key to your local certificate must be unencrypted because Requests does not support using encrypted keys.
30
- - Defaults to None
31
- - For additional configurations, use the member Session object "_session" in accordance with Requests library
32
- - Raises:
33
- - RequestExceptions: exceptions thrown by the Requests library
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
- def authenticate_with_password(self, username=None, password=None):
53
- ''' Authorizes the client with username and password. Must call before using other client functions.
54
- If username and password are not provided, the function obtains credentials from
55
- either environment variables or terminal inputs.
56
- - Args:
57
- - username(str): the username for the Scout instance
58
- - password(str): the password for the Scout instance
59
- - Raises:
60
- - RequestExceptions: exceptions thrown by the Requests library
61
- - Returns:
62
- - requests.Response(Response object): the response associated with the login request
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 get_resource(self, path, **kwargs):
82
- ''' Base function for getting a resource in /api/v0/
83
- - Args:
84
- - path(str): the path appended to /api/v0/
85
- - kwargs(**): a variable number of keyword arguments for the get request
86
- - Raises:
87
- - RequestExceptions: exceptions thrown by the Requests library
88
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
89
- - Returns
90
- - requests.Response(Response object): the response associated with the the get request
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
- ''' Base function for posting a resource in /api/v0/
98
- - Args:
99
- - path(str): the path appended to /api/v0/
100
- - kwargs(**): a variable number of keyword arguments for the post request
101
- - Raises:
102
- - RequestExceptions: exceptions thrown by the Requests library
103
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
104
- - Returns
105
- - The response associated with the the post request
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
- ''' Base function for deleting a resource in /api/v0/
113
- - Args:
114
- - path(str): the path appended to /api/v0/
115
- - kwargs(**): a variable number of keyword arguments for the delete request
116
- - Raises:
117
- - RequestExceptions: exceptions thrown by the Requests library
118
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
119
- - Returns
120
- - The response associated with the the delete request
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
- - Args:
129
- - kwargs(**): a variable number of keyword arguments for the get request
130
- - Raises:
131
- - RequestExceptions: exceptions thrown by the Requests library
132
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
133
- - Returns
134
- - requests.Response(Response object): the response associated with the the get request
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
- - Args:
141
- - kwargs(**): a variable number of keyword arguments for the get request
142
- - Raises:
143
- - RequestExceptions: exceptions thrown by the Requests library
144
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
145
- - Returns
146
- - requests.Response(Response object): the response associated with the the get request
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
- - Args:
153
- - kwargs(**): a variable number of keyword arguments for the get request
154
- - Raises:
155
- - RequestExceptions: exceptions thrown by the Requests library
156
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
157
- - Returns
158
- - requests.Response(Response object): the response associated with the the get request
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
- - Args:
165
- - hostname(str): the IP address associated with the desired robot on the Scout instance
166
- - kwargs(**): a variable number of keyword arguments for the get request
167
- - Raises:
168
- - RequestExceptions: exceptions thrown by the Requests library
169
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
170
- - Returns
171
- - requests.Response(Response object): the response associated with the the get request
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
- - Args:
178
- - kwargs(**): a variable number of keyword arguments for the get request
179
- - Raises:
180
- - RequestExceptions: exceptions thrown by the Requests library
181
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
182
- - Returns
183
- - requests.Response(Response object): the response associated with the the get request
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
- - Args:
190
- - uuid(str): the ID associated with the site walk
191
- - kwargs(**): a variable number of keyword arguments for the get request
192
- - Raises:
193
- - RequestExceptions: exceptions thrown by the Requests library
194
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
195
- - Returns
196
- - requests.Response(Response object): the response associated with the the get request
197
- """
198
- return self.get_resource(f'site_walks/{uuid}')
199
-
200
- def get_site_elements(self, **kwargs):
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
- - Args:
203
- - kwargs(**): a variable number of keyword arguments for the get request
204
- - Raises:
205
- - RequestExceptions: exceptions thrown by the Requests library
206
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
207
- - Returns
208
- - requests.Response(Response object): the response associated with the the get request
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
- - Args:
215
- - uuid(str): the ID associated with the site element
216
- - kwargs(**): a variable number of keyword arguments for the get request
217
- - Raises:
218
- - RequestExceptions: exceptions thrown by the Requests library
219
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
220
- - Returns
221
- - requests.Response(Response object): the response associated with the the get request
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
- - Args:
228
- - kwargs(**): a variable number of keyword arguments for the get request
229
- - Raises:
230
- - RequestExceptions: exceptions thrown by the Requests library
231
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
232
- - Returns
233
- - requests.Response(Response object): the response associated with the the get request
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
- - Args:
240
- - uuid(str): the ID associated with the site dock
241
- - kwargs(**): a variable number of keyword arguments for the get request
242
- - Raises:
243
- - RequestExceptions: exceptions thrown by the Requests library
244
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
245
- - Returns
246
- - requests.Response(Response object): the response associated with the the get request
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
- - Args:
253
- - kwargs(**): a variable number of keyword arguments for the get request
254
- - Raises:
255
- - RequestExceptions: exceptions thrown by the Requests library
256
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
257
- - Returns
258
- - requests.Response(Response object): the response associated with the the get request
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
- - Args:
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(Response object): the response associated with the the get request
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
- - Args:
277
- - uuid(str): the ID associated with the run event
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(Response object): the response associated with the the get request
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
- - Args:
290
- - kwargs(**): a variable number of keyword arguments for the get request
291
- - Raises:
292
- - RequestExceptions: exceptions thrown by the Requests library
293
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
294
- - Returns
295
- - requests.Response(Response object): the response associated with the the get request
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
- - Args:
302
- - uuid(str): the ID associated with the run capture
303
- - kwargs(**): a variable number of keyword arguments for the get request
304
- - Raises:
305
- - RequestExceptions: exceptions thrown by the Requests library
306
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
307
- - Returns
308
- - requests.Response(Response object): the response associated with the the get request
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
- - Args:
315
- - kwargs(**): a variable number of keyword arguments for the get request
316
- - Raises:
317
- - RequestExceptions: exceptions thrown by the Requests library
318
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
319
- - Returns
320
- - requests.Response(Response object): the response associated with the the get request
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
- - Args:
327
- - uuid(str): the ID associated with the run
328
- - kwargs(**): a variable number of keyword arguments for the get request
329
- - Raises:
330
- - RequestExceptions: exceptions thrown by the Requests library
331
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
332
- - Returns
333
- - requests.Response(Response object): the response associated with the the get request
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
- - Args:
340
- - uuid(str): the ID associated with the run
341
- - kwargs(**): a variable number of keyword arguments for the get request
342
- - Raises:
343
- - RequestExceptions: exceptions thrown by the Requests library
344
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
345
- - Returns
346
- - requests.Response(Response object): the response associated with the the get request
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 raw image
352
- - Args:
353
- - url(str): the url associated with the data capture
354
- - kwargs(**): a variable number of keyword arguments for the get request
355
- - Raises:
356
- - RequestExceptions: exceptions thrown by the Requests library
357
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
358
- - Returns
359
- - requests.Response: the raw response associated with the the get request
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 post_export_as_walk(self, site_walk_uuid, **kwargs):
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
- - Args:
370
- - uuid(str): the ID associated with the site walk
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(Response object): the response associated with the the post request
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
- - Args:
383
- - kwargs(**): a variable number of keyword arguments for the post request
384
- - Raises:
385
- - RequestExceptions: exceptions thrown by the Requests library
386
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
387
- - Returns
388
- - requests.Response(Response object): the response associated with the the post request
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
- - Args:
395
- - kwargs(**): a variable number of keyword arguments for the post request
396
- - Raises:
397
- - RequestExceptions: exceptions thrown by the Requests library
398
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
399
- - Returns
400
- - requests.Response(Response object): the response associated with the the post request
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
- - Args:
407
- - kwargs(**): a variable number of keyword arguments for the post request
408
- - Raises:
409
- - RequestExceptions: exceptions thrown by the Requests library
410
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
411
- - Returns
412
- - requests.Response(Response object): the response associated with the the post request
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
- - Args:
419
- - kwargs(**): a variable number of keyword arguments for the post request
420
- - Raises:
421
- - RequestExceptions: exceptions thrown by the Requests library
422
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
423
- - Returns
424
- - requests.Response(Response object): the response associated with the the post request
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
- - Args:
431
- - kwargs(**): a variable number of keyword arguments for the post request
432
- - Raises:
433
- - RequestExceptions: exceptions thrown by the Requests library
434
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
435
- - Returns
436
- - requests.Response(Response object): the response associated with the the post request
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, **kwargs):
441
- """ Create a calendar event to play a mission
442
- - Args:
443
- - kwargs(**): a variable number of keyword arguments for the post request
444
- - Raises:
445
- - RequestExceptions: exceptions thrown by the Requests library
446
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
447
- - Returns
448
- - requests.Response(Response object): the response associated with the the post request
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
- return self.post_resource("calendar/set", **kwargs)
451
-
452
- def delete_site_walk(self, uuid, **kwargs):
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
- - Args:
455
- - uuid(str): the ID associated with the desired site walk
456
- - kwargs(**): a variable number of keyword arguments for the delete request
457
- - Raises:
458
- - RequestExceptions: exceptions thrown by the Requests library
459
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
460
- - Returns
461
- - requests.Response(Response object): the response associated with the the delete request
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, robotHostname, **kwargs):
466
- """ Given a robotHostname, deletes the robot associated with the hostname on the specified scout instance
467
- - Args:
468
- - hostname(str): the IP address associated with the robot
469
- - kwargs(**): a variable number of keyword arguments for the delete request
470
- - Raises:
471
- - RequestExceptions: exceptions thrown by the Requests library
472
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
473
- - Returns
474
- - requests.Response(Response object): the response associated with the the delete request
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/{robotHostname}', **kwargs)
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
- - Args:
481
- - kwargs(**): a variable number of keyword arguments for the delete request
482
- - Raises:
483
- - RequestExceptions: exceptions thrown by the Requests library
484
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
485
- - Returns
486
- - requests.Response(Response object): the response associated with the the delete request
487
- """
488
- return self.post_resource('calendar/delete', **kwargs)
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