Skip to content

Commit 267248e

Browse files
Merge pull request #2328 from VWS-Python/public-make-request
Make 'VWS.make_request' a public method
2 parents a139fa3 + 252435c commit 267248e

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Changelog
44
Next
55
----
66

7+
* Make ``VWS.make_request`` a public method.
8+
79
2024.09.02
810
------------
911

src/vws/vws.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def __init__(
150150
self._server_secret_key = server_secret_key
151151
self._base_vws_url = base_vws_url
152152

153-
def _make_request(
153+
def make_request(
154154
self,
155155
method: str,
156156
data: bytes,
@@ -160,32 +160,34 @@ def _make_request(
160160
"""
161161
Make a request to the Vuforia Target API.
162162
163-
This uses `requests` to make a request against https://vws.vuforia.com.
163+
This uses `requests` to make a request against Vuforia.
164164
The content type of the request will be `application/json`.
165165
166166
Args:
167167
method: The HTTP method which will be used in the request.
168168
data: The request body which will be used in the request.
169169
request_path: The path to the endpoint which will be used in the
170170
request.
171-
expected_result_code: See
172-
https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#result-codes
171+
expected_result_code: See "VWS API Result Codes" on
172+
https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api.
173173
174174
Returns:
175175
The response to the request made by `requests`.
176176
177177
Raises:
178-
~vws.exceptions.OopsAnErrorOccurredPossiblyBadNameError: Vuforia
179-
returns an HTML page with the text "Oops, an error occurred".
178+
~vws.exceptions.custom_exceptions.OopsAnErrorOccurredPossiblyBadNameError:
179+
Vuforia returns an HTML page with the text "Oops, an error
180+
occurred".
181+
180182
This has been seen to happen when the given name includes a bad
181183
character.
182184
~vws.exceptions.custom_exceptions.ServerError: There is an error
183185
with Vuforia's servers.
184186
~vws.exceptions.vws_exceptions.TooManyRequestsError: Vuforia is
185187
rate limiting access.
186-
json.decoder.JSONDecodeError: The server did not respond with valid
187-
JSON. This may happen if the server address is not a valid
188-
Vuforia server.
188+
json.JSONDecodeError: The server did not respond with valid JSON.
189+
This may happen if the server address is not a valid Vuforia
190+
server.
189191
"""
190192
response = _target_api_request(
191193
server_access_key=self._server_access_key,
@@ -309,7 +311,7 @@ def add_target(
309311

310312
content = json.dumps(obj=data).encode(encoding="utf-8")
311313

312-
response = self._make_request(
314+
response = self.make_request(
313315
method=HTTPMethod.POST,
314316
data=content,
315317
request_path="/targets",
@@ -346,7 +348,7 @@ def get_target_record(self, target_id: str) -> TargetStatusAndRecord:
346348
~vws.exceptions.vws_exceptions.TooManyRequestsError: Vuforia is
347349
rate limiting access.
348350
"""
349-
response = self._make_request(
351+
response = self.make_request(
350352
method=HTTPMethod.GET,
351353
data=b"",
352354
request_path=f"/targets/{target_id}",
@@ -442,7 +444,7 @@ def list_targets(self) -> list[str]:
442444
~vws.exceptions.vws_exceptions.TooManyRequestsError: Vuforia is
443445
rate limiting access.
444446
"""
445-
response = self._make_request(
447+
response = self.make_request(
446448
method=HTTPMethod.GET,
447449
data=b"",
448450
request_path="/targets",
@@ -479,7 +481,7 @@ def get_target_summary_report(self, target_id: str) -> TargetSummaryReport:
479481
~vws.exceptions.vws_exceptions.TooManyRequestsError: Vuforia is
480482
rate limiting access.
481483
"""
482-
response = self._make_request(
484+
response = self.make_request(
483485
method=HTTPMethod.GET,
484486
data=b"",
485487
request_path=f"/summary/{target_id}",
@@ -522,7 +524,7 @@ def get_database_summary_report(self) -> DatabaseSummaryReport:
522524
~vws.exceptions.vws_exceptions.TooManyRequestsError: Vuforia is
523525
rate limiting access.
524526
"""
525-
response = self._make_request(
527+
response = self.make_request(
526528
method=HTTPMethod.GET,
527529
data=b"",
528530
request_path="/summary",
@@ -572,7 +574,7 @@ def delete_target(self, target_id: str) -> None:
572574
~vws.exceptions.vws_exceptions.TooManyRequestsError: Vuforia is
573575
rate limiting access.
574576
"""
575-
self._make_request(
577+
self.make_request(
576578
method=HTTPMethod.DELETE,
577579
data=b"",
578580
request_path=f"/targets/{target_id}",
@@ -609,7 +611,7 @@ def get_duplicate_targets(self, target_id: str) -> list[str]:
609611
~vws.exceptions.vws_exceptions.TooManyRequestsError: Vuforia is
610612
rate limiting access.
611613
"""
612-
response = self._make_request(
614+
response = self.make_request(
613615
method=HTTPMethod.GET,
614616
data=b"",
615617
request_path=f"/duplicates/{target_id}",
@@ -695,7 +697,7 @@ def update_target(
695697

696698
content = json.dumps(obj=data).encode(encoding="utf-8")
697699

698-
self._make_request(
700+
self.make_request(
699701
method=HTTPMethod.PUT,
700702
data=content,
701703
request_path=f"/targets/{target_id}",

0 commit comments

Comments
 (0)