victorycode-sdk 1.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.
Files changed (121) hide show
  1. victorycode_sdk/__init__.py +260 -0
  2. victorycode_sdk/api/__init__.py +13 -0
  3. victorycode_sdk/api/authentication_api.py +285 -0
  4. victorycode_sdk/api/classification_api.py +1203 -0
  5. victorycode_sdk/api/game_recap_api.py +1395 -0
  6. victorycode_sdk/api/games_api.py +1497 -0
  7. victorycode_sdk/api/mascot_api.py +1203 -0
  8. victorycode_sdk/api/plays_events_api.py +1057 -0
  9. victorycode_sdk/api/teams_api.py +1220 -0
  10. victorycode_sdk/api/uploads_api.py +872 -0
  11. victorycode_sdk/api/venue_api.py +1203 -0
  12. victorycode_sdk/api_client.py +833 -0
  13. victorycode_sdk/api_response.py +21 -0
  14. victorycode_sdk/configuration.py +698 -0
  15. victorycode_sdk/exceptions.py +218 -0
  16. victorycode_sdk/models/__init__.py +114 -0
  17. victorycode_sdk/models/add_video_to_game_with_s3_link_dto.py +90 -0
  18. victorycode_sdk/models/address.py +96 -0
  19. victorycode_sdk/models/address_dto.py +96 -0
  20. victorycode_sdk/models/bad_request_error_response_dto.py +90 -0
  21. victorycode_sdk/models/classification.py +90 -0
  22. victorycode_sdk/models/client_create_game_with_video_url_dto.py +130 -0
  23. victorycode_sdk/models/complete_multipart_upload_dto.py +97 -0
  24. victorycode_sdk/models/complete_multipart_upload_response.py +90 -0
  25. victorycode_sdk/models/complete_multipart_upload_response_dto.py +94 -0
  26. victorycode_sdk/models/completed_part_dto.py +90 -0
  27. victorycode_sdk/models/conflict_error_response_dto.py +90 -0
  28. victorycode_sdk/models/coordinates.py +90 -0
  29. victorycode_sdk/models/coordinates_dto.py +90 -0
  30. victorycode_sdk/models/create_classification_dto.py +90 -0
  31. victorycode_sdk/models/create_mascot_dto.py +90 -0
  32. victorycode_sdk/models/create_team_dto.py +108 -0
  33. victorycode_sdk/models/create_team_response_dto.py +106 -0
  34. victorycode_sdk/models/create_venue_dto.py +102 -0
  35. victorycode_sdk/models/defense_section_dto.py +101 -0
  36. victorycode_sdk/models/defense_stats_dto.py +106 -0
  37. victorycode_sdk/models/defense_totals_dto.py +100 -0
  38. victorycode_sdk/models/delete_response_dto.py +90 -0
  39. victorycode_sdk/models/down_efficiency_dto.py +90 -0
  40. victorycode_sdk/models/fetch_team_response_dto.py +117 -0
  41. victorycode_sdk/models/fumble_section_dto.py +101 -0
  42. victorycode_sdk/models/fumble_stats_dto.py +98 -0
  43. victorycode_sdk/models/fumble_totals_dto.py +92 -0
  44. victorycode_sdk/models/game_all_play_list_item_dto.py +106 -0
  45. victorycode_sdk/models/game_box_score_meta_dto.py +104 -0
  46. victorycode_sdk/models/game_box_score_response_dto.py +98 -0
  47. victorycode_sdk/models/game_box_score_teams_dto.py +97 -0
  48. victorycode_sdk/models/game_details_response.py +108 -0
  49. victorycode_sdk/models/game_recap_scoring_summary_pro_response.py +101 -0
  50. victorycode_sdk/models/game_recap_scoring_summary_response.py +101 -0
  51. victorycode_sdk/models/game_recap_team_stats_response.py +101 -0
  52. victorycode_sdk/models/game_score_response.py +101 -0
  53. victorycode_sdk/models/game_scoring_summary_data_dto.py +104 -0
  54. victorycode_sdk/models/get_parts_presign_url_response.py +88 -0
  55. victorycode_sdk/models/get_parts_presign_url_response_dto.py +94 -0
  56. victorycode_sdk/models/initiate_multipart_upload_dto.py +92 -0
  57. victorycode_sdk/models/initiate_multipart_upload_response.py +88 -0
  58. victorycode_sdk/models/initiate_multipart_upload_response_dto.py +94 -0
  59. victorycode_sdk/models/interception_section_dto.py +101 -0
  60. victorycode_sdk/models/interception_stats_dto.py +98 -0
  61. victorycode_sdk/models/interception_totals_dto.py +92 -0
  62. victorycode_sdk/models/kicking_section_dto.py +101 -0
  63. victorycode_sdk/models/kicking_stats_dto.py +106 -0
  64. victorycode_sdk/models/kicking_totals_dto.py +100 -0
  65. victorycode_sdk/models/line_of_scrimmage_dto.py +90 -0
  66. victorycode_sdk/models/list_classification_paginated_response_dto.py +101 -0
  67. victorycode_sdk/models/list_game_all_plays_response_dto.py +103 -0
  68. victorycode_sdk/models/list_games_paginated_response_dto.py +101 -0
  69. victorycode_sdk/models/list_mascot_paginated_response_dto.py +101 -0
  70. victorycode_sdk/models/list_play_clips_response_dto.py +105 -0
  71. victorycode_sdk/models/list_team_paginated_response_dto.py +101 -0
  72. victorycode_sdk/models/list_venue_paginated_response_dto.py +101 -0
  73. victorycode_sdk/models/list_video_paginated_response_dto.py +103 -0
  74. victorycode_sdk/models/mascot.py +90 -0
  75. victorycode_sdk/models/mascot_response_dto.py +96 -0
  76. victorycode_sdk/models/not_found_error_response_dto.py +90 -0
  77. victorycode_sdk/models/offense_dto.py +92 -0
  78. victorycode_sdk/models/passing_dto.py +98 -0
  79. victorycode_sdk/models/passing_section_dto.py +101 -0
  80. victorycode_sdk/models/passing_stats_dto.py +117 -0
  81. victorycode_sdk/models/passing_totals_dto.py +111 -0
  82. victorycode_sdk/models/period_score_dto.py +94 -0
  83. victorycode_sdk/models/play_attributes_list_dto.py +106 -0
  84. victorycode_sdk/models/play_clip_list_details_dto.py +104 -0
  85. victorycode_sdk/models/play_clip_list_item_dto.py +104 -0
  86. victorycode_sdk/models/pro_scoring_play_dto.py +202 -0
  87. victorycode_sdk/models/receiving_section_dto.py +101 -0
  88. victorycode_sdk/models/receiving_stats_dto.py +104 -0
  89. victorycode_sdk/models/receiving_totals_dto.py +98 -0
  90. victorycode_sdk/models/red_zone_dto.py +90 -0
  91. victorycode_sdk/models/rushing_dto.py +92 -0
  92. victorycode_sdk/models/rushing_section_dto.py +101 -0
  93. victorycode_sdk/models/rushing_stats_dto.py +102 -0
  94. victorycode_sdk/models/rushing_totals_dto.py +96 -0
  95. victorycode_sdk/models/scoring_play_player_involved_dto.py +106 -0
  96. victorycode_sdk/models/scoring_summary_pro_team_dto.py +90 -0
  97. victorycode_sdk/models/single_classification_response_dto.py +94 -0
  98. victorycode_sdk/models/single_mascot_response_dto.py +94 -0
  99. victorycode_sdk/models/single_team_response_dto.py +94 -0
  100. victorycode_sdk/models/single_venue_response_dto.py +99 -0
  101. victorycode_sdk/models/single_video_response_dto.py +94 -0
  102. victorycode_sdk/models/team_basic_info_dto.py +96 -0
  103. victorycode_sdk/models/team_box_score_dto.py +139 -0
  104. victorycode_sdk/models/team_score_dto.py +109 -0
  105. victorycode_sdk/models/team_stats_dto.py +137 -0
  106. victorycode_sdk/models/token_response.py +92 -0
  107. victorycode_sdk/models/turnovers_dto.py +92 -0
  108. victorycode_sdk/models/unauthorized_error_response_dto.py +90 -0
  109. victorycode_sdk/models/update_classification_dto.py +90 -0
  110. victorycode_sdk/models/update_mascot_dto.py +90 -0
  111. victorycode_sdk/models/update_team_dto.py +108 -0
  112. victorycode_sdk/models/update_venue_dto.py +102 -0
  113. victorycode_sdk/models/venue.py +102 -0
  114. victorycode_sdk/models/video_list_item_dto.py +96 -0
  115. victorycode_sdk/py.typed +0 -0
  116. victorycode_sdk/rest.py +334 -0
  117. victorycode_sdk-1.0.0.dist-info/METADATA +288 -0
  118. victorycode_sdk-1.0.0.dist-info/RECORD +121 -0
  119. victorycode_sdk-1.0.0.dist-info/WHEEL +5 -0
  120. victorycode_sdk-1.0.0.dist-info/licenses/LICENSE +21 -0
  121. victorycode_sdk-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,698 @@
