rxfoundry.clients.swifty-oauth-api 0.0.620__py3-none-any.whl → 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 (116) hide show
  1. {rxfoundry_clients_swifty_oauth_api-0.0.620.dist-info → rxfoundry_clients_swifty_oauth_api-1.0.0.dist-info}/METADATA +1 -1
  2. rxfoundry_clients_swifty_oauth_api-1.0.0.dist-info/RECORD +19 -0
  3. rxfoundry/clients/p2rx_api/__init__.py +0 -79
  4. rxfoundry/clients/p2rx_api/api/__init__.py +0 -17
  5. rxfoundry/clients/p2rx_api/api/async_api.py +0 -862
  6. rxfoundry/clients/p2rx_api/api/code_api.py +0 -337
  7. rxfoundry/clients/p2rx_api/api/fax_api.py +0 -632
  8. rxfoundry/clients/p2rx_api/api/medication_api.py +0 -666
  9. rxfoundry/clients/p2rx_api/api/patient_api.py +0 -981
  10. rxfoundry/clients/p2rx_api/api/pharmacist_api.py +0 -615
  11. rxfoundry/clients/p2rx_api/api/pharmacy_api.py +0 -684
  12. rxfoundry/clients/p2rx_api/api/prescriber_api.py +0 -615
  13. rxfoundry/clients/p2rx_api/api/prescription_api.py +0 -1864
  14. rxfoundry/clients/p2rx_api/api/token_api.py +0 -314
  15. rxfoundry/clients/p2rx_api/api/user_api.py +0 -306
  16. rxfoundry/clients/p2rx_api/api/version_api.py +0 -282
  17. rxfoundry/clients/p2rx_api/api/virtual_pharmacy_api.py +0 -284
  18. rxfoundry/clients/p2rx_api/api_client.py +0 -798
  19. rxfoundry/clients/p2rx_api/api_response.py +0 -21
  20. rxfoundry/clients/p2rx_api/configuration.py +0 -583
  21. rxfoundry/clients/p2rx_api/exceptions.py +0 -217
  22. rxfoundry/clients/p2rx_api/models/__init__.py +0 -50
  23. rxfoundry/clients/p2rx_api/models/address.py +0 -106
  24. rxfoundry/clients/p2rx_api/models/asynchronous_response.py +0 -90
  25. rxfoundry/clients/p2rx_api/models/code.py +0 -92
  26. rxfoundry/clients/p2rx_api/models/code_qualifier_code.py +0 -96
  27. rxfoundry/clients/p2rx_api/models/error_message.py +0 -90
  28. rxfoundry/clients/p2rx_api/models/fax.py +0 -141
  29. rxfoundry/clients/p2rx_api/models/medication.py +0 -137
  30. rxfoundry/clients/p2rx_api/models/medication_program_pricing.py +0 -99
  31. rxfoundry/clients/p2rx_api/models/medication_variant.py +0 -96
  32. rxfoundry/clients/p2rx_api/models/patient.py +0 -128
  33. rxfoundry/clients/p2rx_api/models/patient_activity_notification.py +0 -114
  34. rxfoundry/clients/p2rx_api/models/patient_external_identifier.py +0 -94
  35. rxfoundry/clients/p2rx_api/models/pharmacist.py +0 -104
  36. rxfoundry/clients/p2rx_api/models/pharmacy.py +0 -156
  37. rxfoundry/clients/p2rx_api/models/pharmacy_chain.py +0 -100
  38. rxfoundry/clients/p2rx_api/models/pharmacy_other_identifier.py +0 -98
  39. rxfoundry/clients/p2rx_api/models/pharmacy_program_pricing.py +0 -103
  40. rxfoundry/clients/p2rx_api/models/prescriber.py +0 -106
  41. rxfoundry/clients/p2rx_api/models/prescription.py +0 -278
  42. rxfoundry/clients/p2rx_api/models/prescription_change_request.py +0 -123
  43. rxfoundry/clients/p2rx_api/models/prescription_issue.py +0 -120
  44. rxfoundry/clients/p2rx_api/models/prescription_patch.py +0 -113
  45. rxfoundry/clients/p2rx_api/models/prescription_task.py +0 -130
  46. rxfoundry/clients/p2rx_api/models/prescription_task_status.py +0 -95
  47. rxfoundry/clients/p2rx_api/models/prescription_transfer_request.py +0 -93
  48. rxfoundry/clients/p2rx_api/models/prescription_verification.py +0 -107
  49. rxfoundry/clients/p2rx_api/models/pricing_program.py +0 -90
  50. rxfoundry/clients/p2rx_api/models/surescripts_message.py +0 -111
  51. rxfoundry/clients/p2rx_api/models/token.py +0 -92
  52. rxfoundry/clients/p2rx_api/models/user.py +0 -98
  53. rxfoundry/clients/p2rx_api/models/version.py +0 -88
  54. rxfoundry/clients/p2rx_api/models/virtual_pharmacy.py +0 -96
  55. rxfoundry/clients/p2rx_api/models/workflow_request.py +0 -90
  56. rxfoundry/clients/p2rx_api/py.typed +0 -0
  57. rxfoundry/clients/p2rx_api/rest.py +0 -259
  58. rxfoundry/clients/swifty_api/__init__.py +0 -79
  59. rxfoundry/clients/swifty_api/api/__init__.py +0 -17
  60. rxfoundry/clients/swifty_api/api/async_api.py +0 -862
  61. rxfoundry/clients/swifty_api/api/code_api.py +0 -337
  62. rxfoundry/clients/swifty_api/api/fax_api.py +0 -632
  63. rxfoundry/clients/swifty_api/api/medication_api.py +0 -666
  64. rxfoundry/clients/swifty_api/api/patient_api.py +0 -981
  65. rxfoundry/clients/swifty_api/api/pharmacist_api.py +0 -615
  66. rxfoundry/clients/swifty_api/api/pharmacy_api.py +0 -684
  67. rxfoundry/clients/swifty_api/api/prescriber_api.py +0 -615
  68. rxfoundry/clients/swifty_api/api/prescription_api.py +0 -1864
  69. rxfoundry/clients/swifty_api/api/token_api.py +0 -314
  70. rxfoundry/clients/swifty_api/api/user_api.py +0 -306
  71. rxfoundry/clients/swifty_api/api/version_api.py +0 -282
  72. rxfoundry/clients/swifty_api/api/virtual_pharmacy_api.py +0 -284
  73. rxfoundry/clients/swifty_api/api_client.py +0 -798
  74. rxfoundry/clients/swifty_api/api_response.py +0 -21
  75. rxfoundry/clients/swifty_api/configuration.py +0 -583
  76. rxfoundry/clients/swifty_api/exceptions.py +0 -217
  77. rxfoundry/clients/swifty_api/models/__init__.py +0 -50
  78. rxfoundry/clients/swifty_api/models/address.py +0 -106
  79. rxfoundry/clients/swifty_api/models/asynchronous_response.py +0 -90
  80. rxfoundry/clients/swifty_api/models/code.py +0 -92
  81. rxfoundry/clients/swifty_api/models/code_qualifier_code.py +0 -96
  82. rxfoundry/clients/swifty_api/models/error_message.py +0 -90
  83. rxfoundry/clients/swifty_api/models/fax.py +0 -141
  84. rxfoundry/clients/swifty_api/models/medication.py +0 -137
  85. rxfoundry/clients/swifty_api/models/medication_program_pricing.py +0 -99
  86. rxfoundry/clients/swifty_api/models/medication_variant.py +0 -96
  87. rxfoundry/clients/swifty_api/models/patient.py +0 -128
  88. rxfoundry/clients/swifty_api/models/patient_activity_notification.py +0 -114
  89. rxfoundry/clients/swifty_api/models/patient_external_identifier.py +0 -94
  90. rxfoundry/clients/swifty_api/models/pharmacist.py +0 -104
  91. rxfoundry/clients/swifty_api/models/pharmacy.py +0 -156
  92. rxfoundry/clients/swifty_api/models/pharmacy_chain.py +0 -100
  93. rxfoundry/clients/swifty_api/models/pharmacy_other_identifier.py +0 -98
  94. rxfoundry/clients/swifty_api/models/pharmacy_program_pricing.py +0 -103
  95. rxfoundry/clients/swifty_api/models/prescriber.py +0 -106
  96. rxfoundry/clients/swifty_api/models/prescription.py +0 -278
  97. rxfoundry/clients/swifty_api/models/prescription_change_request.py +0 -123
  98. rxfoundry/clients/swifty_api/models/prescription_issue.py +0 -120
  99. rxfoundry/clients/swifty_api/models/prescription_patch.py +0 -113
  100. rxfoundry/clients/swifty_api/models/prescription_task.py +0 -130
  101. rxfoundry/clients/swifty_api/models/prescription_task_status.py +0 -95
  102. rxfoundry/clients/swifty_api/models/prescription_transfer_request.py +0 -93
  103. rxfoundry/clients/swifty_api/models/prescription_verification.py +0 -107
  104. rxfoundry/clients/swifty_api/models/pricing_program.py +0 -90
  105. rxfoundry/clients/swifty_api/models/surescripts_message.py +0 -111
  106. rxfoundry/clients/swifty_api/models/token.py +0 -92
  107. rxfoundry/clients/swifty_api/models/user.py +0 -98
  108. rxfoundry/clients/swifty_api/models/version.py +0 -88
  109. rxfoundry/clients/swifty_api/models/virtual_pharmacy.py +0 -98
  110. rxfoundry/clients/swifty_api/models/workflow_request.py +0 -90
  111. rxfoundry/clients/swifty_api/py.typed +0 -0
  112. rxfoundry/clients/swifty_api/rest.py +0 -259
  113. rxfoundry/clients/swifty_oauth_api/models/token_post_request.py +0 -94
  114. rxfoundry_clients_swifty_oauth_api-0.0.620.dist-info/RECORD +0 -130
  115. {rxfoundry_clients_swifty_oauth_api-0.0.620.dist-info → rxfoundry_clients_swifty_oauth_api-1.0.0.dist-info}/WHEEL +0 -0
  116. {rxfoundry_clients_swifty_oauth_api-0.0.620.dist-info → rxfoundry_clients_swifty_oauth_api-1.0.0.dist-info}/top_level.txt +0 -0
