daytona_api_client_async 0.21.3a0__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.

Potentially problematic release.


This version of daytona_api_client_async might be problematic. Click here for more details.

Files changed (123) hide show
  1. daytona_api_client_async/__init__.py +129 -0
  2. daytona_api_client_async/api/__init__.py +16 -0
  3. daytona_api_client_async/api/api_keys_api.py +1391 -0
  4. daytona_api_client_async/api/docker_registry_api.py +1965 -0
  5. daytona_api_client_async/api/images_api.py +2350 -0
  6. daytona_api_client_async/api/nodes_api.py +792 -0
  7. daytona_api_client_async/api/object_storage_api.py +298 -0
  8. daytona_api_client_async/api/organizations_api.py +6762 -0
  9. daytona_api_client_async/api/preview_api.py +819 -0
  10. daytona_api_client_async/api/runners_api.py +792 -0
  11. daytona_api_client_async/api/sandbox_api.py +3994 -0
  12. daytona_api_client_async/api/snapshots_api.py +2059 -0
  13. daytona_api_client_async/api/toolbox_api.py +11819 -0
  14. daytona_api_client_async/api/users_api.py +2075 -0
  15. daytona_api_client_async/api/volumes_api.py +1419 -0
  16. daytona_api_client_async/api/workspace_api.py +4036 -0
  17. daytona_api_client_async/api_client.py +801 -0
  18. daytona_api_client_async/api_response.py +21 -0
  19. daytona_api_client_async/configuration.py +579 -0
  20. daytona_api_client_async/exceptions.py +217 -0
  21. daytona_api_client_async/models/__init__.py +101 -0
  22. daytona_api_client_async/models/account_provider.py +103 -0
  23. daytona_api_client_async/models/api_key_list.py +130 -0
  24. daytona_api_client_async/models/api_key_response.py +123 -0
  25. daytona_api_client_async/models/build_image.py +107 -0
  26. daytona_api_client_async/models/build_info.py +108 -0
  27. daytona_api_client_async/models/build_snapshot.py +115 -0
  28. daytona_api_client_async/models/command.py +105 -0
  29. daytona_api_client_async/models/completion_context.py +103 -0
  30. daytona_api_client_async/models/completion_item.py +113 -0
  31. daytona_api_client_async/models/completion_list.py +111 -0
  32. daytona_api_client_async/models/create_api_key.py +119 -0
  33. daytona_api_client_async/models/create_build_info.py +103 -0
  34. daytona_api_client_async/models/create_docker_registry.py +120 -0
  35. daytona_api_client_async/models/create_image.py +105 -0
  36. daytona_api_client_async/models/create_linked_account.py +103 -0
  37. daytona_api_client_async/models/create_node.py +135 -0
  38. daytona_api_client_async/models/create_organization.py +101 -0
  39. daytona_api_client_async/models/create_organization_invitation.py +115 -0
  40. daytona_api_client_async/models/create_organization_quota.py +117 -0
  41. daytona_api_client_async/models/create_organization_role.py +113 -0
  42. daytona_api_client_async/models/create_runner.py +135 -0
  43. daytona_api_client_async/models/create_sandbox.py +161 -0
  44. daytona_api_client_async/models/create_session_request.py +101 -0
  45. daytona_api_client_async/models/create_snapshot.py +121 -0
  46. daytona_api_client_async/models/create_user.py +125 -0
  47. daytona_api_client_async/models/create_volume.py +101 -0
  48. daytona_api_client_async/models/create_workspace.py +161 -0
  49. daytona_api_client_async/models/docker_registry.py +123 -0
  50. daytona_api_client_async/models/execute_request.py +105 -0
  51. daytona_api_client_async/models/execute_response.py +103 -0
  52. daytona_api_client_async/models/file_info.py +115 -0
  53. daytona_api_client_async/models/file_status.py +107 -0
  54. daytona_api_client_async/models/git_add_request.py +103 -0
  55. daytona_api_client_async/models/git_branch_request.py +103 -0
  56. daytona_api_client_async/models/git_checkout_request.py +103 -0
  57. daytona_api_client_async/models/git_clone_request.py +111 -0
  58. daytona_api_client_async/models/git_commit_info.py +109 -0
  59. daytona_api_client_async/models/git_commit_request.py +107 -0
  60. daytona_api_client_async/models/git_commit_response.py +101 -0
  61. daytona_api_client_async/models/git_delete_branch_request.py +103 -0
  62. daytona_api_client_async/models/git_repo_request.py +105 -0
  63. daytona_api_client_async/models/git_status.py +117 -0
  64. daytona_api_client_async/models/image_dto.py +145 -0
  65. daytona_api_client_async/models/image_state.py +45 -0
  66. daytona_api_client_async/models/list_branch_response.py +101 -0
  67. daytona_api_client_async/models/lsp_completion_params.py +117 -0
  68. daytona_api_client_async/models/lsp_document_request.py +105 -0
  69. daytona_api_client_async/models/lsp_location.py +107 -0
  70. daytona_api_client_async/models/lsp_server_request.py +103 -0
  71. daytona_api_client_async/models/lsp_symbol.py +109 -0
  72. daytona_api_client_async/models/match.py +105 -0
  73. daytona_api_client_async/models/organization.py +120 -0
  74. daytona_api_client_async/models/organization_invitation.py +144 -0
  75. daytona_api_client_async/models/organization_role.py +122 -0
  76. daytona_api_client_async/models/organization_suspension.py +104 -0
  77. daytona_api_client_async/models/organization_user.py +131 -0
  78. daytona_api_client_async/models/paginated_images_dto.py +115 -0
  79. daytona_api_client_async/models/paginated_snapshots_dto.py +115 -0
  80. daytona_api_client_async/models/port_preview_url.py +103 -0
  81. daytona_api_client_async/models/position.py +103 -0
  82. daytona_api_client_async/models/project_dir_response.py +101 -0
  83. daytona_api_client_async/models/range.py +110 -0
  84. daytona_api_client_async/models/registry_push_access_dto.py +111 -0
  85. daytona_api_client_async/models/replace_request.py +105 -0
  86. daytona_api_client_async/models/replace_result.py +105 -0
  87. daytona_api_client_async/models/sandbox.py +180 -0
  88. daytona_api_client_async/models/sandbox_info.py +105 -0
  89. daytona_api_client_async/models/sandbox_labels.py +101 -0
  90. daytona_api_client_async/models/sandbox_state.py +52 -0
  91. daytona_api_client_async/models/sandbox_volume.py +103 -0
  92. daytona_api_client_async/models/search_files_response.py +101 -0
  93. daytona_api_client_async/models/session.py +116 -0
  94. daytona_api_client_async/models/session_execute_request.py +105 -0
  95. daytona_api_client_async/models/session_execute_response.py +105 -0
  96. daytona_api_client_async/models/set_image_general_status.py +101 -0
  97. daytona_api_client_async/models/set_snapshot_general_status_dto.py +101 -0
  98. daytona_api_client_async/models/snapshot_dto.py +161 -0
  99. daytona_api_client_async/models/snapshot_state.py +46 -0
  100. daytona_api_client_async/models/storage_access_dto.py +111 -0
  101. daytona_api_client_async/models/toggle_state.py +101 -0
  102. daytona_api_client_async/models/update_assigned_organization_roles.py +101 -0
  103. daytona_api_client_async/models/update_docker_registry.py +105 -0
  104. daytona_api_client_async/models/update_organization_invitation.py +113 -0
  105. daytona_api_client_async/models/update_organization_member_role.py +108 -0
  106. daytona_api_client_async/models/update_organization_quota.py +162 -0
  107. daytona_api_client_async/models/update_organization_role.py +113 -0
  108. daytona_api_client_async/models/usage_overview.py +113 -0
  109. daytona_api_client_async/models/user.py +115 -0
  110. daytona_api_client_async/models/user_public_key.py +103 -0
  111. daytona_api_client_async/models/volume_dto.py +126 -0
  112. daytona_api_client_async/models/volume_state.py +43 -0
  113. daytona_api_client_async/models/workspace.py +204 -0
  114. daytona_api_client_async/models/workspace_info.py +105 -0
  115. daytona_api_client_async/models/workspace_labels.py +101 -0
  116. daytona_api_client_async/models/workspace_state.py +51 -0
  117. daytona_api_client_async/models/workspace_volume.py +103 -0
  118. daytona_api_client_async/py.typed +0 -0
  119. daytona_api_client_async/rest.py +214 -0
  120. daytona_api_client_async-0.21.3a0.dist-info/METADATA +25 -0
  121. daytona_api_client_async-0.21.3a0.dist-info/RECORD +123 -0
  122. daytona_api_client_async-0.21.3a0.dist-info/WHEEL +5 -0
  123. daytona_api_client_async-0.21.3a0.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,579 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Daytona
