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,188 @@
1
+ """Get app URLs from the FastAPI backend."""
2
+
3
+ from http import HTTPStatus
4
+ from typing import Any, Dict, List, Optional
5
+ from warnings import warn
6
+
7
+ import httpx
8
+ import attr
9
+
10
+ from ...client import Client, get_default_client
11
+ from ...types import Response
12
+ from ... import errors
13
+ from ...models.get_apps_url_json_body import GetAppsUrlJsonBody
14
+
15
+
16
+ client_missing_msg = """No client was passed to this function. The default admin client will be used, but this is deprecated and will be removed soon.
17
+ Please create a client using octostar.client.make_client() and run the function via client.execute()."""
18
+
19
+
20
+ @attr.s(auto_attribs=True)
21
+ class AppUrlInfo:
22
+ """URL information for a single app."""
23
+
24
+ app_id: str
25
+ app_url: str
26
+ additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
27
+
28
+ @classmethod
29
+ def from_dict(cls, src_dict: Dict[str, Any]) -> "AppUrlInfo":
30
+ d = src_dict.copy()
31
+ app_id = d.pop("app_id")
32
+ app_url = d.pop("app_url")
33
+ info = cls(app_id=app_id, app_url=app_url)
34
+ info.additional_properties = d
35
+ return info
36
+
37
+
38
+ def _get_kwargs(
39
+ *,
40
+ client: Client = None,
41
+ json_body: GetAppsUrlJsonBody = None,
42
+ ) -> Dict[str, Any]:
43
+ if not client:
44
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
45
+ client = get_default_client()
46
+
47
+ base_url = client.get_base_url_v1()
48
+ url = f"{base_url}/api/v1/apps/urls"
49
+
50
+ headers: Dict[str, str] = client.get_headers()
51
+ headers["Content-Type"] = "application/json"
52
+ cookies: Dict[str, Any] = client.get_cookies()
53
+
54
+ if not json_body:
55
+ raise ValueError("json_body is required for getting app URLs")
56
+
57
+ # Convert to new format
58
+ json_data = {"app_ids": json_body.app_ids}
59
+
60
+ return {
61
+ "method": "post",
62
+ "url": url,
63
+ "headers": headers,
64
+ "cookies": cookies,
65
+ "timeout": client.get_timeout(),
66
+ "follow_redirects": client.follow_redirects,
67
+ "json": json_data,
68
+ }
69
+
70
+
71
+ def _parse_response(
72
+ *, client: Client = None, response: httpx.Response
73
+ ) -> Optional[List[AppUrlInfo]]:
74
+ if not client:
75
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
76
+ client = get_default_client()
77
+
78
+ if response.status_code == HTTPStatus.OK:
79
+ data = response.json()
80
+ urls = data.get("urls", [])
81
+ return [AppUrlInfo.from_dict(item) for item in urls]
82
+ if client.raise_on_unexpected_status:
83
+ raise errors.UnexpectedStatus(response.status_code, response.content)
84
+ return None
85
+
86
+
87
+ def _build_response(
88
+ *, client: Client = None, response: httpx.Response
89
+ ) -> Response[List[AppUrlInfo]]:
90
+ if not client:
91
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
92
+ client = get_default_client()
93
+
94
+ return Response(
95
+ status_code=HTTPStatus(response.status_code),
96
+ content=response.content,
97
+ headers=response.headers,
98
+ parsed=_parse_response(client=client, response=response),
99
+ )
100
+
101
+
102
+ def sync_detailed(
103
+ *,
104
+ client: Client = None,
105
+ json_body: GetAppsUrlJsonBody = None,
106
+ ) -> Response[List[AppUrlInfo]]:
107
+ """Get URLs for multiple apps.
108
+
109
+ Args:
110
+ client: The Client with which to connect to Octostar.
111
+ json_body: GetAppsUrlJsonBody with list of app IDs.
112
+
113
+ Returns:
114
+ Response with list of AppUrlInfo objects.
115
+ """
116
+ if not client:
117
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
118
+ client = get_default_client()
119
+
120
+ kwargs = _get_kwargs(client=client, json_body=json_body)
121
+
122
+ response = httpx.request(verify=client.verify_ssl, **kwargs)
123
+ if response.is_error:
124
+ print(
125
+ f"{response.status_code} Error: {response.text} for request",
126
+ str(kwargs),
127
+ )
128
+ return _build_response(client=client, response=response)
129
+
130
+
131
+ def sync(
132
+ *,
133
+ client: Client = None,
134
+ json_body: GetAppsUrlJsonBody = None,
135
+ ) -> Optional[List[AppUrlInfo]]:
136
+ """Get URLs for multiple apps.
137
+
138
+ Args:
139
+ client: The Client with which to connect to Octostar.
140
+ json_body: GetAppsUrlJsonBody with list of app IDs.
141
+
142
+ Returns:
143
+ List of AppUrlInfo objects or None if request failed.
144
+ """
145
+ return sync_detailed(client=client, json_body=json_body).parsed
146
+
147
+
148
+ async def asyncio_detailed(
149
+ *,
150
+ client: Client = None,
151
+ json_body: GetAppsUrlJsonBody = None,
152
+ ) -> Response[List[AppUrlInfo]]:
153
+ """Get URLs for multiple apps asynchronously.
154
+
155
+ Args:
156
+ client: The Client with which to connect to Octostar.
157
+ json_body: GetAppsUrlJsonBody with list of app IDs.
158
+
159
+ Returns:
160
+ Response with list of AppUrlInfo objects.
161
+ """
162
+ if not client:
163
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
164
+ client = get_default_client()
165
+
166
+ kwargs = _get_kwargs(client=client, json_body=json_body)
167
+
168
+ async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
169
+ response = await _client.request(**kwargs)
170
+
171
+ return _build_response(client=client, response=response)
172
+
173
+
174
+ async def asyncio(
175
+ *,
176
+ client: Client = None,
177
+ json_body: GetAppsUrlJsonBody = None,
178
+ ) -> Optional[List[AppUrlInfo]]:
179
+ """Get URLs for multiple apps asynchronously.
180
+
181
+ Args:
182
+ client: The Client with which to connect to Octostar.
183
+ json_body: GetAppsUrlJsonBody with list of app IDs.
184
+
185
+ Returns:
186
+ List of AppUrlInfo objects or None if request failed.
187
+ """
188
+ return (await asyncio_detailed(client=client, json_body=json_body)).parsed
@@ -0,0 +1,210 @@
1
+ """Get job logs from the FastAPI backend."""
2
+
3
+ from http import HTTPStatus
4
+ from typing import Any, Dict, Optional, Union
5
+ from warnings import warn
6
+
7
+ import httpx
8
+
9
+ from ...client import Client, get_default_client
10
+ from ...types import Response, UNSET, Unset
11
+ from ... import errors
12
+
13
+
14
+ client_missing_msg = """No client was passed to this function. The default admin client will be used, but this is deprecated and will be removed soon.
15
+ Please create a client using octostar.client.make_client() and run the function via client.execute()."""
16
+
17
+
18
+ def _get_kwargs(
19
+ job_id: str,
20
+ *,
21
+ client: Client = None,
22
+ since_seconds: Union[Unset, None, int] = UNSET,
23
+ tail_lines: Union[Unset, None, int] = UNSET,
24
+ ) -> Dict[str, Any]:
25
+ if not client:
26
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
27
+ client = get_default_client()
28
+
29
+ base_url = client.get_base_url_v1()
30
+ url = f"{base_url}/api/v1/apps/jobs/{job_id}/logs"
31
+
32
+ headers: Dict[str, str] = client.get_headers()
33
+ cookies: Dict[str, Any] = client.get_cookies()
34
+
35
+ params: Dict[str, Any] = {}
36
+ if not isinstance(since_seconds, Unset) and since_seconds is not None:
37
+ params["since_seconds"] = since_seconds
38
+ if not isinstance(tail_lines, Unset) and tail_lines is not None:
39
+ params["tail_lines"] = tail_lines
40
+
41
+ return {
42
+ "method": "get",
43
+ "url": url,
44
+ "headers": headers,
45
+ "cookies": cookies,
46
+ "params": params,
47
+ "timeout": client.get_timeout(),
48
+ "follow_redirects": client.follow_redirects,
49
+ }
50
+
51
+
52
+ def _parse_response(
53
+ *, client: Client = None, response: httpx.Response
54
+ ) -> Optional[bytes]:
55
+ """Parse response - returns raw bytes for log content."""
56
+ if not client:
57
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
58
+ client = get_default_client()
59
+
60
+ if response.status_code == HTTPStatus.OK:
61
+ return response.content
62
+ if client.raise_on_unexpected_status:
63
+ raise errors.UnexpectedStatus(response.status_code, response.content)
64
+ return None
65
+
66
+
67
+ def _build_response(
68
+ *, client: Client = None, response: httpx.Response
69
+ ) -> Response[bytes]:
70
+ if not client:
71
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
72
+ client = get_default_client()
73
+
74
+ return Response(
75
+ status_code=HTTPStatus(response.status_code),
76
+ content=response.content,
77
+ headers=response.headers,
78
+ parsed=_parse_response(client=client, response=response),
79
+ )
80
+
81
+
82
+ def sync_detailed(
83
+ job_id: str,
84
+ *,
85
+ client: Client = None,
86
+ since_seconds: Union[Unset, None, int] = UNSET,
87
+ tail_lines: Union[Unset, None, int] = UNSET,
88
+ ) -> Response[bytes]:
89
+ """Get job logs.
90
+
91
+ Args:
92
+ job_id: The job ID to get logs for.
93
+ client: The Client with which to connect to Octostar.
94
+ since_seconds: Only return logs from the last N seconds.
95
+ tail_lines: Only return the last N lines.
96
+
97
+ Returns:
98
+ Response with raw log content in bytes.
99
+ """
100
+ if not client:
101
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
102
+ client = get_default_client()
103
+
104
+ kwargs = _get_kwargs(
105
+ job_id=job_id,
106
+ client=client,
107
+ since_seconds=since_seconds,
108
+ tail_lines=tail_lines,
109
+ )
110
+
111
+ response = httpx.request(verify=client.verify_ssl, **kwargs)
112
+ if response.is_error:
113
+ print(
114
+ f"{response.status_code} Error: {response.text} for request",
115
+ str(kwargs),
116
+ )
117
+ return _build_response(client=client, response=response)
118
+
119
+
120
+ def sync(
121
+ job_id: str,
122
+ *,
123
+ client: Client = None,
124
+ since_seconds: Union[Unset, None, int] = UNSET,
125
+ tail_lines: Union[Unset, None, int] = UNSET,
126
+ ) -> Optional[bytes]:
127
+ """Get job logs.
128
+
129
+ Args:
130
+ job_id: The job ID to get logs for.
131
+ client: The Client with which to connect to Octostar.
132
+ since_seconds: Only return logs from the last N seconds.
133
+ tail_lines: Only return the last N lines.
134
+
135
+ Returns:
136
+ Raw log content or None if request failed.
137
+ """
138
+ response = sync_detailed(
139
+ job_id=job_id,
140
+ client=client,
141
+ since_seconds=since_seconds,
142
+ tail_lines=tail_lines,
143
+ )
144
+ if response.status_code == HTTPStatus.OK:
145
+ return response.content
146
+ return None
147
+
148
+
149
+ async def asyncio_detailed(
150
+ job_id: str,
151
+ *,
152
+ client: Client = None,
153
+ since_seconds: Union[Unset, None, int] = UNSET,
154
+ tail_lines: Union[Unset, None, int] = UNSET,
155
+ ) -> Response[bytes]:
156
+ """Get job logs asynchronously.
157
+
158
+ Args:
159
+ job_id: The job ID to get logs for.
160
+ client: The Client with which to connect to Octostar.
161
+ since_seconds: Only return logs from the last N seconds.
162
+ tail_lines: Only return the last N lines.
163
+
164
+ Returns:
165
+ Response with raw log content.
166
+ """
167
+ if not client:
168
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
169
+ client = get_default_client()
170
+
171
+ kwargs = _get_kwargs(
172
+ job_id=job_id,
173
+ client=client,
174
+ since_seconds=since_seconds,
175
+ tail_lines=tail_lines,
176
+ )
177
+
178
+ async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
179
+ response = await _client.request(**kwargs)
180
+
181
+ return _build_response(client=client, response=response)
182
+
183
+
184
+ async def asyncio(
185
+ job_id: str,
186
+ *,
187
+ client: Client = None,
188
+ since_seconds: Union[Unset, None, int] = UNSET,
189
+ tail_lines: Union[Unset, None, int] = UNSET,
190
+ ) -> Optional[bytes]:
191
+ """Get job logs asynchronously.
192
+
193
+ Args:
194
+ job_id: The job ID to get logs for.
195
+ client: The Client with which to connect to Octostar.
196
+ since_seconds: Only return logs from the last N seconds.
197
+ tail_lines: Only return the last N lines.
198
+
199
+ Returns:
200
+ Raw log content or None if request failed.
201
+ """
202
+ response = await asyncio_detailed(
203
+ job_id=job_id,
204
+ client=client,
205
+ since_seconds=since_seconds,
206
+ tail_lines=tail_lines,
207
+ )
208
+ if response.status_code == HTTPStatus.OK:
209
+ return response.content
210
+ return None
@@ -0,0 +1,162 @@
1
+ """Get job progress from the FastAPI backend."""
2
+
3
+ from http import HTTPStatus
4
+ from typing import Any, Dict, Optional
5
+ from warnings import warn
6
+
7
+ import httpx
8
+
9
+ from ...client import Client, get_default_client
10
+ from ...types import Response
11
+ from ... import errors
12
+
13
+
14
+ client_missing_msg = """No client was passed to this function. The default admin client will be used, but this is deprecated and will be removed soon.
15
+ Please create a client using octostar.client.make_client() and run the function via client.execute()."""
16
+
17
+
18
+ def _get_kwargs(
19
+ job_id: str,
20
+ *,
21
+ client: Client = None,
22
+ ) -> Dict[str, Any]:
23
+ if not client:
24
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
25
+ client = get_default_client()
26
+
27
+ base_url = client.get_base_url_v1()
28
+ url = f"{base_url}/api/v1/apps/jobs/{job_id}/progress"
29
+
30
+ headers: Dict[str, str] = client.get_headers()
31
+ cookies: Dict[str, Any] = client.get_cookies()
32
+
33
+ return {
34
+ "method": "get",
35
+ "url": url,
36
+ "headers": headers,
37
+ "cookies": cookies,
38
+ "timeout": client.get_timeout(),
39
+ "follow_redirects": client.follow_redirects,
40
+ }
41
+
42
+
43
+ def _parse_response(
44
+ *, client: Client = None, response: httpx.Response
45
+ ) -> Optional[Dict[str, Any]]:
46
+ if not client:
47
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
48
+ client = get_default_client()
49
+
50
+ if response.status_code == HTTPStatus.OK:
51
+ return response.json()
52
+ if client.raise_on_unexpected_status:
53
+ raise errors.UnexpectedStatus(response.status_code, response.content)
54
+ return None
55
+
56
+
57
+ def _build_response(
58
+ *, client: Client = None, response: httpx.Response
59
+ ) -> Response[Dict[str, Any]]:
60
+ if not client:
61
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
62
+ client = get_default_client()
63
+
64
+ return Response(
65
+ status_code=HTTPStatus(response.status_code),
66
+ content=response.content,
67
+ headers=response.headers,
68
+ parsed=_parse_response(client=client, response=response),
69
+ )
70
+
71
+
72
+ def sync_detailed(
73
+ job_id: str,
74
+ *,
75
+ client: Client = None,
76
+ ) -> Response[Dict[str, Any]]:
77
+ """Get job progress.
78
+
79
+ Args:
80
+ job_id: The job ID to get progress for.
81
+ client: The Client with which to connect to Octostar.
82
+
83
+ Returns:
84
+ Response with job progress data including:
85
+ - job_id: The job ID
86
+ - progress: Progress value (0.0 to 1.0), or None if not set
87
+ - status: Job status
88
+ - message: Optional progress message
89
+ """
90
+ if not client:
91
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
92
+ client = get_default_client()
93
+
94
+ kwargs = _get_kwargs(job_id=job_id, client=client)
95
+
96
+ response = httpx.request(verify=client.verify_ssl, **kwargs)
97
+ if response.is_error:
98
+ print(
99
+ f"{response.status_code} Error: {response.text} for request",
100
+ str(kwargs),
101
+ )
102
+ return _build_response(client=client, response=response)
103
+
104
+
105
+ def sync(
106
+ job_id: str,
107
+ *,
108
+ client: Client = None,
109
+ ) -> Optional[Dict[str, Any]]:
110
+ """Get job progress.
111
+
112
+ Args:
113
+ job_id: The job ID to get progress for.
114
+ client: The Client with which to connect to Octostar.
115
+
116
+ Returns:
117
+ Job progress data or None if request failed.
118
+ """
119
+ return sync_detailed(job_id=job_id, client=client).parsed
120
+
121
+
122
+ async def asyncio_detailed(
123
+ job_id: str,
124
+ *,
125
+ client: Client = None,
126
+ ) -> Response[Dict[str, Any]]:
127
+ """Get job progress asynchronously.
128
+
129
+ Args:
130
+ job_id: The job ID to get progress for.
131
+ client: The Client with which to connect to Octostar.
132
+
133
+ Returns:
134
+ Response with job progress data.
135
+ """
136
+ if not client:
137
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
138
+ client = get_default_client()
139
+
140
+ kwargs = _get_kwargs(job_id=job_id, client=client)
141
+
142
+ async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
143
+ response = await _client.request(**kwargs)
144
+
145
+ return _build_response(client=client, response=response)
146
+
147
+
148
+ async def asyncio(
149
+ job_id: str,
150
+ *,
151
+ client: Client = None,
152
+ ) -> Optional[Dict[str, Any]]:
153
+ """Get job progress asynchronously.
154
+
155
+ Args:
156
+ job_id: The job ID to get progress for.
157
+ client: The Client with which to connect to Octostar.
158
+
159
+ Returns:
160
+ Job progress data or None if request failed.
161
+ """
162
+ return (await asyncio_detailed(job_id=job_id, client=client)).parsed
@@ -0,0 +1,160 @@
1
+ """Kill a job via the FastAPI backend."""
2
+
3
+ from http import HTTPStatus
4
+ from typing import Any, Dict, Optional
5
+ from warnings import warn
6
+
7
+ import httpx
8
+
9
+ from ...client import Client, get_default_client
10
+ from ...types import Response
11
+ from ... import errors
12
+
13
+
14
+ client_missing_msg = """No client was passed to this function. The default admin client will be used, but this is deprecated and will be removed soon.
15
+ Please create a client using octostar.client.make_client() and run the function via client.execute()."""
16
+
17
+
18
+ def _get_kwargs(
19
+ job_id: str,
20
+ *,
21
+ client: Client = None,
22
+ ) -> Dict[str, Any]:
23
+ if not client:
24
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
25
+ client = get_default_client()
26
+
27
+ base_url = client.get_base_url_v1()
28
+ url = f"{base_url}/api/v1/apps/jobs/{job_id}"
29
+
30
+ headers: Dict[str, str] = client.get_headers()
31
+ cookies: Dict[str, Any] = client.get_cookies()
32
+
33
+ return {
34
+ "method": "delete",
35
+ "url": url,
36
+ "headers": headers,
37
+ "cookies": cookies,
38
+ "timeout": client.get_timeout(),
39
+ "follow_redirects": client.follow_redirects,
40
+ }
41
+
42
+
43
+ def _parse_response(
44
+ *, client: Client = None, response: httpx.Response
45
+ ) -> Optional[Dict[str, Any]]:
46
+ if not client:
47
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
48
+ client = get_default_client()
49
+
50
+ if response.status_code == HTTPStatus.OK:
51
+ return response.json()
52
+ if client.raise_on_unexpected_status:
53
+ raise errors.UnexpectedStatus(response.status_code, response.content)
54
+ return None
55
+
56
+
57
+ def _build_response(
58
+ *, client: Client = None, response: httpx.Response
59
+ ) -> Response[Dict[str, Any]]:
60
+ if not client:
61
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
62
+ client = get_default_client()
63
+
64
+ return Response(
65
+ status_code=HTTPStatus(response.status_code),
66
+ content=response.content,
67
+ headers=response.headers,
68
+ parsed=_parse_response(client=client, response=response),
69
+ )
70
+
71
+
72
+ def sync_detailed(
73
+ job_id: str,
74
+ *,
75
+ client: Client = None,
76
+ ) -> Response[Dict[str, Any]]:
77
+ """Kill a running job.
78
+
79
+ Args:
80
+ job_id: The job ID to kill.
81
+ client: The Client with which to connect to Octostar.
82
+
83
+ Returns:
84
+ Response with kill confirmation including:
85
+ - status: Operation status
86
+ - job_id: The killed job ID
87
+ """
88
+ if not client:
89
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
90
+ client = get_default_client()
91
+
92
+ kwargs = _get_kwargs(job_id=job_id, client=client)
93
+
94
+ response = httpx.request(verify=client.verify_ssl, **kwargs)
95
+ if response.is_error:
96
+ print(
97
+ f"{response.status_code} Error: {response.text} for request",
98
+ str(kwargs),
99
+ )
100
+ return _build_response(client=client, response=response)
101
+
102
+
103
+ def sync(
104
+ job_id: str,
105
+ *,
106
+ client: Client = None,
107
+ ) -> Optional[Dict[str, Any]]:
108
+ """Kill a running job.
109
+
110
+ Args:
111
+ job_id: The job ID to kill.
112
+ client: The Client with which to connect to Octostar.
113
+
114
+ Returns:
115
+ Kill confirmation data or None if request failed.
116
+ """
117
+ return sync_detailed(job_id=job_id, client=client).parsed
118
+
119
+
120
+ async def asyncio_detailed(
121
+ job_id: str,
122
+ *,
123
+ client: Client = None,
124
+ ) -> Response[Dict[str, Any]]:
125
+ """Kill a running job asynchronously.
126
+
127
+ Args:
128
+ job_id: The job ID to kill.
129
+ client: The Client with which to connect to Octostar.
130
+
131
+ Returns:
132
+ Response with kill confirmation.
133
+ """
134
+ if not client:
135
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
136
+ client = get_default_client()
137
+
138
+ kwargs = _get_kwargs(job_id=job_id, client=client)
139
+
140
+ async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
141
+ response = await _client.request(**kwargs)
142
+
143
+ return _build_response(client=client, response=response)
144
+
145
+
146
+ async def asyncio(
147
+ job_id: str,
148
+ *,
149
+ client: Client = None,
150
+ ) -> Optional[Dict[str, Any]]:
151
+ """Kill a running job asynchronously.
152
+
153
+ Args:
154
+ job_id: The job ID to kill.
155
+ client: The Client with which to connect to Octostar.
156
+
157
+ Returns:
158
+ Kill confirmation data or None if request failed.
159
+ """
160
+ return (await asyncio_detailed(job_id=job_id, client=client)).parsed