@@ -64,6 +64,8 @@ def _get_image_data(image: _ImageType) -> bytes:
64
64
65
65
@beartype
66
66
def _target_api_request (
67
+ * ,
68
+ content_type : str ,
67
69
server_access_key : str ,
68
70
server_secret_key : str ,
69
71
method : str ,
@@ -75,9 +77,9 @@ def _target_api_request(
75
77
Make a request to the Vuforia Target API.
76
78
77
79
This uses `requests` to make a request against https://vws.vuforia.com.
78
- The content type of the request will be `application/json`.
79
80
80
81
Args:
82
+ content_type: The content type of the request.
81
83
server_access_key: A VWS server access key.
82
84
server_secret_key: A VWS server secret key.
83
85
method: The HTTP method which will be used in the request.
@@ -90,7 +92,6 @@ def _target_api_request(
90
92
The response to the request made by `requests`.
91
93
"""
92
94
date_string = rfc_1123_date ()
93
- content_type = "application/json"
94
95
95
96
signature_string = authorization_header (
96
97
access_key = server_access_key ,
@@ -152,16 +153,17 @@ def __init__(
152
153
153
154
def make_request (
154
155
self ,
156
+ * ,
155
157
method : str ,
156
158
data : bytes ,
157
159
request_path : str ,
158
160
expected_result_code : str ,
161
+ content_type : str ,
159
162
) -> Response :
160
163
"""
161
164
Make a request to the Vuforia Target API.
162
165
163
166
This uses `requests` to make a request against Vuforia.
164
- The content type of the request will be `application/json`.
165
167
166
168
Args:
167
169
method: The HTTP method which will be used in the request.
@@ -170,6 +172,7 @@ def make_request(
170
172
request.
171
173
expected_result_code: See "VWS API Result Codes" on
172
174
https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api.
175
+ content_type: The content type of the request.
173
176
174
177
Returns:
175
178
The response to the request made by `requests`.
@@ -190,6 +193,7 @@ def make_request(
190
193
server.
191
194
"""
192
195
response = _target_api_request (
196
+ content_type = content_type ,
193
197
server_access_key = self ._server_access_key ,
194
198
server_secret_key = self ._server_secret_key ,
195
199
method = method ,
@@ -316,6 +320,7 @@ def add_target(
316
320
data = content ,
317
321
request_path = "/targets" ,
318
322
expected_result_code = "TargetCreated" ,
323
+ content_type = "application/json" ,
319
324
)
320
325
321
326
return str (json .loads (s = response .text )["target_id" ])
@@ -353,6 +358,7 @@ def get_target_record(self, target_id: str) -> TargetStatusAndRecord:
353
358
data = b"" ,
354
359
request_path = f"/targets/{ target_id } " ,
355
360
expected_result_code = "Success" ,
361
+ content_type = "application/json" ,
356
362
)
357
363
358
364
result_data = json .loads (s = response .text )
@@ -449,6 +455,7 @@ def list_targets(self) -> list[str]:
449
455
data = b"" ,
450
456
request_path = "/targets" ,
451
457
expected_result_code = "Success" ,
458
+ content_type = "application/json" ,
452
459
)
453
460
454
461
return list (json .loads (s = response .text )["results" ])
@@ -486,6 +493,7 @@ def get_target_summary_report(self, target_id: str) -> TargetSummaryReport:
486
493
data = b"" ,
487
494
request_path = f"/summary/{ target_id } " ,
488
495
expected_result_code = "Success" ,
496
+ content_type = "application/json" ,
489
497
)
490
498
491
499
result_data = dict (json .loads (s = response .text ))
@@ -529,6 +537,7 @@ def get_database_summary_report(self) -> DatabaseSummaryReport:
529
537
data = b"" ,
530
538
request_path = "/summary" ,
531
539
expected_result_code = "Success" ,
540
+ content_type = "application/json" ,
532
541
)
533
542
534
543
response_data = dict (json .loads (s = response .text ))
@@ -579,6 +588,7 @@ def delete_target(self, target_id: str) -> None:
579
588
data = b"" ,
580
589
request_path = f"/targets/{ target_id } " ,
581
590
expected_result_code = "Success" ,
591
+ content_type = "application/json" ,
582
592
)
583
593
584
594
def get_duplicate_targets (self , target_id : str ) -> list [str ]:
@@ -616,6 +626,7 @@ def get_duplicate_targets(self, target_id: str) -> list[str]:
616
626
data = b"" ,
617
627
request_path = f"/duplicates/{ target_id } " ,
618
628
expected_result_code = "Success" ,
629
+ content_type = "application/json" ,
619
630
)
620
631
621
632
return list (json .loads (s = response .text )["similar_targets" ])
@@ -702,4 +713,5 @@ def update_target(
702
713
data = content ,
703
714
request_path = f"/targets/{ target_id } " ,
704
715
expected_result_code = "Success" ,
716
+ content_type = "application/json" ,
705
717
)
0 commit comments