robosystems-client 0.2.1__py3-none-any.whl → 0.2.3__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.
Potentially problematic release.
This version of robosystems-client might be problematic. Click here for more details.
- robosystems_client/api/tables/delete_file.py +437 -0
- robosystems_client/api/tables/get_file_info.py +397 -0
- robosystems_client/api/tables/get_upload_url.py +548 -0
- robosystems_client/api/tables/ingest_tables.py +616 -0
- robosystems_client/api/tables/list_table_files.py +509 -0
- robosystems_client/api/tables/list_tables.py +488 -0
- robosystems_client/api/tables/query_tables.py +487 -0
- robosystems_client/api/tables/update_file_status.py +539 -0
- robosystems_client/extensions/__init__.py +11 -0
- robosystems_client/extensions/extensions.py +3 -0
- robosystems_client/extensions/graph_client.py +326 -0
- robosystems_client/extensions/query_client.py +74 -1
- robosystems_client/extensions/table_ingest_client.py +31 -40
- robosystems_client/models/__init__.py +13 -17
- robosystems_client/models/create_graph_request.py +11 -0
- robosystems_client/models/{delete_file_v1_graphs_graph_id_tables_files_file_id_delete_response_delete_file_v1_graphs_graph_id_tables_files_file_id_delete.py → delete_file_response.py} +45 -9
- robosystems_client/models/file_info.py +169 -0
- robosystems_client/models/file_status_update.py +41 -0
- robosystems_client/models/get_file_info_response.py +205 -0
- robosystems_client/models/list_table_files_response.py +105 -0
- robosystems_client/models/{get_file_info_v1_graphs_graph_id_tables_files_file_id_get_response_get_file_info_v1_graphs_graph_id_tables_files_file_id_get.py → update_file_status_response_updatefilestatus.py} +5 -8
- {robosystems_client-0.2.1.dist-info → robosystems_client-0.2.3.dist-info}/METADATA +1 -1
- {robosystems_client-0.2.1.dist-info → robosystems_client-0.2.3.dist-info}/RECORD +25 -23
- robosystems_client/api/tables/delete_file_v1_graphs_graph_id_tables_files_file_id_delete.py +0 -287
- robosystems_client/api/tables/get_file_info_v1_graphs_graph_id_tables_files_file_id_get.py +0 -283
- robosystems_client/api/tables/get_upload_url_v1_graphs_graph_id_tables_table_name_files_post.py +0 -260
- robosystems_client/api/tables/ingest_tables_v1_graphs_graph_id_tables_ingest_post.py +0 -251
- robosystems_client/api/tables/list_table_files_v1_graphs_graph_id_tables_table_name_files_get.py +0 -283
- robosystems_client/api/tables/list_tables_v1_graphs_graph_id_tables_get.py +0 -224
- robosystems_client/api/tables/query_tables_v1_graphs_graph_id_tables_query_post.py +0 -247
- robosystems_client/api/tables/update_file_v1_graphs_graph_id_tables_files_file_id_patch.py +0 -306
- robosystems_client/models/file_update_request.py +0 -62
- robosystems_client/models/list_table_files_v1_graphs_graph_id_tables_table_name_files_get_response_list_table_files_v1_graphs_graph_id_tables_table_name_files_get.py +0 -47
- robosystems_client/models/update_file_v1_graphs_graph_id_tables_files_file_id_patch_response_update_file_v1_graphs_graph_id_tables_files_file_id_patch.py +0 -47
- {robosystems_client-0.2.1.dist-info → robosystems_client-0.2.3.dist-info}/WHEEL +0 -0
- {robosystems_client-0.2.1.dist-info → robosystems_client-0.2.3.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,548 @@
|
|
|
1
|
+
from http import HTTPStatus
|
|
2
|
+
from typing import Any, Optional, Union, cast
|
|
3
|
+
|
|
4
|
+
import httpx
|
|
5
|
+
|
|
6
|
+
from ... import errors
|
|
7
|
+
from ...client import AuthenticatedClient, Client
|
|
8
|
+
from ...models.error_response import ErrorResponse
|
|
9
|
+
from ...models.file_upload_request import FileUploadRequest
|
|
10
|
+
from ...models.file_upload_response import FileUploadResponse
|
|
11
|
+
from ...models.http_validation_error import HTTPValidationError
|
|
12
|
+
from ...types import UNSET, Response, Unset
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _get_kwargs(
|
|
16
|
+
graph_id: str,
|
|
17
|
+
table_name: str,
|
|
18
|
+
*,
|
|
19
|
+
body: FileUploadRequest,
|
|
20
|
+
token: Union[None, Unset, str] = UNSET,
|
|
21
|
+
authorization: Union[None, Unset, str] = UNSET,
|
|
22
|
+
) -> dict[str, Any]:
|
|
23
|
+
headers: dict[str, Any] = {}
|
|
24
|
+
if not isinstance(authorization, Unset):
|
|
25
|
+
headers["authorization"] = authorization
|
|
26
|
+
|
|
27
|
+
params: dict[str, Any] = {}
|
|
28
|
+
|
|
29
|
+
json_token: Union[None, Unset, str]
|
|
30
|
+
if isinstance(token, Unset):
|
|
31
|
+
json_token = UNSET
|
|
32
|
+
else:
|
|
33
|
+
json_token = token
|
|
34
|
+
params["token"] = json_token
|
|
35
|
+
|
|
36
|
+
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
|
|
37
|
+
|
|
38
|
+
_kwargs: dict[str, Any] = {
|
|
39
|
+
"method": "post",
|
|
40
|
+
"url": f"/v1/graphs/{graph_id}/tables/{table_name}/files",
|
|
41
|
+
"params": params,
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
_kwargs["json"] = body.to_dict()
|
|
45
|
+
|
|
46
|
+
headers["Content-Type"] = "application/json"
|
|
47
|
+
|
|
48
|
+
_kwargs["headers"] = headers
|
|
49
|
+
return _kwargs
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _parse_response(
|
|
53
|
+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
|
54
|
+
) -> Optional[Union[Any, ErrorResponse, FileUploadResponse, HTTPValidationError]]:
|
|
55
|
+
if response.status_code == 200:
|
|
56
|
+
response_200 = FileUploadResponse.from_dict(response.json())
|
|
57
|
+
|
|
58
|
+
return response_200
|
|
59
|
+
|
|
60
|
+
if response.status_code == 400:
|
|
61
|
+
response_400 = ErrorResponse.from_dict(response.json())
|
|
62
|
+
|
|
63
|
+
return response_400
|
|
64
|
+
|
|
65
|
+
if response.status_code == 401:
|
|
66
|
+
response_401 = cast(Any, None)
|
|
67
|
+
return response_401
|
|
68
|
+
|
|
69
|
+
if response.status_code == 403:
|
|
70
|
+
response_403 = ErrorResponse.from_dict(response.json())
|
|
71
|
+
|
|
72
|
+
return response_403
|
|
73
|
+
|
|
74
|
+
if response.status_code == 404:
|
|
75
|
+
response_404 = ErrorResponse.from_dict(response.json())
|
|
76
|
+
|
|
77
|
+
return response_404
|
|
78
|
+
|
|
79
|
+
if response.status_code == 422:
|
|
80
|
+
response_422 = HTTPValidationError.from_dict(response.json())
|
|
81
|
+
|
|
82
|
+
return response_422
|
|
83
|
+
|
|
84
|
+
if response.status_code == 500:
|
|
85
|
+
response_500 = cast(Any, None)
|
|
86
|
+
return response_500
|
|
87
|
+
|
|
88
|
+
if client.raise_on_unexpected_status:
|
|
89
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
90
|
+
else:
|
|
91
|
+
return None
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def _build_response(
|
|
95
|
+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
|
96
|
+
) -> Response[Union[Any, ErrorResponse, FileUploadResponse, HTTPValidationError]]:
|
|
97
|
+
return Response(
|
|
98
|
+
status_code=HTTPStatus(response.status_code),
|
|
99
|
+
content=response.content,
|
|
100
|
+
headers=response.headers,
|
|
101
|
+
parsed=_parse_response(client=client, response=response),
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def sync_detailed(
|
|
106
|
+
graph_id: str,
|
|
107
|
+
table_name: str,
|
|
108
|
+
*,
|
|
109
|
+
client: AuthenticatedClient,
|
|
110
|
+
body: FileUploadRequest,
|
|
111
|
+
token: Union[None, Unset, str] = UNSET,
|
|
112
|
+
authorization: Union[None, Unset, str] = UNSET,
|
|
113
|
+
) -> Response[Union[Any, ErrorResponse, FileUploadResponse, HTTPValidationError]]:
|
|
114
|
+
r""" Get File Upload URL
|
|
115
|
+
|
|
116
|
+
Generate a presigned S3 URL for secure file upload.
|
|
117
|
+
|
|
118
|
+
**Purpose:**
|
|
119
|
+
Initiate file upload to a staging table by generating a secure, time-limited
|
|
120
|
+
presigned S3 URL. Files are uploaded directly to S3, bypassing the API for
|
|
121
|
+
optimal performance.
|
|
122
|
+
|
|
123
|
+
**Upload Workflow:**
|
|
124
|
+
1. Call this endpoint to get presigned URL
|
|
125
|
+
2. PUT file directly to S3 URL (using curl, axios, etc.)
|
|
126
|
+
3. Call PATCH /tables/files/{file_id} with status='uploaded'
|
|
127
|
+
4. Backend validates file and calculates metrics
|
|
128
|
+
5. File ready for ingestion
|
|
129
|
+
|
|
130
|
+
**Supported Formats:**
|
|
131
|
+
- Parquet (`application/x-parquet` with `.parquet` extension)
|
|
132
|
+
- CSV (`text/csv` with `.csv` extension)
|
|
133
|
+
- JSON (`application/json` with `.json` extension)
|
|
134
|
+
|
|
135
|
+
**Validation:**
|
|
136
|
+
- File extension must match content type
|
|
137
|
+
- File name 1-255 characters
|
|
138
|
+
- No path traversal characters (.. / \)
|
|
139
|
+
- Auto-creates table if it doesn't exist
|
|
140
|
+
|
|
141
|
+
**Auto-Table Creation:**
|
|
142
|
+
If the table doesn't exist, it's automatically created with:
|
|
143
|
+
- Type inferred from name (e.g., \"Transaction\" → relationship)
|
|
144
|
+
- Empty schema (populated on ingestion)
|
|
145
|
+
- Ready for file uploads
|
|
146
|
+
|
|
147
|
+
**Example Response:**
|
|
148
|
+
```json
|
|
149
|
+
{
|
|
150
|
+
\"upload_url\": \"https://bucket.s3.amazonaws.com/path?X-Amz-Algorithm=...\",
|
|
151
|
+
\"expires_in\": 3600,
|
|
152
|
+
\"file_id\": \"f123-456-789\",
|
|
153
|
+
\"s3_key\": \"user-staging/user123/kg456/Entity/f123.../data.parquet\"
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Example Usage:**
|
|
158
|
+
```bash
|
|
159
|
+
# Step 1: Get upload URL
|
|
160
|
+
curl -X POST \"https://api.robosystems.ai/v1/graphs/kg123/tables/Entity/files\" \
|
|
161
|
+
-H \"Authorization: Bearer YOUR_TOKEN\" \
|
|
162
|
+
-H \"Content-Type: application/json\" \
|
|
163
|
+
-d '{
|
|
164
|
+
\"file_name\": \"entities.parquet\",
|
|
165
|
+
\"content_type\": \"application/x-parquet\"
|
|
166
|
+
}'
|
|
167
|
+
|
|
168
|
+
# Step 2: Upload file directly to S3
|
|
169
|
+
curl -X PUT \"$UPLOAD_URL\" \
|
|
170
|
+
-H \"Content-Type: application/x-parquet\" \
|
|
171
|
+
--data-binary \"@entities.parquet\"
|
|
172
|
+
|
|
173
|
+
# Step 3: Mark as uploaded
|
|
174
|
+
curl -X PATCH \"https://api.robosystems.ai/v1/graphs/kg123/tables/files/$FILE_ID\" \
|
|
175
|
+
-H \"Authorization: Bearer YOUR_TOKEN\" \
|
|
176
|
+
-H \"Content-Type: application/json\" \
|
|
177
|
+
-d '{\"status\": \"uploaded\"}'
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Tips:**
|
|
181
|
+
- Presigned URLs expire (default: 1 hour)
|
|
182
|
+
- Use appropriate Content-Type header when uploading to S3
|
|
183
|
+
- File extension must match content type
|
|
184
|
+
- Large files benefit from direct S3 upload
|
|
185
|
+
|
|
186
|
+
**Note:**
|
|
187
|
+
Upload URL generation is included - no credit consumption.
|
|
188
|
+
|
|
189
|
+
Args:
|
|
190
|
+
graph_id (str): Graph database identifier
|
|
191
|
+
table_name (str): Table name
|
|
192
|
+
token (Union[None, Unset, str]): JWT token for SSE authentication
|
|
193
|
+
authorization (Union[None, Unset, str]):
|
|
194
|
+
body (FileUploadRequest):
|
|
195
|
+
|
|
196
|
+
Raises:
|
|
197
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
198
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
199
|
+
|
|
200
|
+
Returns:
|
|
201
|
+
Response[Union[Any, ErrorResponse, FileUploadResponse, HTTPValidationError]]
|
|
202
|
+
"""
|
|
203
|
+
|
|
204
|
+
kwargs = _get_kwargs(
|
|
205
|
+
graph_id=graph_id,
|
|
206
|
+
table_name=table_name,
|
|
207
|
+
body=body,
|
|
208
|
+
token=token,
|
|
209
|
+
authorization=authorization,
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
response = client.get_httpx_client().request(
|
|
213
|
+
**kwargs,
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
return _build_response(client=client, response=response)
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
def sync(
|
|
220
|
+
graph_id: str,
|
|
221
|
+
table_name: str,
|
|
222
|
+
*,
|
|
223
|
+
client: AuthenticatedClient,
|
|
224
|
+
body: FileUploadRequest,
|
|
225
|
+
token: Union[None, Unset, str] = UNSET,
|
|
226
|
+
authorization: Union[None, Unset, str] = UNSET,
|
|
227
|
+
) -> Optional[Union[Any, ErrorResponse, FileUploadResponse, HTTPValidationError]]:
|
|
228
|
+
r""" Get File Upload URL
|
|
229
|
+
|
|
230
|
+
Generate a presigned S3 URL for secure file upload.
|
|
231
|
+
|
|
232
|
+
**Purpose:**
|
|
233
|
+
Initiate file upload to a staging table by generating a secure, time-limited
|
|
234
|
+
presigned S3 URL. Files are uploaded directly to S3, bypassing the API for
|
|
235
|
+
optimal performance.
|
|
236
|
+
|
|
237
|
+
**Upload Workflow:**
|
|
238
|
+
1. Call this endpoint to get presigned URL
|
|
239
|
+
2. PUT file directly to S3 URL (using curl, axios, etc.)
|
|
240
|
+
3. Call PATCH /tables/files/{file_id} with status='uploaded'
|
|
241
|
+
4. Backend validates file and calculates metrics
|
|
242
|
+
5. File ready for ingestion
|
|
243
|
+
|
|
244
|
+
**Supported Formats:**
|
|
245
|
+
- Parquet (`application/x-parquet` with `.parquet` extension)
|
|
246
|
+
- CSV (`text/csv` with `.csv` extension)
|
|
247
|
+
- JSON (`application/json` with `.json` extension)
|
|
248
|
+
|
|
249
|
+
**Validation:**
|
|
250
|
+
- File extension must match content type
|
|
251
|
+
- File name 1-255 characters
|
|
252
|
+
- No path traversal characters (.. / \)
|
|
253
|
+
- Auto-creates table if it doesn't exist
|
|
254
|
+
|
|
255
|
+
**Auto-Table Creation:**
|
|
256
|
+
If the table doesn't exist, it's automatically created with:
|
|
257
|
+
- Type inferred from name (e.g., \"Transaction\" → relationship)
|
|
258
|
+
- Empty schema (populated on ingestion)
|
|
259
|
+
- Ready for file uploads
|
|
260
|
+
|
|
261
|
+
**Example Response:**
|
|
262
|
+
```json
|
|
263
|
+
{
|
|
264
|
+
\"upload_url\": \"https://bucket.s3.amazonaws.com/path?X-Amz-Algorithm=...\",
|
|
265
|
+
\"expires_in\": 3600,
|
|
266
|
+
\"file_id\": \"f123-456-789\",
|
|
267
|
+
\"s3_key\": \"user-staging/user123/kg456/Entity/f123.../data.parquet\"
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
**Example Usage:**
|
|
272
|
+
```bash
|
|
273
|
+
# Step 1: Get upload URL
|
|
274
|
+
curl -X POST \"https://api.robosystems.ai/v1/graphs/kg123/tables/Entity/files\" \
|
|
275
|
+
-H \"Authorization: Bearer YOUR_TOKEN\" \
|
|
276
|
+
-H \"Content-Type: application/json\" \
|
|
277
|
+
-d '{
|
|
278
|
+
\"file_name\": \"entities.parquet\",
|
|
279
|
+
\"content_type\": \"application/x-parquet\"
|
|
280
|
+
}'
|
|
281
|
+
|
|
282
|
+
# Step 2: Upload file directly to S3
|
|
283
|
+
curl -X PUT \"$UPLOAD_URL\" \
|
|
284
|
+
-H \"Content-Type: application/x-parquet\" \
|
|
285
|
+
--data-binary \"@entities.parquet\"
|
|
286
|
+
|
|
287
|
+
# Step 3: Mark as uploaded
|
|
288
|
+
curl -X PATCH \"https://api.robosystems.ai/v1/graphs/kg123/tables/files/$FILE_ID\" \
|
|
289
|
+
-H \"Authorization: Bearer YOUR_TOKEN\" \
|
|
290
|
+
-H \"Content-Type: application/json\" \
|
|
291
|
+
-d '{\"status\": \"uploaded\"}'
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
**Tips:**
|
|
295
|
+
- Presigned URLs expire (default: 1 hour)
|
|
296
|
+
- Use appropriate Content-Type header when uploading to S3
|
|
297
|
+
- File extension must match content type
|
|
298
|
+
- Large files benefit from direct S3 upload
|
|
299
|
+
|
|
300
|
+
**Note:**
|
|
301
|
+
Upload URL generation is included - no credit consumption.
|
|
302
|
+
|
|
303
|
+
Args:
|
|
304
|
+
graph_id (str): Graph database identifier
|
|
305
|
+
table_name (str): Table name
|
|
306
|
+
token (Union[None, Unset, str]): JWT token for SSE authentication
|
|
307
|
+
authorization (Union[None, Unset, str]):
|
|
308
|
+
body (FileUploadRequest):
|
|
309
|
+
|
|
310
|
+
Raises:
|
|
311
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
312
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
313
|
+
|
|
314
|
+
Returns:
|
|
315
|
+
Union[Any, ErrorResponse, FileUploadResponse, HTTPValidationError]
|
|
316
|
+
"""
|
|
317
|
+
|
|
318
|
+
return sync_detailed(
|
|
319
|
+
graph_id=graph_id,
|
|
320
|
+
table_name=table_name,
|
|
321
|
+
client=client,
|
|
322
|
+
body=body,
|
|
323
|
+
token=token,
|
|
324
|
+
authorization=authorization,
|
|
325
|
+
).parsed
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
async def asyncio_detailed(
|
|
329
|
+
graph_id: str,
|
|
330
|
+
table_name: str,
|
|
331
|
+
*,
|
|
332
|
+
client: AuthenticatedClient,
|
|
333
|
+
body: FileUploadRequest,
|
|
334
|
+
token: Union[None, Unset, str] = UNSET,
|
|
335
|
+
authorization: Union[None, Unset, str] = UNSET,
|
|
336
|
+
) -> Response[Union[Any, ErrorResponse, FileUploadResponse, HTTPValidationError]]:
|
|
337
|
+
r""" Get File Upload URL
|
|
338
|
+
|
|
339
|
+
Generate a presigned S3 URL for secure file upload.
|
|
340
|
+
|
|
341
|
+
**Purpose:**
|
|
342
|
+
Initiate file upload to a staging table by generating a secure, time-limited
|
|
343
|
+
presigned S3 URL. Files are uploaded directly to S3, bypassing the API for
|
|
344
|
+
optimal performance.
|
|
345
|
+
|
|
346
|
+
**Upload Workflow:**
|
|
347
|
+
1. Call this endpoint to get presigned URL
|
|
348
|
+
2. PUT file directly to S3 URL (using curl, axios, etc.)
|
|
349
|
+
3. Call PATCH /tables/files/{file_id} with status='uploaded'
|
|
350
|
+
4. Backend validates file and calculates metrics
|
|
351
|
+
5. File ready for ingestion
|
|
352
|
+
|
|
353
|
+
**Supported Formats:**
|
|
354
|
+
- Parquet (`application/x-parquet` with `.parquet` extension)
|
|
355
|
+
- CSV (`text/csv` with `.csv` extension)
|
|
356
|
+
- JSON (`application/json` with `.json` extension)
|
|
357
|
+
|
|
358
|
+
**Validation:**
|
|
359
|
+
- File extension must match content type
|
|
360
|
+
- File name 1-255 characters
|
|
361
|
+
- No path traversal characters (.. / \)
|
|
362
|
+
- Auto-creates table if it doesn't exist
|
|
363
|
+
|
|
364
|
+
**Auto-Table Creation:**
|
|
365
|
+
If the table doesn't exist, it's automatically created with:
|
|
366
|
+
- Type inferred from name (e.g., \"Transaction\" → relationship)
|
|
367
|
+
- Empty schema (populated on ingestion)
|
|
368
|
+
- Ready for file uploads
|
|
369
|
+
|
|
370
|
+
**Example Response:**
|
|
371
|
+
```json
|
|
372
|
+
{
|
|
373
|
+
\"upload_url\": \"https://bucket.s3.amazonaws.com/path?X-Amz-Algorithm=...\",
|
|
374
|
+
\"expires_in\": 3600,
|
|
375
|
+
\"file_id\": \"f123-456-789\",
|
|
376
|
+
\"s3_key\": \"user-staging/user123/kg456/Entity/f123.../data.parquet\"
|
|
377
|
+
}
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
**Example Usage:**
|
|
381
|
+
```bash
|
|
382
|
+
# Step 1: Get upload URL
|
|
383
|
+
curl -X POST \"https://api.robosystems.ai/v1/graphs/kg123/tables/Entity/files\" \
|
|
384
|
+
-H \"Authorization: Bearer YOUR_TOKEN\" \
|
|
385
|
+
-H \"Content-Type: application/json\" \
|
|
386
|
+
-d '{
|
|
387
|
+
\"file_name\": \"entities.parquet\",
|
|
388
|
+
\"content_type\": \"application/x-parquet\"
|
|
389
|
+
}'
|
|
390
|
+
|
|
391
|
+
# Step 2: Upload file directly to S3
|
|
392
|
+
curl -X PUT \"$UPLOAD_URL\" \
|
|
393
|
+
-H \"Content-Type: application/x-parquet\" \
|
|
394
|
+
--data-binary \"@entities.parquet\"
|
|
395
|
+
|
|
396
|
+
# Step 3: Mark as uploaded
|
|
397
|
+
curl -X PATCH \"https://api.robosystems.ai/v1/graphs/kg123/tables/files/$FILE_ID\" \
|
|
398
|
+
-H \"Authorization: Bearer YOUR_TOKEN\" \
|
|
399
|
+
-H \"Content-Type: application/json\" \
|
|
400
|
+
-d '{\"status\": \"uploaded\"}'
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
**Tips:**
|
|
404
|
+
- Presigned URLs expire (default: 1 hour)
|
|
405
|
+
- Use appropriate Content-Type header when uploading to S3
|
|
406
|
+
- File extension must match content type
|
|
407
|
+
- Large files benefit from direct S3 upload
|
|
408
|
+
|
|
409
|
+
**Note:**
|
|
410
|
+
Upload URL generation is included - no credit consumption.
|
|
411
|
+
|
|
412
|
+
Args:
|
|
413
|
+
graph_id (str): Graph database identifier
|
|
414
|
+
table_name (str): Table name
|
|
415
|
+
token (Union[None, Unset, str]): JWT token for SSE authentication
|
|
416
|
+
authorization (Union[None, Unset, str]):
|
|
417
|
+
body (FileUploadRequest):
|
|
418
|
+
|
|
419
|
+
Raises:
|
|
420
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
421
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
422
|
+
|
|
423
|
+
Returns:
|
|
424
|
+
Response[Union[Any, ErrorResponse, FileUploadResponse, HTTPValidationError]]
|
|
425
|
+
"""
|
|
426
|
+
|
|
427
|
+
kwargs = _get_kwargs(
|
|
428
|
+
graph_id=graph_id,
|
|
429
|
+
table_name=table_name,
|
|
430
|
+
body=body,
|
|
431
|
+
token=token,
|
|
432
|
+
authorization=authorization,
|
|
433
|
+
)
|
|
434
|
+
|
|
435
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
436
|
+
|
|
437
|
+
return _build_response(client=client, response=response)
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
async def asyncio(
|
|
441
|
+
graph_id: str,
|
|
442
|
+
table_name: str,
|
|
443
|
+
*,
|
|
444
|
+
client: AuthenticatedClient,
|
|
445
|
+
body: FileUploadRequest,
|
|
446
|
+
token: Union[None, Unset, str] = UNSET,
|
|
447
|
+
authorization: Union[None, Unset, str] = UNSET,
|
|
448
|
+
) -> Optional[Union[Any, ErrorResponse, FileUploadResponse, HTTPValidationError]]:
|
|
449
|
+
r""" Get File Upload URL
|
|
450
|
+
|
|
451
|
+
Generate a presigned S3 URL for secure file upload.
|
|
452
|
+
|
|
453
|
+
**Purpose:**
|
|
454
|
+
Initiate file upload to a staging table by generating a secure, time-limited
|
|
455
|
+
presigned S3 URL. Files are uploaded directly to S3, bypassing the API for
|
|
456
|
+
optimal performance.
|
|
457
|
+
|
|
458
|
+
**Upload Workflow:**
|
|
459
|
+
1. Call this endpoint to get presigned URL
|
|
460
|
+
2. PUT file directly to S3 URL (using curl, axios, etc.)
|
|
461
|
+
3. Call PATCH /tables/files/{file_id} with status='uploaded'
|
|
462
|
+
4. Backend validates file and calculates metrics
|
|
463
|
+
5. File ready for ingestion
|
|
464
|
+
|
|
465
|
+
**Supported Formats:**
|
|
466
|
+
- Parquet (`application/x-parquet` with `.parquet` extension)
|
|
467
|
+
- CSV (`text/csv` with `.csv` extension)
|
|
468
|
+
- JSON (`application/json` with `.json` extension)
|
|
469
|
+
|
|
470
|
+
**Validation:**
|
|
471
|
+
- File extension must match content type
|
|
472
|
+
- File name 1-255 characters
|
|
473
|
+
- No path traversal characters (.. / \)
|
|
474
|
+
- Auto-creates table if it doesn't exist
|
|
475
|
+
|
|
476
|
+
**Auto-Table Creation:**
|
|
477
|
+
If the table doesn't exist, it's automatically created with:
|
|
478
|
+
- Type inferred from name (e.g., \"Transaction\" → relationship)
|
|
479
|
+
- Empty schema (populated on ingestion)
|
|
480
|
+
- Ready for file uploads
|
|
481
|
+
|
|
482
|
+
**Example Response:**
|
|
483
|
+
```json
|
|
484
|
+
{
|
|
485
|
+
\"upload_url\": \"https://bucket.s3.amazonaws.com/path?X-Amz-Algorithm=...\",
|
|
486
|
+
\"expires_in\": 3600,
|
|
487
|
+
\"file_id\": \"f123-456-789\",
|
|
488
|
+
\"s3_key\": \"user-staging/user123/kg456/Entity/f123.../data.parquet\"
|
|
489
|
+
}
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
**Example Usage:**
|
|
493
|
+
```bash
|
|
494
|
+
# Step 1: Get upload URL
|
|
495
|
+
curl -X POST \"https://api.robosystems.ai/v1/graphs/kg123/tables/Entity/files\" \
|
|
496
|
+
-H \"Authorization: Bearer YOUR_TOKEN\" \
|
|
497
|
+
-H \"Content-Type: application/json\" \
|
|
498
|
+
-d '{
|
|
499
|
+
\"file_name\": \"entities.parquet\",
|
|
500
|
+
\"content_type\": \"application/x-parquet\"
|
|
501
|
+
}'
|
|
502
|
+
|
|
503
|
+
# Step 2: Upload file directly to S3
|
|
504
|
+
curl -X PUT \"$UPLOAD_URL\" \
|
|
505
|
+
-H \"Content-Type: application/x-parquet\" \
|
|
506
|
+
--data-binary \"@entities.parquet\"
|
|
507
|
+
|
|
508
|
+
# Step 3: Mark as uploaded
|
|
509
|
+
curl -X PATCH \"https://api.robosystems.ai/v1/graphs/kg123/tables/files/$FILE_ID\" \
|
|
510
|
+
-H \"Authorization: Bearer YOUR_TOKEN\" \
|
|
511
|
+
-H \"Content-Type: application/json\" \
|
|
512
|
+
-d '{\"status\": \"uploaded\"}'
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
**Tips:**
|
|
516
|
+
- Presigned URLs expire (default: 1 hour)
|
|
517
|
+
- Use appropriate Content-Type header when uploading to S3
|
|
518
|
+
- File extension must match content type
|
|
519
|
+
- Large files benefit from direct S3 upload
|
|
520
|
+
|
|
521
|
+
**Note:**
|
|
522
|
+
Upload URL generation is included - no credit consumption.
|
|
523
|
+
|
|
524
|
+
Args:
|
|
525
|
+
graph_id (str): Graph database identifier
|
|
526
|
+
table_name (str): Table name
|
|
527
|
+
token (Union[None, Unset, str]): JWT token for SSE authentication
|
|
528
|
+
authorization (Union[None, Unset, str]):
|
|
529
|
+
body (FileUploadRequest):
|
|
530
|
+
|
|
531
|
+
Raises:
|
|
532
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
533
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
534
|
+
|
|
535
|
+
Returns:
|
|
536
|
+
Union[Any, ErrorResponse, FileUploadResponse, HTTPValidationError]
|
|
537
|
+
"""
|
|
538
|
+
|
|
539
|
+
return (
|
|
540
|
+
await asyncio_detailed(
|
|
541
|
+
graph_id=graph_id,
|
|
542
|
+
table_name=table_name,
|
|
543
|
+
client=client,
|
|
544
|
+
body=body,
|
|
545
|
+
token=token,
|
|
546
|
+
authorization=authorization,
|
|
547
|
+
)
|
|
548
|
+
).parsed
|