cogbox_toolbox_api_client_async 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_async/__init__.py +386 -0
  2. cogbox_toolbox_api_client_async/api/__init__.py +46 -0
  3. cogbox_toolbox_api_client_async/api/computer_use_api.py +9075 -0
  4. cogbox_toolbox_api_client_async/api/file_system_api.py +3583 -0
  5. cogbox_toolbox_api_client_async/api/git_api.py +2969 -0
  6. cogbox_toolbox_api_client_async/api/info_api.py +773 -0
  7. cogbox_toolbox_api_client_async/api/interpreter_api.py +1075 -0
  8. cogbox_toolbox_api_client_async/api/lsp_api.py +1971 -0
  9. cogbox_toolbox_api_client_async/api/port_api.py +543 -0
  10. cogbox_toolbox_api_client_async/api/process_api.py +4865 -0
  11. cogbox_toolbox_api_client_async/api/server_api.py +298 -0
  12. cogbox_toolbox_api_client_async/api_client.py +812 -0
  13. cogbox_toolbox_api_client_async/api_response.py +21 -0
  14. cogbox_toolbox_api_client_async/configuration.py +624 -0
  15. cogbox_toolbox_api_client_async/exceptions.py +218 -0
  16. cogbox_toolbox_api_client_async/models/__init__.py +224 -0
  17. cogbox_toolbox_api_client_async/models/accessibility_bounds.py +108 -0
  18. cogbox_toolbox_api_client_async/models/accessibility_invoke_request.py +104 -0
  19. cogbox_toolbox_api_client_async/models/accessibility_node_request.py +102 -0
  20. cogbox_toolbox_api_client_async/models/accessibility_nodes_response.py +112 -0
  21. cogbox_toolbox_api_client_async/models/accessibility_set_value_request.py +104 -0
  22. cogbox_toolbox_api_client_async/models/accessibility_tree_response.py +108 -0
  23. cogbox_toolbox_api_client_async/models/chart.py +132 -0
  24. cogbox_toolbox_api_client_async/models/chart_element.py +134 -0
  25. cogbox_toolbox_api_client_async/models/code_run_artifacts.py +110 -0
  26. cogbox_toolbox_api_client_async/models/code_run_request.py +110 -0
  27. cogbox_toolbox_api_client_async/models/code_run_response.py +110 -0
  28. cogbox_toolbox_api_client_async/models/command.py +106 -0
  29. cogbox_toolbox_api_client_async/models/completion_context.py +104 -0
  30. cogbox_toolbox_api_client_async/models/completion_item.py +114 -0
  31. cogbox_toolbox_api_client_async/models/completion_list.py +112 -0
  32. cogbox_toolbox_api_client_async/models/computer_use_accessibility_node.py +129 -0
  33. cogbox_toolbox_api_client_async/models/computer_use_start_response.py +117 -0
  34. cogbox_toolbox_api_client_async/models/computer_use_status_response.py +102 -0
  35. cogbox_toolbox_api_client_async/models/computer_use_stop_response.py +117 -0
  36. cogbox_toolbox_api_client_async/models/create_context_request.py +104 -0
  37. cogbox_toolbox_api_client_async/models/create_session_request.py +102 -0
  38. cogbox_toolbox_api_client_async/models/display_info.py +112 -0
  39. cogbox_toolbox_api_client_async/models/display_info_response.py +110 -0
  40. cogbox_toolbox_api_client_async/models/execute_request.py +108 -0
  41. cogbox_toolbox_api_client_async/models/execute_response.py +104 -0
  42. cogbox_toolbox_api_client_async/models/file_info.py +118 -0
  43. cogbox_toolbox_api_client_async/models/file_status.py +109 -0
  44. cogbox_toolbox_api_client_async/models/files_download_request.py +102 -0
  45. cogbox_toolbox_api_client_async/models/find_accessibility_nodes_request.py +114 -0
  46. cogbox_toolbox_api_client_async/models/git_add_request.py +104 -0
  47. cogbox_toolbox_api_client_async/models/git_branch_request.py +104 -0
  48. cogbox_toolbox_api_client_async/models/git_checkout_request.py +104 -0
  49. cogbox_toolbox_api_client_async/models/git_clone_request.py +114 -0
  50. cogbox_toolbox_api_client_async/models/git_commit_info.py +110 -0
  51. cogbox_toolbox_api_client_async/models/git_commit_request.py +110 -0
  52. cogbox_toolbox_api_client_async/models/git_commit_response.py +102 -0
  53. cogbox_toolbox_api_client_async/models/git_delete_branch_request.py +104 -0
  54. cogbox_toolbox_api_client_async/models/git_repo_request.py +106 -0
  55. cogbox_toolbox_api_client_async/models/git_status.py +118 -0
  56. cogbox_toolbox_api_client_async/models/initialize_request.py +102 -0
  57. cogbox_toolbox_api_client_async/models/interpreter_context.py +110 -0
  58. cogbox_toolbox_api_client_async/models/is_port_in_use_response.py +102 -0
  59. cogbox_toolbox_api_client_async/models/keyboard_hotkey_request.py +102 -0
  60. cogbox_toolbox_api_client_async/models/keyboard_press_request.py +104 -0
  61. cogbox_toolbox_api_client_async/models/keyboard_type_request.py +104 -0
  62. cogbox_toolbox_api_client_async/models/list_branch_response.py +102 -0
  63. cogbox_toolbox_api_client_async/models/list_contexts_response.py +110 -0
  64. cogbox_toolbox_api_client_async/models/list_recordings_response.py +110 -0
  65. cogbox_toolbox_api_client_async/models/lsp_completion_params.py +118 -0
  66. cogbox_toolbox_api_client_async/models/lsp_document_request.py +106 -0
  67. cogbox_toolbox_api_client_async/models/lsp_location.py +108 -0
  68. cogbox_toolbox_api_client_async/models/lsp_position.py +104 -0
  69. cogbox_toolbox_api_client_async/models/lsp_range.py +111 -0
  70. cogbox_toolbox_api_client_async/models/lsp_server_request.py +104 -0
  71. cogbox_toolbox_api_client_async/models/lsp_symbol.py +110 -0
  72. cogbox_toolbox_api_client_async/models/match.py +106 -0
  73. cogbox_toolbox_api_client_async/models/mouse_click_request.py +108 -0
  74. cogbox_toolbox_api_client_async/models/mouse_click_response.py +104 -0
  75. cogbox_toolbox_api_client_async/models/mouse_drag_request.py +110 -0
  76. cogbox_toolbox_api_client_async/models/mouse_drag_response.py +104 -0
  77. cogbox_toolbox_api_client_async/models/mouse_move_request.py +104 -0
  78. cogbox_toolbox_api_client_async/models/mouse_position_response.py +104 -0
  79. cogbox_toolbox_api_client_async/models/mouse_scroll_request.py +109 -0
  80. cogbox_toolbox_api_client_async/models/port_list.py +102 -0
  81. cogbox_toolbox_api_client_async/models/position.py +104 -0
  82. cogbox_toolbox_api_client_async/models/process_errors_response.py +104 -0
  83. cogbox_toolbox_api_client_async/models/process_logs_response.py +104 -0
  84. cogbox_toolbox_api_client_async/models/process_restart_response.py +104 -0
  85. cogbox_toolbox_api_client_async/models/process_status.py +108 -0
  86. cogbox_toolbox_api_client_async/models/process_status_response.py +104 -0
  87. cogbox_toolbox_api_client_async/models/pty_create_request.py +112 -0
  88. cogbox_toolbox_api_client_async/models/pty_create_response.py +102 -0
  89. cogbox_toolbox_api_client_async/models/pty_list_response.py +110 -0
  90. cogbox_toolbox_api_client_async/models/pty_resize_request.py +105 -0
  91. cogbox_toolbox_api_client_async/models/pty_session_info.py +116 -0
  92. cogbox_toolbox_api_client_async/models/recording.py +116 -0
  93. cogbox_toolbox_api_client_async/models/replace_request.py +106 -0
  94. cogbox_toolbox_api_client_async/models/replace_result.py +106 -0
  95. cogbox_toolbox_api_client_async/models/screenshot_response.py +110 -0
  96. cogbox_toolbox_api_client_async/models/scroll_response.py +102 -0
  97. cogbox_toolbox_api_client_async/models/search_files_response.py +102 -0
  98. cogbox_toolbox_api_client_async/models/session.py +112 -0
  99. cogbox_toolbox_api_client_async/models/session_command_logs_response.py +106 -0
  100. cogbox_toolbox_api_client_async/models/session_execute_request.py +108 -0
  101. cogbox_toolbox_api_client_async/models/session_execute_response.py +110 -0
  102. cogbox_toolbox_api_client_async/models/session_send_input_request.py +102 -0
  103. cogbox_toolbox_api_client_async/models/start_recording_request.py +102 -0
  104. cogbox_toolbox_api_client_async/models/status.py +48 -0
  105. cogbox_toolbox_api_client_async/models/stop_recording_request.py +102 -0
  106. cogbox_toolbox_api_client_async/models/user_home_dir_response.py +102 -0
  107. cogbox_toolbox_api_client_async/models/window_info.py +114 -0
  108. cogbox_toolbox_api_client_async/models/windows_response.py +110 -0
  109. cogbox_toolbox_api_client_async/models/work_dir_response.py +102 -0
  110. cogbox_toolbox_api_client_async/py.typed +0 -0
  111. cogbox_toolbox_api_client_async/rest.py +226 -0
  112. cogbox_toolbox_api_client_async-0.190.1.dist-info/METADATA +20 -0
  113. cogbox_toolbox_api_client_async-0.190.1.dist-info/RECORD +116 -0
  114. cogbox_toolbox_api_client_async-0.190.1.dist-info/WHEEL +5 -0
  115. cogbox_toolbox_api_client_async-0.190.1.dist-info/licenses/LICENSE +190 -0
  116. cogbox_toolbox_api_client_async-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,624 @@
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 base64
14
+ import copy
15
+ import http.client as httplib
16
+ import logging
17
+ from logging import FileHandler
18
+ import sys
19
+ from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union
20
+ from typing_extensions import NotRequired, Self
21
+
22
+
23
+
24
+ JSON_SCHEMA_VALIDATION_KEYWORDS = {
25
+ 'multipleOf', 'maximum', 'exclusiveMaximum',
26
+ 'minimum', 'exclusiveMinimum', 'maxLength',
27
+ 'minLength', 'pattern', 'maxItems', 'minItems'
28
+ }
29
+
30
+ ServerVariablesT = Dict[str, str]
31
+
32
+ GenericAuthSetting = TypedDict(
33
+ "GenericAuthSetting",
34
+ {
35
+ "type": str,
36
+ "in": str,
37
+ "key": str,
38
+ "value": str,
39
+ },
40
+ )
41
+
42
+
43
+ OAuth2AuthSetting = TypedDict(
44
+ "OAuth2AuthSetting",
45
+ {
46
+ "type": Literal["oauth2"],
47
+ "in": Literal["header"],
48
+ "key": Literal["Authorization"],
49
+ "value": str,
50
+ },
51
+ )
52
+
53
+
54
+ APIKeyAuthSetting = TypedDict(
55
+ "APIKeyAuthSetting",
56
+ {
57
+ "type": Literal["api_key"],
58
+ "in": str,
59
+ "key": str,
60
+ "value": Optional[str],
61
+ },
62
+ )
63
+
64
+
65
+ BasicAuthSetting = TypedDict(
66
+ "BasicAuthSetting",
67
+ {
68
+ "type": Literal["basic"],
69
+ "in": Literal["header"],
70
+ "key": Literal["Authorization"],
71
+ "value": Optional[str],
72
+ },
73
+ )
74
+
75
+
76
+ BearerFormatAuthSetting = TypedDict(
77
+ "BearerFormatAuthSetting",
78
+ {
79
+ "type": Literal["bearer"],
80
+ "in": Literal["header"],
81
+ "format": Literal["JWT"],
82
+ "key": Literal["Authorization"],
83
+ "value": str,
84
+ },
85
+ )
86
+
87
+
88
+ BearerAuthSetting = TypedDict(
89
+ "BearerAuthSetting",
90
+ {
91
+ "type": Literal["bearer"],
92
+ "in": Literal["header"],
93
+ "key": Literal["Authorization"],
94
+ "value": str,
95
+ },
96
+ )
97
+
98
+
99
+ HTTPSignatureAuthSetting = TypedDict(
100
+ "HTTPSignatureAuthSetting",
101
+ {
102
+ "type": Literal["http-signature"],
103
+ "in": Literal["header"],
104
+ "key": Literal["Authorization"],
105
+ "value": None,
106
+ },
107
+ )
108
+
109
+
110
+ AuthSettings = TypedDict(
111
+ "AuthSettings",
112
+ {
113
+ "Bearer": APIKeyAuthSetting,
114
+ },
115
+ total=False,
116
+ )
117
+
118
+
119
+ class HostSettingVariable(TypedDict):
120
+ description: str
121
+ default_value: str
122
+ enum_values: List[str]
123
+
124
+
125
+ class HostSetting(TypedDict):
126
+ url: str
127
+ description: str
128
+ variables: NotRequired[Dict[str, HostSettingVariable]]
129
+
130
+
131
+ class Configuration:
132
+ """This class contains various settings of the API client.
133
+
134
+ :param host: Base url.
135
+ :param ignore_operation_servers
136
+ Boolean to ignore operation servers for the API client.
137
+ Config will use `host` as the base url regardless of the operation servers.
138
+ :param api_key: Dict to store API key(s).
139
+ Each entry in the dict specifies an API key.
140
+ The dict key is the name of the security scheme in the OAS specification.
141
+ The dict value is the API key secret.
142
+ :param api_key_prefix: Dict to store API prefix (e.g. Bearer).
143
+ The dict key is the name of the security scheme in the OAS specification.
144
+ The dict value is an API key prefix when generating the auth data.
145
+ :param username: Username for HTTP basic authentication.
146
+ :param password: Password for HTTP basic authentication.
147
+ :param access_token: Access token.
148
+ :param server_index: Index to servers configuration.
149
+ :param server_variables: Mapping with string values to replace variables in
150
+ templated server configuration. The validation of enums is performed for
151
+ variables with defined enum values before.
152
+ :param server_operation_index: Mapping from operation ID to an index to server
153
+ configuration.
154
+ :param server_operation_variables: Mapping from operation ID to a mapping with
155
+ string values to replace variables in templated server configuration.
156
+ The validation of enums is performed for variables with defined enum
157
+ values before.
158
+ :param verify_ssl: bool - Set this to false to skip verifying SSL certificate
159
+ when calling API from https server.
160
+ :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
161
+ in PEM format.
162
+ :param retries: int | aiohttp_retry.RetryOptionsBase - Retry configuration.
163
+ :param ca_cert_data: verify the peer using concatenated CA certificate data
164
+ in PEM (str) or DER (bytes) format.
165
+ :param cert_file: the path to a client certificate file, for mTLS.
166
+ :param key_file: the path to a client key file, for mTLS.
167
+ :param assert_hostname: Set this to True/False to enable/disable SSL hostname verification.
168
+ :param tls_server_name: SSL/TLS Server Name Indication (SNI). Set this to the SNI value expected by the server.
169
+ :param connection_pool_maxsize: Connection pool max size. None in the constructor is coerced to 100 for async and cpu_count * 5 for sync.
170
+ :param proxy: Proxy URL.
171
+ :param proxy_headers: Proxy headers.
172
+ :param safe_chars_for_path_param: Safe characters for path parameter encoding.
173
+ :param client_side_validation: Enable client-side validation. Default True.
174
+ :param socket_options: Options to pass down to the underlying urllib3 socket.
175
+ :param datetime_format: Datetime format string for serialization.
176
+ :param date_format: Date format string for serialization.
177
+
178
+ :Example:
179
+
180
+ API Key Authentication Example.
181
+ Given the following security scheme in the OpenAPI specification:
182
+ components:
183
+ securitySchemes:
184
+ cookieAuth: # name for the security scheme
185
+ type: apiKey
186
+ in: cookie
187
+ name: JSESSIONID # cookie name
188
+
189
+ You can programmatically set the cookie:
190
+
191
+ conf = cogbox_toolbox_api_client_async.Configuration(
192
+ api_key={'cookieAuth': 'abc123'}
193
+ api_key_prefix={'cookieAuth': 'JSESSIONID'}
194
+ )
195
+
196
+ The following cookie will be added to the HTTP request:
197
+ Cookie: JSESSIONID abc123
198
+ """
199
+
200
+ _default: ClassVar[Optional[Self]] = None
201
+
202
+ def __init__(
203
+ self,
204
+ host: Optional[str]=None,
205
+ api_key: Optional[Dict[str, str]]=None,
206
+ api_key_prefix: Optional[Dict[str, str]]=None,
207
+ username: Optional[str]=None,
208
+ password: Optional[str]=None,
209
+ access_token: Optional[str]=None,
210
+ server_index: Optional[int]=None,
211
+ server_variables: Optional[ServerVariablesT]=None,
212
+ server_operation_index: Optional[Dict[int, int]]=None,
213
+ server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
214
+ ignore_operation_servers: bool=False,
215
+ ssl_ca_cert: Optional[str]=None,
216
+ retries: Optional[Union[int, Any]] = None,
217
+ ca_cert_data: Optional[Union[str, bytes]] = None,
218
+ cert_file: Optional[str]=None,
219
+ key_file: Optional[str]=None,
220
+ verify_ssl: bool=True,
221
+ assert_hostname: Optional[bool]=None,
222
+ tls_server_name: Optional[str]=None,
223
+ connection_pool_maxsize: Optional[int]=None,
224
+ proxy: Optional[str]=None,
225
+ proxy_headers: Optional[Any]=None,
226
+ safe_chars_for_path_param: str='',
227
+ client_side_validation: bool=True,
228
+ socket_options: Optional[Any]=None,
229
+ datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z",
230
+ date_format: str="%Y-%m-%d",
231
+ *,
232
+ debug: Optional[bool] = None,
233
+ ) -> None:
234
+ """Constructor
235
+ """
236
+ self._base_path = "http://localhost" if host is None else host
237
+ """Default Base url
238
+ """
239
+ self.server_index = 0 if server_index is None and host is None else server_index
240
+ self.server_operation_index = server_operation_index or {}
241
+ """Default server index
242
+ """
243
+ self.server_variables = server_variables or {}
244
+ self.server_operation_variables = server_operation_variables or {}
245
+ """Default server variables
246
+ """
247
+ self.ignore_operation_servers = ignore_operation_servers
248
+ """Ignore operation servers
249
+ """
250
+ self.temp_folder_path = None
251
+ """Temp file folder for downloading files
252
+ """
253
+ # Authentication Settings
254
+ self.api_key = {}
255
+ if api_key:
256
+ self.api_key = api_key
257
+ """dict to store API key(s)
258
+ """
259
+ self.api_key_prefix = {}
260
+ if api_key_prefix:
261
+ self.api_key_prefix = api_key_prefix
262
+ """dict to store API prefix (e.g. Bearer)
263
+ """
264
+ self.refresh_api_key_hook = None
265
+ """function hook to refresh API key if expired
266
+ """
267
+ self.username = username
268
+ """Username for HTTP basic authentication
269
+ """
270
+ self.password = password
271
+ """Password for HTTP basic authentication
272
+ """
273
+ self.access_token = access_token
274
+ """Access token
275
+ """
276
+ self.logger = {}
277
+ """Logging Settings
278
+ """
279
+ self.logger["package_logger"] = logging.getLogger("cogbox_toolbox_api_client_async")
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 100
326
+ """This value is passed to the aiohttp to limit simultaneous connections.
327
+ None in the constructor is coerced to default 100.
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 "Basic " + base64.b64encode(
526
+ (username + ":" + password).encode('utf-8')
527
+ ).decode('utf-8')
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 'Bearer' in self.api_key:
536
+ auth['Bearer'] = {
537
+ 'type': 'api_key',
538
+ 'in': 'header',
539
+ 'key': 'Authorization',
540
+ 'value': self.get_api_key_with_prefix(
541
+ 'Bearer',
542
+ ),
543
+ }
544
+ return auth
545
+
546
+ def to_debug_report(self) -> str:
547
+ """Gets the essential information for debugging.
548
+
549
+ :return: The report for debugging.
550
+ """
551
+ return "Python SDK Debug Report:\n"\
552
+ "OS: {env}\n"\
553
+ "Python Version: {pyversion}\n"\
554
+ "Version of the API: v0.0.0-dev\n"\
555
+ "SDK Package Version: 0.0.0-dev".\
556
+ format(env=sys.platform, pyversion=sys.version)
557
+
558
+ def get_host_settings(self) -> List[HostSetting]:
559
+ """Gets an array of host settings
560
+
561
+ :return: An array of host settings
562
+ """
563
+ return [
564
+ {
565
+ 'url': "",
566
+ 'description': "No description provided",
567
+ }
568
+ ]
569
+
570
+ def get_host_from_settings(
571
+ self,
572
+ index: Optional[int],
573
+ variables: Optional[ServerVariablesT]=None,
574
+ servers: Optional[List[HostSetting]]=None,
575
+ ) -> str:
576
+ """Gets host URL based on the index and variables
577
+ :param index: array index of the host settings
578
+ :param variables: hash of variable and the corresponding value
579
+ :param servers: an array of host settings or None
580
+ :return: URL based on host settings
581
+ """
582
+ if index is None:
583
+ return self._base_path
584
+
585
+ variables = {} if variables is None else variables
586
+ servers = self.get_host_settings() if servers is None else servers
587
+
588
+ try:
589
+ server = servers[index]
590
+ except IndexError:
591
+ raise ValueError(
592
+ "Invalid index {0} when selecting the host settings. "
593
+ "Must be less than {1}".format(index, len(servers)))
594
+
595
+ url = server['url']
596
+
597
+ # go through variables and replace placeholders
598
+ for variable_name, variable in server.get('variables', {}).items():
599
+ used_value = variables.get(
600
+ variable_name, variable['default_value'])
601
+
602
+ if 'enum_values' in variable \
603
+ and variable['enum_values'] \
604
+ and used_value not in variable['enum_values']:
605
+ raise ValueError(
606
+ "The variable `{0}` in the host URL has invalid value "
607
+ "{1}. Must be {2}.".format(
608
+ variable_name, variables[variable_name],
609
+ variable['enum_values']))
610
+
611
+ url = url.replace("{" + variable_name + "}", used_value)
612
+
613
+ return url
614
+
615
+ @property
616
+ def host(self) -> str:
617
+ """Return generated host."""
618
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
619
+
620
+ @host.setter
621
+ def host(self, value: str) -> None:
622
+ """Fix base path."""
623
+ self._base_path = value
624
+ self.server_index = None