5
+
6
+ Daytona AI platform API Docs
7
+
8
+ The version of the OpenAPI document: 1.0
9
+ Contact: support@daytona.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 sys
21
+ from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union
22
+ from typing_extensions import NotRequired, Self
23
+
24
+ import urllib3
25
+
26
+
27
+ JSON_SCHEMA_VALIDATION_KEYWORDS = {
28
+ 'multipleOf', 'maximum', 'exclusiveMaximum',
29
+ 'minimum', 'exclusiveMinimum', 'maxLength',
30
+ 'minLength', 'pattern', 'maxItems', 'minItems'
31
+ }
32
+
33
+ ServerVariablesT = Dict[str, str]
34
+
35
+ GenericAuthSetting = TypedDict(
36
+ "GenericAuthSetting",
37
+ {
38
+ "type": str,
39
+ "in": str,
40
+ "key": str,
41
+ "value": str,
42
+ },
43
+ )
44
+
45
+
46
+ OAuth2AuthSetting = TypedDict(
47
+ "OAuth2AuthSetting",
48
+ {
49
+ "type": Literal["oauth2"],
50
+ "in": Literal["header"],
51
+ "key": Literal["Authorization"],
52
+ "value": str,
53
+ },
54
+ )
55
+
56
+
57
+ APIKeyAuthSetting = TypedDict(
58
+ "APIKeyAuthSetting",
59
+ {
60
+ "type": Literal["api_key"],
61
+ "in": str,
62
+ "key": str,
63
+ "value": Optional[str],
64
+ },
65
+ )
66
+
67
+
68
+ BasicAuthSetting = TypedDict(
69
+ "BasicAuthSetting",
70
+ {
71
+ "type": Literal["basic"],
72
+ "in": Literal["header"],
73
+ "key": Literal["Authorization"],
74
+ "value": Optional[str],
75
+ },
76
+ )
77
+
78
+
79
+ BearerFormatAuthSetting = TypedDict(
80
+ "BearerFormatAuthSetting",
81
+ {
82
+ "type": Literal["bearer"],
83
+ "in": Literal["header"],
84
+ "format": Literal["JWT"],
85
+ "key": Literal["Authorization"],
86
+ "value": str,
87
+ },
88
+ )
89
+
90
+
91
+ BearerAuthSetting = TypedDict(
92
+ "BearerAuthSetting",
93
+ {
94
+ "type": Literal["bearer"],
95
+ "in": Literal["header"],
96
+ "key": Literal["Authorization"],
97
+ "value": str,
98
+ },
99
+ )
100
+
101
+
102
+ HTTPSignatureAuthSetting = TypedDict(
103
+ "HTTPSignatureAuthSetting",
104
+ {
105
+ "type": Literal["http-signature"],
106
+ "in": Literal["header"],
107
+ "key": Literal["Authorization"],
108
+ "value": None,
109
+ },
110
+ )
111
+
112
+
113
+ AuthSettings = TypedDict(
114
+ "AuthSettings",
115
+ {
116
+ "bearer": BearerFormatAuthSetting,
117
+ },
118
+ total=False,
119
+ )
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
+
170
+ _default: ClassVar[Optional[Self]] = None
171
+
172
+ def __init__(
173
+ self,
174
+ host: Optional[str]=None,
175
+ api_key: Optional[Dict[str, str]]=None,
176
+ api_key_prefix: Optional[Dict[str, str]]=None,
177
+ username: Optional[str]=None,
178
+ password: Optional[str]=None,
179
+ access_token: Optional[str]=None,
180
+ server_index: Optional[int]=None,
181
+ server_variables: Optional[ServerVariablesT]=None,
182
+ server_operation_index: Optional[Dict[int, int]]=None,
183
+ server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
184
+ ignore_operation_servers: bool=False,
185
+ ssl_ca_cert: Optional[str]=None,
186
+ retries: Optional[int] = None,
187
+ ca_cert_data: Optional[Union[str, bytes]] = None,
188
+ *,
189
+ debug: Optional[bool] = None,
190
+ ) -> None:
191
+ """Constructor
192
+ """
193
+ self._base_path = "http://localhost:3000" if host is None else host
194
+ """Default Base url
195
+ """
196
+ self.server_index = 0 if server_index is None and host is None else server_index
197
+ self.server_operation_index = server_operation_index or {}
198
+ """Default server index
199
+ """
200
+ self.server_variables = server_variables or {}
201
+ self.server_operation_variables = server_operation_variables or {}
202
+ """Default server variables
203
+ """
204
+ self.ignore_operation_servers = ignore_operation_servers
205
+ """Ignore operation servers
206
+ """
207
+ self.temp_folder_path = None
208
+ """Temp file folder for downloading files
209
+ """
210
+ # Authentication Settings
211
+ self.api_key = {}
212
+ if api_key:
213
+ self.api_key = api_key
214
+ """dict to store API key(s)
215
+ """
216
+ self.api_key_prefix = {}
217
+ if api_key_prefix:
218
+ self.api_key_prefix = api_key_prefix
219
+ """dict to store API prefix (e.g. Bearer)
220
+ """
221
+ self.refresh_api_key_hook = None
222
+ """function hook to refresh API key if expired
223
+ """
224
+ self.username = username
225
+ """Username for HTTP basic authentication
226
+ """
227
+ self.password = password
228
+ """Password for HTTP basic authentication
229
+ """
230
+ self.access_token = access_token
231
+ """Access token
232
+ """
233
+ self.logger = {}
234
+ """Logging Settings
235
+ """
236
+ self.logger["package_logger"] = logging.getLogger("daytona_api_client_async")
237
+ self.logger["urllib3_logger"] = logging.getLogger("urllib3")
238
+ self.logger_format = '%(asctime)s %(levelname)s %(message)s'
239
+ """Log format
240
+ """
241
+ self.logger_stream_handler = None
242
+ """Log stream handler
243
+ """
244
+ self.logger_file_handler: Optional[FileHandler] = None
245
+ """Log file handler
246
+ """
247
+ self.logger_file = None
248
+ """Debug file location
249
+ """
250
+ if debug is not None:
251
+ self.debug = debug
252
+ else:
253
+ self.__debug = False
254
+ """Debug switch
255
+ """
256
+
257
+ self.verify_ssl = True
258
+ """SSL/TLS verification
259
+ Set this to false to skip verifying SSL certificate when calling API
260
+ from https server.
261
+ """
262
+ self.ssl_ca_cert = ssl_ca_cert
263
+ """Set this to customize the certificate file to verify the peer.
264
+ """
265
+ self.ca_cert_data = ca_cert_data
266
+ """Set this to verify the peer using PEM (str) or DER (bytes)
267
+ certificate data.
268
+ """
269
+ self.cert_file = None
270
+ """client certificate file
271
+ """
272
+ self.key_file = None
273
+ """client key file
274
+ """
275
+ self.assert_hostname = None
276
+ """Set this to True/False to enable/disable SSL hostname verification.
277
+ """
278
+ self.tls_server_name = None
279
+ """SSL/TLS Server Name Indication (SNI)
280
+ Set this to the SNI value expected by the server.
281
+ """
282
+
283
+ self.connection_pool_maxsize = 100
284
+ """This value is passed to the aiohttp to limit simultaneous connections.
285
+ Default values is 100, None means no-limit.
286
+ """
287
+
288
+ self.proxy: Optional[str] = None
289
+ """Proxy URL
290
+ """
291
+ self.proxy_headers = None
292
+ """Proxy headers
293
+ """
294
+ self.safe_chars_for_path_param = ''
295
+ """Safe chars for path_param
296
+ """
297
+ self.retries = retries
298
+ """Adding retries to override urllib3 default value 3
299
+ """
300
+ # Enable client side validation
301
+ self.client_side_validation = True
302
+
303
+ self.socket_options = None
304
+ """Options to pass down to the underlying urllib3 socket
305
+ """
306
+
307
+ self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z"
308
+ """datetime format
309
+ """
310
+
311
+ self.date_format = "%Y-%m-%d"
312
+ """date format
313
+ """
314
+
315
+ def __deepcopy__(self, memo: Dict[int, Any]) -> Self:
316
+ cls = self.__class__
317
+ result = cls.__new__(cls)
318
+ memo[id(self)] = result
319
+ for k, v in self.__dict__.items():
320
+ if k not in ('logger', 'logger_file_handler'):
321
+ setattr(result, k, copy.deepcopy(v, memo))
322
+ # shallow copy of loggers
323
+ result.logger = copy.copy(self.logger)
324
+ # use setters to configure loggers
325
+ result.logger_file = self.logger_file
326
+ result.debug = self.debug
327
+ return result
328
+
329
+ def __setattr__(self, name: str, value: Any) -> None:
330
+ object.__setattr__(self, name, value)
331
+
332
+ @classmethod
333
+ def set_default(cls, default: Optional[Self]) -> None:
334
+ """Set default instance of configuration.
335
+
336
+ It stores default configuration, which can be
337
+ returned by get_default_copy method.
338
+
339
+ :param default: object of Configuration
340
+ """
341
+ cls._default = default
342
+
343
+ @classmethod
344
+ def get_default_copy(cls) -> Self:
345
+ """Deprecated. Please use `get_default` instead.
346
+
347
+ Deprecated. Please use `get_default` instead.
348
+
349
+ :return: The configuration object.
350
+ """
351
+ return cls.get_default()
352
+
353
+ @classmethod
354
+ def get_default(cls) -> Self:
355
+ """Return the default configuration.
356
+
357
+ This method returns newly created, based on default constructor,
358
+ object of Configuration class or returns a copy of default
359
+ configuration.
360
+
361
+ :return: The configuration object.
362
+ """
363
+ if cls._default is None:
364
+ cls._default = cls()
365
+ return cls._default
366
+
367
+ @property
368
+ def logger_file(self) -> Optional[str]:
369
+ """The logger file.
370
+
371
+ If the logger_file is None, then add stream handler and remove file
372
+ handler. Otherwise, add file handler and remove stream handler.
373
+
374
+ :param value: The logger_file path.
375
+ :type: str
376
+ """
377
+ return self.__logger_file
378
+
379
+ @logger_file.setter
380
+ def logger_file(self, value: Optional[str]) -> None:
381
+ """The logger file.
382
+
383
+ If the logger_file is None, then add stream handler and remove file
384
+ handler. Otherwise, add file handler and remove stream handler.
385
+
386
+ :param value: The logger_file path.
387
+ :type: str
388
+ """
389
+ self.__logger_file = value
390
+ if self.__logger_file:
391
+ # If set logging file,
392
+ # then add file handler and remove stream handler.
393
+ self.logger_file_handler = logging.FileHandler(self.__logger_file)
394
+ self.logger_file_handler.setFormatter(self.logger_formatter)
395
+ for _, logger in self.logger.items():
396
+ logger.addHandler(self.logger_file_handler)
397
+
398
+ @property
399
+ def debug(self) -> bool:
400
+ """Debug status
401
+
402
+ :param value: The debug status, True or False.
403
+ :type: bool
404
+ """
405
+ return self.__debug
406
+
407
+ @debug.setter
408
+ def debug(self, value: bool) -> None:
409
+ """Debug status
410
+
411
+ :param value: The debug status, True or False.
412
+ :type: bool
413
+ """
414
+ self.__debug = value
415
+ if self.__debug:
416
+ # if debug status is True, turn on debug logging
417
+ for _, logger in self.logger.items():
418
+ logger.setLevel(logging.DEBUG)
419
+ # turn on httplib debug
420
+ httplib.HTTPConnection.debuglevel = 1
421
+ else:
422
+ # if debug status is False, turn off debug logging,
423
+ # setting log level to default `logging.WARNING`
424
+ for _, logger in self.logger.items():
425
+ logger.setLevel(logging.WARNING)
426
+ # turn off httplib debug
427
+ httplib.HTTPConnection.debuglevel = 0
428
+
429
+ @property
430
+ def logger_format(self) -> str:
431
+ """The logger format.
432
+
433
+ The logger_formatter will be updated when sets logger_format.
434
+
435
+ :param value: The format string.
436
+ :type: str
437
+ """
438
+ return self.__logger_format
439
+
440
+ @logger_format.setter
441
+ def logger_format(self, value: str) -> None:
442
+ """The logger format.
443
+
444
+ The logger_formatter will be updated when sets logger_format.
445
+
446
+ :param value: The format string.
447
+ :type: str
448
+ """
449
+ self.__logger_format = value
450
+ self.logger_formatter = logging.Formatter(self.__logger_format)
451
+
452
+ def get_api_key_with_prefix(self, identifier: str, alias: Optional[str]=None) -> Optional[str]:
453
+ """Gets API key (with prefix if set).
454
+
455
+ :param identifier: The identifier of apiKey.
456
+ :param alias: The alternative identifier of apiKey.
457
+ :return: The token for api key authentication.
458
+ """
459
+ if self.refresh_api_key_hook is not None:
460
+ self.refresh_api_key_hook(self)
461
+ key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
462
+ if key:
463
+ prefix = self.api_key_prefix.get(identifier)
464
+ if prefix:
465
+ return "%s %s" % (prefix, key)
466
+ else:
467
+ return key
468
+
469
+ return None
470
+
471
+ def get_basic_auth_token(self) -> Optional[str]:
472
+ """Gets HTTP basic authentication header (string).
473
+
474
+ :return: The token for basic HTTP authentication.
475
+ """
476
+ username = ""
477
+ if self.username is not None:
478
+ username = self.username
479
+ password = ""
480
+ if self.password is not None:
481
+ password = self.password
482
+ return urllib3.util.make_headers(
483
+ basic_auth=username + ':' + password
484
+ ).get('authorization')
485
+
486
+ def auth_settings(self)-> AuthSettings:
487
+ """Gets Auth Settings dict for api client.
488
+
489
+ :return: The Auth Settings information dict.
490
+ """
491
+ auth: AuthSettings = {}
492
+ if self.access_token is not None:
493
+ auth['bearer'] = {
494
+ 'type': 'bearer',
495
+ 'in': 'header',
496
+ 'format': 'JWT',
497
+ 'key': 'Authorization',
498
+ 'value': 'Bearer ' + self.access_token
499
+ }
500
+ return auth
501
+
502
+ def to_debug_report(self) -> str:
503
+ """Gets the essential information for debugging.
504
+
505
+ :return: The report for debugging.
506
+ """
507
+ return "Python SDK Debug Report:\n"\
508
+ "OS: {env}\n"\
509
+ "Python Version: {pyversion}\n"\
510
+ "Version of the API: 1.0\n"\
511
+ "SDK Package Version: 0.0.0-dev".\
512
+ format(env=sys.platform, pyversion=sys.version)
513
+
514
+ def get_host_settings(self) -> List[HostSetting]:
515
+ """Gets an array of host settings
516
+
517
+ :return: An array of host settings
518
+ """
519
+ return [
520
+ {
521
+ 'url': "http://localhost:3000",
522
+ 'description': "No description provided",
523
+ }
524
+ ]
525
+
526
+ def get_host_from_settings(
527
+ self,
528
+ index: Optional[int],
529
+ variables: Optional[ServerVariablesT]=None,
530
+ servers: Optional[List[HostSetting]]=None,
531
+ ) -> str:
532
+ """Gets host URL based on the index and variables
533
+ :param index: array index of the host settings
534
+ :param variables: hash of variable and the corresponding value
535
+ :param servers: an array of host settings or None
536
+ :return: URL based on host settings
537
+ """
538
+ if index is None:
539
+ return self._base_path
540
+
541
+ variables = {} if variables is None else variables
542
+ servers = self.get_host_settings() if servers is None else servers
543
+
544
+ try:
545
+ server = servers[index]
546
+ except IndexError:
547
+ raise ValueError(
548
+ "Invalid index {0} when selecting the host settings. "
549
+ "Must be less than {1}".format(index, len(servers)))
550
+
551
+ url = server['url']
552
+
553
+ # go through variables and replace placeholders
554
+ for variable_name, variable in server.get('variables', {}).items():
555
+ used_value = variables.get(
556
+ variable_name, variable['default_value'])
557
+
558
+ if 'enum_values' in variable \
559
+ and used_value not in variable['enum_values']:
560
+ raise ValueError(
561
+ "The variable `{0}` in the host URL has invalid value "
562
+ "{1}. Must be {2}.".format(
563
+ variable_name, variables[variable_name],
564
+ variable['enum_values']))
565
+
566
+ url = url.replace("{" + variable_name + "}", used_value)
567
+
568
+ return url
569
+
570
+ @property
571
+ def host(self) -> str:
572
+ """Return generated host."""
573
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
574
+
575
+ @host.setter
576
+ def host(self, value: str) -> None:
577
+ """Fix base path."""
578
+ self._base_path = value
579
+ self.server_index = None