wandelbots-isaacsim-api 2.2.2__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 (85) hide show
  1. wandelbots_isaacsim_api/__init__.py +50 -0
  2. wandelbots_isaacsim_api/api/__init__.py +25 -0
  3. wandelbots_isaacsim_api/api/collision_world_api.py +316 -0
  4. wandelbots_isaacsim_api/api/default_api.py +800 -0
  5. wandelbots_isaacsim_api/api/manipulators_motion_group_api.py +1619 -0
  6. wandelbots_isaacsim_api/api/periphery_camera_api.py +3434 -0
  7. wandelbots_isaacsim_api/api/prims_api.py +4963 -0
  8. wandelbots_isaacsim_api/api/stage_api.py +2351 -0
  9. wandelbots_isaacsim_api/api/teaching_api.py +1312 -0
  10. wandelbots_isaacsim_api/api/trajectory_api.py +1686 -0
  11. wandelbots_isaacsim_api/api/ui_api.py +562 -0
  12. wandelbots_isaacsim_api/api_client.py +800 -0
  13. wandelbots_isaacsim_api/api_response.py +21 -0
  14. wandelbots_isaacsim_api/collision/__init__.py +0 -0
  15. wandelbots_isaacsim_api/collision/utils.py +99 -0
  16. wandelbots_isaacsim_api/configuration.py +561 -0
  17. wandelbots_isaacsim_api/exceptions.py +216 -0
  18. wandelbots_isaacsim_api/models/__init__.py +135 -0
  19. wandelbots_isaacsim_api/models/auth0_credentials.py +100 -0
  20. wandelbots_isaacsim_api/models/body_apply_relative_pose.py +99 -0
  21. wandelbots_isaacsim_api/models/body_assign_default_poses.py +91 -0
  22. wandelbots_isaacsim_api/models/body_reset_to_default_poses.py +91 -0
  23. wandelbots_isaacsim_api/models/body_set_joint_state.py +93 -0
  24. wandelbots_isaacsim_api/models/body_set_prim_metadata.py +97 -0
  25. wandelbots_isaacsim_api/models/body_set_prim_visibility.py +103 -0
  26. wandelbots_isaacsim_api/models/body_set_semantic_label.py +93 -0
  27. wandelbots_isaacsim_api/models/body_update_colliders.py +93 -0
  28. wandelbots_isaacsim_api/models/body_update_pose.py +97 -0
  29. wandelbots_isaacsim_api/models/bounding_box2_d.py +98 -0
  30. wandelbots_isaacsim_api/models/bounding_box3_d.py +100 -0
  31. wandelbots_isaacsim_api/models/box.py +119 -0
  32. wandelbots_isaacsim_api/models/box_sweep_parameters.py +111 -0
  33. wandelbots_isaacsim_api/models/capsule.py +105 -0
  34. wandelbots_isaacsim_api/models/collider.py +101 -0
  35. wandelbots_isaacsim_api/models/convex_hull.py +103 -0
  36. wandelbots_isaacsim_api/models/create_ghost_object.py +102 -0
  37. wandelbots_isaacsim_api/models/custom_prim.py +100 -0
  38. wandelbots_isaacsim_api/models/custom_prim_data.py +93 -0
  39. wandelbots_isaacsim_api/models/cylinder.py +105 -0
  40. wandelbots_isaacsim_api/models/ghost_object.py +106 -0
  41. wandelbots_isaacsim_api/models/ghost_object_source.py +93 -0
  42. wandelbots_isaacsim_api/models/gizmo_prim.py +98 -0
  43. wandelbots_isaacsim_api/models/http_validation_error.py +108 -0
  44. wandelbots_isaacsim_api/models/instance_segmentation_data.py +97 -0
  45. wandelbots_isaacsim_api/models/instance_segmentation_info.py +91 -0
  46. wandelbots_isaacsim_api/models/motion_group_configuration.py +99 -0
  47. wandelbots_isaacsim_api/models/motion_stream_configuration.py +101 -0
  48. wandelbots_isaacsim_api/models/patch_trajectory_data.py +107 -0
  49. wandelbots_isaacsim_api/models/plane.py +101 -0
  50. wandelbots_isaacsim_api/models/point_cloud.py +95 -0
  51. wandelbots_isaacsim_api/models/pose.py +137 -0
  52. wandelbots_isaacsim_api/models/pose_position_inner.py +138 -0
  53. wandelbots_isaacsim_api/models/prim.py +165 -0
  54. wandelbots_isaacsim_api/models/prim_selection.py +91 -0
  55. wandelbots_isaacsim_api/models/quat_pose.py +92 -0
  56. wandelbots_isaacsim_api/models/relative_pose_mode.py +39 -0
  57. wandelbots_isaacsim_api/models/response_get_pose.py +134 -0
  58. wandelbots_isaacsim_api/models/response_get_relative_pose.py +134 -0
  59. wandelbots_isaacsim_api/models/response_list_default_poses_value.py +140 -0
  60. wandelbots_isaacsim_api/models/semantic_segmentation_data.py +97 -0
  61. wandelbots_isaacsim_api/models/semantic_segmentation_info.py +91 -0
  62. wandelbots_isaacsim_api/models/shape.py +194 -0
  63. wandelbots_isaacsim_api/models/simulation_state.py +101 -0
  64. wandelbots_isaacsim_api/models/sphere.py +103 -0
  65. wandelbots_isaacsim_api/models/sphere_sweep_parameters.py +107 -0
  66. wandelbots_isaacsim_api/models/stage_units.py +91 -0
  67. wandelbots_isaacsim_api/models/sweep_arguments.py +134 -0
  68. wandelbots_isaacsim_api/models/tcp_source.py +99 -0
  69. wandelbots_isaacsim_api/models/trajectory_data.py +101 -0
  70. wandelbots_isaacsim_api/models/trajectory_marker.py +97 -0
  71. wandelbots_isaacsim_api/models/trajectory_object.py +101 -0
  72. wandelbots_isaacsim_api/models/trajectory_options.py +94 -0
  73. wandelbots_isaacsim_api/models/usd_stage_model.py +91 -0
  74. wandelbots_isaacsim_api/models/validation_error.py +112 -0
  75. wandelbots_isaacsim_api/models/validation_error_loc_inner.py +138 -0
  76. wandelbots_isaacsim_api/models/ws_pose.py +92 -0
  77. wandelbots_isaacsim_api/py.typed +0 -0
  78. wandelbots_isaacsim_api/rest.py +212 -0
  79. wandelbots_isaacsim_api/trajectory/__init__.py +17 -0
  80. wandelbots_isaacsim_api/trajectory/trajectory_viewer.py +111 -0
  81. wandelbots_isaacsim_api/trajectory/utils.py +154 -0
  82. wandelbots_isaacsim_api-2.2.2.dist-info/LICENSE +201 -0
  83. wandelbots_isaacsim_api-2.2.2.dist-info/METADATA +60 -0
  84. wandelbots_isaacsim_api-2.2.2.dist-info/RECORD +85 -0
  85. wandelbots_isaacsim_api-2.2.2.dist-info/WHEEL +4 -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
