signwell-sdk-python 0.1.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 (110) hide show
  1. signwell_sdk/__init__.py +287 -0
  2. signwell_sdk/api/__init__.py +10 -0
  3. signwell_sdk/api/api_application_api.py +481 -0
  4. signwell_sdk/api/bulk_send_api.py +1589 -0
  5. signwell_sdk/api/document_api.py +2425 -0
  6. signwell_sdk/api/me_api.py +246 -0
  7. signwell_sdk/api/regional_api.py +345 -0
  8. signwell_sdk/api/template_api.py +1298 -0
  9. signwell_sdk/api/webhooks_api.py +710 -0
  10. signwell_sdk/api_client.py +747 -0
  11. signwell_sdk/api_response.py +20 -0
  12. signwell_sdk/configuration.py +599 -0
  13. signwell_sdk/embedded.py +385 -0
  14. signwell_sdk/exceptions.py +314 -0
  15. signwell_sdk/models/__init__.py +114 -0
  16. signwell_sdk/models/account_info_response.py +143 -0
  17. signwell_sdk/models/account_info_response_active_users_inner.py +107 -0
  18. signwell_sdk/models/account_info_response_preferences.py +147 -0
  19. signwell_sdk/models/additional_fields_inner_inner.py +274 -0
  20. signwell_sdk/models/additional_fields_inner_inner_value.py +189 -0
  21. signwell_sdk/models/additional_files_inner.py +103 -0
  22. signwell_sdk/models/api_application_response.py +137 -0
  23. signwell_sdk/models/api_application_response_owner.py +107 -0
  24. signwell_sdk/models/api_application_response_preferences.py +135 -0
  25. signwell_sdk/models/attachment_request_info.py +99 -0
  26. signwell_sdk/models/attachment_requests_inner.py +110 -0
  27. signwell_sdk/models/bulk_send_create_response.py +132 -0
  28. signwell_sdk/models/bulk_send_csv_request.py +100 -0
  29. signwell_sdk/models/bulk_send_csv_template_response.py +97 -0
  30. signwell_sdk/models/bulk_send_documents_response.py +167 -0
  31. signwell_sdk/models/bulk_send_list_item.py +141 -0
  32. signwell_sdk/models/bulk_send_list_response.py +138 -0
  33. signwell_sdk/models/bulk_send_response.py +151 -0
  34. signwell_sdk/models/bulk_send_response_templates_inner.py +98 -0
  35. signwell_sdk/models/bulk_send_validate_csv_response.py +129 -0
  36. signwell_sdk/models/checkbox_group_info.py +138 -0
  37. signwell_sdk/models/checkbox_groups_inner.py +136 -0
  38. signwell_sdk/models/checkbox_validation.py +35 -0
  39. signwell_sdk/models/completed_pdf_response.py +177 -0
  40. signwell_sdk/models/completed_pdf_url_response.py +97 -0
  41. signwell_sdk/models/copied_contact_info.py +99 -0
  42. signwell_sdk/models/copied_contacts_inner.py +98 -0
  43. signwell_sdk/models/copied_placeholders_inner.py +111 -0
  44. signwell_sdk/models/create_bulk_send_request.py +155 -0
  45. signwell_sdk/models/create_webhook_request.py +100 -0
  46. signwell_sdk/models/date_format.py +36 -0
  47. signwell_sdk/models/detailed_option.py +105 -0
  48. signwell_sdk/models/document_from_template_request.py +377 -0
  49. signwell_sdk/models/document_from_template_response.py +353 -0
  50. signwell_sdk/models/document_from_template_response_fields_inner_inner.py +270 -0
  51. signwell_sdk/models/document_from_template_response_fields_inner_inner_recipient.py +99 -0
  52. signwell_sdk/models/document_from_template_response_recipients_inner.py +206 -0
  53. signwell_sdk/models/document_list_response.py +138 -0
  54. signwell_sdk/models/document_request.py +350 -0
  55. signwell_sdk/models/document_response.py +357 -0
  56. signwell_sdk/models/document_response_attachment_requests_inner.py +101 -0
  57. signwell_sdk/models/document_response_fields_inner_inner.py +268 -0
  58. signwell_sdk/models/document_response_fields_inner_inner_options_inner.py +101 -0
  59. signwell_sdk/models/document_response_fields_inner_inner_recipient.py +98 -0
  60. signwell_sdk/models/document_response_fields_inner_inner_value.py +195 -0
  61. signwell_sdk/models/document_response_recipients_inner.py +208 -0
  62. signwell_sdk/models/document_template_list_response.py +138 -0
  63. signwell_sdk/models/document_template_request.py +307 -0
  64. signwell_sdk/models/document_template_response.py +323 -0
  65. signwell_sdk/models/document_template_response_copied_placeholders_inner.py +131 -0
  66. signwell_sdk/models/document_template_response_placeholders_inner.py +144 -0
  67. signwell_sdk/models/document_template_update_request.py +208 -0
  68. signwell_sdk/models/dropdown_option.py +153 -0
  69. signwell_sdk/models/error_response.py +107 -0
  70. signwell_sdk/models/error_response_meta.py +101 -0
  71. signwell_sdk/models/field_type.py +46 -0
  72. signwell_sdk/models/fields_inner_inner.py +268 -0
  73. signwell_sdk/models/file_format.py +33 -0
  74. signwell_sdk/models/file_info.py +98 -0
  75. signwell_sdk/models/files_inner.py +103 -0
  76. signwell_sdk/models/label_info.py +98 -0
  77. signwell_sdk/models/label_request.py +97 -0
  78. signwell_sdk/models/label_response.py +98 -0
  79. signwell_sdk/models/me_response.py +130 -0
  80. signwell_sdk/models/me_response_contact.py +147 -0
  81. signwell_sdk/models/me_response_user.py +117 -0
  82. signwell_sdk/models/me_response_user_preferences.py +105 -0
  83. signwell_sdk/models/nom151_certificate_response.py +107 -0
  84. signwell_sdk/models/nom151_certificate_response_nom151.py +125 -0
  85. signwell_sdk/models/nom151_url_response.py +97 -0
  86. signwell_sdk/models/pagination_meta.py +119 -0
  87. signwell_sdk/models/placeholders_inner.py +115 -0
  88. signwell_sdk/models/rate_limit_error_response.py +97 -0
  89. signwell_sdk/models/recipients_inner.py +141 -0
  90. signwell_sdk/models/reminder_recipients_inner.py +100 -0
  91. signwell_sdk/models/send_reminder_request.py +114 -0
  92. signwell_sdk/models/template_attachment_requests_inner.py +110 -0
  93. signwell_sdk/models/template_checkbox_groups_inner.py +136 -0
  94. signwell_sdk/models/template_field_values_inner.py +109 -0
  95. signwell_sdk/models/template_field_values_inner_value.py +189 -0
  96. signwell_sdk/models/template_fields_inner_inner.py +266 -0
  97. signwell_sdk/models/template_recipients_inner.py +146 -0
  98. signwell_sdk/models/text_validation.py +42 -0
  99. signwell_sdk/models/update_document_and_send_request.py +234 -0
  100. signwell_sdk/models/update_recipients_map_inner.py +118 -0
  101. signwell_sdk/models/update_recipients_request.py +111 -0
  102. signwell_sdk/models/validation_error_response.py +99 -0
  103. signwell_sdk/models/webhook_response.py +110 -0
  104. signwell_sdk/py.typed +0 -0
  105. signwell_sdk/rest.py +209 -0
  106. signwell_sdk/webhook.py +214 -0
  107. signwell_sdk_python-0.1.0.dist-info/METADATA +177 -0
  108. signwell_sdk_python-0.1.0.dist-info/RECORD +110 -0
  109. signwell_sdk_python-0.1.0.dist-info/WHEEL +4 -0
  110. signwell_sdk_python-0.1.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,20 @@
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
+
10
+ class ApiResponse(BaseModel, Generic[T]):
11
+ """
12
+ API response object
13
+ """
14
+
15
+ status_code: StrictInt = Field(description="HTTP status code")
16
+ headers: Mapping[str, str] | None = Field(None, description="HTTP headers")
17
+ data: T = Field(description="Deserialized data given the data type")
18
+ raw_data: StrictBytes = Field(description="Raw data (HTTP response body)")
19
+
20
+ model_config = {"arbitrary_types_allowed": True}
@@ -0,0 +1,599 @@
1
+ """
2
+ SignWell Developer API
3
+
4
+ API for creating, managing, and tracking electronic signature workflows.
5
+
6
+ The version of the OpenAPI document: v1
7
+ Contact: support@signwell.com
8
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
9
+
10
+ Do not edit the class manually.
11
+ """ # noqa: E501
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",
27
+ "maximum",
28
+ "exclusiveMaximum",
29
+ "minimum",
30
+ "exclusiveMinimum",
31
+ "maxLength",
32
+ "minLength",
33
+ "pattern",
34
+ "maxItems",
35
+ "minItems",
36
+ }
37
+
38
+ ServerVariablesT = Dict[str, str]
39
+
40
+ GenericAuthSetting = TypedDict(
41
+ "GenericAuthSetting",
42
+ {
43
+ "type": str,
44
+ "in": str,
45
+ "key": str,
46
+ "value": str,
47
+ },
48
+ )
49
+
50
+
51
+ OAuth2AuthSetting = TypedDict(
52
+ "OAuth2AuthSetting",
53
+ {
54
+ "type": Literal["oauth2"],
55
+ "in": Literal["header"],
56
+ "key": Literal["Authorization"],
57
+ "value": str,
58
+ },
59
+ )
60
+
61
+
62
+ APIKeyAuthSetting = TypedDict(
63
+ "APIKeyAuthSetting",
64
+ {
65
+ "type": Literal["api_key"],
66
+ "in": str,
67
+ "key": str,
68
+ "value": str | None,
69
+ },
70
+ )
71
+
72
+
73
+ BasicAuthSetting = TypedDict(
74
+ "BasicAuthSetting",
75
+ {
76
+ "type": Literal["basic"],
77
+ "in": Literal["header"],
78
+ "key": Literal["Authorization"],
79
+ "value": str | None,
80
+ },
81
+ )
82
+
83
+
84
+ BearerFormatAuthSetting = TypedDict(
85
+ "BearerFormatAuthSetting",
86
+ {
87
+ "type": Literal["bearer"],
88
+ "in": Literal["header"],
89
+ "format": Literal["JWT"],
90
+ "key": Literal["Authorization"],
91
+ "value": str,
92
+ },
93
+ )
94
+
95
+
96
+ BearerAuthSetting = TypedDict(
97
+ "BearerAuthSetting",
98
+ {
99
+ "type": Literal["bearer"],
100
+ "in": Literal["header"],
101
+ "key": Literal["Authorization"],
102
+ "value": str,
103
+ },
104
+ )
105
+
106
+
107
+ HTTPSignatureAuthSetting = TypedDict(
108
+ "HTTPSignatureAuthSetting",
109
+ {
110
+ "type": Literal["http-signature"],
111
+ "in": Literal["header"],
112
+ "key": Literal["Authorization"],
113
+ "value": None,
114
+ },
115
+ )
116
+
117
+
118
+ class AuthSettings(TypedDict, total=False):
119
+ api_key: APIKeyAuthSetting
120
+
121
+
122
+ class HostSettingVariable(TypedDict):
123
+ description: str
124
+ default_value: str
125
+ enum_values: List[str]
126
+
127
+
128
+ class HostSetting(TypedDict):
129
+ url: str
130
+ description: str
131
+ variables: NotRequired[Dict[str, HostSettingVariable]]
132
+
133
+
134
+ class Configuration:
135
+ """This class contains various settings of the API client.
136
+
137
+ :param host: Base url.
138
+ :param ignore_operation_servers
139
+ Boolean to ignore operation servers for the API client.
140
+ Config will use `host` as the base url regardless of the operation servers.
141
+ :param api_key: Dict to store API key(s).
142
+ Each entry in the dict specifies an API key.
143
+ The dict key is the name of the security scheme in the OAS specification.
144
+ The dict value is the API key secret.
145
+ :param api_key_prefix: Dict to store API prefix (e.g. Bearer).
146
+ The dict key is the name of the security scheme in the OAS specification.
147
+ The dict value is an API key prefix when generating the auth data.
148
+ :param username: Username for HTTP basic authentication.
149
+ :param password: Password for HTTP basic authentication.
150
+ :param access_token: Access token.
151
+ :param server_index: Index to servers configuration.
152
+ :param server_variables: Mapping with string values to replace variables in
153
+ templated server configuration. The validation of enums is performed for
154
+ variables with defined enum values before.
155
+ :param server_operation_index: Mapping from operation ID to an index to server
156
+ configuration.
157
+ :param server_operation_variables: Mapping from operation ID to a mapping with
158
+ string values to replace variables in templated server configuration.
159
+ The validation of enums is performed for variables with defined enum
160
+ values before.
161
+ :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
162
+ in PEM format.
163
+ :param retries: Number of retries for API requests.
164
+ :param ca_cert_data: verify the peer using concatenated CA certificate data
165
+ in PEM (str) or DER (bytes) format.
166
+
167
+ :Example:
168
+
169
+ API Key Authentication Example.
170
+ Given the following security scheme in the OpenAPI specification:
171
+ components:
172
+ securitySchemes:
173
+ cookieAuth: # name for the security scheme
174
+ type: apiKey
175
+ in: cookie
176
+ name: JSESSIONID # cookie name
177
+
178
+ You can programmatically set the cookie:
179
+
180
+ conf = signwell_sdk.Configuration(
181
+ api_key={'cookieAuth': 'abc123'}
182
+ api_key_prefix={'cookieAuth': 'JSESSIONID'}
183
+ )
184
+
185
+ The following cookie will be added to the HTTP request:
186
+ Cookie: JSESSIONID abc123
187
+ """
188
+
189
+ _default: ClassVar[Self | None] = None
190
+
191
+ def __init__(
192
+ self,
193
+ host: str | None = None,
194
+ api_key: Dict[str, str] | None = None,
195
+ api_key_prefix: Dict[str, str] | None = None,
196
+ username: str | None = None,
197
+ password: str | None = None,
198
+ access_token: str | None = None,
199
+ server_index: int | None = None,
200
+ server_variables: ServerVariablesT | None = None,
201
+ server_operation_index: Dict[int, int] | None = None,
202
+ server_operation_variables: Dict[int, ServerVariablesT] | None = None,
203
+ ignore_operation_servers: bool = False,
204
+ ssl_ca_cert: str | None = None,
205
+ retries: int | None = None,
206
+ ca_cert_data: Union[str, bytes] | None = None,
207
+ *,
208
+ debug: bool | None = None,
209
+ ) -> None:
210
+ """Constructor"""
211
+ self._base_path = "https://www.signwell.com" if host is None else host
212
+ """Default Base url
213
+ """
214
+ self.server_index = 0 if server_index is None and host is None else server_index
215
+ self.server_operation_index = server_operation_index or {}
216
+ """Default server index
217
+ """
218
+ self.server_variables = server_variables or {}
219
+ self.server_operation_variables = server_operation_variables or {}
220
+ """Default server variables
221
+ """
222
+ self.ignore_operation_servers = ignore_operation_servers
223
+ """Ignore operation servers
224
+ """
225
+ self.temp_folder_path = None
226
+ """Temp file folder for downloading files
227
+ """
228
+ # Authentication Settings
229
+ self.api_key = {}
230
+ if api_key:
231
+ self.api_key = api_key
232
+ """dict to store API key(s)
233
+ """
234
+ self.api_key_prefix = {}
235
+ if api_key_prefix:
236
+ self.api_key_prefix = api_key_prefix
237
+ """dict to store API prefix (e.g. Bearer)
238
+ """
239
+ self.refresh_api_key_hook = None
240
+ """function hook to refresh API key if expired
241
+ """
242
+ self.username = username
243
+ """Username for HTTP basic authentication
244
+ """
245
+ self.password = password
246
+ """Password for HTTP basic authentication
247
+ """
248
+ self.access_token = access_token
249
+ """Access token
250
+ """
251
+ self.logger = {}
252
+ """Logging Settings
253
+ """
254
+ self.logger["package_logger"] = logging.getLogger("signwell_sdk")
255
+ self.logger["urllib3_logger"] = logging.getLogger("urllib3")
256
+ self.logger_format = "%(asctime)s %(levelname)s %(message)s"
257
+ """Log format
258
+ """
259
+ self.logger_stream_handler = None
260
+ """Log stream handler
261
+ """
262
+ self.logger_file_handler: FileHandler | None = None
263
+ """Log file handler
264
+ """
265
+ self.logger_file = None
266
+ """Debug file location
267
+ """
268
+ if debug is not None:
269
+ self.debug = debug
270
+ else:
271
+ self.__debug = False
272
+ """Debug switch
273
+ """
274
+
275
+ self.verify_ssl = True
276
+ """SSL/TLS verification
277
+ WARNING: keep this enabled in production. Set this to false only for
278
+ short-lived local debugging against trusted test endpoints; disabling
279
+ verification makes HTTPS requests vulnerable to interception.
280
+ """
281
+ self.ssl_ca_cert = ssl_ca_cert
282
+ """Set this to customize the certificate file to verify the peer.
283
+ """
284
+ self.ca_cert_data = ca_cert_data
285
+ """Set this to verify the peer using PEM (str) or DER (bytes)
286
+ certificate data.
287
+ """
288
+ self.cert_file = None
289
+ """client certificate file
290
+ """
291
+ self.key_file = None
292
+ """client key file
293
+ """
294
+ self.assert_hostname = None
295
+ """Set this to True/False to enable/disable SSL hostname verification.
296
+ """
297
+ self.tls_server_name = None
298
+ """SSL/TLS Server Name Indication (SNI)
299
+ Set this to the SNI value expected by the server.
300
+ """
301
+
302
+ self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
303
+ """urllib3 connection pool's maximum number of connections saved
304
+ per pool. urllib3 uses 1 connection as default value, but this is
305
+ not the best value when you are making a lot of possibly parallel
306
+ requests to the same host, which is often the case here.
307
+ cpu_count * 5 is used as default value to increase performance.
308
+ """
309
+
310
+ self.proxy: str | None = None
311
+ """Proxy URL
312
+ """
313
+ self.proxy_headers = None
314
+ """Proxy headers
315
+ """
316
+ self.safe_chars_for_path_param = ""
317
+ """Safe chars for path_param
318
+ """
319
+ self.retries = retries
320
+ """Adding retries to override urllib3 default value 3
321
+ """
322
+ # Enable client side validation
323
+ self.client_side_validation = True
324
+
325
+ self.socket_options = None
326
+ """Options to pass down to the underlying urllib3 socket
327
+ """
328
+
329
+ self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z"
330
+ """datetime format
331
+ """
332
+
333
+ self.date_format = "%Y-%m-%d"
334
+ """date format
335
+ """
336
+
337
+ def __deepcopy__(self, memo: Dict[int, Any]) -> Self:
338
+ cls = self.__class__
339
+ result = cls.__new__(cls)
340
+ memo[id(self)] = result
341
+ for k, v in self.__dict__.items():
342
+ if k not in ("logger", "logger_file_handler"):
343
+ setattr(result, k, copy.deepcopy(v, memo))
344
+ # shallow copy of loggers
345
+ result.logger = copy.copy(self.logger)
346
+ # use setters to configure loggers
347
+ result.logger_file = self.logger_file
348
+ result.debug = self.debug
349
+ return result
350
+
351
+ def __setattr__(self, name: str, value: Any) -> None:
352
+ object.__setattr__(self, name, value)
353
+
354
+ @classmethod
355
+ def set_default(cls, default: Self | None) -> None:
356
+ """Set default instance of configuration.
357
+
358
+ It stores default configuration, which can be
359
+ returned by get_default_copy method.
360
+
361
+ :param default: object of Configuration
362
+ """
363
+ cls._default = default
364
+
365
+ @classmethod
366
+ def get_default_copy(cls) -> Self:
367
+ """Deprecated. Please use `get_default` instead.
368
+
369
+ Deprecated. Please use `get_default` instead.
370
+
371
+ :return: The configuration object.
372
+ """
373
+ return cls.get_default()
374
+
375
+ @classmethod
376
+ def get_default(cls) -> Self:
377
+ """Return the default configuration.
378
+
379
+ This method returns newly created, based on default constructor,
380
+ object of Configuration class or returns a copy of default
381
+ configuration.
382
+
383
+ :return: The configuration object.
384
+ """
385
+ if cls._default is None:
386
+ cls._default = cls()
387
+ return cls._default
388
+
389
+ @property
390
+ def logger_file(self) -> str | None:
391
+ """The logger file.
392
+
393
+ Reassigning logger_file removes and closes any existing SDK file handler
394
+ before attaching a new one.
395
+
396
+ :param value: The logger_file path.
397
+ :type: str
398
+ """
399
+ return self.__logger_file
400
+
401
+ @logger_file.setter
402
+ def logger_file(self, value: str | None) -> None:
403
+ """The logger file.
404
+
405
+ Reassigning logger_file removes and closes any existing SDK file handler
406
+ before attaching a new one.
407
+
408
+ :param value: The logger_file path.
409
+ :type: str
410
+ """
411
+ if self.logger_file_handler is not None:
412
+ for _, logger in self.logger.items():
413
+ if self.logger_file_handler in logger.handlers:
414
+ logger.removeHandler(self.logger_file_handler)
415
+ self.logger_file_handler.close()
416
+ self.logger_file_handler = None
417
+
418
+ self.__logger_file = value
419
+ if self.__logger_file:
420
+ self.logger_file_handler = logging.FileHandler(self.__logger_file)
421
+ self.logger_file_handler.setFormatter(self.logger_formatter)
422
+ for _, logger in self.logger.items():
423
+ logger.addHandler(self.logger_file_handler)
424
+
425
+ @property
426
+ def debug(self) -> bool:
427
+ """Debug status
428
+
429
+ :param value: The debug status, True or False.
430
+ :type: bool
431
+ """
432
+ return self.__debug
433
+
434
+ @debug.setter
435
+ def debug(self, value: bool) -> None:
436
+ """Debug status
437
+
438
+ :param value: The debug status, True or False.
439
+ :type: bool
440
+ """
441
+ self.__debug = value
442
+ if self.__debug:
443
+ # If debug status is True, turn on SDK logger debug output without
444
+ # enabling global httplib wire dumps. Raw HTTP debug output can
445
+ # include authentication headers in application logs.
446
+ for _, logger in self.logger.items():
447
+ logger.setLevel(logging.DEBUG)
448
+ else:
449
+ # if debug status is False, turn off debug logging,
450
+ # setting log level to default `logging.WARNING`
451
+ for _, logger in self.logger.items():
452
+ logger.setLevel(logging.WARNING)
453
+
454
+ @property
455
+ def logger_format(self) -> str:
456
+ """The logger format.
457
+
458
+ The logger_formatter will be updated when sets logger_format.
459
+
460
+ :param value: The format string.
461
+ :type: str
462
+ """
463
+ return self.__logger_format
464
+
465
+ @logger_format.setter
466
+ def logger_format(self, value: str) -> None:
467
+ """The logger format.
468
+
469
+ The logger_formatter will be updated when sets logger_format.
470
+
471
+ :param value: The format string.
472
+ :type: str
473
+ """
474
+ self.__logger_format = value
475
+ self.logger_formatter = logging.Formatter(self.__logger_format)
476
+
477
+ def get_api_key_with_prefix(self, identifier: str, alias: str | None = None) -> str | None:
478
+ """Gets API key (with prefix if set).
479
+
480
+ :param identifier: The identifier of apiKey.
481
+ :param alias: The alternative identifier of apiKey.
482
+ :return: The token for api key authentication.
483
+ """
484
+ if self.refresh_api_key_hook is not None:
485
+ self.refresh_api_key_hook(self)
486
+ key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
487
+ if key:
488
+ prefix = self.api_key_prefix.get(identifier)
489
+ if prefix:
490
+ return "%s %s" % (prefix, key)
491
+ else:
492
+ return key
493
+
494
+ return None
495
+
496
+ def get_basic_auth_token(self) -> str | None:
497
+ """Gets HTTP basic authentication header (string).
498
+
499
+ :return: The token for basic HTTP authentication.
500
+ """
501
+ username = ""
502
+ if self.username is not None:
503
+ username = self.username
504
+ return urllib3.util.make_headers(basic_auth=username + ":" + (self.password or "")).get("authorization")
505
+
506
+ def auth_settings(self) -> AuthSettings:
507
+ """Gets Auth Settings dict for api client.
508
+
509
+ :return: The Auth Settings information dict.
510
+ """
511
+ auth: AuthSettings = {}
512
+ if "api_key" in self.api_key:
513
+ auth["api_key"] = {
514
+ "type": "api_key",
515
+ "in": "header",
516
+ "key": "X-Api-Key",
517
+ "value": self.get_api_key_with_prefix(
518
+ "api_key",
519
+ ),
520
+ }
521
+ return auth
522
+
523
+ def to_debug_report(self) -> str:
524
+ """Gets the essential information for debugging.
525
+
526
+ :return: The report for debugging.
527
+ """
528
+ return (
529
+ "Python SDK Debug Report:\n"
530
+ f"OS: {sys.platform}\n"
531
+ f"Python Version: {sys.version}\n"
532
+ "Version of the API: v1\n"
533
+ "SDK Package Version: 0.1.0"
534
+ )
535
+
536
+ def get_host_settings(self) -> List[HostSetting]:
537
+ """Gets an array of host settings
538
+
539
+ :return: An array of host settings
540
+ """
541
+ return [
542
+ {
543
+ "url": "https://www.signwell.com",
544
+ "description": "No description provided",
545
+ }
546
+ ]
547
+
548
+ def get_host_from_settings(
549
+ self,
550
+ index: int | None,
551
+ variables: ServerVariablesT | None = None,
552
+ servers: List[HostSetting] | None = None,
553
+ ) -> str:
554
+ """Gets host URL based on the index and variables
555
+ :param index: array index of the host settings
556
+ :param variables: hash of variable and the corresponding value
557
+ :param servers: an array of host settings or None
558
+ :return: URL based on host settings
559
+ """
560
+ if index is None:
561
+ return self._base_path
562
+
563
+ variables = {} if variables is None else variables
564
+ servers = self.get_host_settings() if servers is None else servers
565
+
566
+ try:
567
+ server = servers[index]
568
+ except IndexError:
569
+ raise ValueError(
570
+ f"Invalid index {index} when selecting the host settings. Must be less than {len(servers)}"
571
+ )
572
+
573
+ url = server["url"]
574
+
575
+ # go through variables and replace placeholders
576
+ for variable_name, variable in server.get("variables", {}).items():
577
+ used_value = variables.get(variable_name, variable["default_value"])
578
+
579
+ if "enum_values" in variable and used_value not in variable["enum_values"]:
580
+ raise ValueError(
581
+ "The variable `{0}` in the host URL has invalid value {1}. Must be {2}.".format(
582
+ variable_name, variables[variable_name], variable["enum_values"]
583
+ )
584
+ )
585
+
586
+ url = url.replace("{" + variable_name + "}", used_value)
587
+
588
+ return url
589
+
590
+ @property
591
+ def host(self) -> str:
592
+ """Return generated host."""
593
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
594
+
595
+ @host.setter
596
+ def host(self, value: str) -> None:
597
+ """Fix base path."""
598
+ self._base_path = value
599
+ self.server_index = None