@@ -190,7 +190,8 @@ def add_target(
190190 Add a target to a Vuforia Web Services database.
191191
192192 See
193- https://library.vuforia.com/articles/Solution/How-To-Use-the-Vuforia-Web-Services-API#How-To-Add-a-Target.
193+ https://library.vuforia.com/articles/Solution/How-To-Use-the-Vuforia-Web-Services-API#How-To-Add-a-Target
194+ for parameter details.
194195
195196 Args:
196197 name: The name of the target.
@@ -275,14 +276,18 @@ def get_target_record(self, target_id: str) -> Dict[str, Union[str, int]]:
275276
276277 return dict (response .json ()['target_record' ])
277278
278- @timeout_decorator .timeout (seconds = 60 * 5 )
279- def wait_for_target_processed (self , target_id : str ) -> None :
279+ def _wait_for_target_processed (
280+ self ,
281+ target_id : str ,
282+ seconds_between_requests : float ,
283+ ) -> None :
280284 """
281- Wait up to five minutes (arbitrary) for a target to get past the
282- processing stage.
285+ Wait indefinitely for a target to get past the processing stage.
283286
284287 Args:
285288 target_id: The ID of the target to wait for.
289+ seconds_between_requests: The number of seconds to wait between
290+ requests made while polling the target status.
286291
287292 Raises:
288293 ~vws.exceptions.AuthenticationFailure: The secret key is not
@@ -299,10 +304,35 @@ def wait_for_target_processed(self, target_id: str) -> None:
299304 if report ['status' ] != 'processing' :
300305 return
301306
302- # We wait 0.2 seconds rather than less than that to decrease the
303- # number of calls made to the API, to decrease the likelihood of
304- # hitting the request quota.
305- sleep (0.2 )
307+ sleep (seconds_between_requests )
308+
309+ @timeout_decorator .timeout (seconds = 60 * 5 )
310+ def wait_for_target_processed (self , target_id : str ) -> None :
311+ """
312+ Wait up to five minutes (arbitrary) for a target to get past the
313+ processing stage.
314+
315+ Args:
316+ target_id: The ID of the target to wait for.
317+
318+ Raises:
319+ ~vws.exceptions.AuthenticationFailure: The secret key is not
320+ correct.
321+ ~vws.exceptions.Fail: There was an error with the request. For
322+ example, the given access key does not match a known database.
323+ TimeoutError: The target remained in the processing stage for more
324+ than five minutes.
325+ ~vws.exceptions.UnknownTarget: The given target ID does not match a
326+ target in the database.
327+ """
328+ # We wait 0.2 seconds rather than less than that to decrease the
329+ # number of calls made to the API, to decrease the likelihood of
330+ # hitting the request quota.
331+ seconds_between_requests = 0.2
332+ self ._wait_for_target_processed (
333+ target_id = target_id ,
334+ seconds_between_requests = seconds_between_requests ,
335+ )
306336
307337 def list_targets (self ) -> List [str ]:
308338 """
@@ -413,3 +443,34 @@ def delete_target(self, target_id: str) -> None:
413443 request_path = f'/targets/{ target_id } ' ,
414444 expected_result_code = 'Success' ,
415445 )
446+
447+ def get_duplicate_targets (self , target_id : str ) -> List [str ]:
448+ """
449+ Get targets which may be considered duplicates of a given target.
450+
451+ See
452+ https://library.vuforia.com/articles/Solution/How-To-Use-the-Vuforia-Web-Services-API.html#How-To-Check-for-Duplicate-Targets.
453+
454+ Args:
455+ target_id: The ID of the target to delete.
456+
457+ Returns:
458+ The target IDs of duplicate targets.
459+
460+ Raises:
461+ ~vws.exceptions.AuthenticationFailure: The secret key is not
462+ correct.
463+ ~vws.exceptions.Fail: There was an error with the request. For
464+ example, the given access key does not match a known database.
465+ ~vws.exceptions.UnknownTarget: The given target ID does not match a
466+ target in the database.
467+ ~vws.exceptions.ProjectInactive: The project is inactive.
468+ """
469+ response = self ._make_request (
470+ method = 'GET' ,
471+ content = b'' ,
472+ request_path = f'/duplicates/{ target_id } ' ,
473+ expected_result_code = 'Success' ,
474+ )
475+
476+ return list (response .json ()['similar_targets' ])
0 commit comments