@@ -1,21 +0,0 @@
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
- }
@@ -1,583 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- P2RX API
5
-
6
- API for the P2RX Backend
7
-
8
- The version of the OpenAPI document: 0.1.DEV-0
9
- Contact: paul.tindall@rxfoundry.com
10
- Generated by OpenAPI Generator (https://openapi-generator.tech)
11
-
12
- Do not edit the class manually.
13
- """ # noqa: E501
14
-
15
-
16
- import copy
17
- import http.client as httplib
18
- import logging
19
- from logging import FileHandler
20
- import multiprocessing
21
- import sys
22
- from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union
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
- "opaque_token": BearerFormatAuthSetting,
118
- },
119
- total=False,
120
- )
121
-
122
-
123
- class HostSettingVariable(TypedDict):
124
- description: str
125
- default_value: str
126
- enum_values: List[str]
127
-
128
-
129
- class HostSetting(TypedDict):
130
- url: str
131
- description: str
132
- variables: NotRequired[Dict[str, HostSettingVariable]]
133
-
134
-
135
- class Configuration:
136
- """This class contains various settings of the API client.
137
-
138
- :param host: Base url.
139
- :param ignore_operation_servers
140
- Boolean to ignore operation servers for the API client.
141
- Config will use `host` as the base url regardless of the operation servers.
142
- :param api_key: Dict to store API key(s).
143
- Each entry in the dict specifies an API key.
144
- The dict key is the name of the security scheme in the OAS specification.
145
- The dict value is the API key secret.
146
- :param api_key_prefix: Dict to store API prefix (e.g. Bearer).
147
- The dict key is the name of the security scheme in the OAS specification.
148
- The dict value is an API key prefix when generating the auth data.
149
- :param username: Username for HTTP basic authentication.
150
- :param password: Password for HTTP basic authentication.
151
- :param access_token: Access token.
152
- :param server_index: Index to servers configuration.
153
- :param server_variables: Mapping with string values to replace variables in
154
- templated server configuration. The validation of enums is performed for
155
- variables with defined enum values before.
156
- :param server_operation_index: Mapping from operation ID to an index to server
157
- configuration.
158
- :param server_operation_variables: Mapping from operation ID to a mapping with
159
- string values to replace variables in templated server configuration.
160
- The validation of enums is performed for variables with defined enum
161
- values before.
162
- :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
163
- in PEM format.
164
- :param retries: Number of retries for API requests.
165
- :param ca_cert_data: verify the peer using concatenated CA certificate data
166
- in PEM (str) or DER (bytes) format.
167
-
168
- :Example:
169
- """
170
-
171
- _default: ClassVar[Optional[Self]] = None
172
-
173
- def __init__(
174
- self,
175
- host: Optional[str]=None,
176
- api_key: Optional[Dict[str, str]]=None,
177
- api_key_prefix: Optional[Dict[str, str]]=None,
178
- username: Optional[str]=None,
179
- password: Optional[str]=None,
180
- access_token: Optional[str]=None,
181
- server_index: Optional[int]=None,
182
- server_variables: Optional[ServerVariablesT]=None,
183
- server_operation_index: Optional[Dict[int, int]]=None,
184
- server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
185
- ignore_operation_servers: bool=False,
186
- ssl_ca_cert: Optional[str]=None,
187
- retries: Optional[int] = None,
188
- ca_cert_data: Optional[Union[str, bytes]] = None,
189
- *,
190
- debug: Optional[bool] = None,
191
- ) -> None:
192
- """Constructor
193
- """
194
- self._base_path = "/api" if host is None else host
195
- """Default Base url
196
- """
197
- self.server_index = 0 if server_index is None and host is None else server_index
198
- self.server_operation_index = server_operation_index or {}
199
- """Default server index
200
- """
201
- self.server_variables = server_variables or {}
202
- self.server_operation_variables = server_operation_variables or {}
203
- """Default server variables
204
- """
205
- self.ignore_operation_servers = ignore_operation_servers
206
- """Ignore operation servers
207
- """
208
- self.temp_folder_path = None
209
- """Temp file folder for downloading files
210
- """
211
- # Authentication Settings
212
- self.api_key = {}
213
- if api_key:
214
- self.api_key = api_key
215
- """dict to store API key(s)
216
- """
217
- self.api_key_prefix = {}
218
- if api_key_prefix:
219
- self.api_key_prefix = api_key_prefix
220
- """dict to store API prefix (e.g. Bearer)
221
- """
222
- self.refresh_api_key_hook = None
223
- """function hook to refresh API key if expired
224
- """
225
- self.username = username
226
- """Username for HTTP basic authentication
227
- """
228
- self.password = password
229
- """Password for HTTP basic authentication
230
- """
231
- self.access_token = access_token
232
- """Access token
233
- """
234
- self.logger = {}
235
- """Logging Settings
236
- """
237
- self.logger["package_logger"] = logging.getLogger("rxfoundry.clients.swifty_api")
238
- self.logger["urllib3_logger"] = logging.getLogger("urllib3")
239
- self.logger_format = '%(asctime)s %(levelname)s %(message)s'
240
- """Log format
241
- """
242
- self.logger_stream_handler = None
243
- """Log stream handler
244
- """
245
- self.logger_file_handler: Optional[FileHandler] = None
246
- """Log file handler
247
- """
248
- self.logger_file = None
249
- """Debug file location
250
- """
251
- if debug is not None:
252
- self.debug = debug
253
- else:
254
- self.__debug = False
255
- """Debug switch
256
- """
257
-
258
- self.verify_ssl = True
259
- """SSL/TLS verification
260
- Set this to false to skip verifying SSL certificate when calling API
261
- from https server.
262
- """
263
- self.ssl_ca_cert = ssl_ca_cert
264
- """Set this to customize the certificate file to verify the peer.
265
- """
266
- self.ca_cert_data = ca_cert_data
267
- """Set this to verify the peer using PEM (str) or DER (bytes)
268
- certificate data.
269
- """
270
- self.cert_file = None
271
- """client certificate file
272
- """
273
- self.key_file = None
274
- """client key file
275
- """
276
- self.assert_hostname = None
277
- """Set this to True/False to enable/disable SSL hostname verification.
278
- """
279
- self.tls_server_name = None
280
- """SSL/TLS Server Name Indication (SNI)
281
- Set this to the SNI value expected by the server.
282
- """
283
-
284
- self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
285
- """urllib3 connection pool's maximum number of connections saved
286
- per pool. urllib3 uses 1 connection as default value, but this is
287
- not the best value when you are making a lot of possibly parallel
288
- requests to the same host, which is often the case here.
289
- cpu_count * 5 is used as default value to increase performance.
290
- """
291
-
292
- self.proxy: Optional[str] = None
293
- """Proxy URL
294
- """
295
- self.proxy_headers = None
296
- """Proxy headers
297
- """
298
- self.safe_chars_for_path_param = ''
299
- """Safe chars for path_param
300
- """
301
- self.retries = retries
302
- """Adding retries to override urllib3 default value 3
303
- """
304
- # Enable client side validation
305
- self.client_side_validation = True
306
-
307
- self.socket_options = None
308
- """Options to pass down to the underlying urllib3 socket
309
- """
310
-
311
- self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z"
312
- """datetime format
313
- """
314
-
315
- self.date_format = "%Y-%m-%d"
316
- """date format
317
- """
318
-
319
- def __deepcopy__(self, memo: Dict[int, Any]) -> Self:
320
- cls = self.__class__
321
- result = cls.__new__(cls)
322
- memo[id(self)] = result
323
- for k, v in self.__dict__.items():
324
- if k not in ('logger', 'logger_file_handler'):
325
- setattr(result, k, copy.deepcopy(v, memo))
326
- # shallow copy of loggers
327
- result.logger = copy.copy(self.logger)
328
- # use setters to configure loggers
329
- result.logger_file = self.logger_file
330
- result.debug = self.debug
331
- return result
332
-
333
- def __setattr__(self, name: str, value: Any) -> None:
334
- object.__setattr__(self, name, value)
335
-
336
- @classmethod
337
- def set_default(cls, default: Optional[Self]) -> None:
338
- """Set default instance of configuration.
339
-
340
- It stores default configuration, which can be
341
- returned by get_default_copy method.
342
-
343
- :param default: object of Configuration
344
- """
345
- cls._default = default
346
-
347
- @classmethod
348
- def get_default_copy(cls) -> Self:
349
- """Deprecated. Please use `get_default` instead.
350
-
351
- Deprecated. Please use `get_default` instead.
352
-
353
- :return: The configuration object.
354
- """
355
- return cls.get_default()
356
-
357
- @classmethod
358
- def get_default(cls) -> Self:
359
- """Return the default configuration.
360
-
361
- This method returns newly created, based on default constructor,
362
- object of Configuration class or returns a copy of default
363
- configuration.
364
-
365
- :return: The configuration object.
366
- """
367
- if cls._default is None:
368
- cls._default = cls()
369
- return cls._default
370
-
371
- @property
372
- def logger_file(self) -> Optional[str]:
373
- """The logger file.
374
-
375
- If the logger_file is None, then add stream handler and remove file
376
- handler. Otherwise, add file handler and remove stream handler.
377
-
378
- :param value: The logger_file path.
379
- :type: str
380
- """
381
- return self.__logger_file
382
-
383
- @logger_file.setter
384
- def logger_file(self, value: Optional[str]) -> None:
385
- """The logger file.
386
-
387
- If the logger_file is None, then add stream handler and remove file
388
- handler. Otherwise, add file handler and remove stream handler.
389
-
390
- :param value: The logger_file path.
391
- :type: str
392
- """
393
- self.__logger_file = value
394
- if self.__logger_file:
395
- # If set logging file,
396
- # then add file handler and remove stream handler.
397
- self.logger_file_handler = logging.FileHandler(self.__logger_file)
398
- self.logger_file_handler.setFormatter(self.logger_formatter)
399
- for _, logger in self.logger.items():
400
- logger.addHandler(self.logger_file_handler)
401
-
402
- @property
403
- def debug(self) -> bool:
404
- """Debug status
405
-
406
- :param value: The debug status, True or False.
407
- :type: bool
408
- """
409
- return self.__debug
410
-
411
- @debug.setter
412
- def debug(self, value: bool) -> None:
413
- """Debug status
414
-
415
- :param value: The debug status, True or False.
416
- :type: bool
417
- """
418
- self.__debug = value
419
- if self.__debug:
420
- # if debug status is True, turn on debug logging
421
- for _, logger in self.logger.items():
422
- logger.setLevel(logging.DEBUG)
423
- # turn on httplib debug
424
- httplib.HTTPConnection.debuglevel = 1
425
- else:
426
- # if debug status is False, turn off debug logging,
427
- # setting log level to default `logging.WARNING`
428
- for _, logger in self.logger.items():
429
- logger.setLevel(logging.WARNING)
430
- # turn off httplib debug
431
- httplib.HTTPConnection.debuglevel = 0
432
-
433
- @property
434
- def logger_format(self) -> str:
435
- """The logger format.
436
-
437
- The logger_formatter will be updated when sets logger_format.
438
-
439
- :param value: The format string.
440
- :type: str
441
- """
442
- return self.__logger_format
443
-
444
- @logger_format.setter
445
- def logger_format(self, value: str) -> None:
446
- """The logger format.
447
-
448
- The logger_formatter will be updated when sets logger_format.
449
-
450
- :param value: The format string.
451
- :type: str
452
- """
453
- self.__logger_format = value
454
- self.logger_formatter = logging.Formatter(self.__logger_format)
455
-
456
- def get_api_key_with_prefix(self, identifier: str, alias: Optional[str]=None) -> Optional[str]:
457
- """Gets API key (with prefix if set).
458
-
459
- :param identifier: The identifier of apiKey.
460
- :param alias: The alternative identifier of apiKey.
461
- :return: The token for api key authentication.
462
- """
463
- if self.refresh_api_key_hook is not None:
464
- self.refresh_api_key_hook(self)
465
- key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
466
- if key:
467
- prefix = self.api_key_prefix.get(identifier)
468
- if prefix:
469
- return "%s %s" % (prefix, key)
470
- else:
471
- return key
472
-
473
- return None
474
-
475
- def get_basic_auth_token(self) -> Optional[str]:
476
- """Gets HTTP basic authentication header (string).
477
-
478
- :return: The token for basic HTTP authentication.
479
- """
480
- username = ""
481
- if self.username is not None:
482
- username = self.username
483
- password = ""
484
- if self.password is not None:
485
- password = self.password
486
- return urllib3.util.make_headers(
487
- basic_auth=username + ':' + password
488
- ).get('authorization')
489
-
490
- def auth_settings(self)-> AuthSettings:
491
- """Gets Auth Settings dict for api client.
492
-
493
- :return: The Auth Settings information dict.
494
- """
495
- auth: AuthSettings = {}
496
- if self.access_token is not None:
497
- auth['opaque_token'] = {
498
- 'type': 'bearer',
499
- 'in': 'header',
500
- 'format': 'opaque',
501
- 'key': 'Authorization',
502
- 'value': 'Bearer ' + self.access_token
503
- }
504
- return auth
505
-
506
- def to_debug_report(self) -> str:
507
- """Gets the essential information for debugging.
508
-
509
- :return: The report for debugging.
510
- """
511
- return "Python SDK Debug Report:\n"\
512
- "OS: {env}\n"\
513
- "Python Version: {pyversion}\n"\
514
- "Version of the API: 0.1.DEV-0\n"\
515
- "SDK Package Version: 1.0.0".\
516
- format(env=sys.platform, pyversion=sys.version)
517
-
518
- def get_host_settings(self) -> List[HostSetting]:
519
- """Gets an array of host settings
520
-
521
- :return: An array of host settings
522
- """
523
- return [
524
- {
525
- 'url': "/api",
526
- 'description': "No description provided",
527
- }
528
- ]
529
-
530
- def get_host_from_settings(
531
- self,
532
- index: Optional[int],
533
- variables: Optional[ServerVariablesT]=None,
534
- servers: Optional[List[HostSetting]]=None,
535
- ) -> str:
536
- """Gets host URL based on the index and variables
537
- :param index: array index of the host settings
538
- :param variables: hash of variable and the corresponding value
539
- :param servers: an array of host settings or None
540
- :return: URL based on host settings
541
- """
542
- if index is None:
543
- return self._base_path
544
-
545
- variables = {} if variables is None else variables
546
- servers = self.get_host_settings() if servers is None else servers
547
-
548
- try:
549
- server = servers[index]
550
- except IndexError:
551
- raise ValueError(
552
- "Invalid index {0} when selecting the host settings. "
553
- "Must be less than {1}".format(index, len(servers)))
554
-
555
- url = server['url']
556
-
557
- # go through variables and replace placeholders
558
- for variable_name, variable in server.get('variables', {}).items():
559
- used_value = variables.get(
560
- variable_name, variable['default_value'])
561
-
562
- if 'enum_values' in variable \
563
- and used_value not in variable['enum_values']:
564
- raise ValueError(
565
- "The variable `{0}` in the host URL has invalid value "
566
- "{1}. Must be {2}.".format(
567
- variable_name, variables[variable_name],
568
- variable['enum_values']))
569
-
570
- url = url.replace("{" + variable_name + "}", used_value)
571
-
572
- return url
573
-
574
- @property
575
- def host(self) -> str:
576
- """Return generated host."""
577
- return self.get_host_from_settings(self.server_index, variables=self.server_variables)
578
-
579
- @host.setter
580
- def host(self, value: str) -> None:
581
- """Fix base path."""
582
- self._base_path = value
583
- self.server_index = None