across-server-openapi-python 0.0.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 (128) hide show
  1. across/__init__.py +0 -0
  2. across/sdk/__init__.py +0 -0
  3. across/sdk/v1/__init__.py +251 -0
  4. across/sdk/v1/abstract_credential_storage.py +16 -0
  5. across/sdk/v1/api/__init__.py +20 -0
  6. across/sdk/v1/api/auth_api.py +1097 -0
  7. across/sdk/v1/api/filter_api.py +623 -0
  8. across/sdk/v1/api/group_api.py +586 -0
  9. across/sdk/v1/api/group_invite_api.py +1165 -0
  10. across/sdk/v1/api/group_role_api.py +2070 -0
  11. across/sdk/v1/api/instrument_api.py +633 -0
  12. across/sdk/v1/api/internal_api.py +571 -0
  13. across/sdk/v1/api/observation_api.py +940 -0
  14. across/sdk/v1/api/observatory_api.py +670 -0
  15. across/sdk/v1/api/permission_api.py +285 -0
  16. across/sdk/v1/api/role_api.py +552 -0
  17. across/sdk/v1/api/schedule_api.py +1914 -0
  18. across/sdk/v1/api/service_account_api.py +2353 -0
  19. across/sdk/v1/api/telescope_api.py +667 -0
  20. across/sdk/v1/api/tle_api.py +317 -0
  21. across/sdk/v1/api/tools_api.py +812 -0
  22. across/sdk/v1/api/user_api.py +2263 -0
  23. across/sdk/v1/api_client.py +801 -0
  24. across/sdk/v1/api_client_wrapper.py +239 -0
  25. across/sdk/v1/api_response.py +21 -0
  26. across/sdk/v1/configuration.py +605 -0
  27. across/sdk/v1/exceptions.py +216 -0
  28. across/sdk/v1/models/__init__.py +103 -0
  29. across/sdk/v1/models/access_token_response.py +89 -0
  30. across/sdk/v1/models/across_server_routes_v1_group_invite_schemas_group_invite.py +104 -0
  31. across/sdk/v1/models/across_server_routes_v1_group_role_schemas_group_role.py +124 -0
  32. across/sdk/v1/models/across_server_routes_v1_group_role_schemas_service_account.py +106 -0
  33. across/sdk/v1/models/across_server_routes_v1_group_role_schemas_user.py +95 -0
  34. across/sdk/v1/models/across_server_routes_v1_group_schemas_group.py +111 -0
  35. across/sdk/v1/models/across_server_routes_v1_group_schemas_user.py +105 -0
  36. across/sdk/v1/models/across_server_routes_v1_role_schemas_user.py +96 -0
  37. across/sdk/v1/models/across_server_routes_v1_system_service_account_schemas_service_account.py +90 -0
  38. across/sdk/v1/models/across_server_routes_v1_system_service_account_schemas_service_account_secret.py +92 -0
  39. across/sdk/v1/models/across_server_routes_v1_user_schemas_group.py +101 -0
  40. across/sdk/v1/models/across_server_routes_v1_user_schemas_group_invite.py +99 -0
  41. across/sdk/v1/models/across_server_routes_v1_user_schemas_group_role.py +99 -0
  42. across/sdk/v1/models/across_server_routes_v1_user_schemas_user.py +135 -0
  43. across/sdk/v1/models/across_server_routes_v1_user_service_account_schemas_service_account.py +111 -0
  44. across/sdk/v1/models/across_server_routes_v1_user_service_account_schemas_service_account_secret.py +118 -0
  45. across/sdk/v1/models/alt_az_constraint.py +130 -0
  46. across/sdk/v1/models/bandpass.py +149 -0
  47. across/sdk/v1/models/bandpass_type.py +155 -0
  48. across/sdk/v1/models/constrained_date.py +93 -0
  49. across/sdk/v1/models/constraint_reason.py +89 -0
  50. across/sdk/v1/models/constraint_type.py +43 -0
  51. across/sdk/v1/models/coordinate.py +100 -0
  52. across/sdk/v1/models/date_range.py +90 -0
  53. across/sdk/v1/models/depth_unit.py +39 -0
  54. across/sdk/v1/models/earth_limb_constraint.py +124 -0
  55. across/sdk/v1/models/energy_bandpass.py +121 -0
  56. across/sdk/v1/models/energy_unit.py +40 -0
  57. across/sdk/v1/models/ephemeris_type.py +39 -0
  58. across/sdk/v1/models/filter.py +135 -0
  59. across/sdk/v1/models/frequency_bandpass.py +121 -0
  60. across/sdk/v1/models/frequency_unit.py +40 -0
  61. across/sdk/v1/models/grant_type.py +37 -0
  62. across/sdk/v1/models/ground_parameters.py +91 -0
  63. across/sdk/v1/models/group_invite_create.py +87 -0
  64. across/sdk/v1/models/group_invite_group_details.py +94 -0
  65. across/sdk/v1/models/group_read.py +91 -0
  66. across/sdk/v1/models/group_role_create.py +89 -0
  67. across/sdk/v1/models/group_role_read.py +99 -0
  68. across/sdk/v1/models/http_validation_error.py +95 -0
  69. across/sdk/v1/models/id_name_schema.py +96 -0
  70. across/sdk/v1/models/instrument.py +163 -0
  71. across/sdk/v1/models/instrument_constraints_inner.py +237 -0
  72. across/sdk/v1/models/ivoa_obs_category.py +39 -0
  73. across/sdk/v1/models/ivoa_obs_tracking_type.py +38 -0
  74. across/sdk/v1/models/jpl_parameters.py +87 -0
  75. across/sdk/v1/models/moon_angle_constraint.py +124 -0
  76. across/sdk/v1/models/nullable_date_range.py +100 -0
  77. across/sdk/v1/models/observation.py +248 -0
  78. across/sdk/v1/models/observation_create.py +249 -0
  79. across/sdk/v1/models/observation_status.py +40 -0
  80. across/sdk/v1/models/observation_type.py +39 -0
  81. across/sdk/v1/models/observatory.py +145 -0
  82. across/sdk/v1/models/observatory_ephemeris_type.py +96 -0
  83. across/sdk/v1/models/observatory_type.py +37 -0
  84. across/sdk/v1/models/page_observation.py +116 -0
  85. across/sdk/v1/models/page_schedule.py +116 -0
  86. across/sdk/v1/models/parameters.py +164 -0
  87. across/sdk/v1/models/permission.py +89 -0
  88. across/sdk/v1/models/point.py +89 -0
  89. across/sdk/v1/models/role.py +100 -0
  90. across/sdk/v1/models/role_base.py +89 -0
  91. across/sdk/v1/models/saa_polygon_constraint.py +101 -0
  92. across/sdk/v1/models/schedule.py +144 -0
  93. across/sdk/v1/models/schedule_cadence.py +99 -0
  94. across/sdk/v1/models/schedule_create.py +123 -0
  95. across/sdk/v1/models/schedule_create_many.py +97 -0
  96. across/sdk/v1/models/schedule_fidelity.py +37 -0
  97. across/sdk/v1/models/schedule_status.py +38 -0
  98. across/sdk/v1/models/service_account_create.py +101 -0
  99. across/sdk/v1/models/service_account_secret.py +103 -0
  100. across/sdk/v1/models/service_account_update.py +106 -0
  101. across/sdk/v1/models/spice_parameters.py +89 -0
  102. across/sdk/v1/models/sun_angle_constraint.py +124 -0
  103. across/sdk/v1/models/system_service_account.py +121 -0
  104. across/sdk/v1/models/system_service_account_secret.py +123 -0
  105. across/sdk/v1/models/telescope.py +135 -0
  106. across/sdk/v1/models/telescope_instrument.py +163 -0
  107. across/sdk/v1/models/tle.py +99 -0
  108. across/sdk/v1/models/tle_create.py +94 -0
  109. across/sdk/v1/models/tle_parameters.py +89 -0
  110. across/sdk/v1/models/unit_value.py +94 -0
  111. across/sdk/v1/models/user_create.py +93 -0
  112. across/sdk/v1/models/user_info.py +95 -0
  113. across/sdk/v1/models/user_update.py +106 -0
  114. across/sdk/v1/models/validation_error.py +99 -0
  115. across/sdk/v1/models/validation_error_loc_inner.py +138 -0
  116. across/sdk/v1/models/visibility_result.py +97 -0
  117. across/sdk/v1/models/visibility_type.py +38 -0
  118. across/sdk/v1/models/visibility_window.py +99 -0
  119. across/sdk/v1/models/wavelength_bandpass.py +142 -0
  120. across/sdk/v1/models/wavelength_unit.py +39 -0
  121. across/sdk/v1/models/window.py +96 -0
  122. across/sdk/v1/py.typed +0 -0
  123. across/sdk/v1/rest.py +258 -0
  124. across_server_openapi_python-0.0.1.dist-info/METADATA +326 -0
  125. across_server_openapi_python-0.0.1.dist-info/RECORD +128 -0
  126. across_server_openapi_python-0.0.1.dist-info/WHEEL +5 -0
  127. across_server_openapi_python-0.0.1.dist-info/licenses/LICENSE +42 -0
  128. across_server_openapi_python-0.0.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,605 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ ACROSS Server
