kelvin-python-api-client 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 (43) hide show
  1. kelvin/api/client/__init__.py +15 -0
  2. kelvin/api/client/api/app_manager.py +646 -0
  3. kelvin/api/client/api/app_registry.py +342 -0
  4. kelvin/api/client/api/asset.py +1012 -0
  5. kelvin/api/client/api/asset_insights.py +67 -0
  6. kelvin/api/client/api/bridge.py +306 -0
  7. kelvin/api/client/api/control_change.py +398 -0
  8. kelvin/api/client/api/data_tag.py +499 -0
  9. kelvin/api/client/api/datastreams.py +1021 -0
  10. kelvin/api/client/api/filestorage.py +234 -0
  11. kelvin/api/client/api/instance.py +559 -0
  12. kelvin/api/client/api/orchestration.py +717 -0
  13. kelvin/api/client/api/parameters.py +417 -0
  14. kelvin/api/client/api/recommendation.py +804 -0
  15. kelvin/api/client/api/secret.py +173 -0
  16. kelvin/api/client/api/thread.py +435 -0
  17. kelvin/api/client/api/timeseries.py +273 -0
  18. kelvin/api/client/api/user.py +382 -0
  19. kelvin/api/client/api/workload.py +437 -0
  20. kelvin/api/client/base_client.py +924 -0
  21. kelvin/api/client/base_model.py +187 -0
  22. kelvin/api/client/client.py +181 -0
  23. kelvin/api/client/config.py +709 -0
  24. kelvin/api/client/data_model.py +523 -0
  25. kelvin/api/client/dataframe_conversion.py +172 -0
  26. kelvin/api/client/deeplist.py +285 -0
  27. kelvin/api/client/error.py +77 -0
  28. kelvin/api/client/model/__init__.py +3 -0
  29. kelvin/api/client/model/enum.py +82 -0
  30. kelvin/api/client/model/pagination.py +61 -0
  31. kelvin/api/client/model/requests.py +3352 -0
  32. kelvin/api/client/model/response.py +68 -0
  33. kelvin/api/client/model/responses.py +4799 -0
  34. kelvin/api/client/model/type.py +2025 -0
  35. kelvin/api/client/py.typed +0 -0
  36. kelvin/api/client/retry.py +88 -0
  37. kelvin/api/client/serialize.py +222 -0
  38. kelvin/api/client/utils.py +316 -0
  39. kelvin/api/client/version.py +16 -0
  40. kelvin_python_api_client-0.0.1.dist-info/METADATA +75 -0
  41. kelvin_python_api_client-0.0.1.dist-info/RECORD +43 -0
  42. kelvin_python_api_client-0.0.1.dist-info/WHEEL +5 -0
  43. kelvin_python_api_client-0.0.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,437 @@
