maytes-api-client-py 0.1.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.
Files changed (65) hide show
  1. maytes_api_client/__init__.py +150 -0
  2. maytes_api_client/api/__init__.py +5 -0
  3. maytes_api_client/api/default_api.py +2661 -0
  4. maytes_api_client/api_client.py +804 -0
  5. maytes_api_client/api_response.py +21 -0
  6. maytes_api_client/configuration.py +630 -0
  7. maytes_api_client/exceptions.py +218 -0
  8. maytes_api_client/managed_client.py +199 -0
  9. maytes_api_client/models/__init__.py +64 -0
  10. maytes_api_client/models/cancel_checkout409_response.py +101 -0
  11. maytes_api_client/models/cancel_checkout_request.py +88 -0
  12. maytes_api_client/models/cancel_checkout_response.py +92 -0
  13. maytes_api_client/models/capture_checkout409_response.py +101 -0
  14. maytes_api_client/models/capture_checkout422_response.py +101 -0
  15. maytes_api_client/models/capture_checkout_request.py +118 -0
  16. maytes_api_client/models/capture_checkout_response.py +92 -0
  17. maytes_api_client/models/checkout.py +159 -0
  18. maytes_api_client/models/checkout_cancelled.py +97 -0
  19. maytes_api_client/models/checkout_captured.py +109 -0
  20. maytes_api_client/models/checkout_created.py +95 -0
  21. maytes_api_client/models/checkout_discount.py +133 -0
  22. maytes_api_client/models/checkout_fee.py +150 -0
  23. maytes_api_client/models/create_checkout401_response.py +101 -0
  24. maytes_api_client/models/create_checkout409_response.py +101 -0
  25. maytes_api_client/models/create_checkout422_response.py +101 -0
  26. maytes_api_client/models/create_checkout_request.py +213 -0
  27. maytes_api_client/models/create_checkout_response.py +92 -0
  28. maytes_api_client/models/create_refund_request.py +91 -0
  29. maytes_api_client/models/customer_data.py +107 -0
  30. maytes_api_client/models/digital_goods_custom_data.py +93 -0
  31. maytes_api_client/models/digital_goods_line_item.py +150 -0
  32. maytes_api_client/models/donation_line_item.py +144 -0
  33. maytes_api_client/models/error_response_dto.py +94 -0
  34. maytes_api_client/models/fee.py +103 -0
  35. maytes_api_client/models/fee_breakdown_line.py +101 -0
  36. maytes_api_client/models/food_beverage_line_item.py +144 -0
  37. maytes_api_client/models/get_checkout404_response.py +101 -0
  38. maytes_api_client/models/get_checkout422_response.py +101 -0
  39. maytes_api_client/models/get_checkout_response.py +92 -0
  40. maytes_api_client/models/get_settlement_response.py +92 -0
  41. maytes_api_client/models/health_response.py +88 -0
  42. maytes_api_client/models/line_item.py +210 -0
  43. maytes_api_client/models/list_settlements_response.py +96 -0
  44. maytes_api_client/models/o_auth_token_request.py +102 -0
  45. maytes_api_client/models/o_auth_token_response.py +96 -0
  46. maytes_api_client/models/other_line_item.py +144 -0
  47. maytes_api_client/models/physical_goods_custom_data.py +90 -0
  48. maytes_api_client/models/physical_goods_line_item.py +150 -0
  49. maytes_api_client/models/refund_checkout402_response.py +101 -0
  50. maytes_api_client/models/refund_checkout409_response.py +101 -0
  51. maytes_api_client/models/service_custom_data.py +93 -0
  52. maytes_api_client/models/service_line_item.py +150 -0
  53. maytes_api_client/models/settlement.py +160 -0
  54. maytes_api_client/models/tax.py +111 -0
  55. maytes_api_client/models/ticket_custom_data.py +125 -0
  56. maytes_api_client/models/ticket_line_item.py +150 -0
  57. maytes_api_client/models/ticket_seating.py +94 -0
  58. maytes_api_client/py.typed +0 -0
  59. maytes_api_client/rest.py +263 -0
  60. maytes_api_client/webhook_verifier.py +197 -0
  61. maytes_api_client_py-0.1.1.dist-info/METADATA +70 -0
  62. maytes_api_client_py-0.1.1.dist-info/RECORD +65 -0
  63. maytes_api_client_py-0.1.1.dist-info/WHEEL +5 -0
  64. maytes_api_client_py-0.1.1.dist-info/licenses/LICENSE +21 -0
  65. maytes_api_client_py-0.1.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ """API response object."""
