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