octostar-python-client 0.1.759__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 (257) hide show
  1. octostar/__init__.py +9 -0
  2. octostar/api/__init__.py +1 -0
  3. octostar/api/apps/__init__.py +0 -0
  4. octostar/api/apps/deploy_app.py +210 -0
  5. octostar/api/apps/execute_app_job.py +188 -0
  6. octostar/api/apps/get_app_logs.py +210 -0
  7. octostar/api/apps/get_apps_url.py +188 -0
  8. octostar/api/apps/get_job_logs.py +210 -0
  9. octostar/api/apps/get_job_progress.py +162 -0
  10. octostar/api/apps/kill_job.py +160 -0
  11. octostar/api/apps/list_app_jobs.py +276 -0
  12. octostar/api/apps/list_apps.py +251 -0
  13. octostar/api/apps/set_job_progress.py +216 -0
  14. octostar/api/apps/undeploy_app.py +160 -0
  15. octostar/api/metadata/__init__.py +0 -0
  16. octostar/api/metadata/get_version.py +232 -0
  17. octostar/api/metadata/get_whoami.py +232 -0
  18. octostar/api/notifications/__init__.py +0 -0
  19. octostar/api/notifications/delete_stream.py +222 -0
  20. octostar/api/notifications/get_subscriptions.py +240 -0
  21. octostar/api/notifications/publish_notification.py +275 -0
  22. octostar/api/notifications/pull_events_from_stream.py +282 -0
  23. octostar/api/notifications/push_event_to_stream.py +265 -0
  24. octostar/api/notifications/toast.py +264 -0
  25. octostar/api/ontology/__init__.py +0 -0
  26. octostar/api/ontology/fetch_ontology_data.py +275 -0
  27. octostar/api/ontology/get_ontologies.py +237 -0
  28. octostar/api/ontology/multi_query.py +297 -0
  29. octostar/api/ontology/query.py +276 -0
  30. octostar/api/pipeline/__init__.py +1 -0
  31. octostar/api/pipeline/get_processing_status.py +185 -0
  32. octostar/api/pipeline/update_processing_status.py +164 -0
  33. octostar/api/search/__init__.py +0 -0
  34. octostar/api/search/get_annotations.py +153 -0
  35. octostar/api/workspace_data/__init__.py +0 -0
  36. octostar/api/workspace_data/delete_blob.py +212 -0
  37. octostar/api/workspace_data/delete_entities.py +326 -0
  38. octostar/api/workspace_data/download_blob.py +235 -0
  39. octostar/api/workspace_data/get_attachment.py +336 -0
  40. octostar/api/workspace_data/get_files_tree.py +397 -0
  41. octostar/api/workspace_data/upload_blob.py +235 -0
  42. octostar/api/workspace_data/upsert_entities.py +284 -0
  43. octostar/api/workspace_permissions/__init__.py +0 -0
  44. octostar/api/workspace_permissions/get_permissions.py +325 -0
  45. octostar/api/workspace_tags/__init__.py +0 -0
  46. octostar/api/workspace_tags/delete_tag_from_entities.py +141 -0
  47. octostar/api/workspace_tags/tag_entities.py +180 -0
  48. octostar/client.py +492 -0
  49. octostar/errors.py +50 -0
  50. octostar/models/__init__.py +249 -0
  51. octostar/models/acknowledgement.py +74 -0
  52. octostar/models/acknowledgement_with_data.py +82 -0
  53. octostar/models/app_status.py +239 -0
  54. octostar/models/app_status_annotations.py +66 -0
  55. octostar/models/app_status_labels.py +69 -0
  56. octostar/models/app_with_url.py +82 -0
  57. octostar/models/child_processing_status.py +118 -0
  58. octostar/models/delete_entities_response_401.py +74 -0
  59. octostar/models/delete_entities_response_409.py +82 -0
  60. octostar/models/delete_entities_response_500.py +82 -0
  61. octostar/models/delete_stream_response_401.py +74 -0
  62. octostar/models/delete_tag_from_entities_response_401.py +74 -0
  63. octostar/models/deploy_app_json_body.py +90 -0
  64. octostar/models/deploy_app_json_body_secrets.py +65 -0
  65. octostar/models/deploy_app_response_200.py +98 -0
  66. octostar/models/deploy_app_response_200_data.py +60 -0
  67. octostar/models/deploy_app_response_400.py +82 -0
  68. octostar/models/deploy_app_response_403.py +82 -0
  69. octostar/models/deploy_app_response_404.py +82 -0
  70. octostar/models/deploy_app_response_409.py +82 -0
  71. octostar/models/deploy_app_response_500.py +82 -0
  72. octostar/models/entity.py +80 -0
  73. octostar/models/entity_response.py +99 -0
  74. octostar/models/entity_response_s3_urls.py +93 -0
  75. octostar/models/entity_response_s3_urls_additional_property.py +105 -0
  76. octostar/models/entity_response_s3_urls_additional_property_fields.py +114 -0
  77. octostar/models/execute_app_job_json_body.py +151 -0
  78. octostar/models/execute_app_job_json_body_annotation.py +65 -0
  79. octostar/models/execute_app_job_response_401.py +74 -0
  80. octostar/models/fetch_ontology_data_response_200.py +60 -0
  81. octostar/models/fetch_ontology_data_response_401.py +74 -0
  82. octostar/models/fetch_ontology_data_response_500.py +82 -0
  83. octostar/models/get_app_logs_response_401.py +74 -0
  84. octostar/models/get_app_logs_response_404.py +74 -0
  85. octostar/models/get_app_logs_response_500.py +82 -0
  86. octostar/models/get_apps_url_json_body.py +76 -0
  87. octostar/models/get_apps_url_response_401.py +74 -0
  88. octostar/models/get_apps_url_response_500.py +82 -0
  89. octostar/models/get_attachment_response_200.py +74 -0
  90. octostar/models/get_attachment_response_401.py +74 -0
  91. octostar/models/get_files_tree_response_200.py +106 -0
  92. octostar/models/get_files_tree_response_200_status.py +8 -0
  93. octostar/models/get_files_tree_response_400.py +111 -0
  94. octostar/models/get_files_tree_response_400_data.py +60 -0
  95. octostar/models/get_files_tree_response_400_status.py +8 -0
  96. octostar/models/get_files_tree_response_401.py +74 -0
  97. octostar/models/get_files_tree_response_500.py +111 -0
  98. octostar/models/get_files_tree_response_500_data.py +60 -0
  99. octostar/models/get_files_tree_response_500_status.py +8 -0
  100. octostar/models/get_job_logs_response_401.py +74 -0
  101. octostar/models/get_job_logs_response_404.py +74 -0
  102. octostar/models/get_job_logs_response_500.py +82 -0
  103. octostar/models/get_job_progress_response_401.py +74 -0
  104. octostar/models/get_object_response_401.py +74 -0
  105. octostar/models/get_ontologies_response_401.py +74 -0
  106. octostar/models/get_ontologies_response_500.py +81 -0
  107. octostar/models/get_permissions_response_200.py +98 -0
  108. octostar/models/get_permissions_response_400.py +82 -0
  109. octostar/models/get_permissions_response_401.py +74 -0
  110. octostar/models/get_permissions_response_500.py +82 -0
  111. octostar/models/get_processing_status_response_200.py +104 -0
  112. octostar/models/get_processing_status_response_200_data.py +87 -0
  113. octostar/models/get_processing_status_response_400.py +82 -0
  114. octostar/models/get_processing_status_response_500.py +82 -0
  115. octostar/models/get_subscriptions_response_200_item.py +74 -0
  116. octostar/models/get_version_response_200.py +74 -0
  117. octostar/models/get_version_response_404.py +74 -0
  118. octostar/models/get_whoami_response_200.py +129 -0
  119. octostar/models/get_whoami_response_401.py +74 -0
  120. octostar/models/insert_entity.py +114 -0
  121. octostar/models/insert_entity_base.py +266 -0
  122. octostar/models/insert_entity_relationships_item.py +107 -0
  123. octostar/models/insert_entity_request.py +94 -0
  124. octostar/models/internal_server_error.py +82 -0
  125. octostar/models/job_execution_result.py +146 -0
  126. octostar/models/job_status.py +196 -0
  127. octostar/models/job_status_labels.py +60 -0
  128. octostar/models/job_with_url.py +82 -0
  129. octostar/models/kill_job_response_401.py +74 -0
  130. octostar/models/list_app_jobs_response_401.py +74 -0
  131. octostar/models/list_app_jobs_response_500.py +82 -0
  132. octostar/models/list_apps_response_401.py +74 -0
  133. octostar/models/list_apps_response_500.py +82 -0
  134. octostar/models/multi_query_json_body.py +100 -0
  135. octostar/models/multi_query_json_body_queries_item.py +80 -0
  136. octostar/models/multi_query_response_400.py +82 -0
  137. octostar/models/multi_query_response_401.py +74 -0
  138. octostar/models/not_found_error.py +74 -0
  139. octostar/models/octostar_event.py +96 -0
  140. octostar/models/octostar_event_octostar_payload.py +100 -0
  141. octostar/models/octostar_event_octostar_payload_level.py +11 -0
  142. octostar/models/os_notification.py +122 -0
  143. octostar/models/processing_status.py +262 -0
  144. octostar/models/processing_status_code.py +14 -0
  145. octostar/models/progress_request.py +73 -0
  146. octostar/models/publish_notification_response_401.py +74 -0
  147. octostar/models/pull_events_from_stream_response_401.py +74 -0
  148. octostar/models/push_event_to_stream_response_401.py +74 -0
  149. octostar/models/query_json_body.py +101 -0
  150. octostar/models/query_json_body_params.py +60 -0
  151. octostar/models/query_response_400.py +82 -0
  152. octostar/models/query_response_401.py +74 -0
  153. octostar/models/set_job_progress_response_401.py +74 -0
  154. octostar/models/string_to_value_label_map.py +99 -0
  155. octostar/models/string_to_value_label_map_data.py +89 -0
  156. octostar/models/string_to_value_label_map_data_additional_property.py +80 -0
  157. octostar/models/successful_get_tags.py +103 -0
  158. octostar/models/successful_insertion.py +98 -0
  159. octostar/models/tag_entities_response_401.py +74 -0
  160. octostar/models/toast_level.py +11 -0
  161. octostar/models/toast_response_401.py +74 -0
  162. octostar/models/undeploy_app_response_401.py +74 -0
  163. octostar/models/update_processing_status_response_200.py +82 -0
  164. octostar/models/update_processing_status_response_400.py +82 -0
  165. octostar/models/update_processing_status_response_500.py +82 -0
  166. octostar/models/upsert_entities_response_401.py +74 -0
  167. octostar/models/upsert_entity.py +114 -0
  168. octostar/models/upsert_entity_base.py +266 -0
  169. octostar/models/upsert_entity_relationships_item.py +107 -0
  170. octostar/py.typed +1 -0
  171. octostar/types.py +54 -0
  172. octostar/utils/__init__.py +15 -0
  173. octostar/utils/chat/__init__.py +0 -0
  174. octostar/utils/chat/chat.py +513 -0
  175. octostar/utils/chat/detokenize.py +105 -0
  176. octostar/utils/chat/get_default_model.py +50 -0
  177. octostar/utils/chat/list_models.py +91 -0
  178. octostar/utils/chat/tokenize.py +105 -0
  179. octostar/utils/commons.py +226 -0
  180. octostar/utils/exceptions.py +134 -0
  181. octostar/utils/jobs/__init__.py +0 -0
  182. octostar/utils/jobs/apps/__init__.py +0 -0
  183. octostar/utils/jobs/apps/deploy_app.py +81 -0
  184. octostar/utils/jobs/apps/execute_app_job.py +114 -0
  185. octostar/utils/jobs/apps/get_app_logs.py +113 -0
  186. octostar/utils/jobs/apps/get_app_secret.py +102 -0
  187. octostar/utils/jobs/apps/get_apps_url.py +73 -0
  188. octostar/utils/jobs/apps/list_app_jobs.py +62 -0
  189. octostar/utils/jobs/apps/list_apps.py +126 -0
  190. octostar/utils/jobs/apps/undeploy_app.py +48 -0
  191. octostar/utils/jobs/get_job_logs.py +113 -0
  192. octostar/utils/jobs/get_job_progress.py +76 -0
  193. octostar/utils/jobs/kill_job.py +47 -0
  194. octostar/utils/jobs/set_job_progress.py +67 -0
  195. octostar/utils/meta/__init__.py +0 -0
  196. octostar/utils/meta/get_version.py +30 -0
  197. octostar/utils/meta/get_whoami.py +30 -0
  198. octostar/utils/notifications/__init__.py +0 -0
  199. octostar/utils/notifications/delete_stream.py +58 -0
  200. octostar/utils/notifications/get_my_subscriptions.py +49 -0
  201. octostar/utils/notifications/publish_notification.py +73 -0
  202. octostar/utils/notifications/pull_event_from_stream.py +63 -0
  203. octostar/utils/notifications/pull_events_from_stream.py +64 -0
  204. octostar/utils/notifications/push_event_to_stream.py +109 -0
  205. octostar/utils/notifications/push_events_to_stream.py +137 -0
  206. octostar/utils/notifications/toast.py +92 -0
  207. octostar/utils/ontology/__init__.py +10 -0
  208. octostar/utils/ontology/fetch_ontology_data.py +141 -0
  209. octostar/utils/ontology/get_ontologies.py +55 -0
  210. octostar/utils/ontology/multiquery_ontology.py +287 -0
  211. octostar/utils/ontology/query_ontology.py +186 -0
  212. octostar/utils/pipeline/__init__.py +1 -0
  213. octostar/utils/pipeline/get_processing_status.py +230 -0
  214. octostar/utils/pipeline/update_processing_status.py +286 -0
  215. octostar/utils/search/__init__.py +11 -0
  216. octostar/utils/search/bulk_update.py +138 -0
  217. octostar/utils/search/count.py +117 -0
  218. octostar/utils/search/get_entity_annotations.py +304 -0
  219. octostar/utils/search/get_index_definition.py +111 -0
  220. octostar/utils/search/multi_search.py +129 -0
  221. octostar/utils/workspace/__init__.py +0 -0
  222. octostar/utils/workspace/delete_entities.py +247 -0
  223. octostar/utils/workspace/delete_entity.py +81 -0
  224. octostar/utils/workspace/delete_relationship.py +78 -0
  225. octostar/utils/workspace/delete_relationships.py +85 -0
  226. octostar/utils/workspace/delete_temporary_blob.py +85 -0
  227. octostar/utils/workspace/extract_entities.py +140 -0
  228. octostar/utils/workspace/get_filepath_from_item.py +85 -0
  229. octostar/utils/workspace/get_filepaths_from_items.py +100 -0
  230. octostar/utils/workspace/get_files_tree.py +102 -0
  231. octostar/utils/workspace/get_item_from_filepath.py +102 -0
  232. octostar/utils/workspace/get_items_from_filepaths.py +108 -0
  233. octostar/utils/workspace/linkcharts/__init__.py +0 -0
  234. octostar/utils/workspace/linkcharts/create_linkchart.py +241 -0
  235. octostar/utils/workspace/permissions/PermissionLevel.py +8 -0
  236. octostar/utils/workspace/permissions/__init__.py +1 -0
  237. octostar/utils/workspace/permissions/get_permissions.py +81 -0
  238. octostar/utils/workspace/read_attachment.py +284 -0
  239. octostar/utils/workspace/read_file.py +113 -0
  240. octostar/utils/workspace/read_temporary_blob.py +428 -0
  241. octostar/utils/workspace/saved_searches/__init__.py +0 -0
  242. octostar/utils/workspace/saved_searches/create_saved_search.py +183 -0
  243. octostar/utils/workspace/tags/__init__.py +0 -0
  244. octostar/utils/workspace/tags/delete_tag_from_entities.py +96 -0
  245. octostar/utils/workspace/tags/tag_entities.py +175 -0
  246. octostar/utils/workspace/upsert_entities.py +268 -0
  247. octostar/utils/workspace/upsert_entity.py +110 -0
  248. octostar/utils/workspace/upsert_relationship.py +128 -0
  249. octostar/utils/workspace/upsert_relationships.py +194 -0
  250. octostar/utils/workspace/write_attachment.py +263 -0
  251. octostar/utils/workspace/write_file.py +335 -0
  252. octostar/utils/workspace/write_temporary_blob.py +218 -0
  253. octostar_python_client-0.1.759.dist-info/METADATA +159 -0
  254. octostar_python_client-0.1.759.dist-info/RECORD +257 -0
  255. octostar_python_client-0.1.759.dist-info/WHEEL +5 -0
  256. octostar_python_client-0.1.759.dist-info/licenses/LICENSE +21 -0
  257. octostar_python_client-0.1.759.dist-info/top_level.txt +1 -0