+ }
File without changes
@@ -0,0 +1,99 @@
1
+ import wandelbots_api_client as nova_api
2
+ import wandelbots_isaacsim_api as isaac_sim_api
3
+ from typing import cast
4
+
5
+
6
+ def to_nova_collider(
7
+ shape: isaac_sim_api.models.Collider,
8
+ ) -> nova_api.models.Collider:
9
+ pose = nova_api.models.Pose2(
10
+ position=[
11
+ shape.pose.position[0].actual_instance,
12
+ shape.pose.position[1].actual_instance,
13
+ shape.pose.position[2].actual_instance,
14
+ ],
15
+ orientation=[
16
+ shape.pose.orientation[0].actual_instance,
17
+ shape.pose.orientation[1].actual_instance,
18
+ shape.pose.orientation[2].actual_instance,
19
+ ],
20
+ )
21
+
22
+ if isinstance(shape.shape.actual_instance, isaac_sim_api.models.Sphere):
23
+ return nova_api.models.Collider(
24
+ shape=nova_api.models.ColliderShape(
25
+ nova_api.models.Sphere2(
26
+ radius=shape.shape.actual_instance.radius,
27
+ shape_type="sphere",
28
+ )
29
+ ),
30
+ pose=pose,
31
+ )
32
+ elif isinstance(shape.shape.actual_instance, isaac_sim_api.models.Box):
33
+ return nova_api.models.Collider(
34
+ shape=nova_api.models.ColliderShape(
35
+ nova_api.models.Box2(
36
+ size_x=shape.shape.actual_instance.size_x,
37
+ size_y=shape.shape.actual_instance.size_y,
38
+ size_z=shape.shape.actual_instance.size_z,
39
+ shape_type="box",
40
+ box_type="FULL",
41
+ )
42
+ ),
43
+ pose=pose,
44
+ )
45
+ elif isinstance(shape.shape.actual_instance, isaac_sim_api.models.Capsule):
46
+ return nova_api.models.Collider(
47
+ shape=nova_api.models.ColliderShape(
48
+ nova_api.models.Capsule2(
49
+ cylinder_height=shape.shape.actual_instance.height,
50
+ radius=shape.shape.actual_instance.radius,
51
+ shape_type="capsule",
52
+ )
53
+ ),
54
+ pose=pose,
55
+ )
56
+ elif isinstance(shape.shape.actual_instance, isaac_sim_api.models.Cylinder):
57
+ return nova_api.models.Collider(
58
+ shape=nova_api.models.ColliderShape(
59
+ nova_api.models.Cylinder2(
60
+ height=shape.shape.actual_instance.height,
61
+ radius=shape.shape.actual_instance.radius,
62
+ shape_type="cylinder",
63
+ )
64
+ ),
65
+ pose=pose,
66
+ )
67
+ elif isinstance(shape.shape.actual_instance, isaac_sim_api.models.Plane):
68
+ return nova_api.models.Collider(
69
+ shape=nova_api.models.ColliderShape(
70
+ nova_api.models.Plane2(shape_type="plane")
71
+ ),
72
+ pose=pose,
73
+ )
74
+ elif isinstance(shape.shape.actual_instance, isaac_sim_api.models.ConvexHull):
75
+ return nova_api.models.Collider(
76
+ shape=nova_api.models.ColliderShape(
77
+ nova_api.models.convex_hull2.ConvexHull2(
78
+ shape_type="convex_hull",
79
+ vertices=cast(
80
+ isaac_sim_api.models.ConvexHull,
81
+ shape.shape.actual_instance,
82
+ ).vertices,
83
+ )
84
+ ),
85
+ pose=pose,
86
+ )
87
+ return None
88
+
89
+
90
+ async def sweep_colliders(
91
+ api_client: isaac_sim_api.ApiClient,
92
+ sweep_parameters: isaac_sim_api.models.SphereSweepParameters
93
+ | isaac_sim_api.models.BoxSweepParameters,
94
+ ) -> dict[str, nova_api.models.Collider]:
95
+ collider_api = isaac_sim_api.CollisionWorldApi(api_client)
96
+ colliders = await collider_api.sweep_collisions(
97
+ isaac_sim_api.models.SweepArguments(sweep_parameters)
98
+ )
99
+ return {shape_id: to_nova_collider(shape) for shape_id, shape in colliders.items()}
@@ -0,0 +1,561 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Wandelbots Omniservice
5
+
6
+ A microservice-based framework for managing Omniverse functionalities
7
+
8
+ The version of the OpenAPI document: 2.2.2
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ import copy
16
+ import http.client as httplib
17
+ import logging
18
+ from logging import FileHandler
19
+ import sys
20
+ from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict
21
+ from typing_extensions import NotRequired, Self
22
+
23
+ import urllib3
24
+
25
+
26
+ JSON_SCHEMA_VALIDATION_KEYWORDS = {
27
+ 'multipleOf', 'maximum', 'exclusiveMaximum',
28
+ 'minimum', 'exclusiveMinimum', 'maxLength',
29
+ 'minLength', 'pattern', 'maxItems', 'minItems'
30
+ }
31
+
32
+ ServerVariablesT = Dict[str, str]
33
+
34
+ GenericAuthSetting = TypedDict(
35
+ "GenericAuthSetting",
36
+ {
37
+ "type": str,
38
+ "in": str,
39
+ "key": str,
40
+ "value": str,
41
+ },
42
+ )
43
+
44
+
45
+ OAuth2AuthSetting = TypedDict(
46
+ "OAuth2AuthSetting",
47
+ {
48
+ "type": Literal["oauth2"],
49
+ "in": Literal["header"],
50
+ "key": Literal["Authorization"],
51
+ "value": str,
52
+ },
53
+ )
54
+
55
+
56
+ APIKeyAuthSetting = TypedDict(
57
+ "APIKeyAuthSetting",
58
+ {
59
+ "type": Literal["api_key"],
60
+ "in": str,
61
+ "key": str,
62
+ "value": Optional[str],
63
+ },
64
+ )
65
+
66
+
67
+ BasicAuthSetting = TypedDict(
68
+ "BasicAuthSetting",
69
+ {
70
+ "type": Literal["basic"],
71
+ "in": Literal["header"],
72
+ "key": Literal["Authorization"],
73
+ "value": Optional[str],
74
+ },
75
+ )
76
+
77
+
78
+ BearerFormatAuthSetting = TypedDict(
79
+ "BearerFormatAuthSetting",
80
+ {
81
+ "type": Literal["bearer"],
82
+ "in": Literal["header"],
83
+ "format": Literal["JWT"],
84
+ "key": Literal["Authorization"],
85
+ "value": str,
86
+ },
87
+ )
88
+
89
+
90
+ BearerAuthSetting = TypedDict(
91
+ "BearerAuthSetting",
92
+ {
93
+ "type": Literal["bearer"],
94
+ "in": Literal["header"],
95
+ "key": Literal["Authorization"],
96
+ "value": str,
97
+ },
98
+ )
99
+
100
+
101
+ HTTPSignatureAuthSetting = TypedDict(
102
+ "HTTPSignatureAuthSetting",
103
+ {
104
+ "type": Literal["http-signature"],
105
+ "in": Literal["header"],
106
+ "key": Literal["Authorization"],
107
+ "value": None,
108
+ },
109
+ )
110
+
111
+
112
+ AuthSettings = TypedDict(
113
+ "AuthSettings",
114
+ {
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 ssl_ca_cert: str - the path to a file of concatenated CA certificates
160
+ in PEM format.
161
+ :param retries: Number of retries for API requests.
162
+
163
+ """
164
+
165
+ _default: ClassVar[Optional[Self]] = None
166
+
167
+ def __init__(
168
+ self,
169
+ host: Optional[str]=None,
170
+ api_key: Optional[Dict[str, str]]=None,
171
+ api_key_prefix: Optional[Dict[str, str]]=None,
172
+ username: Optional[str]=None,
173
+ password: Optional[str]=None,
174
+ access_token: Optional[str]=None,
175
+ server_index: Optional[int]=None,
176
+ server_variables: Optional[ServerVariablesT]=None,
177
+ server_operation_index: Optional[Dict[int, int]]=None,
178
+ server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
179
+ ignore_operation_servers: bool=False,
180
+ ssl_ca_cert: Optional[str]=None,
181
+ retries: Optional[int] = None,
182
+ *,
183
+ debug: Optional[bool] = None,
184
+ ) -> None:
185
+ """Constructor
186
+ """
187
+ self._base_path = "http://localhost" if host is None else host
188
+ """Default Base url
189
+ """
190
+ self.server_index = 0 if server_index is None and host is None else server_index
191
+ self.server_operation_index = server_operation_index or {}
192
+ """Default server index
193
+ """
194
+ self.server_variables = server_variables or {}
195
+ self.server_operation_variables = server_operation_variables or {}
196
+ """Default server variables
197
+ """
198
+ self.ignore_operation_servers = ignore_operation_servers
199
+ """Ignore operation servers
200
+ """
201
+ self.temp_folder_path = None
202
+ """Temp file folder for downloading files
203
+ """
204
+ # Authentication Settings
205
+ self.api_key = {}
206
+ if api_key:
207
+ self.api_key = api_key
208
+ """dict to store API key(s)
209
+ """
210
+ self.api_key_prefix = {}
211
+ if api_key_prefix:
212
+ self.api_key_prefix = api_key_prefix
213
+ """dict to store API prefix (e.g. Bearer)
214
+ """
215
+ self.refresh_api_key_hook = None
216
+ """function hook to refresh API key if expired
217
+ """
218
+ self.username = username
219
+ """Username for HTTP basic authentication
220
+ """
221
+ self.password = password
222
+ """Password for HTTP basic authentication
223
+ """
224
+ self.access_token = access_token
225
+ """Access token
226
+ """
227
+ self.logger = {}
228
+ """Logging Settings
229
+ """
230
+ self.logger["package_logger"] = logging.getLogger("wandelbots_isaacsim_api")
231
+ self.logger["urllib3_logger"] = logging.getLogger("urllib3")
232
+ self.logger_format = '%(asctime)s %(levelname)s %(message)s'
233
+ """Log format
234
+ """
235
+ self.logger_stream_handler = None
236
+ """Log stream handler
237
+ """
238
+ self.logger_file_handler: Optional[FileHandler] = None
239
+ """Log file handler
240
+ """
241
+ self.logger_file = None
242
+ """Debug file location
243
+ """
244
+ if debug is not None:
245
+ self.debug = debug
246
+ else:
247
+ self.__debug = False
248
+ """Debug switch
249
+ """
250
+
251
+ self.verify_ssl = True
252
+ """SSL/TLS verification
253
+ Set this to false to skip verifying SSL certificate when calling API
254
+ from https server.
255
+ """
256
+ self.ssl_ca_cert = ssl_ca_cert
257
+ """Set this to customize the certificate file to verify the peer.
258
+ """
259
+ self.cert_file = None
260
+ """client certificate file
261
+ """
262
+ self.key_file = None
263
+ """client key file
264
+ """
265
+ self.assert_hostname = None
266
+ """Set this to True/False to enable/disable SSL hostname verification.
267
+ """
268
+ self.tls_server_name = None
269
+ """SSL/TLS Server Name Indication (SNI)
270
+ Set this to the SNI value expected by the server.
271
+ """
272
+
273
+ self.connection_pool_maxsize = 100
274
+ """This value is passed to the aiohttp to limit simultaneous connections.
275
+ Default values is 100, None means no-limit.
276
+ """
277
+
278
+ self.proxy: Optional[str] = None
279
+ """Proxy URL
280
+ """
281
+ self.proxy_headers = None
282
+ """Proxy headers
283
+ """
284
+ self.safe_chars_for_path_param = ''
285
+ """Safe chars for path_param
286
+ """
287
+ self.retries = retries
288
+ """Adding retries to override urllib3 default value 3
289
+ """
290
+ # Enable client side validation
291
+ self.client_side_validation = True
292
+
293
+ self.socket_options = None
294
+ """Options to pass down to the underlying urllib3 socket
295
+ """
296
+
297
+ self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z"
298
+ """datetime format
299
+ """
300
+
301
+ self.date_format = "%Y-%m-%d"
302
+ """date format
303
+ """
304
+
305
+ def __deepcopy__(self, memo: Dict[int, Any]) -> Self:
306
+ cls = self.__class__
307
+ result = cls.__new__(cls)
308
+ memo[id(self)] = result
309
+ for k, v in self.__dict__.items():
310
+ if k not in ('logger', 'logger_file_handler'):
311
+ setattr(result, k, copy.deepcopy(v, memo))
312
+ # shallow copy of loggers
313
+ result.logger = copy.copy(self.logger)
314
+ # use setters to configure loggers
315
+ result.logger_file = self.logger_file
316
+ result.debug = self.debug
317
+ return result
318
+
319
+ def __setattr__(self, name: str, value: Any) -> None:
320
+ object.__setattr__(self, name, value)
321
+
322
+ @classmethod
323
+ def set_default(cls, default: Optional[Self]) -> None:
324
+ """Set default instance of configuration.
325
+
326
+ It stores default configuration, which can be
327
+ returned by get_default_copy method.
328
+
329
+ :param default: object of Configuration
330
+ """
331
+ cls._default = default
332
+
333
+ @classmethod
334
+ def get_default_copy(cls) -> Self:
335
+ """Deprecated. Please use `get_default` instead.
336
+
337
+ Deprecated. Please use `get_default` instead.
338
+
339
+ :return: The configuration object.
340
+ """
341
+ return cls.get_default()
342
+
343
+ @classmethod
344
+ def get_default(cls) -> Self:
345
+ """Return the default configuration.
346
+
347
+ This method returns newly created, based on default constructor,
348
+ object of Configuration class or returns a copy of default
349
+ configuration.
350
+
351
+ :return: The configuration object.
352
+ """
353
+ if cls._default is None:
354
+ cls._default = cls()
355
+ return cls._default
356
+
357
+ @property
358
+ def logger_file(self) -> Optional[str]:
359
+ """The logger file.
360
+
361
+ If the logger_file is None, then add stream handler and remove file
362
+ handler. Otherwise, add file handler and remove stream handler.
363
+
364
+ :param value: The logger_file path.
365
+ :type: str
366
+ """
367
+ return self.__logger_file
368
+
369
+ @logger_file.setter
370
+ def logger_file(self, value: Optional[str]) -> None:
371
+ """The logger file.
372
+
373
+ If the logger_file is None, then add stream handler and remove file
374
+ handler. Otherwise, add file handler and remove stream handler.
375
+
376
+ :param value: The logger_file path.
377
+ :type: str
378
+ """
379
+ self.__logger_file = value
380
+ if self.__logger_file:
381
+ # If set logging file,
382
+ # then add file handler and remove stream handler.
383
+ self.logger_file_handler = logging.FileHandler(self.__logger_file)
384
+ self.logger_file_handler.setFormatter(self.logger_formatter)
385
+ for _, logger in self.logger.items():
386
+ logger.addHandler(self.logger_file_handler)
387
+
388
+ @property
389
+ def debug(self) -> bool:
390
+ """Debug status
391
+
392
+ :param value: The debug status, True or False.
393
+ :type: bool
394
+ """
395
+ return self.__debug
396
+
397
+ @debug.setter
398
+ def debug(self, value: bool) -> None:
399
+ """Debug status
400
+
401
+ :param value: The debug status, True or False.
402
+ :type: bool
403
+ """
404
+ self.__debug = value
405
+ if self.__debug:
406
+ # if debug status is True, turn on debug logging
407
+ for _, logger in self.logger.items():
408
+ logger.setLevel(logging.DEBUG)
409
+ # turn on httplib debug
410
+ httplib.HTTPConnection.debuglevel = 1
411
+ else:
412
+ # if debug status is False, turn off debug logging,
413
+ # setting log level to default `logging.WARNING`
414
+ for _, logger in self.logger.items():
415
+ logger.setLevel(logging.WARNING)
416
+ # turn off httplib debug
417
+ httplib.HTTPConnection.debuglevel = 0
418
+
419
+ @property
420
+ def logger_format(self) -> str:
421
+ """The logger format.
422
+
423
+ The logger_formatter will be updated when sets logger_format.
424
+
425
+ :param value: The format string.
426
+ :type: str
427
+ """
428
+ return self.__logger_format
429
+
430
+ @logger_format.setter
431
+ def logger_format(self, value: str) -> None:
432
+ """The logger format.
433
+
434
+ The logger_formatter will be updated when sets logger_format.
435
+
436
+ :param value: The format string.
437
+ :type: str
438
+ """
439
+ self.__logger_format = value
440
+ self.logger_formatter = logging.Formatter(self.__logger_format)
441
+
442
+ def get_api_key_with_prefix(self, identifier: str, alias: Optional[str]=None) -> Optional[str]:
443
+ """Gets API key (with prefix if set).
444
+
445
+ :param identifier: The identifier of apiKey.
446
+ :param alias: The alternative identifier of apiKey.
447
+ :return: The token for api key authentication.
448
+ """
449
+ if self.refresh_api_key_hook is not None:
450
+ self.refresh_api_key_hook(self)
451
+ key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
452
+ if key:
453
+ prefix = self.api_key_prefix.get(identifier)
454
+ if prefix:
455
+ return "%s %s" % (prefix, key)
456
+ else:
457
+ return key
458
+
459
+ return None
460
+
461
+ def get_basic_auth_token(self) -> Optional[str]:
462
+ """Gets HTTP basic authentication header (string).
463
+
464
+ :return: The token for basic HTTP authentication.
465
+ """
466
+ username = ""
467
+ if self.username is not None:
468
+ username = self.username
469
+ password = ""
470
+ if self.password is not None:
471
+ password = self.password
472
+ return urllib3.util.make_headers(
473
+ basic_auth=username + ':' + password
474
+ ).get('authorization')
475
+
476
+ def auth_settings(self)-> AuthSettings:
477
+ """Gets Auth Settings dict for api client.
478
+
479
+ :return: The Auth Settings information dict.
480
+ """
481
+ auth: AuthSettings = {}
482
+ return auth
483
+
484
+ def to_debug_report(self) -> str:
485
+ """Gets the essential information for debugging.
486
+
487
+ :return: The report for debugging.
488
+ """
489
+ return "Python SDK Debug Report:\n"\
490
+ "OS: {env}\n"\
491
+ "Python Version: {pyversion}\n"\
492
+ "Version of the API: 2.2.2\n"\
493
+ "SDK Package Version: 2.2.2".\
494
+ format(env=sys.platform, pyversion=sys.version)
495
+
496
+ def get_host_settings(self) -> List[HostSetting]:
497
+ """Gets an array of host settings
498
+
499
+ :return: An array of host settings
500
+ """
501
+ return [
502
+ {
503
+ 'url': "",
504
+ 'description': "No description provided",
505
+ }
506
+ ]
507
+
508
+ def get_host_from_settings(
509
+ self,
510
+ index: Optional[int],
511
+ variables: Optional[ServerVariablesT]=None,
512
+ servers: Optional[List[HostSetting]]=None,
513
+ ) -> str:
514
+ """Gets host URL based on the index and variables
515
+ :param index: array index of the host settings
516
+ :param variables: hash of variable and the corresponding value
517
+ :param servers: an array of host settings or None
518
+ :return: URL based on host settings
519
+ """
520
+ if index is None:
521
+ return self._base_path
522
+
523
+ variables = {} if variables is None else variables
524
+ servers = self.get_host_settings() if servers is None else servers
525
+
526
+ try:
527
+ server = servers[index]
528
+ except IndexError:
529
+ raise ValueError(
530
+ "Invalid index {0} when selecting the host settings. "
531
+ "Must be less than {1}".format(index, len(servers)))
532
+
533
+ url = server['url']
534
+
535
+ # go through variables and replace placeholders
536
+ for variable_name, variable in server.get('variables', {}).items():
537
+ used_value = variables.get(
538
+ variable_name, variable['default_value'])
539
+
540
+ if 'enum_values' in variable \
541
+ and used_value not in variable['enum_values']:
542
+ raise ValueError(
543
+ "The variable `{0}` in the host URL has invalid value "
544
+ "{1}. Must be {2}.".format(
545
+ variable_name, variables[variable_name],
546
+ variable['enum_values']))
547
+
548
+ url = url.replace("{" + variable_name + "}", used_value)
549
+
550
+ return url
551
+
552
+ @property
553
+ def host(self) -> str:
554
+ """Return generated host."""
555
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
556
+
557
+ @host.setter
558
+ def host(self, value: str) -> None:
559
+ """Fix base path."""
560
+ self._base_path = value
561
+ self.server_index = None