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,297 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, Dict, List, Optional, Union, cast
3
+ from warnings import warn
4
+
5
+ import httpx
6
+
7
+ from ...client import AuthenticatedClient, Client, get_default_client
8
+ from ...types import Response, UNSET
9
+ from ... import errors
10
+
11
+ from ...models.multi_query_response_400 import MultiQueryResponse400
12
+ from ...models.multi_query_json_body import MultiQueryJsonBody
13
+ from ...models.multi_query_response_401 import MultiQueryResponse401
14
+ from typing import cast
15
+ from typing import Dict
16
+
17
+
18
+ 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.
19
+ Please create a client using octostar.client.make_client() and run the function via client.execute()."""
20
+
21
+
22
+ def _get_kwargs(
23
+ *,
24
+ client: Client = None,
25
+ json_body: MultiQueryJsonBody,
26
+ ontology: str,
27
+ ) -> Dict[str, Any]:
28
+ if not client:
29
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
30
+ client = get_default_client()
31
+ # raise RuntimeError("Missing client!")
32
+
33
+ base_url = client.get_base_url_v1()
34
+ url = "{}/api/v1/ontology/multi_query".format(base_url)
35
+
36
+ headers: Dict[str, str] = client.get_headers()
37
+ cookies: Dict[str, Any] = client.get_cookies()
38
+
39
+ params: Dict[str, Any] = {}
40
+ params["ontology"] = ontology
41
+
42
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
43
+
44
+ json_json_body = json_body.to_dict()
45
+
46
+ return {
47
+ "method": "post",
48
+ "url": url,
49
+ "headers": headers,
50
+ "cookies": cookies,
51
+ "timeout": client.get_timeout(),
52
+ "follow_redirects": client.follow_redirects,
53
+ "json": json_json_body,
54
+ "params": params,
55
+ }
56
+
57
+
58
+ def _parse_response(
59
+ *, client: Client = None, response: httpx.Response
60
+ ) -> Optional[Union[MultiQueryResponse400, MultiQueryResponse401]]:
61
+ if not client:
62
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
63
+ client = get_default_client()
64
+ # raise RuntimeError("Missing client!")
65
+ if response.status_code == HTTPStatus.OK:
66
+ # multi_query returns NDJSON (streaming), not a single JSON object
67
+ response_200 = cast(Any, response.text)
68
+ return response_200
69
+ if response.status_code == HTTPStatus.BAD_REQUEST:
70
+ response_400 = MultiQueryResponse400.from_dict(response.json())
71
+
72
+ return response_400
73
+ if response.status_code == HTTPStatus.UNAUTHORIZED:
74
+ response_401 = MultiQueryResponse401.from_dict(response.json())
75
+
76
+ return response_401
77
+ if client.raise_on_unexpected_status:
78
+ raise errors.UnexpectedStatus(response.status_code, response.content)
79
+ else:
80
+ return None
81
+
82
+
83
+ def _build_response(
84
+ *, client: Client = None, response: httpx.Response
85
+ ) -> Response[Union[MultiQueryResponse400, MultiQueryResponse401]]:
86
+ if not client:
87
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
88
+ client = get_default_client()
89
+ # raise RuntimeError("Missing client!")
90
+ response_kwargs = {
91
+ "status_code": HTTPStatus(response.status_code),
92
+ "content": response.content,
93
+ "headers": response.headers,
94
+ "parsed": _parse_response(client=client, response=response),
95
+ }
96
+ return Response(**response_kwargs)
97
+
98
+
99
+ def _build_chunk_response(
100
+ *, client: Client = None, response: httpx.Response, chunk: bytes
101
+ ) -> Response[Union[MultiQueryResponse400, MultiQueryResponse401]]:
102
+ if not client:
103
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
104
+ client = get_default_client()
105
+ # raise RuntimeError("Missing client!")
106
+ response_kwargs = {
107
+ "status_code": HTTPStatus(response.status_code),
108
+ "content": chunk,
109
+ "headers": response.headers,
110
+ "parsed": None, # cannot parse incomplete chunks of data, we leave it to the user
111
+ }
112
+ return Response(**response_kwargs)
113
+
114
+
115
+ def sync_detailed(
116
+ *,
117
+ client: Client = None,
118
+ json_body: MultiQueryJsonBody,
119
+ ontology: str,
120
+ ) -> Response[Union[MultiQueryResponse400, MultiQueryResponse401]]:
121
+ """## Execute a batch of SQL queries
122
+
123
+ This operation will execute the provided SQL queries as a batch
124
+
125
+ ### Args:
126
+ * `ontology`: ontology (str):
127
+ * `json_body`: json_body (MultiQueryJsonBody): The SQL queries to be executed
128
+
129
+ ### Raises:
130
+ * `errors.UnexpectedStatus`: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
131
+ * `httpx.TimeoutException`: If the request takes longer than Client.timeout.
132
+
133
+ ## Returns:
134
+ * `Response[Union[MultiQueryResponse400, MultiQueryResponse401]]`
135
+ """
136
+
137
+ if not client:
138
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
139
+ client = get_default_client()
140
+ # raise RuntimeError("Missing client!")
141
+ kwargs = _get_kwargs(
142
+ client=client,
143
+ json_body=json_body,
144
+ ontology=ontology,
145
+ )
146
+
147
+ response = httpx.request(
148
+ verify=client.verify_ssl,
149
+ **kwargs,
150
+ )
151
+ if response.is_error:
152
+ print(
153
+ f"{str(response.status_code)} Error: {response.text} for request",
154
+ str(kwargs),
155
+ )
156
+ return _build_response(client=client, response=response)
157
+
158
+
159
+ def sync(
160
+ *,
161
+ client: Client = None,
162
+ json_body: MultiQueryJsonBody,
163
+ ontology: str,
164
+ ) -> Optional[Union[MultiQueryResponse400, MultiQueryResponse401]]:
165
+ """## Execute a batch of SQL queries
166
+
167
+ This operation will execute the provided SQL queries as a batch
168
+
169
+ ### Args:
170
+ * `ontology`: ontology (str):
171
+ * `json_body`: json_body (MultiQueryJsonBody): The SQL queries to be executed
172
+
173
+ ### Raises:
174
+ * `errors.UnexpectedStatus`: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
175
+ * `httpx.TimeoutException`: If the request takes longer than Client.timeout.
176
+
177
+ ## Returns:
178
+ * `Union[MultiQueryResponse400, MultiQueryResponse401]`
179
+ """
180
+
181
+ return sync_detailed(
182
+ client=client,
183
+ json_body=json_body,
184
+ ontology=ontology,
185
+ ).parsed
186
+
187
+
188
+ async def asyncio_detailed(
189
+ *,
190
+ client: Client = None,
191
+ json_body: MultiQueryJsonBody,
192
+ ontology: str,
193
+ ) -> Response[Union[MultiQueryResponse400, MultiQueryResponse401]]:
194
+ """## Execute a batch of SQL queries
195
+
196
+ This operation will execute the provided SQL queries as a batch
197
+
198
+ ### Args:
199
+ * `ontology`: ontology (str):
200
+ * `json_body`: json_body (MultiQueryJsonBody): The SQL queries to be executed
201
+
202
+ ### Raises:
203
+ * `errors.UnexpectedStatus`: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
204
+ * `httpx.TimeoutException`: If the request takes longer than Client.timeout.
205
+
206
+ ## Returns:
207
+ * `Response[Union[MultiQueryResponse400, MultiQueryResponse401]]`
208
+ """
209
+
210
+ if not client:
211
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
212
+ client = get_default_client()
213
+ # raise RuntimeError("Missing client!")
214
+ kwargs = _get_kwargs(
215
+ client=client,
216
+ json_body=json_body,
217
+ ontology=ontology,
218
+ )
219
+
220
+ async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
221
+ response = await _client.request(**kwargs)
222
+
223
+ return _build_response(client=client, response=response)
224
+
225
+
226
+ async def asyncio(
227
+ *,
228
+ client: Client = None,
229
+ json_body: MultiQueryJsonBody,
230
+ ontology: str,
231
+ ) -> Optional[Union[MultiQueryResponse400, MultiQueryResponse401]]:
232
+ """## Execute a batch of SQL queries
233
+
234
+ This operation will execute the provided SQL queries as a batch
235
+
236
+ ### Args:
237
+ * `ontology`: ontology (str):
238
+ * `json_body`: json_body (MultiQueryJsonBody): The SQL queries to be executed
239
+
240
+ ### Raises:
241
+ * `errors.UnexpectedStatus`: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
242
+ * `httpx.TimeoutException`: If the request takes longer than Client.timeout.
243
+
244
+ ## Returns:
245
+ * `Union[MultiQueryResponse400, MultiQueryResponse401]`
246
+ """
247
+
248
+ return (
249
+ await asyncio_detailed(
250
+ client=client,
251
+ json_body=json_body,
252
+ ontology=ontology,
253
+ )
254
+ ).parsed
255
+
256
+
257
+ from collections.abc import AsyncIterator
258
+
259
+
260
+ async def streaming_detailed(
261
+ *,
262
+ client: Client = None,
263
+ json_body: MultiQueryJsonBody,
264
+ ontology: str,
265
+ ) -> AsyncIterator[Response[Union[MultiQueryResponse400, MultiQueryResponse401]]]:
266
+ """## Execute a batch of SQL queries
267
+
268
+ This operation will execute the provided SQL queries as a batch
269
+
270
+ ### Args:
271
+ * `ontology`: ontology (str):
272
+ * `json_body`: json_body (MultiQueryJsonBody): The SQL queries to be executed
273
+
274
+ ### Raises:
275
+ * `errors.UnexpectedStatus`: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
276
+ * `httpx.TimeoutException`: If the request takes longer than Client.timeout.
277
+
278
+ ## Returns:
279
+ * `Response[Union[MultiQueryResponse400, MultiQueryResponse401]]`
280
+ """
281
+
282
+ if not client:
283
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
284
+ client = get_default_client()
285
+
286
+ kwargs = _get_kwargs(
287
+ client=client,
288
+ json_body=json_body,
289
+ ontology=ontology,
290
+ )
291
+
292
+ async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
293
+ async with _client.stream(**kwargs) as response:
294
+ async for chunk in response.aiter_bytes():
295
+ yield _build_chunk_response(
296
+ client=client, response=response, chunk=chunk
297
+ )
@@ -0,0 +1,276 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, Dict, List, Optional, Union, cast
3
+ from warnings import warn
4
+ import uuid
5
+
6
+ import httpx
7
+
8
+ from ...client import AuthenticatedClient, Client, get_default_client
9
+ from ...types import Response, UNSET, Unset
10
+ from ... import errors
11
+ from ...models.query_response_400 import QueryResponse400
12
+ from ...models.query_response_401 import QueryResponse401
13
+ from ...models.query_json_body import QueryJsonBody
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
+ def _get_kwargs(
21
+ *,
22
+ client: Client = None,
23
+ json_body: QueryJsonBody,
24
+ ontology: str,
25
+ accept: Union[Unset, str] = "application/json",
26
+ ) -> Dict[str, Any]:
27
+ if not client:
28
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
29
+ client = get_default_client()
30
+ # raise RuntimeError("Missing client!")
31
+
32
+ base_url = client.get_base_url_v1()
33
+ url = "{}/api/v1/ontology/query".format(base_url)
34
+
35
+ headers: Dict[str, str] = client.get_headers()
36
+ cookies: Dict[str, Any] = client.get_cookies()
37
+
38
+ if not isinstance(accept, Unset):
39
+ headers["Accept"] = accept
40
+
41
+ params: Dict[str, Any] = {}
42
+ params["ontology"] = ontology
43
+
44
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
45
+
46
+ # Translate SDK format to API format:
47
+ # SDK uses {"query": "..."}, API expects {"query_id": "...", "sql": "..."}
48
+ sdk_body = json_body.to_dict()
49
+ json_json_body = {
50
+ "query_id": uuid.uuid4().hex[:12], # Generate 12-char hex query_id
51
+ "sql": sdk_body.get("query", ""), # Translate 'query' to 'sql'
52
+ }
53
+ # Preserve any additional params from SDK
54
+ if sdk_body.get("params"):
55
+ json_json_body["params"] = sdk_body["params"]
56
+
57
+ return {
58
+ "method": "post",
59
+ "url": url,
60
+ "headers": headers,
61
+ "cookies": cookies,
62
+ "timeout": client.get_timeout(),
63
+ "follow_redirects": client.follow_redirects,
64
+ "json": json_json_body,
65
+ "params": params,
66
+ }
67
+
68
+
69
+ def _parse_response(
70
+ *, client: Client = None, response: httpx.Response
71
+ ) -> Optional[Union[Dict[str, Any], QueryResponse400, QueryResponse401]]:
72
+ if not client:
73
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
74
+ client = get_default_client()
75
+ # raise RuntimeError("Missing client!")
76
+ if response.status_code == HTTPStatus.OK:
77
+ # Success case - return the query results as a dict
78
+ return response.json()
79
+ if response.status_code == HTTPStatus.BAD_REQUEST:
80
+ response_400 = QueryResponse400.from_dict(response.json())
81
+
82
+ return response_400
83
+ if response.status_code == HTTPStatus.UNAUTHORIZED:
84
+ response_401 = QueryResponse401.from_dict(response.json())
85
+
86
+ return response_401
87
+ if client.raise_on_unexpected_status:
88
+ raise errors.UnexpectedStatus(response.status_code, response.content)
89
+ else:
90
+ return None
91
+
92
+
93
+ def _build_response(
94
+ *, client: Client = None, response: httpx.Response
95
+ ) -> Response[Union[Dict[str, Any], QueryResponse400, QueryResponse401]]:
96
+ if not client:
97
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
98
+ client = get_default_client()
99
+ # raise RuntimeError("Missing client!")
100
+ response_kwargs = {
101
+ "status_code": HTTPStatus(response.status_code),
102
+ "content": response.content,
103
+ "headers": response.headers,
104
+ "parsed": _parse_response(client=client, response=response),
105
+ }
106
+ return Response(**response_kwargs)
107
+
108
+
109
+ def _build_chunk_response(
110
+ *, client: Client = None, response: httpx.Response, chunk: bytes
111
+ ) -> Response[Union[Dict[str, Any], QueryResponse400, QueryResponse401]]:
112
+ if not client:
113
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
114
+ client = get_default_client()
115
+ # raise RuntimeError("Missing client!")
116
+ response_kwargs = {
117
+ "status_code": HTTPStatus(response.status_code),
118
+ "content": chunk,
119
+ "headers": response.headers,
120
+ "parsed": None, # cannot parse incomplete chunks of data, we leave it to the user
121
+ }
122
+ return Response(**response_kwargs)
123
+
124
+
125
+ def sync_detailed(
126
+ *,
127
+ client: Client = None,
128
+ json_body: QueryJsonBody,
129
+ ontology: str,
130
+ accept: Union[Unset, str] = "application/json",
131
+ ) -> Response[Union[Dict[str, Any], QueryResponse400, QueryResponse401]]:
132
+ """## Execute SQL query
133
+
134
+ This operation will execute the provided SQL query
135
+
136
+ ### Args:
137
+ * `ontology`: ontology (str):
138
+ * `Accept`: accept (Union[Unset, str]): Default: 'application/json'.
139
+ * `json_body`: json_body (QueryJsonBody): The SQL query to be executed
140
+
141
+ ### Raises:
142
+ * `errors.UnexpectedStatus`: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
143
+ * `httpx.TimeoutException`: If the request takes longer than Client.timeout.
144
+
145
+ ## Returns:
146
+ * `Response[Union[Dict[str, Any], QueryResponse400, QueryResponse401]]`
147
+ """
148
+
149
+ if not client:
150
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
151
+ client = get_default_client()
152
+ # raise RuntimeError("Missing client!")
153
+ kwargs = _get_kwargs(
154
+ client=client,
155
+ json_body=json_body,
156
+ ontology=ontology,
157
+ accept=accept,
158
+ )
159
+
160
+ response = httpx.request(
161
+ verify=client.verify_ssl,
162
+ **kwargs,
163
+ )
164
+ if response.is_error:
165
+ print(
166
+ f"{str(response.status_code)} Error: {response.text} for request",
167
+ str(kwargs),
168
+ )
169
+ return _build_response(client=client, response=response)
170
+
171
+
172
+ def sync(
173
+ *,
174
+ client: Client = None,
175
+ json_body: QueryJsonBody,
176
+ ontology: str,
177
+ accept: Union[Unset, str] = "application/json",
178
+ ) -> Optional[Union[Dict[str, Any], QueryResponse400, QueryResponse401]]:
179
+ """## Execute SQL query
180
+
181
+ This operation will execute the provided SQL query
182
+
183
+ ### Args:
184
+ * `ontology`: ontology (str):
185
+ * `Accept`: accept (Union[Unset, str]): Default: 'application/json'.
186
+ * `json_body`: json_body (QueryJsonBody): The SQL query to be executed
187
+
188
+ ### Raises:
189
+ * `errors.UnexpectedStatus`: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
190
+ * `httpx.TimeoutException`: If the request takes longer than Client.timeout.
191
+
192
+ ## Returns:
193
+ * `Union[Dict[str, Any], QueryResponse400, QueryResponse401]`
194
+ """
195
+
196
+ return sync_detailed(
197
+ client=client,
198
+ json_body=json_body,
199
+ ontology=ontology,
200
+ accept=accept,
201
+ ).parsed
202
+
203
+
204
+ async def asyncio_detailed(
205
+ *,
206
+ client: Client = None,
207
+ json_body: QueryJsonBody,
208
+ ontology: str,
209
+ accept: Union[Unset, str] = "application/json",
210
+ ) -> Response[Union[Dict[str, Any], QueryResponse400, QueryResponse401]]:
211
+ """## Execute SQL query
212
+
213
+ This operation will execute the provided SQL query
214
+
215
+ ### Args:
216
+ * `ontology`: ontology (str):
217
+ * `Accept`: accept (Union[Unset, str]): Default: 'application/json'.
218
+ * `json_body`: json_body (QueryJsonBody): The SQL query to be executed
219
+
220
+ ### Raises:
221
+ * `errors.UnexpectedStatus`: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
222
+ * `httpx.TimeoutException`: If the request takes longer than Client.timeout.
223
+
224
+ ## Returns:
225
+ * `Response[Union[Dict[str, Any], QueryResponse400, QueryResponse401]]`
226
+ """
227
+
228
+ if not client:
229
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
230
+ client = get_default_client()
231
+ # raise RuntimeError("Missing client!")
232
+ kwargs = _get_kwargs(
233
+ client=client,
234
+ json_body=json_body,
235
+ ontology=ontology,
236
+ accept=accept,
237
+ )
238
+
239
+ async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
240
+ response = await _client.request(**kwargs)
241
+
242
+ return _build_response(client=client, response=response)
243
+
244
+
245
+ async def asyncio(
246
+ *,
247
+ client: Client = None,
248
+ json_body: QueryJsonBody,
249
+ ontology: str,
250
+ accept: Union[Unset, str] = "application/json",
251
+ ) -> Optional[Union[Dict[str, Any], QueryResponse400, QueryResponse401]]:
252
+ """## Execute SQL query
253
+
254
+ This operation will execute the provided SQL query
255
+
256
+ ### Args:
257
+ * `ontology`: ontology (str):
258
+ * `Accept`: accept (Union[Unset, str]): Default: 'application/json'.
259
+ * `json_body`: json_body (QueryJsonBody): The SQL query to be executed
260
+
261
+ ### Raises:
262
+ * `errors.UnexpectedStatus`: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
263
+ * `httpx.TimeoutException`: If the request takes longer than Client.timeout.
264
+
265
+ ## Returns:
266
+ * `Union[Dict[str, Any], QueryResponse400, QueryResponse401]`
267
+ """
268
+
269
+ return (
270
+ await asyncio_detailed(
271
+ client=client,
272
+ json_body=json_body,
273
+ ontology=ontology,
274
+ accept=accept,
275
+ )
276
+ ).parsed
@@ -0,0 +1 @@
1
+