@@ -0,0 +1,113 @@
1
+ import os
2
+ import logging
3
+ import re
4
+
5
+ _logger = logging.getLogger(__name__)
6
+
7
+ from ...api.apps import get_job_logs
8
+ from ...client import Client
9
+ from ..exceptions import ApiConnectionError
10
+
11
+
12
+ def sync(
13
+ job_id: str = os.getenv("OS_JOB_ID"),
14
+ since_seconds: int = None,
15
+ tail_lines: int = None,
16
+ client: Client = None,
17
+ ):
18
+ """
19
+ # Get Job Logs
20
+
21
+ Retrieves the logs of a running job given its ID.
22
+
23
+ ## Arguments
24
+ - `job_id`: The running job ID.
25
+ - `since_seconds`: The maximum amount of seconds prior to now to get logs for.
26
+ - `tail_lines`: The maximum amount of log lines to retrieve.
27
+
28
+ - `client`: The Client with which to connect to Octostar. If None, the default one is used.
29
+
30
+ ## Returns
31
+ An UTF-8 string with the job logs, or in bytes if they could not be decoded.
32
+
33
+ ## Raises
34
+ - `ApiConnectionError`: If the request was unsuccessful on the server.
35
+ """
36
+ response = get_job_logs.sync_detailed(
37
+ job_id=job_id,
38
+ since_seconds=since_seconds,
39
+ tail_lines=tail_lines,
40
+ client=client,
41
+ )
42
+ if response.status_code != 200:
43
+ raise ApiConnectionError("get_job_logs", response, client)
44
+ logs = response.content
45
+ try:
46
+ escaped_logs = logs.decode("utf-8", "replace")
47
+ escaped_logs = re.sub(
48
+ r"\\.",
49
+ lambda x: {
50
+ "\\n": "\n",
51
+ "\\t": "\t",
52
+ "\\r": "\r",
53
+ '\\"': '"',
54
+ "\\'": "'",
55
+ }.get(x[0], x[0]),
56
+ escaped_logs,
57
+ )
58
+ return escaped_logs
59
+ except Exception:
60
+ _logger.warning("Could not decode logs! Returning raw bytes")
61
+ return logs
62
+
63
+
64
+ async def asyncio(
65
+ job_id: str = os.getenv("OS_JOB_ID"),
66
+ since_seconds: int = None,
67
+ tail_lines: int = None,
68
+ client: Client = None,
69
+ ):
70
+ """
71
+ # Get Job Logs Asynchronously
72
+
73
+ Asynchronously retrieves the logs of a running job given its ID.
74
+
75
+ ## Arguments
76
+ - `job_id`: The running job ID.
77
+ - `since_seconds`: The maximum amount of seconds prior to now to get logs for.
78
+ - `tail_lines`: The maximum amount of log lines to retrieve.
79
+
80
+ - `client`: The Client with which to connect to Octostar. If None, the default one is used.
81
+
82
+ ## Returns
83
+ An UTF-8 string with the job logs, or in bytes if they could not be decoded.
84
+
85
+ ## Raises
86
+ - `ApiConnectionError`: If the request was unsuccessful on the server.
87
+ """
88
+ response = await get_job_logs.asyncio_detailed(
89
+ job_id=job_id,
90
+ since_seconds=since_seconds,
91
+ tail_lines=tail_lines,
92
+ client=client,
93
+ )
94
+ if response.status_code != 200:
95
+ raise ApiConnectionError("get_job_logs", response, client)
96
+ logs = response.content
97
+ try:
98
+ escaped_logs = logs.decode("utf-8", "replace")
99
+ escaped_logs = re.sub(
100
+ r"\\.",
101
+ lambda x: {
102
+ "\\n": "\n",
103
+ "\\t": "\t",
104
+ "\\r": "\r",
105
+ '\\"': '"',
106
+ "\\'": "'",
107
+ }.get(x[0], x[0]),
108
+ escaped_logs,
109
+ )
110
+ return escaped_logs
111
+ except Exception:
112
+ _logger.warning("Could not decode logs! Returning raw bytes")
113
+ return logs
@@ -0,0 +1,76 @@
1
+ import os
2
+ import logging
3
+
4
+ _logger = logging.getLogger(__name__)
5
+
6
+ from ...api.apps import get_job_progress
7
+ from ...client import Client
8
+ from ..exceptions import ApiConnectionError
9
+
10
+
11
+ def _format_progress_response(content: dict) -> str:
12
+ """Format the new API response as a progress string for backward compatibility.
13
+
14
+ The new API returns: {job_id, progress (float 0-1), status, message}
15
+ The old API returned: a string message with the progress.
16
+
17
+ Returns the message if set, otherwise formats the progress as a percentage.
18
+ """
19
+ if content.get("message"):
20
+ return content["message"]
21
+ progress = content.get("progress")
22
+ if progress is not None:
23
+ return f"{int(progress * 100)}%"
24
+ return content.get("status", "unknown")
25
+
26
+
27
+ def sync(job_id: str = os.getenv("OS_JOB_ID"), client: Client = None):
28
+ """
29
+ # Get Job Progress
30
+
31
+ Get the progress status of a job. Note the progress status is determined by the job
32
+ and its behavior is dependant on the implementation of the job itself.
33
+
34
+ ## Arguments
35
+ - `job_id`: The running job ID.
36
+ - `client`: The Client with which to connect to Octostar. If None, the default one is used.
37
+
38
+ ## Returns
39
+ A string containing the progress status (usually containing some percentage value).
40
+
41
+ ## Raises
42
+ - `ApiConnectionError`: If the request was unsuccessful on the server.
43
+ """
44
+ response = get_job_progress.sync_detailed(job_id=job_id, client=client)
45
+ if response.status_code != 200:
46
+ raise ApiConnectionError("get_job_progress", response, client)
47
+ content = response.parsed
48
+ if not content:
49
+ raise ApiConnectionError("get_job_progress", response, client)
50
+ return _format_progress_response(content)
51
+
52
+
53
+ async def asyncio(job_id: str = os.getenv("OS_JOB_ID"), client: Client = None):
54
+ """
55
+ # Get Job Progress Asynchronously
56
+
57
+ Get asynchronously the progress status of a job. Note the progress status is determined by the job
58
+ and its behavior is dependant on the implementation of the job itself.
59
+
60
+ ## Arguments
61
+ - `job_id`: The running app/job ID.
62
+ - `client`: The Client with which to connect to Octostar. If None, the default one is used.
63
+
64
+ ## Returns
65
+ A string containing the progress status (usually containing some percentage value).
66
+
67
+ ## Raises
68
+ - `ApiConnectionError`: If the request was unsuccessful on the server.
69
+ """
70
+ response = await get_job_progress.asyncio_detailed(job_id=job_id, client=client)
71
+ if response.status_code != 200:
72
+ raise ApiConnectionError("get_job_progress", response, client)
73
+ content = response.parsed
74
+ if not content:
75
+ raise ApiConnectionError("get_job_progress", response, client)
76
+ return _format_progress_response(content)
@@ -0,0 +1,47 @@
1
+ import logging
2
+
3
+ _logger = logging.getLogger(__name__)
4
+
5
+ from ...api.apps import kill_job
6
+ from ...client import Client
7
+ from ..exceptions import ApiConnectionError
8
+
9
+
10
+ def sync(job_id: str, client: Client = None):
11
+ """
12
+ # Cancel a currently running job
13
+
14
+ ## Arguments
15
+ - `job_id`: The unique job ID to cancel.
16
+ - `client`: The Client with which to connect to Octostar. If None, the default one is used.
17
+
18
+ ## Returns
19
+ An acknowledgment.
20
+
21
+ ## Raises
22
+ - `ApiConnectionError`: If the operation was unsuccessful on the server.
23
+ """
24
+ response = kill_job.sync_detailed(job_id=job_id, client=client)
25
+ if response.status_code != 200:
26
+ raise ApiConnectionError("kill_job", response, client)
27
+ return response.parsed
28
+
29
+
30
+ async def asyncio(job_id: str, client: Client = None):
31
+ """
32
+ # Cancel asynchronously a currently running job
33
+
34
+ ## Arguments
35
+ - `job_id`: The job ID to cancel.
36
+ - `client`: The Client with which to connect to Octostar. If None, the default one is used.
37
+
38
+ ## Returns
39
+ An acknowledgment.
40
+
41
+ ## Raises
42
+ - `ApiConnectionError`: If the operation was unsuccessful on the server.
43
+ """
44
+ response = await kill_job.asyncio_detailed(job_id=job_id, client=client)
45
+ if response.status_code != 200:
46
+ raise ApiConnectionError("kill_job", response, client)
47
+ return response.parsed
@@ -0,0 +1,67 @@
1
+ import os
2
+ import logging
3
+
4
+ _logger = logging.getLogger(__name__)
5
+
6
+ from ...api.apps import set_job_progress
7
+ from ...client import Client
8
+ from ...models.progress_request import ProgressRequest
9
+ from ..exceptions import ApiConnectionError
10
+
11
+
12
+ def sync(
13
+ progress_string: str, job_id: str = os.getenv("OS_JOB_ID"), client: Client = None
14
+ ):
15
+ """
16
+ # Set Job Progress
17
+
18
+ Set or update the progress status of a job.
19
+
20
+ ## Arguments
21
+ - `progress_string`: A string indicative of the progress status.
22
+ - `job_id`: The running job ID.
23
+ - `client`: The Client with which to connect to Octostar. If None, the default one is used.
24
+
25
+ ## Returns
26
+ `True` if progress update was successful.
27
+
28
+ ## Raises
29
+ - `ApiConnectionError`: If the request was unsuccessful on the server.
30
+ """
31
+ response = set_job_progress.sync_detailed(
32
+ job_id=job_id,
33
+ json_body=ProgressRequest(progress=progress_string),
34
+ client=client,
35
+ )
36
+ if response.status_code != 200:
37
+ raise ApiConnectionError("set_job_progress", response, client)
38
+ return True
39
+
40
+
41
+ async def asyncio(
42
+ progress_string: str, job_id: str = os.getenv("OS_JOB_ID"), client: Client = None
43
+ ):
44
+ """
45
+ # Set Job Progress Asynchronously
46
+
47
+ Set or update asynchronously the progress status of a job.
48
+
49
+ ## Arguments
50
+ - `progress_string`: A string indicative of the progress status.
51
+ - `job_id`: The running job ID.
52
+ - `client`: The Client with which to connect to Octostar. If None, the default one is used.
53
+
54
+ ## Returns
55
+ `True` if progress update was successful.
56
+
57
+ ## Raises
58
+ - `ApiConnectionError`: If the request was unsuccessful on the server.
59
+ """
60
+ response = await set_job_progress.asyncio_detailed(
61
+ job_id=job_id,
62
+ json_body=ProgressRequest(progress=progress_string),
63
+ client=client,
64
+ )
65
+ if response.status_code != 200:
66
+ raise ApiConnectionError("set_job_progress", response, client)
67
+ return True
File without changes
@@ -0,0 +1,30 @@
1
+ import os
2
+
3
+ from ...api.metadata import get_version
4
+
5
+
6
+ def sync(client):
7
+ """
8
+ # Get the current Octostar version
9
+
10
+ ## Arguments
11
+ - `client`: The Client with which to connect to Octostar. If None, the default one is used.
12
+
13
+ ## Returns
14
+ The octostar version as a string.
15
+ """
16
+ return get_version.sync_detailed(client=client).parsed
17
+
18
+
19
+ async def asyncio(client):
20
+ """
21
+ # Get asynchronously the current Octostar version
22
+
23
+ ## Arguments
24
+ - `client`: The Client with which to connect to Octostar. If None, the default one is used.
25
+
26
+ ## Returns
27
+ A dictionary containing the username, its signed JWT and a few other info.
28
+ """
29
+ out = get_version.asyncio_detailed(client=client)
30
+ return (await out).parsed
@@ -0,0 +1,30 @@
1
+ import os
2
+
3
+ from ...api.metadata import get_whoami
4
+
5
+
6
+ def sync(client):
7
+ """
8
+ # Get information about the user
9
+
10
+ ## Arguments
11
+ - `client`: The Client with which to connect to Octostar. If None, the default one is used.
12
+
13
+ ## Returns
14
+ A dictionary containing the username, its signed JWT and a few other info.
15
+ """
16
+ return get_whoami.sync_detailed(client=client).parsed
17
+
18
+
19
+ async def asyncio(client):
20
+ """
21
+ # Get asynchronously information about the user
22
+
23
+ ## Arguments
24
+ - `client`: The Client with which to connect to Octostar. If None, the default one is used.
25
+
26
+ ## Returns
27
+ A dictionary containing the username, its signed JWT and a few other info.
28
+ """
29
+ out = get_whoami.asyncio_detailed(client=client)
30
+ return (await out).parsed
File without changes
@@ -0,0 +1,58 @@
1
+ import os
2
+ import logging
3
+
4
+ _logger = logging.getLogger(__name__)
5
+
6
+ from ...api.notifications import delete_stream
7
+ from ...client import Client
8
+ from ..exceptions import ApiConnectionError
9
+
10
+
11
+ def sync(stream_id: str, client: Client = None):
12
+ """
13
+ # Delete Event Stream
14
+
15
+ Deletes an event stream.
16
+
17
+ ## Arguments
18
+ - `stream_id`: The unique ID for the event stream.
19
+ - `client`: The Client with which to connect to Octostar. If None, the default one is used.
20
+
21
+ ## Returns
22
+ `True` if the event stream has been deleted successfully.
23
+
24
+ ## Raises
25
+ - `ApiConnectionError`: If the request was unsuccessful on the server.
26
+ """
27
+ response = delete_stream.sync_detailed(stream_id=stream_id, client=client)
28
+ if response.status_code != 200 or (
29
+ "status" in response.parsed.additional_properties
30
+ and response.parsed.additional_properties["status"] != "success"
31
+ ):
32
+ raise ApiConnectionError("delete_stream", response, client)
33
+ return True
34
+
35
+
36
+ async def asyncio(stream_id: str, client: Client = None):
37
+ """
38
+ # Delete Event Stream Asynchronously
39
+
40
+ Asynchronously deletes an event stream.
41
+
42
+ ## Arguments
43
+ - `stream_id`: The unique ID for the event stream.
44
+ - `client`: The Client with which to connect to Octostar. If None, the default one is used.
45
+
46
+ ## Returns
47
+ `True` if the event stream has been deleted successfully.
48
+
49
+ ## Raises
50
+ - `ApiConnectionError`: If the request was unsuccessful on the server.
51
+ """
52
+ response = await delete_stream.asyncio_detailed(stream_id=stream_id, client=client)
53
+ if response.status_code != 200 or (
54
+ "status" in response.parsed.additional_properties
55
+ and response.parsed.additional_properties["status"] != "success"
56
+ ):
57
+ raise ApiConnectionError("delete_stream", response, client)
58
+ return True
@@ -0,0 +1,49 @@
1
+ import logging
2
+
3
+ _logger = logging.getLogger(__name__)
4
+
5
+ from ...api.notifications import get_subscriptions
6
+ from ...client import Client
7
+ from ..exceptions import ApiConnectionError
8
+
9
+
10
+ def sync(client: Client = None):
11
+ """
12
+ # Get User Subscriptions
13
+
14
+ Retrieves the subscriptions the user is listening to.
15
+
16
+ ## Arguments
17
+ - `client`: The Client with which to connect to Octostar. If None, the default one is used.
18
+
19
+ ## Returns
20
+ A list of subscription IDs.
21
+
22
+ ## Raises
23
+ - `ApiConnectionError`: If the request was unsuccessful on the server.
24
+ """
25
+ response = get_subscriptions.sync_detailed(client=client)
26
+ if response.status_code != 200:
27
+ raise ApiConnectionError("get_my_subscriptions", response, client)
28
+ return response.parsed
29
+
30
+
31
+ async def asyncio(client: Client = None):
32
+ """
33
+ # Get User Subscriptions Asynchronously
34
+
35
+ Asynchronously retrieves the subscriptions the user is listening to.
36
+
37
+ ## Arguments
38
+ - `client`: The Client with which to connect to Octostar. If None, the default one is used.
39
+
40
+ ## Returns
41
+ A list of subscription IDs.
42
+
43
+ ## Raises
44
+ - `ApiConnectionError`: If the request was unsuccessful on the server.
45
+ """
46
+ response = await get_subscriptions.asyncio_detailed(client=client)
47
+ if response.status_code != 200:
48
+ raise ApiConnectionError("get_my_subscriptions", response, client)
49
+ return response.parsed
@@ -0,0 +1,73 @@
1
+ from typing import List, Dict, Any, Union
2
+ import logging
3
+
4
+ _logger = logging.getLogger(__name__)
5
+
6
+ from ...api.notifications import publish_notification as api_publish_notification
7
+ from ...models.os_notification import OsNotification
8
+ from ...client import Client
9
+ from ..exceptions import ApiConnectionError
10
+
11
+
12
+ def sync(
13
+ notification: Union[Dict[str, Any], List[Dict[str, Any]]], client: Client = None
14
+ ):
15
+ """
16
+ # Publishes desktop notifications to specified channels (users).
17
+
18
+ ## Arguments
19
+ - `notification`: One or more notification dictionaries. Each notification should contain:
20
+ - `channel`: Username or channel to send the notification to (required)
21
+ - `title`: Notification title (required)
22
+ - `body`: Notification body text (required)
23
+ - `workspace_id`: Workspace ID related to the notification (optional)
24
+ - `type`: Notification type, e.g., "octostar:desktop:builtins:wso:update" (optional)
25
+ - `expires_at`: ISO 8601 timestamp when notification expires (optional)
26
+ - `client`: The Client with which to connect to Octostar. If None, the default one is used.
27
+
28
+ ## Raises
29
+ - `ApiConnectionError`: If the request was unsuccessful on the server.
30
+ """
31
+ if not isinstance(notification, list):
32
+ notification = [notification]
33
+ default_fields = {"type": "octostar:desktop:builtins:wso:update"}
34
+ notification_objects = [
35
+ OsNotification.from_dict({**default_fields, **notif}) for notif in notification
36
+ ]
37
+ response = api_publish_notification.sync_detailed(
38
+ json_body=notification_objects, client=client
39
+ )
40
+ if response.status_code != 201:
41
+ raise ApiConnectionError("publish_notification", response, client)
42
+
43
+
44
+ async def asyncio(
45
+ notification: Union[Dict[str, Any], List[Dict[str, Any]]], client: Client = None
46
+ ):
47
+ """
48
+ # Publishes asynchronously desktop notifications to specified channels (users).
49
+
50
+ ## Arguments
51
+ - `notification`: One or more notification dictionaries. Each notification should contain:
52
+ - `channel`: Username or channel to send the notification to (required)
53
+ - `title`: Notification title (required)
54
+ - `body`: Notification body text (required)
55
+ - `workspace_id`: Workspace ID related to the notification (optional)
56
+ - `type`: Notification type, e.g., "octostar:desktop:builtins:wso:update" (optional)
57
+ - `expires_at`: ISO 8601 timestamp when notification expires (optional)
58
+ - `client`: The Client with which to connect to Octostar. If None, the default one is used.
59
+
60
+ ## Raises
61
+ - `ApiConnectionError`: If the request was unsuccessful on the server.
62
+ """
63
+ if not isinstance(notification, list):
64
+ notification = [notification]
65
+ default_fields = {"type": "octostar:desktop:builtins:wso:update"}
66
+ notification_objects = [
67
+ OsNotification.from_dict({**default_fields, **notif}) for notif in notification
68
+ ]
69
+ response = await api_publish_notification.asyncio_detailed(
70
+ json_body=notification_objects, client=client
71
+ )
72
+ if response.status_code != 201:
73
+ raise ApiConnectionError("publish_notification", response, client)
@@ -0,0 +1,63 @@
1
+ import logging
2
+
3
+ _logger = logging.getLogger(__name__)
4
+
5
+ from ...api.notifications import pull_events_from_stream
6
+ from ...client import Client
7
+ from ..exceptions import ApiConnectionError
8
+
9
+
10
+ def sync(stream_id: str, client: Client = None):
11
+ """
12
+ # Get Latest Event from Stream
13
+
14
+ Retrieves the latest event in a stream.
15
+
16
+ ## Arguments
17
+ - `stream_id`: The unique ID for the event stream.
18
+ - `client`: The Client with which to connect to Octostar. If None, the default one is used.
19
+
20
+ ## Returns
21
+ An Octostar event instance (containing the event info and contents).
22
+
23
+ ## Raises
24
+ - `ApiConnectionError`: If the request was unsuccessful on the server.
25
+ """
26
+ response = pull_events_from_stream.sync_detailed(
27
+ stream_id=stream_id, count=1, client=client
28
+ )
29
+ if response.status_code != 200:
30
+ raise ApiConnectionError("pull_event_from_stream", response, client)
31
+ events = response.parsed
32
+ if events:
33
+ return events[0]
34
+ else:
35
+ return events
36
+
37
+
38
+ async def asyncio(stream_id: str, client: Client = None):
39
+ """
40
+ # Get Latest Event from Stream Asynchronously
41
+
42
+ Asynchronously retrieves the latest event in a stream.
43
+
44
+ ## Arguments
45
+ - `stream_id`: The unique ID for the event stream.
46
+ - `client`: The Client with which to connect to Octostar. If None, the default one is used.
47
+
48
+ ## Returns
49
+ An Octostar event instance (containing the event info and contents).
50
+
51
+ ## Raises
52
+ - `ApiConnectionError`: If the request was unsuccessful on the server.
53
+ """
54
+ response = await pull_events_from_stream.asyncio_detailed(
55
+ stream_id=stream_id, count=1, client=client
56
+ )
57
+ if response.status_code != 200:
58
+ raise ApiConnectionError("pull_event_from_stream", response, client)
59
+ events = response.parsed
60
+ if events:
61
+ return events[0]
62
+ else:
63
+ return events
@@ -0,0 +1,64 @@
1
+ import logging
2
+
3
+ _logger = logging.getLogger(__name__)
4
+
5
+ from ...api.notifications import pull_events_from_stream
6
+ from ...client import Client
7
+
8
+
9
+ def sync(stream_id: str, count: int = 10, client: Client = None):
10
+ """
11
+ # Get Latest Events from Stream
12
+
13
+ Retrieves the N latest events in a stream. Events are returned in LIFO order.
14
+
15
+ ## Arguments
16
+ - `stream_id`: The unique ID for the event stream.
17
+ - `count`: The number of events to fetch.
18
+ - `client`: The Client with which to connect to Octostar. If None, the default one is used.
19
+
20
+ ## Returns
21
+ A list of Octostar event instances (containing the event info and contents).
22
+
23
+ ## Raises
24
+ - `ConnectionError`: If the request was unsuccessful on the server.
25
+ """
26
+ response = pull_events_from_stream.sync_detailed(
27
+ stream_id=stream_id, count=count, client=client
28
+ )
29
+ if response.status_code != 200:
30
+ logger.error(response.content)
31
+ raise ConnectionError(
32
+ "pull_events_from_stream failed with status code "
33
+ + str(response.status_code)
34
+ )
35
+ return response.parsed
36
+
37
+
38
+ async def asyncio(stream_id: str, count: int = 10, client: Client = None):
39
+ """
40
+ # Get Latest Events from Stream Asynchronously
41
+
42
+ Asynchronously retrieves the N latest events in a stream. Events are returned in LIFO order.
43
+
44
+ ## Arguments
45
+ - `stream_id`: The unique ID for the event stream.
46
+ - `count`: The number of events to fetch.
47
+ - `client`: The Client with which to connect to Octostar. If None, the default one is used.
48
+
49
+ ## Returns
50
+ A list of Octostar event instances (containing the event info and contents).
51
+
52
+ ## Raises
53
+ - `ConnectionError`: If the request was unsuccessful on the server.
54
+ """
55
+ response = await pull_events_from_stream.asyncio_detailed(
56
+ stream_id=stream_id, count=count, client=client
57
+ )
58
+ if response.status_code != 200:
59
+ logger.error(response.content)
60
+ raise ConnectionError(
61
+ "pull_events_from_stream failed with status code "
62
+ + str(response.status_code)
63
+ )
64
+ return response.parsed