1
+ """
2
+ Victory Code Client API
3
+
4
+ Client APIs for Tactix partners: authenticate, upload game video, and retrieve games, plays, game recaps and team metadata.
5
+
6
+ The version of the OpenAPI document: 1.0
7
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
8
+
9
+ Do not edit the class manually.
10
+ """ # noqa: E501
11
+
12
+
13
+ import copy
14
+ import http.client as httplib
15
+ import logging
16
+ from logging import FileHandler
17
+ import multiprocessing
18
+ import ssl
19
+ import sys
20
+ from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union
21
+ from urllib.parse import urlparse
22
+ from urllib.request import getproxies
23
+ from typing_extensions import NotRequired, Self
24
+
25
+ import urllib3
26
+
27
+
28
+ JSON_SCHEMA_VALIDATION_KEYWORDS = {
29
+ 'multipleOf', 'maximum', 'exclusiveMaximum',
30
+ 'minimum', 'exclusiveMinimum', 'maxLength',
31
+ 'minLength', 'pattern', 'maxItems', 'minItems'
32
+ }
33
+
34
+ ServerVariablesT = Dict[str, str]
35
+
36
+ GenericAuthSetting = TypedDict(
37
+ "GenericAuthSetting",
38
+ {
39
+ "type": str,
40
+ "in": str,
41
+ "key": str,
42
+ "value": str,
43
+ },
44
+ )
45
+
46
+
47
+ OAuth2AuthSetting = TypedDict(
48
+ "OAuth2AuthSetting",
49
+ {
50
+ "type": Literal["oauth2"],
51
+ "in": Literal["header"],
52
+ "key": Literal["Authorization"],
53
+ "value": str,
54
+ },
55
+ )
56
+
57
+
58
+ APIKeyAuthSetting = TypedDict(
59
+ "APIKeyAuthSetting",
60
+ {
61
+ "type": Literal["api_key"],
62
+ "in": str,
63
+ "key": str,
64
+ "value": Optional[str],
65
+ },
66
+ )
67
+
68
+
69
+ BasicAuthSetting = TypedDict(
70
+ "BasicAuthSetting",
71
+ {
72
+ "type": Literal["basic"],
73
+ "in": Literal["header"],
74
+ "key": Literal["Authorization"],
75
+ "value": Optional[str],
76
+ },
77
+ )
78
+
79
+
80
+ BearerFormatAuthSetting = TypedDict(
81
+ "BearerFormatAuthSetting",
82
+ {
83
+ "type": Literal["bearer"],
84
+ "in": Literal["header"],
85
+ "format": Literal["JWT"],
86
+ "key": Literal["Authorization"],
87
+ "value": str,
88
+ },
89
+ )
90
+
91
+
92
+ BearerAuthSetting = TypedDict(
93
+ "BearerAuthSetting",
94
+ {
95
+ "type": Literal["bearer"],
96
+ "in": Literal["header"],
97
+ "key": Literal["Authorization"],
98
+ "value": str,
99
+ },
100
+ )
101
+
102
+
103
+ HTTPSignatureAuthSetting = TypedDict(
104
+ "HTTPSignatureAuthSetting",
105
+ {
106
+ "type": Literal["http-signature"],
107
+ "in": Literal["header"],
108
+ "key": Literal["Authorization"],
109
+ "value": None,
110
+ },
111
+ )
112
+
113
+
114
+ AuthSettings = TypedDict(
115
+ "AuthSettings",
116
+ {
117
+ "Client-App-Id": APIKeyAuthSetting,
118
+ "Client-App-Token": BearerFormatAuthSetting,
119
+ "AppSecret": APIKeyAuthSetting,
120
+ },
121
+ total=False,
122
+ )
123
+
124
+
125
+ class HostSettingVariable(TypedDict):
126
+ description: str
127
+ default_value: str
128
+ enum_values: List[str]
129
+
130
+
131
+ class HostSetting(TypedDict):
132
+ url: str
133
+ description: str
134
+ variables: NotRequired[Dict[str, HostSettingVariable]]
135
+
136
+
137
+ class Configuration:
138
+ """This class contains various settings of the API client.
139
+
140
+ :param host: Base url.
141
+ :param ignore_operation_servers
142
+ Boolean to ignore operation servers for the API client.
143
+ Config will use `host` as the base url regardless of the operation servers.
144
+ :param api_key: Dict to store API key(s).
145
+ Each entry in the dict specifies an API key.
146
+ The dict key is the name of the security scheme in the OAS specification.
147
+ The dict value is the API key secret.
148
+ :param api_key_prefix: Dict to store API prefix (e.g. Bearer).
149
+ The dict key is the name of the security scheme in the OAS specification.
150
+ The dict value is an API key prefix when generating the auth data.
151
+ :param username: Username for HTTP basic authentication.
152
+ :param password: Password for HTTP basic authentication.
153
+ :param access_token: Access token.
154
+ :param server_index: Index to servers configuration.
155
+ :param server_variables: Mapping with string values to replace variables in
156
+ templated server configuration. The validation of enums is performed for
157
+ variables with defined enum values before.
158
+ :param server_operation_index: Mapping from operation ID to an index to server
159
+ configuration.
160
+ :param server_operation_variables: Mapping from operation ID to a mapping with
161
+ string values to replace variables in templated server configuration.
162
+ The validation of enums is performed for variables with defined enum
163
+ values before.
164
+ :param verify_ssl: bool - Set this to false to skip verifying SSL certificate
165
+ when calling API from https server.
166
+ :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
167
+ in PEM format.
168
+ :param retries: int | urllib3.util.retry.Retry - Retry configuration.
169
+ :param ca_cert_data: verify the peer using concatenated CA certificate data
170
+ in PEM (str) or DER (bytes) format.
171
+ :param cert_file: the path to a client certificate file, for mTLS.
172
+ :param key_file: the path to a client key file, for mTLS.
173
+ :param assert_hostname: Set this to True/False to enable/disable SSL hostname verification.
174
+ :param tls_server_name: SSL/TLS Server Name Indication (SNI). Set this to the SNI value expected by the server.
175
+ :param connection_pool_maxsize: Connection pool max size. None in the constructor is coerced to 100 for async and cpu_count * 5 for sync.
176
+ :param proxy: Proxy URL.
177
+ :param no_proxy: Comma-separated hosts that bypass the proxy.
178
+ :param proxy_headers: Proxy headers.
179
+ :param proxy_ssl_context: SSL context used only for the TLS handshake with the proxy itself, independent of the destination TLS settings.
180
+ :param safe_chars_for_path_param: Safe characters for path parameter encoding.
181
+ :param client_side_validation: Enable client-side validation. Default True.
182
+ :param socket_options: Options to pass down to the underlying urllib3 socket.
183
+ :param datetime_format: Datetime format string for serialization.
184
+ :param date_format: Date format string for serialization.
185
+
186
+ :Example:
187
+
188
+ API Key Authentication Example.
189
+ Given the following security scheme in the OpenAPI specification:
190
+ components:
191
+ securitySchemes:
192
+ cookieAuth: # name for the security scheme
193
+ type: apiKey
194
+ in: cookie
195
+ name: JSESSIONID # cookie name
196
+
197
+ You can programmatically set the cookie:
198
+
199
+ conf = victorycode_sdk.Configuration(
200
+ api_key={'cookieAuth': 'abc123'}
201
+ api_key_prefix={'cookieAuth': 'JSESSIONID'}
202
+ )
203
+
204
+ The following cookie will be added to the HTTP request:
205
+ Cookie: JSESSIONID abc123
206
+ """
207
+
208
+ _default: ClassVar[Optional[Self]] = None
209
+
210
+ def __init__(
211
+ self,
212
+ host: Optional[str]=None,
213
+ api_key: Optional[Dict[str, str]]=None,
214
+ api_key_prefix: Optional[Dict[str, str]]=None,
215
+ username: Optional[str]=None,
216
+ password: Optional[str]=None,
217
+ access_token: Optional[str]=None,
218
+ server_index: Optional[int]=None,
219
+ server_variables: Optional[ServerVariablesT]=None,
220
+ server_operation_index: Optional[Dict[int, int]]=None,
221
+ server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
222
+ ignore_operation_servers: bool=False,
223
+ ssl_ca_cert: Optional[str]=None,
224
+ retries: Optional[Union[int, urllib3.util.retry.Retry]] = None,
225
+ ca_cert_data: Optional[Union[str, bytes]] = None,
226
+ cert_file: Optional[str]=None,
227
+ key_file: Optional[str]=None,
228
+ verify_ssl: bool=True,
229
+ assert_hostname: Optional[bool]=None,
230
+ tls_server_name: Optional[str]=None,
231
+ connection_pool_maxsize: Optional[int]=None,
232
+ proxy: Optional[str]=None,
233
+ no_proxy: Optional[str]=None,
234
+ proxy_headers: Optional[Any]=None,
235
+ proxy_ssl_context: Optional[ssl.SSLContext]=None,
236
+ safe_chars_for_path_param: str='',
237
+ client_side_validation: bool=True,
238
+ socket_options: Optional[Any]=None,
239
+ datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z",
240
+ date_format: str="%Y-%m-%d",
241
+ *,
242
+ debug: Optional[bool] = None,
243
+ ) -> None:
244
+ """Constructor
245
+ """
246
+ self._base_path = "https://sandbox.api.tactixai.com" if host is None else host
247
+ """Default Base url
248
+ """
249
+ self.server_index = 0 if server_index is None and host is None else server_index
250
+ self.server_operation_index = server_operation_index or {}
251
+ """Default server index
252
+ """
253
+ self.server_variables = server_variables or {}
254
+ self.server_operation_variables = server_operation_variables or {}
255
+ """Default server variables
256
+ """
257
+ self.ignore_operation_servers = ignore_operation_servers
258
+ """Ignore operation servers
259
+ """
260
+ self.temp_folder_path = None
261
+ """Temp file folder for downloading files
262
+ """
263
+ # Authentication Settings
264
+ self.api_key = {}
265
+ if api_key:
266
+ self.api_key = api_key
267
+ """dict to store API key(s)
268
+ """
269
+ self.api_key_prefix = {}
270
+ if api_key_prefix:
271
+ self.api_key_prefix = api_key_prefix
272
+ """dict to store API prefix (e.g. Bearer)
273
+ """
274
+ self.refresh_api_key_hook = None
275
+ """function hook to refresh API key if expired
276
+ """
277
+ self.username = username
278
+ """Username for HTTP basic authentication
279
+ """
280
+ self.password = password
281
+ """Password for HTTP basic authentication
282
+ """
283
+ self.access_token = access_token
284
+ """Access token
285
+ """
286
+ self.logger = {}
287
+ """Logging Settings
288
+ """
289
+ self.logger["package_logger"] = logging.getLogger("victorycode_sdk")
290
+ self.logger["urllib3_logger"] = logging.getLogger("urllib3")
291
+ self.logger_format = '%(asctime)s %(levelname)s %(message)s'
292
+ """Log format
293
+ """
294
+ self.logger_stream_handler = None
295
+ """Log stream handler
296
+ """
297
+ self.logger_file_handler: Optional[FileHandler] = None
298
+ """Log file handler
299
+ """
300
+ self.logger_file = None
301
+ """Debug file location
302
+ """
303
+ if debug is not None:
304
+ self.debug = debug
305
+ else:
306
+ self.__debug = False
307
+ """Debug switch
308
+ """
309
+
310
+ self.verify_ssl = verify_ssl
311
+ """SSL/TLS verification
312
+ Set this to false to skip verifying SSL certificate when calling API
313
+ from https server.
314
+ """
315
+ self.ssl_ca_cert = ssl_ca_cert
316
+ """Set this to customize the certificate file to verify the peer.
317
+ """
318
+ self.ca_cert_data = ca_cert_data
319
+ """Set this to verify the peer using PEM (str) or DER (bytes)
320
+ certificate data.
321
+ """
322
+ self.cert_file = cert_file
323
+ """client certificate file
324
+ """
325
+ self.key_file = key_file
326
+ """client key file
327
+ """
328
+ self.assert_hostname = assert_hostname
329
+ """Set this to True/False to enable/disable SSL hostname verification.
330
+ """
331
+ self.tls_server_name = tls_server_name
332
+ """SSL/TLS Server Name Indication (SNI)
333
+ Set this to the SNI value expected by the server.
334
+ """
335
+
336
+ self.connection_pool_maxsize = connection_pool_maxsize if connection_pool_maxsize is not None else multiprocessing.cpu_count() * 5
337
+ """urllib3 connection pool's maximum number of connections saved
338
+ per pool. None in the constructor is coerced to cpu_count * 5.
339
+ """
340
+
341
+ # urllib3 does not read proxy environment variables itself:
342
+ # https://github.com/urllib3/urllib3/issues/1785
343
+ # A proxy taken from the environment is re-resolved when the host is
344
+ # assigned; see the host setter.
345
+ self._proxy_from_env = proxy is None
346
+ if proxy is None or no_proxy is None:
347
+ proxies = getproxies()
348
+ if proxy is None:
349
+ proxy = self._env_proxy(proxies, self.host)
350
+ if no_proxy is None:
351
+ no_proxy = proxies.get("no")
352
+ self._proxy = proxy
353
+ self.no_proxy = no_proxy
354
+ """Hosts that bypass the proxy
355
+ """
356
+ self.proxy_headers = proxy_headers
357
+ """Proxy headers
358
+ """
359
+ self.proxy_ssl_context = proxy_ssl_context
360
+ """SSL context used only for the TLS handshake with the proxy itself
361
+ (e.g. an HTTPS CONNECT tunnel), independent of the destination TLS
362
+ settings above.
363
+ """
364
+ self.safe_chars_for_path_param = safe_chars_for_path_param
365
+ """Safe chars for path_param
366
+ """
367
+ self.retries = retries
368
+ """Retry configuration
369
+ """
370
+ # Enable client side validation
371
+ self.client_side_validation = client_side_validation
372
+
373
+ self.socket_options = socket_options
374
+ """Options to pass down to the underlying urllib3 socket
375
+ """
376
+
377
+ self.datetime_format = datetime_format
378
+ """datetime format
379
+ """
380
+
381
+ self.date_format = date_format
382
+ """date format
383
+ """
384
+
385
+ def __deepcopy__(self, memo: Dict[int, Any]) -> Self:
386
+ cls = self.__class__
387
+ result = cls.__new__(cls)
388
+ memo[id(self)] = result
389
+ for k, v in self.__dict__.items():
390
+ if k == 'proxy_ssl_context':
391
+ # ssl.SSLContext holds unpicklable C state and can't be deepcopied.
392
+ setattr(result, k, v)
393
+ continue
394
+ if k not in ('logger', 'logger_file_handler'):
395
+ setattr(result, k, copy.deepcopy(v, memo))
396
+ # shallow copy of loggers
397
+ result.logger = copy.copy(self.logger)
398
+ # use setter to re-create the file handler (excluded from __dict__ copy)
399
+ result.logger_file = self.logger_file
400
+
401
+ return result
402
+
403
+ def __setattr__(self, name: str, value: Any) -> None:
404
+ object.__setattr__(self, name, value)
405
+
406
+ @classmethod
407
+ def set_default(cls, default: Optional[Self]) -> None:
408
+ """Set default instance of configuration.
409
+
410
+ It stores default configuration, which can be
411
+ returned by get_default_copy method.
412
+
413
+ :param default: object of Configuration
414
+ """
415
+ cls._default = default
416
+
417
+ @classmethod
418
+ def get_default_copy(cls) -> Self:
419
+ """Deprecated. Please use `get_default` instead.
420
+
421
+ Deprecated. Please use `get_default` instead.
422
+
423
+ :return: The configuration object.
424
+ """
425
+ return cls.get_default()
426
+
427
+ @classmethod
428
+ def get_default(cls) -> Self:
429
+ """Return the default configuration.
430
+
431
+ This method returns newly created, based on default constructor,
432
+ object of Configuration class or returns a copy of default
433
+ configuration.
434
+
435
+ :return: The configuration object.
436
+ """
437
+ if cls._default is None:
438
+ cls._default = cls()
439
+ return cls._default
440
+
441
+ @property
442
+ def logger_file(self) -> Optional[str]:
443
+ """The logger file.
444
+
445
+ If the logger_file is None, then add stream handler and remove file
446
+ handler. Otherwise, add file handler and remove stream handler.
447
+
448
+ :param value: The logger_file path.
449
+ :type: str
450
+ """
451
+ return self.__logger_file
452
+
453
+ @logger_file.setter
454
+ def logger_file(self, value: Optional[str]) -> None:
455
+ """The logger file.
456
+
457
+ If the logger_file is None, then add stream handler and remove file
458
+ handler. Otherwise, add file handler and remove stream handler.
459
+
460
+ :param value: The logger_file path.
461
+ :type: str
462
+ """
463
+ self.__logger_file = value
464
+ if self.__logger_file:
465
+ # If set logging file,
466
+ # then add file handler and remove stream handler.
467
+ self.logger_file_handler = logging.FileHandler(self.__logger_file)
468
+ self.logger_file_handler.setFormatter(self.logger_formatter)
469
+ for _, logger in self.logger.items():
470
+ logger.addHandler(self.logger_file_handler)
471
+
472
+ @property
473
+ def debug(self) -> bool:
474
+ """Debug status
475
+
476
+ :param value: The debug status, True or False.
477
+ :type: bool
478
+ """
479
+ return self.__debug
480
+
481
+ @debug.setter
482
+ def debug(self, value: bool) -> None:
483
+ """Debug status
484
+
485
+ :param value: The debug status, True or False.
486
+ :type: bool
487
+ """
488
+ self.__debug = value
489
+ if self.__debug:
490
+ # if debug status is True, turn on debug logging
491
+ for _, logger in self.logger.items():
492
+ logger.setLevel(logging.DEBUG)
493
+ # turn on httplib debug
494
+ httplib.HTTPConnection.debuglevel = 1
495
+ else:
496
+ # if debug status is False, turn off debug logging,
497
+ # setting log level to default `logging.WARNING`
498
+ for _, logger in self.logger.items():
499
+ logger.setLevel(logging.WARNING)
500
+ # turn off httplib debug
501
+ httplib.HTTPConnection.debuglevel = 0
502
+
503
+ @property
504
+ def logger_format(self) -> str:
505
+ """The logger format.
506
+
507
+ The logger_formatter will be updated when sets logger_format.
508
+
509
+ :param value: The format string.
510
+ :type: str
511
+ """
512
+ return self.__logger_format
513
+
514
+ @logger_format.setter
515
+ def logger_format(self, value: str) -> None:
516
+ """The logger format.
517
+
518
+ The logger_formatter will be updated when sets logger_format.
519
+
520
+ :param value: The format string.
521
+ :type: str
522
+ """
523
+ self.__logger_format = value
524
+ self.logger_formatter = logging.Formatter(self.__logger_format)
525
+
526
+ def get_api_key_with_prefix(self, identifier: str, alias: Optional[str]=None) -> Optional[str]:
527
+ """Gets API key (with prefix if set).
528
+
529
+ :param identifier: The identifier of apiKey.
530
+ :param alias: The alternative identifier of apiKey.
531
+ :return: The token for api key authentication.
532
+ """
533
+ if self.refresh_api_key_hook is not None:
534
+ self.refresh_api_key_hook(self)
535
+ key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
536
+ if key:
537
+ prefix = self.api_key_prefix.get(
538
+ identifier, self.api_key_prefix.get(alias) if alias is not None else None)
539
+ if prefix:
540
+ return "%s %s" % (prefix, key)
541
+ else:
542
+ return key
543
+
544
+ return None
545
+
546
+ def get_basic_auth_token(self) -> Optional[str]:
547
+ """Gets HTTP basic authentication header (string).
548
+
549
+ :return: The token for basic HTTP authentication.
550
+ """
551
+ username = ""
552
+ if self.username is not None:
553
+ username = self.username
554
+ password = ""
555
+ if self.password is not None:
556
+ password = self.password
557
+
558
+ return urllib3.util.make_headers(
559
+ basic_auth=username + ':' + password
560
+ ).get('authorization')
561
+
562
+ def auth_settings(self)-> AuthSettings:
563
+ """Gets Auth Settings dict for api client.
564
+
565
+ :return: The Auth Settings information dict.
566
+ """
567
+ auth: AuthSettings = {}
568
+ if 'Client-App-Id' in self.api_key:
569
+ auth['Client-App-Id'] = {
570
+ 'type': 'api_key',
571
+ 'in': 'header',
572
+ 'key': 'App-Id',
573
+ 'value': self.get_api_key_with_prefix(
574
+ 'Client-App-Id',
575
+ ),
576
+ }
577
+ if self.access_token is not None:
578
+ auth['Client-App-Token'] = {
579
+ 'type': 'bearer',
580
+ 'in': 'header',
581
+ 'format': 'JWT',
582
+ 'key': 'Authorization',
583
+ 'value': 'Bearer ' + self.access_token
584
+ }
585
+ if 'AppSecret' in self.api_key:
586
+ auth['AppSecret'] = {
587
+ 'type': 'api_key',
588
+ 'in': 'header',
589
+ 'key': 'App-Secret',
590
+ 'value': self.get_api_key_with_prefix(
591
+ 'AppSecret',
592
+ ),
593
+ }
594
+ return auth
595
+
596
+ def to_debug_report(self) -> str:
597
+ """Gets the essential information for debugging.
598
+
599
+ :return: The report for debugging.
600
+ """
601
+ return "Python SDK Debug Report:\n"\
602
+ "OS: {env}\n"\
603
+ "Python Version: {pyversion}\n"\
604
+ "Version of the API: 1.0\n"\
605
+ "SDK Package Version: 1.0.0".\
606
+ format(env=sys.platform, pyversion=sys.version)
607
+
608
+ def get_host_settings(self) -> List[HostSetting]:
609
+ """Gets an array of host settings
610
+
611
+ :return: An array of host settings
612
+ """
613
+ return [
614
+ {
615
+ 'url': "https://sandbox.api.tactixai.com",
616
+ 'description': "Sandbox",
617
+ },
618
+ {
619
+ 'url': "https://api.tactixai.com",
620
+ 'description': "Production",
621
+ }
622
+ ]
623
+
624
+ def get_host_from_settings(
625
+ self,
626
+ index: Optional[int],
627
+ variables: Optional[ServerVariablesT]=None,
628
+ servers: Optional[List[HostSetting]]=None,
629
+ ) -> str:
630
+ """Gets host URL based on the index and variables
631
+ :param index: array index of the host settings
632
+ :param variables: hash of variable and the corresponding value
633
+ :param servers: an array of host settings or None
634
+ :return: URL based on host settings
635
+ """
636
+ if index is None:
637
+ return self._base_path
638
+
639
+ variables = {} if variables is None else variables
640
+ servers = self.get_host_settings() if servers is None else servers
641
+
642
+ try:
643
+ server = servers[index]
644
+ except IndexError:
645
+ raise ValueError(
646
+ "Invalid index {0} when selecting the host settings. "
647
+ "Must be less than {1}".format(index, len(servers)))
648
+
649
+ url = server['url']
650
+
651
+ # go through variables and replace placeholders
652
+ for variable_name, variable in server.get('variables', {}).items():
653
+ used_value = variables.get(
654
+ variable_name, variable['default_value'])
655
+
656
+ if 'enum_values' in variable \
657
+ and variable['enum_values'] \
658
+ and used_value not in variable['enum_values']:
659
+ raise ValueError(
660
+ "The variable `{0}` in the host URL has invalid value "
661
+ "{1}. Must be {2}.".format(
662
+ variable_name, variables[variable_name],
663
+ variable['enum_values']))
664
+
665
+ url = url.replace("{" + variable_name + "}", used_value)
666
+
667
+ return url
668
+
669
+ @property
670
+ def host(self) -> str:
671
+ """Return generated host."""
672
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
673
+
674
+ @host.setter
675
+ def host(self, value: str) -> None:
676
+ """Fix base path."""
677
+ self._base_path = value
678
+ self.server_index = None
679
+ if self._proxy_from_env:
680
+ # the scheme-specific proxy depends on the host, which is
681
+ # commonly assigned after construction
682
+ self._proxy = self._env_proxy(getproxies(), value)
683
+
684
+ @staticmethod
685
+ def _env_proxy(proxies: Dict[str, str], host: str) -> Optional[str]:
686
+ """Pick the environment proxy that applies to `host`."""
687
+ return proxies.get(urlparse(host).scheme) or proxies.get("all")
688
+
689
+ @property
690
+ def proxy(self) -> Optional[str]:
691
+ """Proxy URL
692
+ """
693
+ return self._proxy
694
+
695
+ @proxy.setter
696
+ def proxy(self, value: Optional[str]) -> None:
697
+ self._proxy = value
698
+ self._proxy_from_env = False