neurograph-core 1.202508112256__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 (105) hide show
  1. neurograph/__init__.py +0 -0
  2. neurograph/v1/__init__.py +227 -0
  3. neurograph/v1/api/__init__.py +15 -0
  4. neurograph/v1/api/atlas_api.py +588 -0
  5. neurograph/v1/api/authentication_api.py +830 -0
  6. neurograph/v1/api/client_api.py +1684 -0
  7. neurograph/v1/api/client_metadata_api.py +871 -0
  8. neurograph/v1/api/lookup_api.py +1049 -0
  9. neurograph/v1/api/organization_api.py +1975 -0
  10. neurograph/v1/api/organization_metadata_api.py +872 -0
  11. neurograph/v1/api/persona_api.py +1920 -0
  12. neurograph/v1/api/system_api.py +293 -0
  13. neurograph/v1/api/tasks_api.py +285 -0
  14. neurograph/v1/api/workbench_api.py +857 -0
  15. neurograph/v1/api_client.py +801 -0
  16. neurograph/v1/api_response.py +21 -0
  17. neurograph/v1/configuration.py +612 -0
  18. neurograph/v1/exceptions.py +216 -0
  19. neurograph/v1/models/__init__.py +96 -0
  20. neurograph/v1/models/atlas_atlas_version.py +99 -0
  21. neurograph/v1/models/atlas_atlas_version_many_response.py +97 -0
  22. neurograph/v1/models/atlas_atlas_version_response.py +101 -0
  23. neurograph/v1/models/atlas_atlas_version_upsert_request.py +95 -0
  24. neurograph/v1/models/auth_service_token_request.py +87 -0
  25. neurograph/v1/models/auth_test_service_token_response.py +89 -0
  26. neurograph/v1/models/auth_test_token_response.py +87 -0
  27. neurograph/v1/models/client_client.py +109 -0
  28. neurograph/v1/models/client_client_creat_response.py +111 -0
  29. neurograph/v1/models/client_client_create_request.py +95 -0
  30. neurograph/v1/models/client_client_get_detail_response.py +93 -0
  31. neurograph/v1/models/client_client_get_many_response.py +105 -0
  32. neurograph/v1/models/client_client_metadata_request.py +89 -0
  33. neurograph/v1/models/client_client_metadata_response.py +97 -0
  34. neurograph/v1/models/client_client_personas_response.py +99 -0
  35. neurograph/v1/models/client_client_url_upsert_request.py +99 -0
  36. neurograph/v1/models/client_client_url_upsert_response.py +101 -0
  37. neurograph/v1/models/client_client_urls_response.py +101 -0
  38. neurograph/v1/models/client_delete_metadata_request.py +87 -0
  39. neurograph/v1/models/client_kpi.py +93 -0
  40. neurograph/v1/models/client_metadata.py +93 -0
  41. neurograph/v1/models/client_persona.py +171 -0
  42. neurograph/v1/models/client_persona_factor.py +99 -0
  43. neurograph/v1/models/client_persona_insight.py +93 -0
  44. neurograph/v1/models/client_persona_personality_trait.py +93 -0
  45. neurograph/v1/models/client_query.py +93 -0
  46. neurograph/v1/models/db_client_url.py +99 -0
  47. neurograph/v1/models/db_persona_factor_create_params.py +97 -0
  48. neurograph/v1/models/lookup_language.py +97 -0
  49. neurograph/v1/models/lookup_lookup_language_response.py +97 -0
  50. neurograph/v1/models/lookup_lookup_state_response.py +97 -0
  51. neurograph/v1/models/lookup_state.py +91 -0
  52. neurograph/v1/models/lookup_state_response.py +93 -0
  53. neurograph/v1/models/organizations_atlas_config.py +97 -0
  54. neurograph/v1/models/organizations_brand_detail_response.py +109 -0
  55. neurograph/v1/models/organizations_brand_upsert_request.py +107 -0
  56. neurograph/v1/models/organizations_delete_metadata_request.py +87 -0
  57. neurograph/v1/models/organizations_delete_metadata_response.py +97 -0
  58. neurograph/v1/models/organizations_metadata.py +93 -0
  59. neurograph/v1/models/organizations_organization.py +103 -0
  60. neurograph/v1/models/organizations_organization_brand.py +107 -0
  61. neurograph/v1/models/organizations_organization_create_request.py +97 -0
  62. neurograph/v1/models/organizations_organization_detail_response.py +123 -0
  63. neurograph/v1/models/organizations_organization_get_many_response.py +103 -0
  64. neurograph/v1/models/organizations_organization_metadata_request.py +89 -0
  65. neurograph/v1/models/organizations_organization_metadata_response.py +97 -0
  66. neurograph/v1/models/organizations_organization_set_atlas_request.py +93 -0
  67. neurograph/v1/models/organizations_organization_set_atlas_response.py +99 -0
  68. neurograph/v1/models/organizations_organization_set_workbench_request.py +93 -0
  69. neurograph/v1/models/organizations_organization_set_workbench_response.py +99 -0
  70. neurograph/v1/models/organizations_organization_update_request.py +99 -0
  71. neurograph/v1/models/organizations_workbench_config.py +97 -0
  72. neurograph/v1/models/personas_match_criteria_row.py +97 -0
  73. neurograph/v1/models/personas_match_criteria_row_in.py +93 -0
  74. neurograph/v1/models/personas_persona_factor.py +101 -0
  75. neurograph/v1/models/personas_persona_factor_create_request.py +95 -0
  76. neurograph/v1/models/personas_persona_factor_create_response.py +97 -0
  77. neurograph/v1/models/personas_persona_insight_create_request.py +91 -0
  78. neurograph/v1/models/personas_persona_insight_create_response.py +95 -0
  79. neurograph/v1/models/personas_persona_instance_create_request.py +123 -0
  80. neurograph/v1/models/personas_persona_instance_create_response.py +127 -0
  81. neurograph/v1/models/personas_persona_kpi_create_request.py +95 -0
  82. neurograph/v1/models/personas_persona_kpi_create_response.py +97 -0
  83. neurograph/v1/models/personas_persona_kpi_req.py +91 -0
  84. neurograph/v1/models/personas_persona_kpi_resp.py +95 -0
  85. neurograph/v1/models/personas_persona_match_criteria_request.py +95 -0
  86. neurograph/v1/models/personas_persona_match_criteria_response.py +97 -0
  87. neurograph/v1/models/personas_persona_seed_create_request.py +89 -0
  88. neurograph/v1/models/personas_persona_seed_create_response.py +97 -0
  89. neurograph/v1/models/personas_persona_trait_create_request.py +95 -0
  90. neurograph/v1/models/personas_persona_trait_create_response.py +97 -0
  91. neurograph/v1/models/personas_personality_trait_in.py +91 -0
  92. neurograph/v1/models/personas_personality_trait_out.py +95 -0
  93. neurograph/v1/models/tasks_sync_from_firebase_result.py +87 -0
  94. neurograph/v1/models/workbench_workbench_url_check_request.py +87 -0
  95. neurograph/v1/models/workbench_workbench_url_check_response.py +111 -0
  96. neurograph/v1/models/workbench_workbench_version.py +99 -0
  97. neurograph/v1/models/workbench_workbench_version_many_response.py +97 -0
  98. neurograph/v1/models/workbench_workbench_version_response.py +101 -0
  99. neurograph/v1/models/workbench_workbench_version_upsert_request.py +95 -0
  100. neurograph/v1/py.typed +0 -0
  101. neurograph/v1/rest.py +258 -0
  102. neurograph_core-1.202508112256.dist-info/METADATA +62 -0
  103. neurograph_core-1.202508112256.dist-info/RECORD +105 -0
  104. neurograph_core-1.202508112256.dist-info/WHEEL +5 -0
  105. neurograph_core-1.202508112256.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,612 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Neurograph Core
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: 1.0
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
+ "ApiKeyAuth": APIKeyAuthSetting,
117
+ "TokenAuth": APIKeyAuthSetting,
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
+ API Key Authentication Example.
171
+ Given the following security scheme in the OpenAPI specification:
172
+ components:
173
+ securitySchemes:
174
+ cookieAuth: # name for the security scheme
175
+ type: apiKey
176
+ in: cookie
177
+ name: JSESSIONID # cookie name
178
+
179
+ You can programmatically set the cookie:
180
+
181
+ conf = neurograph.v1.Configuration(
182
+ api_key={'cookieAuth': 'abc123'}
183
+ api_key_prefix={'cookieAuth': 'JSESSIONID'}
184
+ )
185
+
186
+ The following cookie will be added to the HTTP request:
187
+ Cookie: JSESSIONID abc123
188
+ """
189
+
190
+ _default: ClassVar[Optional[Self]] = None
191
+
192
+ def __init__(
193
+ self,
194
+ host: Optional[str]=None,
195
+ api_key: Optional[Dict[str, str]]=None,
196
+ api_key_prefix: Optional[Dict[str, str]]=None,
197
+ username: Optional[str]=None,
198
+ password: Optional[str]=None,
199
+ access_token: Optional[str]=None,
200
+ server_index: Optional[int]=None,
201
+ server_variables: Optional[ServerVariablesT]=None,
202
+ server_operation_index: Optional[Dict[int, int]]=None,
203
+ server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
204
+ ignore_operation_servers: bool=False,
205
+ ssl_ca_cert: Optional[str]=None,
206
+ retries: Optional[int] = None,
207
+ ca_cert_data: Optional[Union[str, bytes]] = None,
208
+ *,
209
+ debug: Optional[bool] = None,
210
+ ) -> None:
211
+ """Constructor
212
+ """
213
+ self._base_path = "http://localhost" if host is None else host
214
+ """Default Base url
215
+ """
216
+ self.server_index = 0 if server_index is None and host is None else server_index
217
+ self.server_operation_index = server_operation_index or {}
218
+ """Default server index
219
+ """
220
+ self.server_variables = server_variables or {}
221
+ self.server_operation_variables = server_operation_variables or {}
222
+ """Default server variables
223
+ """
224
+ self.ignore_operation_servers = ignore_operation_servers
225
+ """Ignore operation servers
226
+ """
227
+ self.temp_folder_path = None
228
+ """Temp file folder for downloading files
229
+ """
230
+ # Authentication Settings
231
+ self.api_key = {}
232
+ if api_key:
233
+ self.api_key = api_key
234
+ """dict to store API key(s)
235
+ """
236
+ self.api_key_prefix = {}
237
+ if api_key_prefix:
238
+ self.api_key_prefix = api_key_prefix
239
+ """dict to store API prefix (e.g. Bearer)
240
+ """
241
+ self.refresh_api_key_hook = None
242
+ """function hook to refresh API key if expired
243
+ """
244
+ self.username = username
245
+ """Username for HTTP basic authentication
246
+ """
247
+ self.password = password
248
+ """Password for HTTP basic authentication
249
+ """
250
+ self.access_token = access_token
251
+ """Access token
252
+ """
253
+ self.logger = {}
254
+ """Logging Settings
255
+ """
256
+ self.logger["package_logger"] = logging.getLogger("neurograph.v1")
257
+ self.logger["urllib3_logger"] = logging.getLogger("urllib3")
258
+ self.logger_format = '%(asctime)s %(levelname)s %(message)s'
259
+ """Log format
260
+ """
261
+ self.logger_stream_handler = None
262
+ """Log stream handler
263
+ """
264
+ self.logger_file_handler: Optional[FileHandler] = None
265
+ """Log file handler
266
+ """
267
+ self.logger_file = None
268
+ """Debug file location
269
+ """
270
+ if debug is not None:
271
+ self.debug = debug
272
+ else:
273
+ self.__debug = False
274
+ """Debug switch
275
+ """
276
+
277
+ self.verify_ssl = True
278
+ """SSL/TLS verification
279
+ Set this to false to skip verifying SSL certificate when calling API
280
+ from https server.
281
+ """
282
+ self.ssl_ca_cert = ssl_ca_cert
283
+ """Set this to customize the certificate file to verify the peer.
284
+ """
285
+ self.ca_cert_data = ca_cert_data
286
+ """Set this to verify the peer using PEM (str) or DER (bytes)
287
+ certificate data.
288
+ """
289
+ self.cert_file = None
290
+ """client certificate file
291
+ """
292
+ self.key_file = None
293
+ """client key file
294
+ """
295
+ self.assert_hostname = None
296
+ """Set this to True/False to enable/disable SSL hostname verification.
297
+ """
298
+ self.tls_server_name = None
299
+ """SSL/TLS Server Name Indication (SNI)
300
+ Set this to the SNI value expected by the server.
301
+ """
302
+
303
+ self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
304
+ """urllib3 connection pool's maximum number of connections saved
305
+ per pool. urllib3 uses 1 connection as default value, but this is
306
+ not the best value when you are making a lot of possibly parallel
307
+ requests to the same host, which is often the case here.
308
+ cpu_count * 5 is used as default value to increase performance.
309
+ """
310
+
311
+ self.proxy: Optional[str] = None
312
+ """Proxy URL
313
+ """
314
+ self.proxy_headers = None
315
+ """Proxy headers
316
+ """
317
+ self.safe_chars_for_path_param = ''
318
+ """Safe chars for path_param
319
+ """
320
+ self.retries = retries
321
+ """Adding retries to override urllib3 default value 3
322
+ """
323
+ # Enable client side validation
324
+ self.client_side_validation = True
325
+
326
+ self.socket_options = None
327
+ """Options to pass down to the underlying urllib3 socket
328
+ """
329
+
330
+ self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z"
331
+ """datetime format
332
+ """
333
+
334
+ self.date_format = "%Y-%m-%d"
335
+ """date format
336
+ """
337
+
338
+ def __deepcopy__(self, memo: Dict[int, Any]) -> Self:
339
+ cls = self.__class__
340
+ result = cls.__new__(cls)
341
+ memo[id(self)] = result
342
+ for k, v in self.__dict__.items():
343
+ if k not in ('logger', 'logger_file_handler'):
344
+ setattr(result, k, copy.deepcopy(v, memo))
345
+ # shallow copy of loggers
346
+ result.logger = copy.copy(self.logger)
347
+ # use setters to configure loggers
348
+ result.logger_file = self.logger_file
349
+ result.debug = self.debug
350
+ return result
351
+
352
+ def __setattr__(self, name: str, value: Any) -> None:
353
+ object.__setattr__(self, name, value)
354
+
355
+ @classmethod
356
+ def set_default(cls, default: Optional[Self]) -> None:
357
+ """Set default instance of configuration.
358
+
359
+ It stores default configuration, which can be
360
+ returned by get_default_copy method.
361
+
362
+ :param default: object of Configuration
363
+ """
364
+ cls._default = default
365
+
366
+ @classmethod
367
+ def get_default_copy(cls) -> Self:
368
+ """Deprecated. Please use `get_default` instead.
369
+
370
+ Deprecated. Please use `get_default` instead.
371
+
372
+ :return: The configuration object.
373
+ """
374
+ return cls.get_default()
375
+
376
+ @classmethod
377
+ def get_default(cls) -> Self:
378
+ """Return the default configuration.
379
+
380
+ This method returns newly created, based on default constructor,
381
+ object of Configuration class or returns a copy of default
382
+ configuration.
383
+
384
+ :return: The configuration object.
385
+ """
386
+ if cls._default is None:
387
+ cls._default = cls()
388
+ return cls._default
389
+
390
+ @property
391
+ def logger_file(self) -> Optional[str]:
392
+ """The logger file.
393
+
394
+ If the logger_file is None, then add stream handler and remove file
395
+ handler. Otherwise, add file handler and remove stream handler.
396
+
397
+ :param value: The logger_file path.
398
+ :type: str
399
+ """
400
+ return self.__logger_file
401
+
402
+ @logger_file.setter
403
+ def logger_file(self, value: Optional[str]) -> None:
404
+ """The logger file.
405
+
406
+ If the logger_file is None, then add stream handler and remove file
407
+ handler. Otherwise, add file handler and remove stream handler.
408
+
409
+ :param value: The logger_file path.
410
+ :type: str
411
+ """
412
+ self.__logger_file = value
413
+ if self.__logger_file:
414
+ # If set logging file,
415
+ # then add file handler and remove stream handler.
416
+ self.logger_file_handler = logging.FileHandler(self.__logger_file)
417
+ self.logger_file_handler.setFormatter(self.logger_formatter)
418
+ for _, logger in self.logger.items():
419
+ logger.addHandler(self.logger_file_handler)
420
+
421
+ @property
422
+ def debug(self) -> bool:
423
+ """Debug status
424
+
425
+ :param value: The debug status, True or False.
426
+ :type: bool
427
+ """
428
+ return self.__debug
429
+
430
+ @debug.setter
431
+ def debug(self, value: bool) -> None:
432
+ """Debug status
433
+
434
+ :param value: The debug status, True or False.
435
+ :type: bool
436
+ """
437
+ self.__debug = value
438
+ if self.__debug:
439
+ # if debug status is True, turn on debug logging
440
+ for _, logger in self.logger.items():
441
+ logger.setLevel(logging.DEBUG)
442
+ # turn on httplib debug
443
+ httplib.HTTPConnection.debuglevel = 1
444
+ else:
445
+ # if debug status is False, turn off debug logging,
446
+ # setting log level to default `logging.WARNING`
447
+ for _, logger in self.logger.items():
448
+ logger.setLevel(logging.WARNING)
449
+ # turn off httplib debug
450
+ httplib.HTTPConnection.debuglevel = 0
451
+
452
+ @property
453
+ def logger_format(self) -> str:
454
+ """The logger format.
455
+
456
+ The logger_formatter will be updated when sets logger_format.
457
+
458
+ :param value: The format string.
459
+ :type: str
460
+ """
461
+ return self.__logger_format
462
+
463
+ @logger_format.setter
464
+ def logger_format(self, value: str) -> None:
465
+ """The logger format.
466
+
467
+ The logger_formatter will be updated when sets logger_format.
468
+
469
+ :param value: The format string.
470
+ :type: str
471
+ """
472
+ self.__logger_format = value
473
+ self.logger_formatter = logging.Formatter(self.__logger_format)
474
+
475
+ def get_api_key_with_prefix(self, identifier: str, alias: Optional[str]=None) -> Optional[str]:
476
+ """Gets API key (with prefix if set).
477
+
478
+ :param identifier: The identifier of apiKey.
479
+ :param alias: The alternative identifier of apiKey.
480
+ :return: The token for api key authentication.
481
+ """
482
+ if self.refresh_api_key_hook is not None:
483
+ self.refresh_api_key_hook(self)
484
+ key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
485
+ if key:
486
+ prefix = self.api_key_prefix.get(identifier)
487
+ if prefix:
488
+ return "%s %s" % (prefix, key)
489
+ else:
490
+ return key
491
+
492
+ return None
493
+
494
+ def get_basic_auth_token(self) -> Optional[str]:
495
+ """Gets HTTP basic authentication header (string).
496
+
497
+ :return: The token for basic HTTP authentication.
498
+ """
499
+ username = ""
500
+ if self.username is not None:
501
+ username = self.username
502
+ password = ""
503
+ if self.password is not None:
504
+ password = self.password
505
+ return urllib3.util.make_headers(
506
+ basic_auth=username + ':' + password
507
+ ).get('authorization')
508
+
509
+ def auth_settings(self)-> AuthSettings:
510
+ """Gets Auth Settings dict for api client.
511
+
512
+ :return: The Auth Settings information dict.
513
+ """
514
+ auth: AuthSettings = {}
515
+ if 'ApiKeyAuth' in self.api_key:
516
+ auth['ApiKeyAuth'] = {
517
+ 'type': 'api_key',
518
+ 'in': 'header',
519
+ 'key': 'Authorization',
520
+ 'value': self.get_api_key_with_prefix(
521
+ 'ApiKeyAuth',
522
+ ),
523
+ }
524
+ if 'TokenAuth' in self.api_key:
525
+ auth['TokenAuth'] = {
526
+ 'type': 'api_key',
527
+ 'in': 'header',
528
+ 'key': 'Authorization',
529
+ 'value': self.get_api_key_with_prefix(
530
+ 'TokenAuth',
531
+ ),
532
+ }
533
+ return auth
534
+
535
+ def to_debug_report(self) -> str:
536
+ """Gets the essential information for debugging.
537
+
538
+ :return: The report for debugging.
539
+ """
540
+ return "Python SDK Debug Report:\n"\
541
+ "OS: {env}\n"\
542
+ "Python Version: {pyversion}\n"\
543
+ "Version of the API: 1.0\n"\
544
+ "SDK Package Version: 1.0.0".\
545
+ format(env=sys.platform, pyversion=sys.version)
546
+
547
+ def get_host_settings(self) -> List[HostSetting]:
548
+ """Gets an array of host settings
549
+
550
+ :return: An array of host settings
551
+ """
552
+ return [
553
+ {
554
+ 'url': "",
555
+ 'description': "No description provided",
556
+ }
557
+ ]
558
+
559
+ def get_host_from_settings(
560
+ self,
561
+ index: Optional[int],
562
+ variables: Optional[ServerVariablesT]=None,
563
+ servers: Optional[List[HostSetting]]=None,
564
+ ) -> str:
565
+ """Gets host URL based on the index and variables
566
+ :param index: array index of the host settings
567
+ :param variables: hash of variable and the corresponding value
568
+ :param servers: an array of host settings or None
569
+ :return: URL based on host settings
570
+ """
571
+ if index is None:
572
+ return self._base_path
573
+
574
+ variables = {} if variables is None else variables
575
+ servers = self.get_host_settings() if servers is None else servers
576
+
577
+ try:
578
+ server = servers[index]
579
+ except IndexError:
580
+ raise ValueError(
581
+ "Invalid index {0} when selecting the host settings. "
582
+ "Must be less than {1}".format(index, len(servers)))
583
+
584
+ url = server['url']
585
+
586
+ # go through variables and replace placeholders
587
+ for variable_name, variable in server.get('variables', {}).items():
588
+ used_value = variables.get(
589
+ variable_name, variable['default_value'])
590
+
591
+ if 'enum_values' in variable \
592
+ and used_value not in variable['enum_values']:
593
+ raise ValueError(
594
+ "The variable `{0}` in the host URL has invalid value "
595
+ "{1}. Must be {2}.".format(
596
+ variable_name, variables[variable_name],
597
+ variable['enum_values']))
598
+
599
+ url = url.replace("{" + variable_name + "}", used_value)
600
+
601
+ return url
602
+
603
+ @property
604
+ def host(self) -> str:
605
+ """Return generated host."""
606
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
607
+
608
+ @host.setter
609
+ def host(self, value: str) -> None:
610
+ """Fix base path."""
611
+ self._base_path = value
612
+ self.server_index = None