2
+
3
+ from __future__ import annotations
4
+ from typing import Optional, Generic, Mapping, TypeVar
5
+ from pydantic import Field, StrictInt, StrictBytes, BaseModel
6
+
7
+ T = TypeVar("T")
8
+
9
+ class ApiResponse(BaseModel, Generic[T]):
10
+ """
11
+ API response object
12
+ """
13
+
14
+ status_code: StrictInt = Field(description="HTTP status code")
15
+ headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers")
16
+ data: T = Field(description="Deserialized data given the data type")
17
+ raw_data: StrictBytes = Field(description="Raw data (HTTP response body)")
18
+
19
+ model_config = {
20
+ "arbitrary_types_allowed": True
21
+ }
@@ -0,0 +1,630 @@
1
+ """
2
+ Maytes API
3
+
4
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0.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 sys
19
+ from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union
20
+ from typing_extensions import NotRequired, Self
21
+
22
+ import urllib3
23
+
24
+
25
+ JSON_SCHEMA_VALIDATION_KEYWORDS = {
26
+ 'multipleOf', 'maximum', 'exclusiveMaximum',
27
+ 'minimum', 'exclusiveMinimum', 'maxLength',
28
+ 'minLength', 'pattern', 'maxItems', 'minItems'
29
+ }
30
+
31
+ ServerVariablesT = Dict[str, str]
32
+
33
+ GenericAuthSetting = TypedDict(
34
+ "GenericAuthSetting",
35
+ {
36
+ "type": str,
37
+ "in": str,
38
+ "key": str,
39
+ "value": str,
40
+ },
41
+ )
42
+
43
+
44
+ OAuth2AuthSetting = TypedDict(
45
+ "OAuth2AuthSetting",
46
+ {
47
+ "type": Literal["oauth2"],
48
+ "in": Literal["header"],
49
+ "key": Literal["Authorization"],
50
+ "value": str,
51
+ },
52
+ )
53
+
54
+
55
+ APIKeyAuthSetting = TypedDict(
56
+ "APIKeyAuthSetting",
57
+ {
58
+ "type": Literal["api_key"],
59
+ "in": str,
60
+ "key": str,
61
+ "value": Optional[str],
62
+ },
63
+ )
64
+
65
+
66
+ BasicAuthSetting = TypedDict(
67
+ "BasicAuthSetting",
68
+ {
69
+ "type": Literal["basic"],
70
+ "in": Literal["header"],
71
+ "key": Literal["Authorization"],
72
+ "value": Optional[str],
73
+ },
74
+ )
75
+
76
+
77
+ BearerFormatAuthSetting = TypedDict(
78
+ "BearerFormatAuthSetting",
79
+ {
80
+ "type": Literal["bearer"],
81
+ "in": Literal["header"],
82
+ "format": Literal["JWT"],
83
+ "key": Literal["Authorization"],
84
+ "value": str,
85
+ },
86
+ )
87
+
88
+
89
+ BearerAuthSetting = TypedDict(
90
+ "BearerAuthSetting",
91
+ {
92
+ "type": Literal["bearer"],
93
+ "in": Literal["header"],
94
+ "key": Literal["Authorization"],
95
+ "value": str,
96
+ },
97
+ )
98
+
99
+
100
+ HTTPSignatureAuthSetting = TypedDict(
101
+ "HTTPSignatureAuthSetting",
102
+ {
103
+ "type": Literal["http-signature"],
104
+ "in": Literal["header"],
105
+ "key": Literal["Authorization"],
106
+ "value": None,
107
+ },
108
+ )
109
+
110
+
111
+ AuthSettings = TypedDict(
112
+ "AuthSettings",
113
+ {
114
+ "bearer": BearerFormatAuthSetting,
115
+ "basic": BasicAuthSetting,
116
+ },
117
+ total=False,
118
+ )
119
+
120
+
121
+ class HostSettingVariable(TypedDict):
122
+ description: str
123
+ default_value: str
124
+ enum_values: List[str]
125
+
126
+
127
+ class HostSetting(TypedDict):
128
+ url: str
129
+ description: str
130
+ variables: NotRequired[Dict[str, HostSettingVariable]]
131
+
132
+
133
+ class Configuration:
134
+ """This class contains various settings of the API client.
135
+
136
+ :param host: Base url.
137
+ :param ignore_operation_servers
138
+ Boolean to ignore operation servers for the API client.
139
+ Config will use `host` as the base url regardless of the operation servers.
140
+ :param api_key: Dict to store API key(s).
141
+ Each entry in the dict specifies an API key.
142
+ The dict key is the name of the security scheme in the OAS specification.
143
+ The dict value is the API key secret.
144
+ :param api_key_prefix: Dict to store API prefix (e.g. Bearer).
145
+ The dict key is the name of the security scheme in the OAS specification.
146
+ The dict value is an API key prefix when generating the auth data.
147
+ :param username: Username for HTTP basic authentication.
148
+ :param password: Password for HTTP basic authentication.
149
+ :param access_token: Access token.
150
+ :param server_index: Index to servers configuration.
151
+ :param server_variables: Mapping with string values to replace variables in
152
+ templated server configuration. The validation of enums is performed for
153
+ variables with defined enum values before.
154
+ :param server_operation_index: Mapping from operation ID to an index to server
155
+ configuration.
156
+ :param server_operation_variables: Mapping from operation ID to a mapping with
157
+ string values to replace variables in templated server configuration.
158
+ The validation of enums is performed for variables with defined enum
159
+ values before.
160
+ :param verify_ssl: bool - Set this to false to skip verifying SSL certificate
161
+ when calling API from https server.
162
+ :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
163
+ in PEM format.
164
+ :param retries: int | urllib3.util.retry.Retry - Retry configuration.
165
+ :param ca_cert_data: verify the peer using concatenated CA certificate data
166
+ in PEM (str) or DER (bytes) format.
167
+ :param cert_file: the path to a client certificate file, for mTLS.
168
+ :param key_file: the path to a client key file, for mTLS.
169
+ :param assert_hostname: Set this to True/False to enable/disable SSL hostname verification.
170
+ :param tls_server_name: SSL/TLS Server Name Indication (SNI). Set this to the SNI value expected by the server.
171
+ :param connection_pool_maxsize: Connection pool max size. None in the constructor is coerced to 100 for async and cpu_count * 5 for sync.
172
+ :param proxy: Proxy URL.
173
+ :param proxy_headers: Proxy headers.
174
+ :param safe_chars_for_path_param: Safe characters for path parameter encoding.
175
+ :param client_side_validation: Enable client-side validation. Default True.
176
+ :param socket_options: Options to pass down to the underlying urllib3 socket.
177
+ :param datetime_format: Datetime format string for serialization.
178
+ :param date_format: Date format string for serialization.
179
+
180
+ :Example:
181
+
182
+ HTTP Basic Authentication Example.
183
+ Given the following security scheme in the OpenAPI specification:
184
+ components:
185
+ securitySchemes:
186
+ http_basic_auth:
187
+ type: http
188
+ scheme: basic
189
+
190
+ Configure API client with HTTP basic authentication:
191
+
192
+ conf = maytes_api_client.Configuration(
193
+ username='the-user',
194
+ password='the-password',
195
+ )
196
+
197
+ """
198
+
199
+ _default: ClassVar[Optional[Self]] = None
200
+
201
+ def __init__(
202
+ self,
203
+ host: Optional[str]=None,
204
+ api_key: Optional[Dict[str, str]]=None,
205
+ api_key_prefix: Optional[Dict[str, str]]=None,
206
+ username: Optional[str]=None,
207
+ password: Optional[str]=None,
208
+ access_token: Optional[str]=None,
209
+ server_index: Optional[int]=None,
210
+ server_variables: Optional[ServerVariablesT]=None,
211
+ server_operation_index: Optional[Dict[int, int]]=None,
212
+ server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
213
+ ignore_operation_servers: bool=False,
214
+ ssl_ca_cert: Optional[str]=None,
215
+ retries: Optional[Union[int, urllib3.util.retry.Retry]] = None,
216
+ ca_cert_data: Optional[Union[str, bytes]] = None,
217
+ cert_file: Optional[str]=None,
218
+ key_file: Optional[str]=None,
219
+ verify_ssl: bool=True,
220
+ assert_hostname: Optional[bool]=None,
221
+ tls_server_name: Optional[str]=None,
222
+ connection_pool_maxsize: Optional[int]=None,
223
+ proxy: Optional[str]=None,
224
+ proxy_headers: Optional[Any]=None,
225
+ safe_chars_for_path_param: str='',
226
+ client_side_validation: bool=True,
227
+ socket_options: Optional[Any]=None,
228
+ datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z",
229
+ date_format: str="%Y-%m-%d",
230
+ *,
231
+ debug: Optional[bool] = None,
232
+ ) -> None:
233
+ """Constructor
234
+ """
235
+ self._base_path = "http://localhost" if host is None else host
236
+ """Default Base url
237
+ """
238
+ self.server_index = 0 if server_index is None and host is None else server_index
239
+ self.server_operation_index = server_operation_index or {}
240
+ """Default server index
241
+ """
242
+ self.server_variables = server_variables or {}
243
+ self.server_operation_variables = server_operation_variables or {}
244
+ """Default server variables
245
+ """
246
+ self.ignore_operation_servers = ignore_operation_servers
247
+ """Ignore operation servers
248
+ """
249
+ self.temp_folder_path = None
250
+ """Temp file folder for downloading files
251
+ """
252
+ # Authentication Settings
253
+ self.api_key = {}
254
+ if api_key:
255
+ self.api_key = api_key
256
+ """dict to store API key(s)
257
+ """
258
+ self.api_key_prefix = {}
259
+ if api_key_prefix:
260
+ self.api_key_prefix = api_key_prefix
261
+ """dict to store API prefix (e.g. Bearer)
262
+ """
263
+ self.refresh_api_key_hook = None
264
+ """function hook to refresh API key if expired
265
+ """
266
+ self.username = username
267
+ """Username for HTTP basic authentication
268
+ """
269
+ self.password = password
270
+ """Password for HTTP basic authentication
271
+ """
272
+ self.access_token = access_token
273
+ """Access token
274
+ """
275
+ self.logger = {}
276
+ """Logging Settings
277
+ """
278
+ self.logger["package_logger"] = logging.getLogger("maytes_api_client")
279
+ self.logger["urllib3_logger"] = logging.getLogger("urllib3")
280
+ self.logger_format = '%(asctime)s %(levelname)s %(message)s'
281
+ """Log format
282
+ """
283
+ self.logger_stream_handler = None
284
+ """Log stream handler
285
+ """
286
+ self.logger_file_handler: Optional[FileHandler] = None
287
+ """Log file handler
288
+ """
289
+ self.logger_file = None
290
+ """Debug file location
291
+ """
292
+ if debug is not None:
293
+ self.debug = debug
294
+ else:
295
+ self.__debug = False
296
+ """Debug switch
297
+ """
298
+
299
+ self.verify_ssl = verify_ssl
300
+ """SSL/TLS verification
301
+ Set this to false to skip verifying SSL certificate when calling API
302
+ from https server.
303
+ """
304
+ self.ssl_ca_cert = ssl_ca_cert
305
+ """Set this to customize the certificate file to verify the peer.
306
+ """
307
+ self.ca_cert_data = ca_cert_data
308
+ """Set this to verify the peer using PEM (str) or DER (bytes)
309
+ certificate data.
310
+ """
311
+ self.cert_file = cert_file
312
+ """client certificate file
313
+ """
314
+ self.key_file = key_file
315
+ """client key file
316
+ """
317
+ self.assert_hostname = assert_hostname
318
+ """Set this to True/False to enable/disable SSL hostname verification.
319
+ """
320
+ self.tls_server_name = tls_server_name
321
+ """SSL/TLS Server Name Indication (SNI)
322
+ Set this to the SNI value expected by the server.
323
+ """
324
+
325
+ self.connection_pool_maxsize = connection_pool_maxsize if connection_pool_maxsize is not None else multiprocessing.cpu_count() * 5
326
+ """urllib3 connection pool's maximum number of connections saved
327
+ per pool. None in the constructor is coerced to cpu_count * 5.
328
+ """
329
+
330
+ self.proxy = proxy
331
+ """Proxy URL
332
+ """
333
+ self.proxy_headers = proxy_headers
334
+ """Proxy headers
335
+ """
336
+ self.safe_chars_for_path_param = safe_chars_for_path_param
337
+ """Safe chars for path_param
338
+ """
339
+ self.retries = retries
340
+ """Retry configuration
341
+ """
342
+ # Enable client side validation
343
+ self.client_side_validation = client_side_validation
344
+
345
+ self.socket_options = socket_options
346
+ """Options to pass down to the underlying urllib3 socket
347
+ """
348
+
349
+ self.datetime_format = datetime_format
350
+ """datetime format
351
+ """
352
+
353
+ self.date_format = date_format
354
+ """date format
355
+ """
356
+
357
+ def __deepcopy__(self, memo: Dict[int, Any]) -> Self:
358
+ cls = self.__class__
359
+ result = cls.__new__(cls)
360
+ memo[id(self)] = result
361
+ for k, v in self.__dict__.items():
362
+ if k not in ('logger', 'logger_file_handler'):
363
+ setattr(result, k, copy.deepcopy(v, memo))
364
+ # shallow copy of loggers
365
+ result.logger = copy.copy(self.logger)
366
+ # use setters to configure loggers
367
+ result.logger_file = self.logger_file
368
+ result.debug = self.debug
369
+ return result
370
+
371
+ def __setattr__(self, name: str, value: Any) -> None:
372
+ object.__setattr__(self, name, value)
373
+
374
+ @classmethod
375
+ def set_default(cls, default: Optional[Self]) -> None:
376
+ """Set default instance of configuration.
377
+
378
+ It stores default configuration, which can be
379
+ returned by get_default_copy method.
380
+
381
+ :param default: object of Configuration
382
+ """
383
+ cls._default = default
384
+
385
+ @classmethod
386
+ def get_default_copy(cls) -> Self:
387
+ """Deprecated. Please use `get_default` instead.
388
+
389
+ Deprecated. Please use `get_default` instead.
390
+
391
+ :return: The configuration object.
392
+ """
393
+ return cls.get_default()
394
+
395
+ @classmethod
396
+ def get_default(cls) -> Self:
397
+ """Return the default configuration.
398
+
399
+ This method returns newly created, based on default constructor,
400
+ object of Configuration class or returns a copy of default
401
+ configuration.
402
+
403
+ :return: The configuration object.
404
+ """
405
+ if cls._default is None:
406
+ cls._default = cls()
407
+ return cls._default
408
+
409
+ @property
410
+ def logger_file(self) -> Optional[str]:
411
+ """The logger file.
412
+
413
+ If the logger_file is None, then add stream handler and remove file
414
+ handler. Otherwise, add file handler and remove stream handler.
415
+
416
+ :param value: The logger_file path.
417
+ :type: str
418
+ """
419
+ return self.__logger_file
420
+
421
+ @logger_file.setter
422
+ def logger_file(self, value: Optional[str]) -> None:
423
+ """The logger file.
424
+
425
+ If the logger_file is None, then add stream handler and remove file
426
+ handler. Otherwise, add file handler and remove stream handler.
427
+
428
+ :param value: The logger_file path.
429
+ :type: str
430
+ """
431
+ self.__logger_file = value
432
+ if self.__logger_file:
433
+ # If set logging file,
434
+ # then add file handler and remove stream handler.
435
+ self.logger_file_handler = logging.FileHandler(self.__logger_file)
436
+ self.logger_file_handler.setFormatter(self.logger_formatter)
437
+ for _, logger in self.logger.items():
438
+ logger.addHandler(self.logger_file_handler)
439
+
440
+ @property
441
+ def debug(self) -> bool:
442
+ """Debug status
443
+
444
+ :param value: The debug status, True or False.
445
+ :type: bool
446
+ """
447
+ return self.__debug
448
+
449
+ @debug.setter
450
+ def debug(self, value: bool) -> None:
451
+ """Debug status
452
+
453
+ :param value: The debug status, True or False.
454
+ :type: bool
455
+ """
456
+ self.__debug = value
457
+ if self.__debug:
458
+ # if debug status is True, turn on debug logging
459
+ for _, logger in self.logger.items():
460
+ logger.setLevel(logging.DEBUG)
461
+ # turn on httplib debug
462
+ httplib.HTTPConnection.debuglevel = 1
463
+ else:
464
+ # if debug status is False, turn off debug logging,
465
+ # setting log level to default `logging.WARNING`
466
+ for _, logger in self.logger.items():
467
+ logger.setLevel(logging.WARNING)
468
+ # turn off httplib debug
469
+ httplib.HTTPConnection.debuglevel = 0
470
+
471
+ @property
472
+ def logger_format(self) -> str:
473
+ """The logger format.
474
+
475
+ The logger_formatter will be updated when sets logger_format.
476
+
477
+ :param value: The format string.
478
+ :type: str
479
+ """
480
+ return self.__logger_format
481
+
482
+ @logger_format.setter
483
+ def logger_format(self, value: str) -> None:
484
+ """The logger format.
485
+
486
+ The logger_formatter will be updated when sets logger_format.
487
+
488
+ :param value: The format string.
489
+ :type: str
490
+ """
491
+ self.__logger_format = value
492
+ self.logger_formatter = logging.Formatter(self.__logger_format)
493
+
494
+ def get_api_key_with_prefix(self, identifier: str, alias: Optional[str]=None) -> Optional[str]:
495
+ """Gets API key (with prefix if set).
496
+
497
+ :param identifier: The identifier of apiKey.
498
+ :param alias: The alternative identifier of apiKey.
499
+ :return: The token for api key authentication.
500
+ """
501
+ if self.refresh_api_key_hook is not None:
502
+ self.refresh_api_key_hook(self)
503
+ key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
504
+ if key:
505
+ prefix = self.api_key_prefix.get(identifier)
506
+ if prefix:
507
+ return "%s %s" % (prefix, key)
508
+ else:
509
+ return key
510
+
511
+ return None
512
+
513
+ def get_basic_auth_token(self) -> Optional[str]:
514
+ """Gets HTTP basic authentication header (string).
515
+
516
+ :return: The token for basic HTTP authentication.
517
+ """
518
+ username = ""
519
+ if self.username is not None:
520
+ username = self.username
521
+ password = ""
522
+ if self.password is not None:
523
+ password = self.password
524
+
525
+ return urllib3.util.make_headers(
526
+ basic_auth=username + ':' + password
527
+ ).get('authorization')
528
+
529
+ def auth_settings(self)-> AuthSettings:
530
+ """Gets Auth Settings dict for api client.
531
+
532
+ :return: The Auth Settings information dict.
533
+ """
534
+ auth: AuthSettings = {}
535
+ if self.access_token is not None:
536
+ auth['bearer'] = {
537
+ 'type': 'bearer',
538
+ 'in': 'header',
539
+ 'format': 'JWT',
540
+ 'key': 'Authorization',
541
+ 'value': 'Bearer ' + self.access_token
542
+ }
543
+ if self.username is not None and self.password is not None:
544
+ auth['basic'] = {
545
+ 'type': 'basic',
546
+ 'in': 'header',
547
+ 'key': 'Authorization',
548
+ 'value': self.get_basic_auth_token()
549
+ }
550
+ return auth
551
+
552
+ def to_debug_report(self) -> str:
553
+ """Gets the essential information for debugging.
554
+
555
+ :return: The report for debugging.
556
+ """
557
+ return "Python SDK Debug Report:\n"\
558
+ "OS: {env}\n"\
559
+ "Python Version: {pyversion}\n"\
560
+ "Version of the API: 1.0.0\n"\
561
+ "SDK Package Version: 0.1.1".\
562
+ format(env=sys.platform, pyversion=sys.version)
563
+
564
+ def get_host_settings(self) -> List[HostSetting]:
565
+ """Gets an array of host settings
566
+
567
+ :return: An array of host settings
568
+ """
569
+ return [
570
+ {
571
+ 'url': "",
572
+ 'description': "No description provided",
573
+ }
574
+ ]
575
+
576
+ def get_host_from_settings(
577
+ self,
578
+ index: Optional[int],
579
+ variables: Optional[ServerVariablesT]=None,
580
+ servers: Optional[List[HostSetting]]=None,
581
+ ) -> str:
582
+ """Gets host URL based on the index and variables
583
+ :param index: array index of the host settings
584
+ :param variables: hash of variable and the corresponding value
585
+ :param servers: an array of host settings or None
586
+ :return: URL based on host settings
587
+ """
588
+ if index is None:
589
+ return self._base_path
590
+
591
+ variables = {} if variables is None else variables
592
+ servers = self.get_host_settings() if servers is None else servers
593
+
594
+ try:
595
+ server = servers[index]
596
+ except IndexError:
597
+ raise ValueError(
598
+ "Invalid index {0} when selecting the host settings. "
599
+ "Must be less than {1}".format(index, len(servers)))
600
+
601
+ url = server['url']
602
+
603
+ # go through variables and replace placeholders
604
+ for variable_name, variable in server.get('variables', {}).items():
605
+ used_value = variables.get(
606
+ variable_name, variable['default_value'])
607
+
608
+ if 'enum_values' in variable \
609
+ and variable['enum_values'] \
610
+ and used_value not in variable['enum_values']:
611
+ raise ValueError(
612
+ "The variable `{0}` in the host URL has invalid value "
613
+ "{1}. Must be {2}.".format(
614
+ variable_name, variables[variable_name],
615
+ variable['enum_values']))
616
+
617
+ url = url.replace("{" + variable_name + "}", used_value)
618
+
619
+ return url
620
+
621
+ @property
622
+ def host(self) -> str:
623
+ """Return generated host."""
624
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
625
+
626
+ @host.setter
627
+ def host(self, value: str) -> None:
628
+ """Fix base path."""
629
+ self._base_path = value
630
+ self.server_index = None