gsctl 0.29.0a20250114__py2.py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- graphscope/flex/rest/__init__.py +106 -0
- graphscope/flex/rest/api/__init__.py +12 -0
- graphscope/flex/rest/api/alert_api.py +2790 -0
- graphscope/flex/rest/api/data_source_api.py +1177 -0
- graphscope/flex/rest/api/deployment_api.py +1323 -0
- graphscope/flex/rest/api/graph_api.py +2813 -0
- graphscope/flex/rest/api/job_api.py +1408 -0
- graphscope/flex/rest/api/service_api.py +1316 -0
- graphscope/flex/rest/api/stored_procedure_api.py +1454 -0
- graphscope/flex/rest/api/utils_api.py +310 -0
- graphscope/flex/rest/api_client.py +789 -0
- graphscope/flex/rest/api_response.py +21 -0
- graphscope/flex/rest/configuration.py +451 -0
- graphscope/flex/rest/exceptions.py +200 -0
- graphscope/flex/rest/models/__init__.py +82 -0
- graphscope/flex/rest/models/base_edge_type.py +102 -0
- graphscope/flex/rest/models/base_edge_type_vertex_type_pair_relations_inner.py +108 -0
- graphscope/flex/rest/models/base_edge_type_vertex_type_pair_relations_inner_x_csr_params.py +98 -0
- graphscope/flex/rest/models/base_property_meta.py +105 -0
- graphscope/flex/rest/models/base_vertex_type.py +96 -0
- graphscope/flex/rest/models/base_vertex_type_x_csr_params.py +88 -0
- graphscope/flex/rest/models/column_mapping.py +94 -0
- graphscope/flex/rest/models/column_mapping_column.py +90 -0
- graphscope/flex/rest/models/create_alert_receiver_request.py +103 -0
- graphscope/flex/rest/models/create_alert_rule_request.py +112 -0
- graphscope/flex/rest/models/create_dataloading_job_response.py +88 -0
- graphscope/flex/rest/models/create_edge_type.py +114 -0
- graphscope/flex/rest/models/create_graph_request.py +106 -0
- graphscope/flex/rest/models/create_graph_response.py +88 -0
- graphscope/flex/rest/models/create_graph_schema_request.py +106 -0
- graphscope/flex/rest/models/create_property_meta.py +105 -0
- graphscope/flex/rest/models/create_stored_proc_request.py +101 -0
- graphscope/flex/rest/models/create_stored_proc_response.py +88 -0
- graphscope/flex/rest/models/create_vertex_type.py +108 -0
- graphscope/flex/rest/models/dataloading_job_config.py +136 -0
- graphscope/flex/rest/models/dataloading_job_config_edges_inner.py +92 -0
- graphscope/flex/rest/models/dataloading_job_config_loading_config.py +104 -0
- graphscope/flex/rest/models/dataloading_job_config_loading_config_format.py +90 -0
- graphscope/flex/rest/models/dataloading_job_config_vertices_inner.py +88 -0
- graphscope/flex/rest/models/dataloading_mr_job_config.py +88 -0
- graphscope/flex/rest/models/date_type.py +88 -0
- graphscope/flex/rest/models/edge_mapping.py +122 -0
- graphscope/flex/rest/models/edge_mapping_type_triplet.py +92 -0
- graphscope/flex/rest/models/error.py +90 -0
- graphscope/flex/rest/models/get_alert_message_response.py +123 -0
- graphscope/flex/rest/models/get_alert_receiver_response.py +107 -0
- graphscope/flex/rest/models/get_alert_rule_response.py +114 -0
- graphscope/flex/rest/models/get_edge_type.py +116 -0
- graphscope/flex/rest/models/get_graph_response.py +139 -0
- graphscope/flex/rest/models/get_graph_schema_response.py +106 -0
- graphscope/flex/rest/models/get_pod_log_response.py +88 -0
- graphscope/flex/rest/models/get_property_meta.py +107 -0
- graphscope/flex/rest/models/get_resource_usage_response.py +105 -0
- graphscope/flex/rest/models/get_storage_usage_response.py +88 -0
- graphscope/flex/rest/models/get_stored_proc_response.py +130 -0
- graphscope/flex/rest/models/get_vertex_type.py +110 -0
- graphscope/flex/rest/models/gs_data_type.py +152 -0
- graphscope/flex/rest/models/job_status.py +107 -0
- graphscope/flex/rest/models/long_text.py +93 -0
- graphscope/flex/rest/models/node_status.py +94 -0
- graphscope/flex/rest/models/parameter.py +96 -0
- graphscope/flex/rest/models/pod_status.py +108 -0
- graphscope/flex/rest/models/primitive_type.py +95 -0
- graphscope/flex/rest/models/resource_usage.py +92 -0
- graphscope/flex/rest/models/running_deployment_info.py +128 -0
- graphscope/flex/rest/models/running_deployment_status.py +124 -0
- graphscope/flex/rest/models/schema_mapping.py +106 -0
- graphscope/flex/rest/models/service_status.py +112 -0
- graphscope/flex/rest/models/service_status_sdk_endpoints.py +94 -0
- graphscope/flex/rest/models/start_service_request.py +88 -0
- graphscope/flex/rest/models/stored_procedure_meta.py +126 -0
- graphscope/flex/rest/models/string_type.py +92 -0
- graphscope/flex/rest/models/string_type_string.py +124 -0
- graphscope/flex/rest/models/temporal_type.py +92 -0
- graphscope/flex/rest/models/temporal_type_temporal.py +138 -0
- graphscope/flex/rest/models/time_stamp_type.py +88 -0
- graphscope/flex/rest/models/update_alert_message_status_request.py +97 -0
- graphscope/flex/rest/models/update_stored_proc_request.py +88 -0
- graphscope/flex/rest/models/upload_file_response.py +90 -0
- graphscope/flex/rest/models/vertex_mapping.py +100 -0
- graphscope/flex/rest/py.typed +0 -0
- graphscope/flex/rest/rest.py +258 -0
- graphscope/gsctl/V6D_VERSION +1 -0
- graphscope/gsctl/VERSION +1 -0
- graphscope/gsctl/__init__.py +22 -0
- graphscope/gsctl/commands/__init__.py +148 -0
- graphscope/gsctl/commands/common.py +200 -0
- graphscope/gsctl/commands/dev.py +448 -0
- graphscope/gsctl/commands/insight/__init__.py +17 -0
- graphscope/gsctl/commands/insight/glob.py +234 -0
- graphscope/gsctl/commands/insight/graph.py +205 -0
- graphscope/gsctl/commands/interactive/__init__.py +17 -0
- graphscope/gsctl/commands/interactive/glob.py +280 -0
- graphscope/gsctl/commands/interactive/graph.py +259 -0
- graphscope/gsctl/config.py +221 -0
- graphscope/gsctl/gsctl.py +51 -0
- graphscope/gsctl/impl/__init__.py +64 -0
- graphscope/gsctl/impl/alert.py +135 -0
- graphscope/gsctl/impl/common.py +53 -0
- graphscope/gsctl/impl/datasource.py +80 -0
- graphscope/gsctl/impl/deployment.py +62 -0
- graphscope/gsctl/impl/graph.py +150 -0
- graphscope/gsctl/impl/job.py +63 -0
- graphscope/gsctl/impl/service.py +62 -0
- graphscope/gsctl/impl/stored_procedure.py +92 -0
- graphscope/gsctl/impl/utils.py +38 -0
- graphscope/gsctl/scripts/install_deps.sh +969 -0
- graphscope/gsctl/tests/__init__.py +17 -0
- graphscope/gsctl/tests/test_graphscope_insight.py +401 -0
- graphscope/gsctl/tests/test_interactive.py +516 -0
- graphscope/gsctl/utils.py +337 -0
- graphscope/gsctl/version.py +31 -0
- gsctl-0.29.0a20250114.dist-info/METADATA +20 -0
- gsctl-0.29.0a20250114.dist-info/RECORD +117 -0
- gsctl-0.29.0a20250114.dist-info/WHEEL +6 -0
- gsctl-0.29.0a20250114.dist-info/entry_points.txt +3 -0
- gsctl-0.29.0a20250114.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,451 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
"""
|
4
|
+
GraphScope FLEX HTTP SERVICE API
|
5
|
+
|
6
|
+
This is a specification for GraphScope FLEX HTTP service based on the OpenAPI 3.0 specification. You can find out more details about specification at [doc](https://swagger.io/specification/v3/).
|
7
|
+
|
8
|
+
The version of the OpenAPI document: 1.0.0
|
9
|
+
Contact: graphscope@alibaba-inc.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 logging
|
18
|
+
from logging import FileHandler
|
19
|
+
import multiprocessing
|
20
|
+
import sys
|
21
|
+
from typing import Optional
|
22
|
+
import urllib3
|
23
|
+
|
24
|
+
import http.client as httplib
|
25
|
+
|
26
|
+
JSON_SCHEMA_VALIDATION_KEYWORDS = {
|
27
|
+
'multipleOf', 'maximum', 'exclusiveMaximum',
|
28
|
+
'minimum', 'exclusiveMinimum', 'maxLength',
|
29
|
+
'minLength', 'pattern', 'maxItems', 'minItems'
|
30
|
+
}
|
31
|
+
|
32
|
+
class Configuration:
|
33
|
+
"""This class contains various settings of the API client.
|
34
|
+
|
35
|
+
:param host: Base url.
|
36
|
+
:param ignore_operation_servers
|
37
|
+
Boolean to ignore operation servers for the API client.
|
38
|
+
Config will use `host` as the base url regardless of the operation servers.
|
39
|
+
:param api_key: Dict to store API key(s).
|
40
|
+
Each entry in the dict specifies an API key.
|
41
|
+
The dict key is the name of the security scheme in the OAS specification.
|
42
|
+
The dict value is the API key secret.
|
43
|
+
:param api_key_prefix: Dict to store API prefix (e.g. Bearer).
|
44
|
+
The dict key is the name of the security scheme in the OAS specification.
|
45
|
+
The dict value is an API key prefix when generating the auth data.
|
46
|
+
:param username: Username for HTTP basic authentication.
|
47
|
+
:param password: Password for HTTP basic authentication.
|
48
|
+
:param access_token: Access token.
|
49
|
+
:param server_index: Index to servers configuration.
|
50
|
+
:param server_variables: Mapping with string values to replace variables in
|
51
|
+
templated server configuration. The validation of enums is performed for
|
52
|
+
variables with defined enum values before.
|
53
|
+
:param server_operation_index: Mapping from operation ID to an index to server
|
54
|
+
configuration.
|
55
|
+
:param server_operation_variables: Mapping from operation ID to a mapping with
|
56
|
+
string values to replace variables in templated server configuration.
|
57
|
+
The validation of enums is performed for variables with defined enum
|
58
|
+
values before.
|
59
|
+
:param ssl_ca_cert: str - the path to a file of concatenated CA certificates
|
60
|
+
in PEM format.
|
61
|
+
:param retries: Number of retries for API requests.
|
62
|
+
|
63
|
+
"""
|
64
|
+
|
65
|
+
_default = None
|
66
|
+
|
67
|
+
def __init__(self, host=None,
|
68
|
+
api_key=None, api_key_prefix=None,
|
69
|
+
username=None, password=None,
|
70
|
+
access_token=None,
|
71
|
+
server_index=None, server_variables=None,
|
72
|
+
server_operation_index=None, server_operation_variables=None,
|
73
|
+
ignore_operation_servers=False,
|
74
|
+
ssl_ca_cert=None,
|
75
|
+
retries=None,
|
76
|
+
*,
|
77
|
+
debug: Optional[bool] = None
|
78
|
+
) -> None:
|
79
|
+
"""Constructor
|
80
|
+
"""
|
81
|
+
self._base_path = "http://localhost" if host is None else host
|
82
|
+
"""Default Base url
|
83
|
+
"""
|
84
|
+
self.server_index = 0 if server_index is None and host is None else server_index
|
85
|
+
self.server_operation_index = server_operation_index or {}
|
86
|
+
"""Default server index
|
87
|
+
"""
|
88
|
+
self.server_variables = server_variables or {}
|
89
|
+
self.server_operation_variables = server_operation_variables or {}
|
90
|
+
"""Default server variables
|
91
|
+
"""
|
92
|
+
self.ignore_operation_servers = ignore_operation_servers
|
93
|
+
"""Ignore operation servers
|
94
|
+
"""
|
95
|
+
self.temp_folder_path = None
|
96
|
+
"""Temp file folder for downloading files
|
97
|
+
"""
|
98
|
+
# Authentication Settings
|
99
|
+
self.api_key = {}
|
100
|
+
if api_key:
|
101
|
+
self.api_key = api_key
|
102
|
+
"""dict to store API key(s)
|
103
|
+
"""
|
104
|
+
self.api_key_prefix = {}
|
105
|
+
if api_key_prefix:
|
106
|
+
self.api_key_prefix = api_key_prefix
|
107
|
+
"""dict to store API prefix (e.g. Bearer)
|
108
|
+
"""
|
109
|
+
self.refresh_api_key_hook = None
|
110
|
+
"""function hook to refresh API key if expired
|
111
|
+
"""
|
112
|
+
self.username = username
|
113
|
+
"""Username for HTTP basic authentication
|
114
|
+
"""
|
115
|
+
self.password = password
|
116
|
+
"""Password for HTTP basic authentication
|
117
|
+
"""
|
118
|
+
self.access_token = access_token
|
119
|
+
"""Access token
|
120
|
+
"""
|
121
|
+
self.logger = {}
|
122
|
+
"""Logging Settings
|
123
|
+
"""
|
124
|
+
self.logger["package_logger"] = logging.getLogger("graphscope.flex.rest")
|
125
|
+
self.logger["urllib3_logger"] = logging.getLogger("urllib3")
|
126
|
+
self.logger_format = '%(asctime)s %(levelname)s %(message)s'
|
127
|
+
"""Log format
|
128
|
+
"""
|
129
|
+
self.logger_stream_handler = None
|
130
|
+
"""Log stream handler
|
131
|
+
"""
|
132
|
+
self.logger_file_handler: Optional[FileHandler] = None
|
133
|
+
"""Log file handler
|
134
|
+
"""
|
135
|
+
self.logger_file = None
|
136
|
+
"""Debug file location
|
137
|
+
"""
|
138
|
+
if debug is not None:
|
139
|
+
self.debug = debug
|
140
|
+
else:
|
141
|
+
self.__debug = False
|
142
|
+
"""Debug switch
|
143
|
+
"""
|
144
|
+
|
145
|
+
self.verify_ssl = True
|
146
|
+
"""SSL/TLS verification
|
147
|
+
Set this to false to skip verifying SSL certificate when calling API
|
148
|
+
from https server.
|
149
|
+
"""
|
150
|
+
self.ssl_ca_cert = ssl_ca_cert
|
151
|
+
"""Set this to customize the certificate file to verify the peer.
|
152
|
+
"""
|
153
|
+
self.cert_file = None
|
154
|
+
"""client certificate file
|
155
|
+
"""
|
156
|
+
self.key_file = None
|
157
|
+
"""client key file
|
158
|
+
"""
|
159
|
+
self.assert_hostname = None
|
160
|
+
"""Set this to True/False to enable/disable SSL hostname verification.
|
161
|
+
"""
|
162
|
+
self.tls_server_name = None
|
163
|
+
"""SSL/TLS Server Name Indication (SNI)
|
164
|
+
Set this to the SNI value expected by the server.
|
165
|
+
"""
|
166
|
+
|
167
|
+
self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
|
168
|
+
"""urllib3 connection pool's maximum number of connections saved
|
169
|
+
per pool. urllib3 uses 1 connection as default value, but this is
|
170
|
+
not the best value when you are making a lot of possibly parallel
|
171
|
+
requests to the same host, which is often the case here.
|
172
|
+
cpu_count * 5 is used as default value to increase performance.
|
173
|
+
"""
|
174
|
+
|
175
|
+
self.proxy: Optional[str] = None
|
176
|
+
"""Proxy URL
|
177
|
+
"""
|
178
|
+
self.proxy_headers = None
|
179
|
+
"""Proxy headers
|
180
|
+
"""
|
181
|
+
self.safe_chars_for_path_param = ''
|
182
|
+
"""Safe chars for path_param
|
183
|
+
"""
|
184
|
+
self.retries = retries
|
185
|
+
"""Adding retries to override urllib3 default value 3
|
186
|
+
"""
|
187
|
+
# Enable client side validation
|
188
|
+
self.client_side_validation = True
|
189
|
+
|
190
|
+
self.socket_options = None
|
191
|
+
"""Options to pass down to the underlying urllib3 socket
|
192
|
+
"""
|
193
|
+
|
194
|
+
self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z"
|
195
|
+
"""datetime format
|
196
|
+
"""
|
197
|
+
|
198
|
+
self.date_format = "%Y-%m-%d"
|
199
|
+
"""date format
|
200
|
+
"""
|
201
|
+
|
202
|
+
def __deepcopy__(self, memo):
|
203
|
+
cls = self.__class__
|
204
|
+
result = cls.__new__(cls)
|
205
|
+
memo[id(self)] = result
|
206
|
+
for k, v in self.__dict__.items():
|
207
|
+
if k not in ('logger', 'logger_file_handler'):
|
208
|
+
setattr(result, k, copy.deepcopy(v, memo))
|
209
|
+
# shallow copy of loggers
|
210
|
+
result.logger = copy.copy(self.logger)
|
211
|
+
# use setters to configure loggers
|
212
|
+
result.logger_file = self.logger_file
|
213
|
+
result.debug = self.debug
|
214
|
+
return result
|
215
|
+
|
216
|
+
def __setattr__(self, name, value):
|
217
|
+
object.__setattr__(self, name, value)
|
218
|
+
|
219
|
+
@classmethod
|
220
|
+
def set_default(cls, default):
|
221
|
+
"""Set default instance of configuration.
|
222
|
+
|
223
|
+
It stores default configuration, which can be
|
224
|
+
returned by get_default_copy method.
|
225
|
+
|
226
|
+
:param default: object of Configuration
|
227
|
+
"""
|
228
|
+
cls._default = default
|
229
|
+
|
230
|
+
@classmethod
|
231
|
+
def get_default_copy(cls):
|
232
|
+
"""Deprecated. Please use `get_default` instead.
|
233
|
+
|
234
|
+
Deprecated. Please use `get_default` instead.
|
235
|
+
|
236
|
+
:return: The configuration object.
|
237
|
+
"""
|
238
|
+
return cls.get_default()
|
239
|
+
|
240
|
+
@classmethod
|
241
|
+
def get_default(cls):
|
242
|
+
"""Return the default configuration.
|
243
|
+
|
244
|
+
This method returns newly created, based on default constructor,
|
245
|
+
object of Configuration class or returns a copy of default
|
246
|
+
configuration.
|
247
|
+
|
248
|
+
:return: The configuration object.
|
249
|
+
"""
|
250
|
+
if cls._default is None:
|
251
|
+
cls._default = Configuration()
|
252
|
+
return cls._default
|
253
|
+
|
254
|
+
@property
|
255
|
+
def logger_file(self):
|
256
|
+
"""The logger file.
|
257
|
+
|
258
|
+
If the logger_file is None, then add stream handler and remove file
|
259
|
+
handler. Otherwise, add file handler and remove stream handler.
|
260
|
+
|
261
|
+
:param value: The logger_file path.
|
262
|
+
:type: str
|
263
|
+
"""
|
264
|
+
return self.__logger_file
|
265
|
+
|
266
|
+
@logger_file.setter
|
267
|
+
def logger_file(self, value):
|
268
|
+
"""The logger file.
|
269
|
+
|
270
|
+
If the logger_file is None, then add stream handler and remove file
|
271
|
+
handler. Otherwise, add file handler and remove stream handler.
|
272
|
+
|
273
|
+
:param value: The logger_file path.
|
274
|
+
:type: str
|
275
|
+
"""
|
276
|
+
self.__logger_file = value
|
277
|
+
if self.__logger_file:
|
278
|
+
# If set logging file,
|
279
|
+
# then add file handler and remove stream handler.
|
280
|
+
self.logger_file_handler = logging.FileHandler(self.__logger_file)
|
281
|
+
self.logger_file_handler.setFormatter(self.logger_formatter)
|
282
|
+
for _, logger in self.logger.items():
|
283
|
+
logger.addHandler(self.logger_file_handler)
|
284
|
+
|
285
|
+
@property
|
286
|
+
def debug(self):
|
287
|
+
"""Debug status
|
288
|
+
|
289
|
+
:param value: The debug status, True or False.
|
290
|
+
:type: bool
|
291
|
+
"""
|
292
|
+
return self.__debug
|
293
|
+
|
294
|
+
@debug.setter
|
295
|
+
def debug(self, value):
|
296
|
+
"""Debug status
|
297
|
+
|
298
|
+
:param value: The debug status, True or False.
|
299
|
+
:type: bool
|
300
|
+
"""
|
301
|
+
self.__debug = value
|
302
|
+
if self.__debug:
|
303
|
+
# if debug status is True, turn on debug logging
|
304
|
+
for _, logger in self.logger.items():
|
305
|
+
logger.setLevel(logging.DEBUG)
|
306
|
+
# turn on httplib debug
|
307
|
+
httplib.HTTPConnection.debuglevel = 1
|
308
|
+
else:
|
309
|
+
# if debug status is False, turn off debug logging,
|
310
|
+
# setting log level to default `logging.WARNING`
|
311
|
+
for _, logger in self.logger.items():
|
312
|
+
logger.setLevel(logging.WARNING)
|
313
|
+
# turn off httplib debug
|
314
|
+
httplib.HTTPConnection.debuglevel = 0
|
315
|
+
|
316
|
+
@property
|
317
|
+
def logger_format(self):
|
318
|
+
"""The logger format.
|
319
|
+
|
320
|
+
The logger_formatter will be updated when sets logger_format.
|
321
|
+
|
322
|
+
:param value: The format string.
|
323
|
+
:type: str
|
324
|
+
"""
|
325
|
+
return self.__logger_format
|
326
|
+
|
327
|
+
@logger_format.setter
|
328
|
+
def logger_format(self, value):
|
329
|
+
"""The logger format.
|
330
|
+
|
331
|
+
The logger_formatter will be updated when sets logger_format.
|
332
|
+
|
333
|
+
:param value: The format string.
|
334
|
+
:type: str
|
335
|
+
"""
|
336
|
+
self.__logger_format = value
|
337
|
+
self.logger_formatter = logging.Formatter(self.__logger_format)
|
338
|
+
|
339
|
+
def get_api_key_with_prefix(self, identifier, alias=None):
|
340
|
+
"""Gets API key (with prefix if set).
|
341
|
+
|
342
|
+
:param identifier: The identifier of apiKey.
|
343
|
+
:param alias: The alternative identifier of apiKey.
|
344
|
+
:return: The token for api key authentication.
|
345
|
+
"""
|
346
|
+
if self.refresh_api_key_hook is not None:
|
347
|
+
self.refresh_api_key_hook(self)
|
348
|
+
key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
|
349
|
+
if key:
|
350
|
+
prefix = self.api_key_prefix.get(identifier)
|
351
|
+
if prefix:
|
352
|
+
return "%s %s" % (prefix, key)
|
353
|
+
else:
|
354
|
+
return key
|
355
|
+
|
356
|
+
def get_basic_auth_token(self):
|
357
|
+
"""Gets HTTP basic authentication header (string).
|
358
|
+
|
359
|
+
:return: The token for basic HTTP authentication.
|
360
|
+
"""
|
361
|
+
username = ""
|
362
|
+
if self.username is not None:
|
363
|
+
username = self.username
|
364
|
+
password = ""
|
365
|
+
if self.password is not None:
|
366
|
+
password = self.password
|
367
|
+
return urllib3.util.make_headers(
|
368
|
+
basic_auth=username + ':' + password
|
369
|
+
).get('authorization')
|
370
|
+
|
371
|
+
def auth_settings(self):
|
372
|
+
"""Gets Auth Settings dict for api client.
|
373
|
+
|
374
|
+
:return: The Auth Settings information dict.
|
375
|
+
"""
|
376
|
+
auth = {}
|
377
|
+
return auth
|
378
|
+
|
379
|
+
def to_debug_report(self):
|
380
|
+
"""Gets the essential information for debugging.
|
381
|
+
|
382
|
+
:return: The report for debugging.
|
383
|
+
"""
|
384
|
+
return "Python SDK Debug Report:\n"\
|
385
|
+
"OS: {env}\n"\
|
386
|
+
"Python Version: {pyversion}\n"\
|
387
|
+
"Version of the API: 1.0.0\n"\
|
388
|
+
"SDK Package Version: 1.0.0".\
|
389
|
+
format(env=sys.platform, pyversion=sys.version)
|
390
|
+
|
391
|
+
def get_host_settings(self):
|
392
|
+
"""Gets an array of host settings
|
393
|
+
|
394
|
+
:return: An array of host settings
|
395
|
+
"""
|
396
|
+
return [
|
397
|
+
{
|
398
|
+
'url': "",
|
399
|
+
'description': "No description provided",
|
400
|
+
}
|
401
|
+
]
|
402
|
+
|
403
|
+
def get_host_from_settings(self, index, variables=None, servers=None):
|
404
|
+
"""Gets host URL based on the index and variables
|
405
|
+
:param index: array index of the host settings
|
406
|
+
:param variables: hash of variable and the corresponding value
|
407
|
+
:param servers: an array of host settings or None
|
408
|
+
:return: URL based on host settings
|
409
|
+
"""
|
410
|
+
if index is None:
|
411
|
+
return self._base_path
|
412
|
+
|
413
|
+
variables = {} if variables is None else variables
|
414
|
+
servers = self.get_host_settings() if servers is None else servers
|
415
|
+
|
416
|
+
try:
|
417
|
+
server = servers[index]
|
418
|
+
except IndexError:
|
419
|
+
raise ValueError(
|
420
|
+
"Invalid index {0} when selecting the host settings. "
|
421
|
+
"Must be less than {1}".format(index, len(servers)))
|
422
|
+
|
423
|
+
url = server['url']
|
424
|
+
|
425
|
+
# go through variables and replace placeholders
|
426
|
+
for variable_name, variable in server.get('variables', {}).items():
|
427
|
+
used_value = variables.get(
|
428
|
+
variable_name, variable['default_value'])
|
429
|
+
|
430
|
+
if 'enum_values' in variable \
|
431
|
+
and used_value not in variable['enum_values']:
|
432
|
+
raise ValueError(
|
433
|
+
"The variable `{0}` in the host URL has invalid value "
|
434
|
+
"{1}. Must be {2}.".format(
|
435
|
+
variable_name, variables[variable_name],
|
436
|
+
variable['enum_values']))
|
437
|
+
|
438
|
+
url = url.replace("{" + variable_name + "}", used_value)
|
439
|
+
|
440
|
+
return url
|
441
|
+
|
442
|
+
@property
|
443
|
+
def host(self):
|
444
|
+
"""Return generated host."""
|
445
|
+
return self.get_host_from_settings(self.server_index, variables=self.server_variables)
|
446
|
+
|
447
|
+
@host.setter
|
448
|
+
def host(self, value):
|
449
|
+
"""Fix base path."""
|
450
|
+
self._base_path = value
|
451
|
+
self.server_index = None
|
@@ -0,0 +1,200 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
"""
|
4
|
+
GraphScope FLEX HTTP SERVICE API
|
5
|
+
|
6
|
+
This is a specification for GraphScope FLEX HTTP service based on the OpenAPI 3.0 specification. You can find out more details about specification at [doc](https://swagger.io/specification/v3/).
|
7
|
+
|
8
|
+
The version of the OpenAPI document: 1.0.0
|
9
|
+
Contact: graphscope@alibaba-inc.com
|
10
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
11
|
+
|
12
|
+
Do not edit the class manually.
|
13
|
+
""" # noqa: E501
|
14
|
+
|
15
|
+
from typing import Any, Optional
|
16
|
+
from typing_extensions import Self
|
17
|
+
|
18
|
+
class OpenApiException(Exception):
|
19
|
+
"""The base exception class for all OpenAPIExceptions"""
|
20
|
+
|
21
|
+
|
22
|
+
class ApiTypeError(OpenApiException, TypeError):
|
23
|
+
def __init__(self, msg, path_to_item=None, valid_classes=None,
|
24
|
+
key_type=None) -> None:
|
25
|
+
""" Raises an exception for TypeErrors
|
26
|
+
|
27
|
+
Args:
|
28
|
+
msg (str): the exception message
|
29
|
+
|
30
|
+
Keyword Args:
|
31
|
+
path_to_item (list): a list of keys an indices to get to the
|
32
|
+
current_item
|
33
|
+
None if unset
|
34
|
+
valid_classes (tuple): the primitive classes that current item
|
35
|
+
should be an instance of
|
36
|
+
None if unset
|
37
|
+
key_type (bool): False if our value is a value in a dict
|
38
|
+
True if it is a key in a dict
|
39
|
+
False if our item is an item in a list
|
40
|
+
None if unset
|
41
|
+
"""
|
42
|
+
self.path_to_item = path_to_item
|
43
|
+
self.valid_classes = valid_classes
|
44
|
+
self.key_type = key_type
|
45
|
+
full_msg = msg
|
46
|
+
if path_to_item:
|
47
|
+
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
48
|
+
super(ApiTypeError, self).__init__(full_msg)
|
49
|
+
|
50
|
+
|
51
|
+
class ApiValueError(OpenApiException, ValueError):
|
52
|
+
def __init__(self, msg, path_to_item=None) -> None:
|
53
|
+
"""
|
54
|
+
Args:
|
55
|
+
msg (str): the exception message
|
56
|
+
|
57
|
+
Keyword Args:
|
58
|
+
path_to_item (list) the path to the exception in the
|
59
|
+
received_data dict. None if unset
|
60
|
+
"""
|
61
|
+
|
62
|
+
self.path_to_item = path_to_item
|
63
|
+
full_msg = msg
|
64
|
+
if path_to_item:
|
65
|
+
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
66
|
+
super(ApiValueError, self).__init__(full_msg)
|
67
|
+
|
68
|
+
|
69
|
+
class ApiAttributeError(OpenApiException, AttributeError):
|
70
|
+
def __init__(self, msg, path_to_item=None) -> None:
|
71
|
+
"""
|
72
|
+
Raised when an attribute reference or assignment fails.
|
73
|
+
|
74
|
+
Args:
|
75
|
+
msg (str): the exception message
|
76
|
+
|
77
|
+
Keyword Args:
|
78
|
+
path_to_item (None/list) the path to the exception in the
|
79
|
+
received_data dict
|
80
|
+
"""
|
81
|
+
self.path_to_item = path_to_item
|
82
|
+
full_msg = msg
|
83
|
+
if path_to_item:
|
84
|
+
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
85
|
+
super(ApiAttributeError, self).__init__(full_msg)
|
86
|
+
|
87
|
+
|
88
|
+
class ApiKeyError(OpenApiException, KeyError):
|
89
|
+
def __init__(self, msg, path_to_item=None) -> None:
|
90
|
+
"""
|
91
|
+
Args:
|
92
|
+
msg (str): the exception message
|
93
|
+
|
94
|
+
Keyword Args:
|
95
|
+
path_to_item (None/list) the path to the exception in the
|
96
|
+
received_data dict
|
97
|
+
"""
|
98
|
+
self.path_to_item = path_to_item
|
99
|
+
full_msg = msg
|
100
|
+
if path_to_item:
|
101
|
+
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
102
|
+
super(ApiKeyError, self).__init__(full_msg)
|
103
|
+
|
104
|
+
|
105
|
+
class ApiException(OpenApiException):
|
106
|
+
|
107
|
+
def __init__(
|
108
|
+
self,
|
109
|
+
status=None,
|
110
|
+
reason=None,
|
111
|
+
http_resp=None,
|
112
|
+
*,
|
113
|
+
body: Optional[str] = None,
|
114
|
+
data: Optional[Any] = None,
|
115
|
+
) -> None:
|
116
|
+
self.status = status
|
117
|
+
self.reason = reason
|
118
|
+
self.body = body
|
119
|
+
self.data = data
|
120
|
+
self.headers = None
|
121
|
+
|
122
|
+
if http_resp:
|
123
|
+
if self.status is None:
|
124
|
+
self.status = http_resp.status
|
125
|
+
if self.reason is None:
|
126
|
+
self.reason = http_resp.reason
|
127
|
+
if self.body is None:
|
128
|
+
try:
|
129
|
+
self.body = http_resp.data.decode('utf-8')
|
130
|
+
except Exception:
|
131
|
+
pass
|
132
|
+
self.headers = http_resp.getheaders()
|
133
|
+
|
134
|
+
@classmethod
|
135
|
+
def from_response(
|
136
|
+
cls,
|
137
|
+
*,
|
138
|
+
http_resp,
|
139
|
+
body: Optional[str],
|
140
|
+
data: Optional[Any],
|
141
|
+
) -> Self:
|
142
|
+
if http_resp.status == 400:
|
143
|
+
raise BadRequestException(http_resp=http_resp, body=body, data=data)
|
144
|
+
|
145
|
+
if http_resp.status == 401:
|
146
|
+
raise UnauthorizedException(http_resp=http_resp, body=body, data=data)
|
147
|
+
|
148
|
+
if http_resp.status == 403:
|
149
|
+
raise ForbiddenException(http_resp=http_resp, body=body, data=data)
|
150
|
+
|
151
|
+
if http_resp.status == 404:
|
152
|
+
raise NotFoundException(http_resp=http_resp, body=body, data=data)
|
153
|
+
|
154
|
+
if 500 <= http_resp.status <= 599:
|
155
|
+
raise ServiceException(http_resp=http_resp, body=body, data=data)
|
156
|
+
raise ApiException(http_resp=http_resp, body=body, data=data)
|
157
|
+
|
158
|
+
def __str__(self):
|
159
|
+
"""Custom error messages for exception"""
|
160
|
+
error_message = "({0})\n"\
|
161
|
+
"Reason: {1}\n".format(self.status, self.reason)
|
162
|
+
if self.headers:
|
163
|
+
error_message += "HTTP response headers: {0}\n".format(
|
164
|
+
self.headers)
|
165
|
+
|
166
|
+
if self.data or self.body:
|
167
|
+
error_message += "HTTP response body: {0}\n".format(self.data or self.body)
|
168
|
+
|
169
|
+
return error_message
|
170
|
+
|
171
|
+
|
172
|
+
class BadRequestException(ApiException):
|
173
|
+
pass
|
174
|
+
|
175
|
+
|
176
|
+
class NotFoundException(ApiException):
|
177
|
+
pass
|
178
|
+
|
179
|
+
|
180
|
+
class UnauthorizedException(ApiException):
|
181
|
+
pass
|
182
|
+
|
183
|
+
|
184
|
+
class ForbiddenException(ApiException):
|
185
|
+
pass
|
186
|
+
|
187
|
+
|
188
|
+
class ServiceException(ApiException):
|
189
|
+
pass
|
190
|
+
|
191
|
+
|
192
|
+
def render_path(path_to_item):
|
193
|
+
"""Returns a string representation of a path"""
|
194
|
+
result = ""
|
195
|
+
for pth in path_to_item:
|
196
|
+
if isinstance(pth, int):
|
197
|
+
result += "[{0}]".format(pth)
|
198
|
+
else:
|
199
|
+
result += "['{0}']".format(pth)
|
200
|
+
return result
|