daytona_api_client 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 might be problematic. Click here for more details.

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