5
+
6
+ Server providing tools and utilities for various NASA missions to aid in coordination of large observation efforts.
7
+
8
+ The version of the OpenAPI document: 0.3.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 multiprocessing
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
+ "Authorization": BearerAuthSetting,
117
+ "ServiceAccountAuthorization": BasicAuthSetting,
118
+ },
119
+ total=False,
120
+ )
121
+
122
+
123
+ class HostSettingVariable(TypedDict):
124
+ description: str
125
+ default_value: str
126
+ enum_values: List[str]
127
+
128
+
129
+ class HostSetting(TypedDict):
130
+ url: str
131
+ description: str
132
+ variables: NotRequired[Dict[str, HostSettingVariable]]
133
+
134
+
135
+ class Configuration:
136
+ """This class contains various settings of the API client.
137
+
138
+ :param host: Base url.
139
+ :param ignore_operation_servers
140
+ Boolean to ignore operation servers for the API client.
141
+ Config will use `host` as the base url regardless of the operation servers.
142
+ :param api_key: Dict to store API key(s).
143
+ Each entry in the dict specifies an API key.
144
+ The dict key is the name of the security scheme in the OAS specification.
145
+ The dict value is the API key secret.
146
+ :param api_key_prefix: Dict to store API prefix (e.g. Bearer).
147
+ The dict key is the name of the security scheme in the OAS specification.
148
+ The dict value is an API key prefix when generating the auth data.
149
+ :param username: Username for HTTP basic authentication.
150
+ :param password: Password for HTTP basic authentication.
151
+ :param access_token: Access token.
152
+ :param server_index: Index to servers configuration.
153
+ :param server_variables: Mapping with string values to replace variables in
154
+ templated server configuration. The validation of enums is performed for
155
+ variables with defined enum values before.
156
+ :param server_operation_index: Mapping from operation ID to an index to server
157
+ configuration.
158
+ :param server_operation_variables: Mapping from operation ID to a mapping with
159
+ string values to replace variables in templated server configuration.
160
+ The validation of enums is performed for variables with defined enum
161
+ values before.
162
+ :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
163
+ in PEM format.
164
+ :param retries: Number of retries for API requests.
165
+ :param ca_cert_data: verify the peer using concatenated CA certificate data
166
+ in PEM (str) or DER (bytes) format.
167
+
168
+ :Example:
169
+
170
+ HTTP Basic Authentication Example.
171
+ Given the following security scheme in the OpenAPI specification:
172
+ components:
173
+ securitySchemes:
174
+ http_basic_auth:
175
+ type: http
176
+ scheme: basic
177
+
178
+ Configure API client with HTTP basic authentication:
179
+
180
+ conf = across.sdk.v1.Configuration(
181
+ username='the-user',
182
+ password='the-password',
183
+ )
184
+
185
+ """
186
+
187
+ _default: ClassVar[Optional[Self]] = None
188
+
189
+ def __init__(
190
+ self,
191
+ host: Optional[str]=None,
192
+ api_key: Optional[Dict[str, str]]=None,
193
+ api_key_prefix: Optional[Dict[str, str]]=None,
194
+ username: Optional[str]=None,
195
+ password: Optional[str]=None,
196
+ access_token: Optional[str]=None,
197
+ server_index: Optional[int]=None,
198
+ server_variables: Optional[ServerVariablesT]=None,
199
+ server_operation_index: Optional[Dict[int, int]]=None,
200
+ server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
201
+ ignore_operation_servers: bool=False,
202
+ ssl_ca_cert: Optional[str]=None,
203
+ retries: Optional[int] = None,
204
+ ca_cert_data: Optional[Union[str, bytes]] = None,
205
+ *,
206
+ debug: Optional[bool] = None,
207
+ ) -> None:
208
+ """Constructor
209
+ """
210
+ self._base_path = "/api/v1" if host is None else host
211
+ """Default Base url
212
+ """
213
+ self.server_index = 0 if server_index is None and host is None else server_index
214
+ self.server_operation_index = server_operation_index or {}
215
+ """Default server index
216
+ """
217
+ self.server_variables = server_variables or {}
218
+ self.server_operation_variables = server_operation_variables or {}
219
+ """Default server variables
220
+ """
221
+ self.ignore_operation_servers = ignore_operation_servers
222
+ """Ignore operation servers
223
+ """
224
+ self.temp_folder_path = None
225
+ """Temp file folder for downloading files
226
+ """
227
+ # Authentication Settings
228
+ self.api_key = {}
229
+ if api_key:
230
+ self.api_key = api_key
231
+ """dict to store API key(s)
232
+ """
233
+ self.api_key_prefix = {}
234
+ if api_key_prefix:
235
+ self.api_key_prefix = api_key_prefix
236
+ """dict to store API prefix (e.g. Bearer)
237
+ """
238
+ self.refresh_api_key_hook = None
239
+ """function hook to refresh API key if expired
240
+ """
241
+ self.username = username
242
+ """Username for HTTP basic authentication
243
+ """
244
+ self.password = password
245
+ """Password for HTTP basic authentication
246
+ """
247
+ self.access_token = access_token
248
+ """Access token
249
+ """
250
+ self.logger = {}
251
+ """Logging Settings
252
+ """
253
+ self.logger["package_logger"] = logging.getLogger("across.sdk.v1")
254
+ self.logger["urllib3_logger"] = logging.getLogger("urllib3")
255
+ self.logger_format = '%(asctime)s %(levelname)s %(message)s'
256
+ """Log format
257
+ """
258
+ self.logger_stream_handler = None
259
+ """Log stream handler
260
+ """
261
+ self.logger_file_handler: Optional[FileHandler] = None
262
+ """Log file handler
263
+ """
264
+ self.logger_file = None
265
+ """Debug file location
266
+ """
267
+ if debug is not None:
268
+ self.debug = debug
269
+ else:
270
+ self.__debug = False
271
+ """Debug switch
272
+ """
273
+
274
+ self.verify_ssl = True
275
+ """SSL/TLS verification
276
+ Set this to false to skip verifying SSL certificate when calling API
277
+ from https server.
278
+ """
279
+ self.ssl_ca_cert = ssl_ca_cert
280
+ """Set this to customize the certificate file to verify the peer.
281
+ """
282
+ self.ca_cert_data = ca_cert_data
283
+ """Set this to verify the peer using PEM (str) or DER (bytes)
284
+ certificate data.
285
+ """
286
+ self.cert_file = None
287
+ """client certificate file
288
+ """
289
+ self.key_file = None
290
+ """client key file
291
+ """
292
+ self.assert_hostname = None
293
+ """Set this to True/False to enable/disable SSL hostname verification.
294
+ """
295
+ self.tls_server_name = None
296
+ """SSL/TLS Server Name Indication (SNI)
297
+ Set this to the SNI value expected by the server.
298
+ """
299
+
300
+ self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
301
+ """urllib3 connection pool's maximum number of connections saved
302
+ per pool. urllib3 uses 1 connection as default value, but this is
303
+ not the best value when you are making a lot of possibly parallel
304
+ requests to the same host, which is often the case here.
305
+ cpu_count * 5 is used as default value to increase performance.
306
+ """
307
+
308
+ self.proxy: Optional[str] = None
309
+ """Proxy URL
310
+ """
311
+ self.proxy_headers = None
312
+ """Proxy headers
313
+ """
314
+ self.safe_chars_for_path_param = ''
315
+ """Safe chars for path_param
316
+ """
317
+ self.retries = retries
318
+ """Adding retries to override urllib3 default value 3
319
+ """
320
+ # Enable client side validation
321
+ self.client_side_validation = True
322
+
323
+ self.socket_options = None
324
+ """Options to pass down to the underlying urllib3 socket
325
+ """
326
+
327
+ self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z"
328
+ """datetime format
329
+ """
330
+
331
+ self.date_format = "%Y-%m-%d"
332
+ """date format
333
+ """
334
+
335
+ def __deepcopy__(self, memo: Dict[int, Any]) -> Self:
336
+ cls = self.__class__
337
+ result = cls.__new__(cls)
338
+ memo[id(self)] = result
339
+ for k, v in self.__dict__.items():
340
+ if k not in ('logger', 'logger_file_handler'):
341
+ setattr(result, k, copy.deepcopy(v, memo))
342
+ # shallow copy of loggers
343
+ result.logger = copy.copy(self.logger)
344
+ # use setters to configure loggers
345
+ result.logger_file = self.logger_file
346
+ result.debug = self.debug
347
+ return result
348
+
349
+ def __setattr__(self, name: str, value: Any) -> None:
350
+ object.__setattr__(self, name, value)
351
+
352
+ @classmethod
353
+ def set_default(cls, default: Optional[Self]) -> None:
354
+ """Set default instance of configuration.
355
+
356
+ It stores default configuration, which can be
357
+ returned by get_default_copy method.
358
+
359
+ :param default: object of Configuration
360
+ """
361
+ cls._default = default
362
+
363
+ @classmethod
364
+ def get_default_copy(cls) -> Self:
365
+ """Deprecated. Please use `get_default` instead.
366
+
367
+ Deprecated. Please use `get_default` instead.
368
+
369
+ :return: The configuration object.
370
+ """
371
+ return cls.get_default()
372
+
373
+ @classmethod
374
+ def get_default(cls) -> Self:
375
+ """Return the default configuration.
376
+
377
+ This method returns newly created, based on default constructor,
378
+ object of Configuration class or returns a copy of default
379
+ configuration.
380
+
381
+ :return: The configuration object.
382
+ """
383
+ if cls._default is None:
384
+ cls._default = cls()
385
+ return cls._default
386
+
387
+ @property
388
+ def logger_file(self) -> Optional[str]:
389
+ """The logger file.
390
+
391
+ If the logger_file is None, then add stream handler and remove file
392
+ handler. Otherwise, add file handler and remove stream handler.
393
+
394
+ :param value: The logger_file path.
395
+ :type: str
396
+ """
397
+ return self.__logger_file
398
+
399
+ @logger_file.setter
400
+ def logger_file(self, value: Optional[str]) -> None:
401
+ """The logger file.
402
+
403
+ If the logger_file is None, then add stream handler and remove file
404
+ handler. Otherwise, add file handler and remove stream handler.
405
+
406
+ :param value: The logger_file path.
407
+ :type: str
408
+ """
409
+ self.__logger_file = value
410
+ if self.__logger_file:
411
+ # If set logging file,
412
+ # then add file handler and remove stream handler.
413
+ self.logger_file_handler = logging.FileHandler(self.__logger_file)
414
+ self.logger_file_handler.setFormatter(self.logger_formatter)
415
+ for _, logger in self.logger.items():
416
+ logger.addHandler(self.logger_file_handler)
417
+
418
+ @property
419
+ def debug(self) -> bool:
420
+ """Debug status
421
+
422
+ :param value: The debug status, True or False.
423
+ :type: bool
424
+ """
425
+ return self.__debug
426
+
427
+ @debug.setter
428
+ def debug(self, value: bool) -> None:
429
+ """Debug status
430
+
431
+ :param value: The debug status, True or False.
432
+ :type: bool
433
+ """
434
+ self.__debug = value
435
+ if self.__debug:
436
+ # if debug status is True, turn on debug logging
437
+ for _, logger in self.logger.items():
438
+ logger.setLevel(logging.DEBUG)
439
+ # turn on httplib debug
440
+ httplib.HTTPConnection.debuglevel = 1
441
+ else:
442
+ # if debug status is False, turn off debug logging,
443
+ # setting log level to default `logging.WARNING`
444
+ for _, logger in self.logger.items():
445
+ logger.setLevel(logging.WARNING)
446
+ # turn off httplib debug
447
+ httplib.HTTPConnection.debuglevel = 0
448
+
449
+ @property
450
+ def logger_format(self) -> str:
451
+ """The logger format.
452
+
453
+ The logger_formatter will be updated when sets logger_format.
454
+
455
+ :param value: The format string.
456
+ :type: str
457
+ """
458
+ return self.__logger_format
459
+
460
+ @logger_format.setter
461
+ def logger_format(self, value: str) -> None:
462
+ """The logger format.
463
+
464
+ The logger_formatter will be updated when sets logger_format.
465
+
466
+ :param value: The format string.
467
+ :type: str
468
+ """
469
+ self.__logger_format = value
470
+ self.logger_formatter = logging.Formatter(self.__logger_format)
471
+
472
+ def get_api_key_with_prefix(self, identifier: str, alias: Optional[str]=None) -> Optional[str]:
473
+ """Gets API key (with prefix if set).
474
+
475
+ :param identifier: The identifier of apiKey.
476
+ :param alias: The alternative identifier of apiKey.
477
+ :return: The token for api key authentication.
478
+ """
479
+ if self.refresh_api_key_hook is not None:
480
+ self.refresh_api_key_hook(self)
481
+ key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
482
+ if key:
483
+ prefix = self.api_key_prefix.get(identifier)
484
+ if prefix:
485
+ return "%s %s" % (prefix, key)
486
+ else:
487
+ return key
488
+
489
+ return None
490
+
491
+ def get_basic_auth_token(self) -> Optional[str]:
492
+ """Gets HTTP basic authentication header (string).
493
+
494
+ :return: The token for basic HTTP authentication.
495
+ """
496
+ username = ""
497
+ if self.username is not None:
498
+ username = self.username
499
+ password = ""
500
+ if self.password is not None:
501
+ password = self.password
502
+ return urllib3.util.make_headers(
503
+ basic_auth=username + ':' + password
504
+ ).get('authorization')
505
+
506
+ def auth_settings(self)-> AuthSettings:
507
+ """Gets Auth Settings dict for api client.
508
+
509
+ :return: The Auth Settings information dict.
510
+ """
511
+ auth: AuthSettings = {}
512
+ if self.access_token is not None:
513
+ auth['Authorization'] = {
514
+ 'type': 'bearer',
515
+ 'in': 'header',
516
+ 'key': 'Authorization',
517
+ 'value': 'Bearer ' + self.access_token
518
+ }
519
+ if self.username is not None and self.password is not None:
520
+ auth['ServiceAccountAuthorization'] = {
521
+ 'type': 'basic',
522
+ 'in': 'header',
523
+ 'key': 'Authorization',
524
+ 'value': self.get_basic_auth_token()
525
+ }
526
+ return auth
527
+
528
+ def to_debug_report(self) -> str:
529
+ """Gets the essential information for debugging.
530
+
531
+ :return: The report for debugging.
532
+ """
533
+ return "Python SDK Debug Report:\n"\
534
+ "OS: {env}\n"\
535
+ "Python Version: {pyversion}\n"\
536
+ "Version of the API: 0.3.2\n"\
537
+ "SDK Package Version: 1.0.0".\
538
+ format(env=sys.platform, pyversion=sys.version)
539
+
540
+ def get_host_settings(self) -> List[HostSetting]:
541
+ """Gets an array of host settings
542
+
543
+ :return: An array of host settings
544
+ """
545
+ return [
546
+ {
547
+ 'url': "/api/v1",
548
+ 'description': "No description provided",
549
+ }
550
+ ]
551
+
552
+ def get_host_from_settings(
553
+ self,
554
+ index: Optional[int],
555
+ variables: Optional[ServerVariablesT]=None,
556
+ servers: Optional[List[HostSetting]]=None,
557
+ ) -> str:
558
+ """Gets host URL based on the index and variables
559
+ :param index: array index of the host settings
560
+ :param variables: hash of variable and the corresponding value
561
+ :param servers: an array of host settings or None
562
+ :return: URL based on host settings
563
+ """
564
+ if index is None:
565
+ return self._base_path
566
+
567
+ variables = {} if variables is None else variables
568
+ servers = self.get_host_settings() if servers is None else servers
569
+
570
+ try:
571
+ server = servers[index]
572
+ except IndexError:
573
+ raise ValueError(
574
+ "Invalid index {0} when selecting the host settings. "
575
+ "Must be less than {1}".format(index, len(servers)))
576
+
577
+ url = server['url']
578
+
579
+ # go through variables and replace placeholders
580
+ for variable_name, variable in server.get('variables', {}).items():
581
+ used_value = variables.get(
582
+ variable_name, variable['default_value'])
583
+
584
+ if 'enum_values' in variable \
585
+ and used_value not in variable['enum_values']:
586
+ raise ValueError(
587
+ "The variable `{0}` in the host URL has invalid value "
588
+ "{1}. Must be {2}.".format(
589
+ variable_name, variables[variable_name],
590
+ variable['enum_values']))
591
+
592
+ url = url.replace("{" + variable_name + "}", used_value)
593
+
594
+ return url
595
+
596
+ @property
597
+ def host(self) -> str:
598
+ """Return generated host."""
599
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
600
+
601
+ @host.setter
602
+ def host(self, value: str) -> None:
603
+ """Fix base path."""
604
+ self._base_path = value
605
+ self.server_index = None