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