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,235 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, Dict, Optional, Union
3
+ from urllib.parse import quote
4
+ from warnings import warn
5
+
6
+ import httpx
7
+
8
+ from ...client import Client, get_default_client
9
+ from ...types import Response, UNSET, Unset
10
+ from ... import errors
11
+
12
+
13
+ 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.
14
+ Please create a client using octostar.client.make_client() and run the function via client.execute()."""
15
+
16
+
17
+ def _get_kwargs(
18
+ filename: str,
19
+ *,
20
+ client: Client = None,
21
+ external_url: Union[Unset, None, bool] = UNSET,
22
+ accept: Union[Unset, str] = "application/json",
23
+ ) -> Dict[str, Any]:
24
+ if not client:
25
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
26
+ client = get_default_client()
27
+
28
+ base_url = client.get_base_url_v1()
29
+ url = "{}/api/v1/files/download-blob/{}".format(base_url, quote(filename, safe=""))
30
+
31
+ headers: Dict[str, str] = client.get_headers()
32
+ cookies: Dict[str, Any] = client.get_cookies()
33
+
34
+ if not isinstance(accept, Unset):
35
+ headers["Accept"] = accept
36
+
37
+ params: Dict[str, Any] = {}
38
+ params["external_url"] = external_url
39
+
40
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
41
+
42
+ return {
43
+ "method": "get",
44
+ "url": url,
45
+ "headers": headers,
46
+ "cookies": cookies,
47
+ "timeout": client.get_timeout(),
48
+ "follow_redirects": client.follow_redirects,
49
+ "params": params,
50
+ }
51
+
52
+
53
+ def _parse_response(
54
+ *, client: Client = None, response: httpx.Response
55
+ ) -> Optional[Dict[str, Any]]:
56
+ if not client:
57
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
58
+ client = get_default_client()
59
+ if response.status_code == HTTPStatus.OK:
60
+ return response.json()
61
+ if client.raise_on_unexpected_status:
62
+ raise errors.UnexpectedStatus(response.status_code, response.content)
63
+ else:
64
+ return None
65
+
66
+
67
+ def _build_response(
68
+ *, client: Client = None, response: httpx.Response
69
+ ) -> Response[Dict[str, Any]]:
70
+ if not client:
71
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
72
+ client = get_default_client()
73
+ response_kwargs = {
74
+ "status_code": HTTPStatus(response.status_code),
75
+ "content": response.content,
76
+ "headers": response.headers,
77
+ "parsed": _parse_response(client=client, response=response),
78
+ }
79
+ return Response(**response_kwargs)
80
+
81
+
82
+ def sync_detailed(
83
+ filename: str,
84
+ *,
85
+ client: Client = None,
86
+ external_url: Union[Unset, None, bool] = UNSET,
87
+ accept: Union[Unset, str] = "application/json",
88
+ ) -> Response[Dict[str, Any]]:
89
+ """## Request download from temp bucket
90
+
91
+ Generate presigned URL for downloading a file from a temporary S3 bucket.
92
+ Returns a presigned URL that allows direct download from the user's temporary bucket.
93
+
94
+ ### Args:
95
+ * `filename`: filename (str): Name of the file to download
96
+ * `external_url`: external_url (Union[Unset, None, bool]): Whether to use the external endpoint URL
97
+ * `Accept`: accept (Union[Unset, str]): Default: 'application/json'.
98
+
99
+ ### Raises:
100
+ * `errors.UnexpectedStatus`: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
101
+ * `httpx.TimeoutException`: If the request takes longer than Client.timeout.
102
+
103
+ ## Returns:
104
+ * `Response[Dict[str, Any]]` containing 'url' for presigned download
105
+ """
106
+
107
+ if not client:
108
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
109
+ client = get_default_client()
110
+ kwargs = _get_kwargs(
111
+ filename,
112
+ client=client,
113
+ external_url=external_url,
114
+ accept=accept,
115
+ )
116
+
117
+ response = httpx.request(
118
+ verify=client.verify_ssl,
119
+ **kwargs,
120
+ )
121
+ if response.is_error:
122
+ print(
123
+ f"{str(response.status_code)} Error: {response.text} for request",
124
+ str(kwargs),
125
+ )
126
+ return _build_response(client=client, response=response)
127
+
128
+
129
+ def sync(
130
+ filename: str,
131
+ *,
132
+ client: Client = None,
133
+ external_url: Union[Unset, None, bool] = UNSET,
134
+ accept: Union[Unset, str] = "application/json",
135
+ ) -> Optional[Dict[str, Any]]:
136
+ """## Request download from temp bucket
137
+
138
+ Generate presigned URL for downloading a file from a temporary S3 bucket.
139
+ Returns a presigned URL that allows direct download from the user's temporary bucket.
140
+
141
+ ### Args:
142
+ * `filename`: filename (str): Name of the file to download
143
+ * `external_url`: external_url (Union[Unset, None, bool]): Whether to use the external endpoint URL
144
+ * `Accept`: accept (Union[Unset, str]): Default: 'application/json'.
145
+
146
+ ### Raises:
147
+ * `errors.UnexpectedStatus`: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
148
+ * `httpx.TimeoutException`: If the request takes longer than Client.timeout.
149
+
150
+ ## Returns:
151
+ * `Optional[Dict[str, Any]]` containing 'url' for presigned download
152
+ """
153
+
154
+ return sync_detailed(
155
+ filename,
156
+ client=client,
157
+ external_url=external_url,
158
+ accept=accept,
159
+ ).parsed
160
+
161
+
162
+ async def asyncio_detailed(
163
+ filename: str,
164
+ *,
165
+ client: Client = None,
166
+ external_url: Union[Unset, None, bool] = UNSET,
167
+ accept: Union[Unset, str] = "application/json",
168
+ ) -> Response[Dict[str, Any]]:
169
+ """## Request download from temp bucket
170
+
171
+ Generate presigned URL for downloading a file from a temporary S3 bucket.
172
+ Returns a presigned URL that allows direct download from the user's temporary bucket.
173
+
174
+ ### Args:
175
+ * `filename`: filename (str): Name of the file to download
176
+ * `external_url`: external_url (Union[Unset, None, bool]): Whether to use the external endpoint URL
177
+ * `Accept`: accept (Union[Unset, str]): Default: 'application/json'.
178
+
179
+ ### Raises:
180
+ * `errors.UnexpectedStatus`: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
181
+ * `httpx.TimeoutException`: If the request takes longer than Client.timeout.
182
+
183
+ ## Returns:
184
+ * `Response[Dict[str, Any]]` containing 'url' for presigned download
185
+ """
186
+
187
+ if not client:
188
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
189
+ client = get_default_client()
190
+ kwargs = _get_kwargs(
191
+ filename,
192
+ client=client,
193
+ external_url=external_url,
194
+ accept=accept,
195
+ )
196
+
197
+ async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
198
+ response = await _client.request(**kwargs)
199
+
200
+ return _build_response(client=client, response=response)
201
+
202
+
203
+ async def asyncio(
204
+ filename: str,
205
+ *,
206
+ client: Client = None,
207
+ external_url: Union[Unset, None, bool] = UNSET,
208
+ accept: Union[Unset, str] = "application/json",
209
+ ) -> Optional[Dict[str, Any]]:
210
+ """## Request download from temp bucket
211
+
212
+ Generate presigned URL for downloading a file from a temporary S3 bucket.
213
+ Returns a presigned URL that allows direct download from the user's temporary bucket.
214
+
215
+ ### Args:
216
+ * `filename`: filename (str): Name of the file to download
217
+ * `external_url`: external_url (Union[Unset, None, bool]): Whether to use the external endpoint URL
218
+ * `Accept`: accept (Union[Unset, str]): Default: 'application/json'.
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
+ * `Optional[Dict[str, Any]]` containing 'url' for presigned download
226
+ """
227
+
228
+ return (
229
+ await asyncio_detailed(
230
+ filename,
231
+ client=client,
232
+ external_url=external_url,
233
+ accept=accept,
234
+ )
235
+ ).parsed
@@ -0,0 +1,336 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, Dict, List, Optional, Union, cast
3
+ from urllib.parse import quote
4
+ from warnings import warn
5
+
6
+ import httpx
7
+
8
+ from ...client import AuthenticatedClient, Client, get_default_client
9
+ from ...types import Response, UNSET
10
+ from ... import errors
11
+
12
+ from ...types import UNSET, Unset
13
+ from ...models.get_attachment_response_401 import GetAttachmentResponse401
14
+ from typing import Union
15
+ from typing import cast
16
+ from typing import Optional
17
+ from ...models.get_attachment_response_200 import GetAttachmentResponse200
18
+ from typing import Dict
19
+
20
+
21
+ 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.
22
+ Please create a client using octostar.client.make_client() and run the function via client.execute()."""
23
+
24
+
25
+ def _get_kwargs(
26
+ workspace: str,
27
+ file_path: str,
28
+ *,
29
+ client: Client = None,
30
+ no_redirect: Union[Unset, None, str] = UNSET,
31
+ return_url: Union[Unset, None, bool] = UNSET,
32
+ content_disposition: Union[Unset, None, str] = UNSET,
33
+ content_type: Union[Unset, None, str] = UNSET,
34
+ external_url: Union[Unset, None, bool] = UNSET,
35
+ accept: Union[Unset, str] = "application/json",
36
+ ) -> Dict[str, Any]:
37
+ if not client:
38
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
39
+ client = get_default_client()
40
+ # raise RuntimeError("Missing client!")
41
+
42
+ base_url = client.get_base_url_v1()
43
+ # API uses single {path} param that combines workspace and file_path
44
+ full_path = f"{quote(workspace, safe='')}/{quote(file_path, safe='/')}"
45
+ url = "{}/api/v1/files/attachments/{}".format(base_url, full_path)
46
+
47
+ headers: Dict[str, str] = client.get_headers()
48
+ cookies: Dict[str, Any] = client.get_cookies()
49
+
50
+ if not isinstance(accept, Unset):
51
+ headers["Accept"] = accept
52
+
53
+ params: Dict[str, Any] = {}
54
+ params["no_redirect"] = no_redirect
55
+ params["return_url"] = return_url
56
+ params["content_disposition"] = content_disposition
57
+ params["content_type"] = content_type
58
+ params["external_url"] = external_url
59
+
60
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
61
+
62
+ return {
63
+ "method": "get",
64
+ "url": url,
65
+ "headers": headers,
66
+ "cookies": cookies,
67
+ "timeout": client.get_timeout(),
68
+ "follow_redirects": client.follow_redirects,
69
+ "params": params,
70
+ }
71
+
72
+
73
+ def _parse_response(
74
+ *, client: Client = None, response: httpx.Response
75
+ ) -> Optional[Union[Any, GetAttachmentResponse200, GetAttachmentResponse401]]:
76
+ if not client:
77
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
78
+ client = get_default_client()
79
+ # raise RuntimeError("Missing client!")
80
+ if response.status_code == HTTPStatus.OK:
81
+ response_200 = GetAttachmentResponse200.from_dict(response.json())
82
+
83
+ return response_200
84
+ if response.status_code == HTTPStatus.MOVED_PERMANENTLY:
85
+ response_301 = cast(Any, None)
86
+ return response_301
87
+ if response.status_code == HTTPStatus.UNAUTHORIZED:
88
+ response_401 = GetAttachmentResponse401.from_dict(response.json())
89
+
90
+ return response_401
91
+ if client.raise_on_unexpected_status:
92
+ raise errors.UnexpectedStatus(response.status_code, response.content)
93
+ else:
94
+ return None
95
+
96
+
97
+ def _build_response(
98
+ *, client: Client = None, response: httpx.Response
99
+ ) -> Response[Union[Any, GetAttachmentResponse200, GetAttachmentResponse401]]:
100
+ if not client:
101
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
102
+ client = get_default_client()
103
+ # raise RuntimeError("Missing client!")
104
+ response_kwargs = {
105
+ "status_code": HTTPStatus(response.status_code),
106
+ "content": response.content,
107
+ "headers": response.headers,
108
+ "parsed": _parse_response(client=client, response=response),
109
+ }
110
+ return Response(**response_kwargs)
111
+
112
+
113
+ def _build_chunk_response(
114
+ *, client: Client = None, response: httpx.Response, chunk: bytes
115
+ ) -> Response[Union[Any, GetAttachmentResponse200, GetAttachmentResponse401]]:
116
+ if not client:
117
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
118
+ client = get_default_client()
119
+ # raise RuntimeError("Missing client!")
120
+ response_kwargs = {
121
+ "status_code": HTTPStatus(response.status_code),
122
+ "content": chunk,
123
+ "headers": response.headers,
124
+ "parsed": None, # cannot parse incomplete chunks of data, we leave it to the user
125
+ }
126
+ return Response(**response_kwargs)
127
+
128
+
129
+ def sync_detailed(
130
+ workspace: str,
131
+ file_path: str,
132
+ *,
133
+ client: Client = None,
134
+ no_redirect: Union[Unset, None, str] = UNSET,
135
+ return_url: Union[Unset, None, bool] = UNSET,
136
+ content_disposition: Union[Unset, None, str] = UNSET,
137
+ content_type: Union[Unset, None, str] = UNSET,
138
+ external_url: Union[Unset, None, bool] = UNSET,
139
+ accept: Union[Unset, str] = "application/json",
140
+ ) -> Response[Union[Any, GetAttachmentResponse200, GetAttachmentResponse401]]:
141
+ """## Get S3 attachments operation
142
+
143
+ This operation will get attachments given a workspace and file_path
144
+
145
+ ### Args:
146
+ * `workspace`: workspace (str):
147
+ * `file_path`: file_path (str):
148
+ * `no_redirect`: no_redirect (Union[Unset, None, str]):
149
+ * `content_disposition`: content_disposition (Union[Unset, None, str]):
150
+ * `content_type`: content_type (Union[Unset, None, str]):
151
+ * `external_url`: external_url (Union[Unset, None, bool]):
152
+ * `Accept`: accept (Union[Unset, str]): Default: 'application/json'.
153
+
154
+ ### Raises:
155
+ * `errors.UnexpectedStatus`: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
156
+ * `httpx.TimeoutException`: If the request takes longer than Client.timeout.
157
+
158
+ ## Returns:
159
+ * `Response[Union[Any, GetAttachmentResponse200, GetAttachmentResponse401]]`
160
+ """
161
+
162
+ if not client:
163
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
164
+ client = get_default_client()
165
+ # raise RuntimeError("Missing client!")
166
+ kwargs = _get_kwargs(
167
+ workspace=workspace,
168
+ file_path=file_path,
169
+ client=client,
170
+ no_redirect=no_redirect,
171
+ return_url=return_url,
172
+ content_disposition=content_disposition,
173
+ content_type=content_type,
174
+ external_url=external_url,
175
+ accept=accept,
176
+ )
177
+
178
+ response = httpx.request(
179
+ verify=client.verify_ssl,
180
+ **kwargs,
181
+ )
182
+ if response.is_error:
183
+ print(
184
+ f"{str(response.status_code)} Error: {response.text} for request",
185
+ str(kwargs),
186
+ )
187
+ return _build_response(client=client, response=response)
188
+
189
+
190
+ def sync(
191
+ workspace: str,
192
+ file_path: str,
193
+ *,
194
+ client: Client = None,
195
+ no_redirect: Union[Unset, None, str] = UNSET,
196
+ return_url: Union[Unset, None, bool] = UNSET,
197
+ content_disposition: Union[Unset, None, str] = UNSET,
198
+ content_type: Union[Unset, None, str] = UNSET,
199
+ external_url: Union[Unset, None, bool] = UNSET,
200
+ accept: Union[Unset, str] = "application/json",
201
+ ) -> Optional[Union[Any, GetAttachmentResponse200, GetAttachmentResponse401]]:
202
+ """## Get S3 attachments operation
203
+
204
+ This operation will get attachments given a workspace and file_path
205
+
206
+ ### Args:
207
+ * `workspace`: workspace (str):
208
+ * `file_path`: file_path (str):
209
+ * `no_redirect`: no_redirect (Union[Unset, None, str]):
210
+ * `content_disposition`: content_disposition (Union[Unset, None, str]):
211
+ * `content_type`: content_type (Union[Unset, None, str]):
212
+ * `external_url`: external_url (Union[Unset, None, bool]):
213
+ * `Accept`: accept (Union[Unset, str]): Default: 'application/json'.
214
+
215
+ ### Raises:
216
+ * `errors.UnexpectedStatus`: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
217
+ * `httpx.TimeoutException`: If the request takes longer than Client.timeout.
218
+
219
+ ## Returns:
220
+ * `Union[Any, GetAttachmentResponse200, GetAttachmentResponse401]`
221
+ """
222
+
223
+ return sync_detailed(
224
+ workspace=workspace,
225
+ file_path=file_path,
226
+ client=client,
227
+ no_redirect=no_redirect,
228
+ return_url=return_url,
229
+ content_disposition=content_disposition,
230
+ content_type=content_type,
231
+ external_url=external_url,
232
+ accept=accept,
233
+ ).parsed
234
+
235
+
236
+ async def asyncio_detailed(
237
+ workspace: str,
238
+ file_path: str,
239
+ *,
240
+ client: Client = None,
241
+ no_redirect: Union[Unset, None, str] = UNSET,
242
+ return_url: Union[Unset, None, bool] = UNSET,
243
+ content_disposition: Union[Unset, None, str] = UNSET,
244
+ content_type: Union[Unset, None, str] = UNSET,
245
+ external_url: Union[Unset, None, bool] = UNSET,
246
+ accept: Union[Unset, str] = "application/json",
247
+ ) -> Response[Union[Any, GetAttachmentResponse200, GetAttachmentResponse401]]:
248
+ """## Get S3 attachments operation
249
+
250
+ This operation will get attachments given a workspace and file_path
251
+
252
+ ### Args:
253
+ * `workspace`: workspace (str):
254
+ * `file_path`: file_path (str):
255
+ * `no_redirect`: no_redirect (Union[Unset, None, str]):
256
+ * `content_disposition`: content_disposition (Union[Unset, None, str]):
257
+ * `content_type`: content_type (Union[Unset, None, str]):
258
+ * `external_url`: external_url (Union[Unset, None, bool]):
259
+ * `Accept`: accept (Union[Unset, str]): Default: 'application/json'.
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
+ * `Response[Union[Any, GetAttachmentResponse200, GetAttachmentResponse401]]`
267
+ """
268
+
269
+ if not client:
270
+ warn(client_missing_msg, FutureWarning, stacklevel=2)
271
+ client = get_default_client()
272
+ # raise RuntimeError("Missing client!")
273
+ kwargs = _get_kwargs(
274
+ workspace=workspace,
275
+ file_path=file_path,
276
+ client=client,
277
+ no_redirect=no_redirect,
278
+ return_url=return_url,
279
+ content_disposition=content_disposition,
280
+ content_type=content_type,
281
+ external_url=external_url,
282
+ accept=accept,
283
+ )
284
+
285
+ async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
286
+ response = await _client.request(**kwargs)
287
+
288
+ return _build_response(client=client, response=response)
289
+
290
+
291
+ async def asyncio(
292
+ workspace: str,
293
+ file_path: str,
294
+ *,
295
+ client: Client = None,
296
+ no_redirect: Union[Unset, None, str] = UNSET,
297
+ return_url: Union[Unset, None, bool] = UNSET,
298
+ content_disposition: Union[Unset, None, str] = UNSET,
299
+ content_type: Union[Unset, None, str] = UNSET,
300
+ external_url: Union[Unset, None, bool] = UNSET,
301
+ accept: Union[Unset, str] = "application/json",
302
+ ) -> Optional[Union[Any, GetAttachmentResponse200, GetAttachmentResponse401]]:
303
+ """## Get S3 attachments operation
304
+
305
+ This operation will get attachments given a workspace and file_path
306
+
307
+ ### Args:
308
+ * `workspace`: workspace (str):
309
+ * `file_path`: file_path (str):
310
+ * `no_redirect`: no_redirect (Union[Unset, None, str]):
311
+ * `content_disposition`: content_disposition (Union[Unset, None, str]):
312
+ * `content_type`: content_type (Union[Unset, None, str]):
313
+ * `external_url`: external_url (Union[Unset, None, bool]):
314
+ * `Accept`: accept (Union[Unset, str]): Default: 'application/json'.
315
+
316
+ ### Raises:
317
+ * `errors.UnexpectedStatus`: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
318
+ * `httpx.TimeoutException`: If the request takes longer than Client.timeout.
319
+
320
+ ## Returns:
321
+ * `Union[Any, GetAttachmentResponse200, GetAttachmentResponse401]`
322
+ """
323
+
324
+ return (
325
+ await asyncio_detailed(
326
+ workspace=workspace,
327
+ file_path=file_path,
328
+ client=client,
329
+ no_redirect=no_redirect,
330
+ return_url=return_url,
331
+ content_disposition=content_disposition,
332
+ content_type=content_type,
333
+ external_url=external_url,
334
+ accept=accept,
335
+ )
336
+ ).parsed