1
+ """
2
+ Kelvin API Client.
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ from datetime import datetime
8
+ from typing import Any, List, Mapping, Optional, Sequence, Union
9
+
10
+ from typing_extensions import Literal
11
+
12
+ from kelvin.api.client.data_model import DataModelBase
13
+
14
+ from ..model import requests, responses
15
+
16
+
17
+ class Workload(DataModelBase):
18
+ @classmethod
19
+ def deploy_workload(
20
+ cls,
21
+ data: Optional[Union[requests.WorkloadDeploy, Mapping[str, Any]]] = None,
22
+ _dry_run: bool = False,
23
+ _client: Any = None,
24
+ **kwargs: Any,
25
+ ) -> responses.WorkloadDeploy:
26
+ """
27
+ Deploy an App from the App Registry as a Workload to a Cluster/Node.
28
+
29
+ **Permission Required:** `kelvin.permission.workload.update`.
30
+
31
+ ``deployWorkload``: ``POST`` ``/api/v4/workloads/deploy``
32
+
33
+ Parameters
34
+ ----------
35
+ data: requests.WorkloadDeploy, optional
36
+ **kwargs:
37
+ Extra parameters for requests.WorkloadDeploy
38
+ - deploy_workload: dict
39
+
40
+ """
41
+
42
+ from ..model import responses
43
+
44
+ result = cls._make_request(
45
+ _client,
46
+ "post",
47
+ "/api/v4/workloads/deploy",
48
+ {},
49
+ {},
50
+ {},
51
+ {},
52
+ data,
53
+ "requests.WorkloadDeploy",
54
+ False,
55
+ {"201": responses.WorkloadDeploy, "400": None, "401": None, "404": None, "409": None},
56
+ False,
57
+ _dry_run,
58
+ kwargs,
59
+ )
60
+ return result
61
+
62
+ @classmethod
63
+ def list_workloads(
64
+ cls,
65
+ search: Optional[Sequence[str]] = None,
66
+ app_name: Optional[Sequence[str]] = None,
67
+ app_version: Optional[Sequence[str]] = None,
68
+ acp_name: Optional[Sequence[str]] = None,
69
+ cluster_name: Optional[Sequence[str]] = None,
70
+ node_name: Optional[Sequence[str]] = None,
71
+ workload_name: Optional[Sequence[str]] = None,
72
+ enabled: Optional[bool] = None,
73
+ asset_name: Optional[str] = None,
74
+ pagination_type: Optional[Literal["limits", "cursor", "stream"]] = None,
75
+ page_size: Optional[int] = 10000,
76
+ page: Optional[int] = None,
77
+ next: Optional[str] = None,
78
+ previous: Optional[str] = None,
79
+ direction: Optional[Literal["asc", "desc"]] = None,
80
+ sort_by: Optional[Sequence[str]] = None,
81
+ fetch: bool = True,
82
+ _dry_run: bool = False,
83
+ _client: Any = None,
84
+ ) -> Union[List[responses.WorkloadItem], responses.WorkloadsListPaginatedResponseCursor]:
85
+ """
86
+ Returns a list of Workload objects. The list can be optionally filtered and sorted on the server before being returned.
87
+
88
+ **Permission Required:** `kelvin.permission.workload.read`.
89
+
90
+ ``listWorkloads``: ``GET`` ``/api/v4/workloads/list``
91
+
92
+ Parameters
93
+ ----------
94
+ search : :obj:`Sequence[str]`
95
+ Search and filter on the list based on the keys `name`, `title`
96
+ (Display Name), `app_name`, `cluster_name` and `node_name`. All
97
+ strings in the array are treated as `OR`. The search is case
98
+ insensitive and will find partial matches as well.
99
+ app_name : :obj:`Sequence[str]`
100
+ A filter on the list based on the key `app_name`. The filter is on the
101
+ full name only. The string can only contain lowercase alphanumeric
102
+ characters and `.`, `_` or `-` characters.
103
+ app_version : :obj:`Sequence[str]`
104
+ A filter on the list based on the key `app_version`. The filter is on
105
+ the full value only. The string can only contain lowercase
106
+ alphanumeric characters and `.`, `_` or `-` characters.
107
+ acp_name : :obj:`Sequence[str]`
108
+ [`Deprecated`] A filter on the list based on the key `acp_name`. The
109
+ filter is on the full name only. The string can only contain lowercase
110
+ alphanumeric characters and `.`, `_` or `-` characters.
111
+ cluster_name : :obj:`Sequence[str]`
112
+ A filter on the list based on the key `cluster_name`. The filter is on
113
+ the full name only. The string can only contain lowercase alphanumeric
114
+ characters and `.`, `_` or `-` characters. If set, it will override
115
+ acp_name
116
+ node_name : :obj:`Sequence[str]`
117
+ A filter on the list based on the key `node_name`. The filter is on
118
+ the full name only. The string can only contain lowercase alphanumeric
119
+ characters and `.`, `_` or `-` characters.
120
+ workload_name : :obj:`Sequence[str]`
121
+ A filter on the list based on the key `name`. The filter is on the
122
+ full name only. The string can only contain lowercase alphanumeric
123
+ characters and `.`, `_` or `-` characters.
124
+ enabled : :obj:`bool`
125
+ A filter on the list based on the key `status` (start/stop function in
126
+ Kelvin UI) of the Workloads.
127
+ asset_name : :obj:`str`
128
+ A filter on the list based on Asset `name` associated with the
129
+ Workload. The filter is on the full name only. The string can only
130
+ contain lowercase alphanumeric characters and `.`, `_` or `-`
131
+ characters.
132
+ pagination_type : :obj:`Literal['limits', 'cursor', 'stream']`
133
+ Method of pagination to use for return results where `total_items` is
134
+ greater than `page_size`. `cursor` and `limits` will return one `page`
135
+ of results, `stream` will return all results. ('limits', 'cursor',
136
+ 'stream')
137
+ page_size : :obj:`int`
138
+ Number of objects to be returned in each page. Page size can range
139
+ between 1 and 1000 objects.
140
+ page : :obj:`int`
141
+ An integer for the wanted page of results. Used only with
142
+ `pagination_type` set as `limits`.
143
+ next : :obj:`str`
144
+ An alphanumeric string bookmark to indicate where to start for the
145
+ next page. Used only with `pagination_type` set as `cursor`.
146
+ previous : :obj:`str`
147
+ An alphanumeric string bookmark to indicate where to end for the
148
+ previous page. Used only with `pagination_type` set as `cursor`.
149
+ direction : :obj:`Literal['asc', 'desc']`
150
+ Sorting order according to the `sort_by` parameter. ('asc', 'desc')
151
+ sort_by : :obj:`Sequence[str]`
152
+
153
+ """
154
+
155
+ from ..model import responses
156
+
157
+ result = cls._make_request(
158
+ _client,
159
+ "get",
160
+ "/api/v4/workloads/list",
161
+ {},
162
+ {
163
+ "search": search,
164
+ "app_name": app_name,
165
+ "app_version": app_version,
166
+ "acp_name": acp_name,
167
+ "cluster_name": cluster_name,
168
+ "node_name": node_name,
169
+ "workload_name": workload_name,
170
+ "enabled": enabled,
171
+ "asset_name": asset_name,
172
+ "pagination_type": pagination_type,
173
+ "page_size": page_size,
174
+ "page": page,
175
+ "next": next,
176
+ "previous": previous,
177
+ "direction": direction,
178
+ "sort_by": sort_by,
179
+ },
180
+ {},
181
+ {},
182
+ None,
183
+ None,
184
+ False,
185
+ {"200": responses.WorkloadsListPaginatedResponseCursor, "400": None, "401": None},
186
+ False,
187
+ _dry_run,
188
+ )
189
+ return result.fetch("/api/v4/workloads/list", "GET") if fetch and not _dry_run else result
190
+
191
+ @classmethod
192
+ def apply_workload(cls, workload_name: str, _dry_run: bool = False, _client: Any = None) -> None:
193
+ """
194
+ Initiate final deploy action for downloaded Workload. Only valid for Workload that were previously deployed with the keys `pre_download` set to true and `instantly_apply` set to false.
195
+
196
+ **Permission Required:** `kelvin.permission.workload.update`.
197
+
198
+ ``applyWorkload``: ``GET`` ``/api/v4/workloads/{workload_name}/apply``
199
+
200
+ Parameters
201
+ ----------
202
+ workload_name : :obj:`str`, optional
203
+ Unique identifier `name` of the Workload.
204
+
205
+ """
206
+
207
+ result = cls._make_request(
208
+ _client,
209
+ "get",
210
+ "/api/v4/workloads/{workload_name}/apply",
211
+ {"workload_name": workload_name},
212
+ {},
213
+ {},
214
+ {},
215
+ None,
216
+ None,
217
+ False,
218
+ {"200": None, "400": None, "401": None, "404": None, "406": None},
219
+ False,
220
+ _dry_run,
221
+ )
222
+ return result
223
+
224
+ @classmethod
225
+ def download_workload(cls, workload_name: str, _dry_run: bool = False, _client: Any = None) -> str:
226
+ """
227
+ Download the Workload package file for offline installation on the Edge System. The system automatically generates the file for download if the package is not already available.
228
+
229
+ **Permission Required:** `kelvin.permission.workload.read`.
230
+
231
+ ``downloadWorkload``: ``GET`` ``/api/v4/workloads/{workload_name}/download``
232
+
233
+ Parameters
234
+ ----------
235
+ workload_name : :obj:`str`, optional
236
+ Unique identifier `name` of the Workload.
237
+
238
+ """
239
+
240
+ result = cls._make_request(
241
+ _client,
242
+ "get",
243
+ "/api/v4/workloads/{workload_name}/download",
244
+ {"workload_name": workload_name},
245
+ {},
246
+ {},
247
+ {},
248
+ None,
249
+ None,
250
+ False,
251
+ {"200": str, "202": None, "400": None, "401": None, "404": None, "412": None},
252
+ False,
253
+ _dry_run,
254
+ )
255
+ return result
256
+
257
+ @classmethod
258
+ def get_workload(cls, workload_name: str, _dry_run: bool = False, _client: Any = None) -> responses.WorkloadGet:
259
+ """
260
+ Retrieve the parameters of a Workload.
261
+
262
+ **Permission Required:** `kelvin.permission.workload.read`.
263
+
264
+ ``getWorkload``: ``GET`` ``/api/v4/workloads/{workload_name}/get``
265
+
266
+ Parameters
267
+ ----------
268
+ workload_name : :obj:`str`, optional
269
+ Unique identifier `name` of the Workload.
270
+
271
+ """
272
+
273
+ from ..model import responses
274
+
275
+ result = cls._make_request(
276
+ _client,
277
+ "get",
278
+ "/api/v4/workloads/{workload_name}/get",
279
+ {"workload_name": workload_name},
280
+ {},
281
+ {},
282
+ {},
283
+ None,
284
+ None,
285
+ False,
286
+ {"200": responses.WorkloadGet, "400": None, "401": None, "404": None},
287
+ False,
288
+ _dry_run,
289
+ )
290
+ return result
291
+
292
+ @classmethod
293
+ def get_workload_logs(
294
+ cls,
295
+ workload_name: str,
296
+ tail_lines: Optional[int] = None,
297
+ since_time: Optional[datetime] = None,
298
+ _dry_run: bool = False,
299
+ _client: Any = None,
300
+ ) -> responses.WorkloadLogsGet:
301
+ """
302
+ Get Workload Logs
303
+
304
+ **Permission Required:** `kelvin.permission.workload.read`.
305
+
306
+ ``getWorkloadLogs``: ``GET`` ``/api/v4/workloads/{workload_name}/logs/get``
307
+
308
+ Parameters
309
+ ----------
310
+ workload_name : :obj:`str`, optional
311
+ Unique identifier `name` of the Workload.
312
+ tail_lines : :obj:`int`
313
+ Specify the number of the most recent log lines to retrieve, counting
314
+ backwards from the latest entry.
315
+ since_time : :obj:`datetime`
316
+ UTC time of the starting point for log retrieval, formatted in RFC
317
+ 3339.
318
+
319
+ """
320
+
321
+ from ..model import responses
322
+
323
+ result = cls._make_request(
324
+ _client,
325
+ "get",
326
+ "/api/v4/workloads/{workload_name}/logs/get",
327
+ {"workload_name": workload_name},
328
+ {"tail_lines": tail_lines, "since_time": since_time},
329
+ {},
330
+ {},
331
+ None,
332
+ None,
333
+ False,
334
+ {"200": responses.WorkloadLogsGet, "400": None, "401": None, "404": None, "500": None},
335
+ False,
336
+ _dry_run,
337
+ )
338
+ return result
339
+
340
+ @classmethod
341
+ def start_workload(cls, workload_name: str, _dry_run: bool = False, _client: Any = None) -> None:
342
+ """
343
+ Start running the Workload.
344
+
345
+ **Permission Required:** `kelvin.permission.workload.update`.
346
+
347
+ ``startWorkload``: ``GET`` ``/api/v4/workloads/{workload_name}/start``
348
+
349
+ Parameters
350
+ ----------
351
+ workload_name : :obj:`str`, optional
352
+ Unique identifier `name` of the Workload.
353
+
354
+ """
355
+
356
+ result = cls._make_request(
357
+ _client,
358
+ "get",
359
+ "/api/v4/workloads/{workload_name}/start",
360
+ {"workload_name": workload_name},
361
+ {},
362
+ {},
363
+ {},
364
+ None,
365
+ None,
366
+ False,
367
+ {"200": None, "400": None, "401": None, "404": None, "409": None},
368
+ False,
369
+ _dry_run,
370
+ )
371
+ return result
372
+
373
+ @classmethod
374
+ def stop_workload(cls, workload_name: str, _dry_run: bool = False, _client: Any = None) -> None:
375
+ """
376
+ Stop running the Workload.
377
+
378
+ **Permission Required:** `kelvin.permission.workload.update`.
379
+
380
+ ``stopWorkload``: ``GET`` ``/api/v4/workloads/{workload_name}/stop``
381
+
382
+ Parameters
383
+ ----------
384
+ workload_name : :obj:`str`, optional
385
+ Unique identifier `name` of the Workload.
386
+
387
+ """
388
+
389
+ result = cls._make_request(
390
+ _client,
391
+ "get",
392
+ "/api/v4/workloads/{workload_name}/stop",
393
+ {"workload_name": workload_name},
394
+ {},
395
+ {},
396
+ {},
397
+ None,
398
+ None,
399
+ False,
400
+ {"200": None, "400": None, "401": None, "404": None, "409": None},
401
+ False,
402
+ _dry_run,
403
+ )
404
+ return result
405
+
406
+ @classmethod
407
+ def undeploy_workload(cls, workload_name: str, _dry_run: bool = False, _client: Any = None) -> None:
408
+ """
409
+ Undeploy Workload from the Edge System.
410
+
411
+ **Permission Required:** `kelvin.permission.workload.delete`.
412
+
413
+ ``undeployWorkload``: ``POST`` ``/api/v4/workloads/{workload_name}/undeploy``
414
+
415
+ Parameters
416
+ ----------
417
+ workload_name : :obj:`str`, optional
418
+ Unique identifier `name` of the Workload.
419
+
420
+ """
421
+
422
+ result = cls._make_request(
423
+ _client,
424
+ "post",
425
+ "/api/v4/workloads/{workload_name}/undeploy",
426
+ {"workload_name": workload_name},
427
+ {},
428
+ {},
429
+ {},
430
+ None,
431
+ None,
432
+ False,
433
+ {"200": None, "400": None, "401": None, "404": None},
434
+ False,
435
+ _dry_run,
436
+ )
437
+ return result