19
19
20
20
# ------------------------------------------------------- #
21
21
# Files
22
- # Files
23
- # Specification: core :v1.0
22
+ # CRUD API for operating on binary content in file and file[] columns.
23
+ # Specification: workspace :v1.0
24
24
# ------------------------------------------------------- #
25
25
26
26
from requests import request
@@ -46,6 +46,7 @@ def get_item(
46
46
"""
47
47
Retrieves file content from an array by file ID
48
48
49
+ Reference: https://xata.io/docs/api-reference/db/db_branch_name/tables/table_name/data/record_id/column/column_name/file/file_id#download-content-from-a-file-item-in-a-file-array-column
49
50
Path: /db/{db_branch_name}/tables/{table_name}/data/{record_id}/column/{column_name}/file/{file_id}
50
51
Method: GET
51
52
Response status codes:
@@ -54,6 +55,7 @@ def get_item(
54
55
- 401: Authentication Error
55
56
- 404: Example response
56
57
- 5XX: Unexpected Error
58
+ - default: Unexpected Error
57
59
Response: */*
58
60
59
61
:param table_name: str The Table name
@@ -63,7 +65,7 @@ def get_item(
63
65
:param db_name: str = None The name of the database to query. Default: database name from the client.
64
66
:param branch_name: str = None The name of the branch to query. Default: branch name from the client.
65
67
66
- :return ApiResponse
68
+ :returns ApiResponse
67
69
"""
68
70
db_branch_name = self .client .get_db_branch_name (db_name , branch_name )
69
71
url_path = f"/db/{ db_branch_name } /tables/{ table_name } /data/{ record_id } /column/{ column_name } /file/{ file_id } "
@@ -83,6 +85,7 @@ def put_item(
83
85
"""
84
86
Uploads the file content to an array given the file ID
85
87
88
+ Reference: https://xata.io/docs/api-reference/db/db_branch_name/tables/table_name/data/record_id/column/column_name/file/file_id#upload-or-update-the-content-of-a-file-item-in-a-file-array-column
86
89
Path: /db/{db_branch_name}/tables/{table_name}/data/{record_id}/column/{column_name}/file/{file_id}
87
90
Method: PUT
88
91
Response status codes:
@@ -93,6 +96,7 @@ def put_item(
93
96
- 404: Example response
94
97
- 422: Example response
95
98
- 5XX: Unexpected Error
99
+ - default: Unexpected Error
96
100
97
101
:param table_name: str The Table name
98
102
:param record_id: str The Record name
@@ -103,12 +107,13 @@ def put_item(
103
107
:param db_name: str = None The name of the database to query. Default: database name from the client.
104
108
:param branch_name: str = None The name of the branch to query. Default: branch name from the client.
105
109
106
- :return ApiResponse
110
+ :returns ApiResponse
107
111
"""
112
+
108
113
db_branch_name = self .client .get_db_branch_name (db_name , branch_name )
109
114
url_path = f"/db/{ db_branch_name } /tables/{ table_name } /data/{ record_id } /column/{ column_name } /file/{ file_id } "
110
115
headers = {"content-type" : content_type }
111
- return self .request ("PUT" , url_path , headers , data = data )
116
+ return self .request ("PUT" , url_path , headers , data = data , override_base_url = self . get_upload_base_url () )
112
117
113
118
def delete_item (
114
119
self ,
@@ -122,6 +127,7 @@ def delete_item(
122
127
"""
123
128
Deletes an item from an file array column given the file ID
124
129
130
+ Reference: https://xata.io/docs/api-reference/db/db_branch_name/tables/table_name/data/record_id/column/column_name/file/file_id#delete-an-item-from-a-file-array
125
131
Path: /db/{db_branch_name}/tables/{table_name}/data/{record_id}/column/{column_name}/file/{file_id}
126
132
Method: DELETE
127
133
Response status codes:
@@ -130,6 +136,7 @@ def delete_item(
130
136
- 401: Authentication Error
131
137
- 404: Example response
132
138
- 5XX: Unexpected Error
139
+ - default: Unexpected Error
133
140
134
141
:param table_name: str The Table name
135
142
:param record_id: str The Record name
@@ -138,7 +145,7 @@ def delete_item(
138
145
:param db_name: str = None The name of the database to query. Default: database name from the client.
139
146
:param branch_name: str = None The name of the branch to query. Default: branch name from the client.
140
147
141
- :return ApiResponse
148
+ :returns ApiResponse
142
149
"""
143
150
db_branch_name = self .client .get_db_branch_name (db_name , branch_name )
144
151
url_path = f"/db/{ db_branch_name } /tables/{ table_name } /data/{ record_id } /column/{ column_name } /file/{ file_id } "
@@ -150,6 +157,7 @@ def get(
150
157
"""
151
158
Retrieves the file content from a file column
152
159
160
+ Reference: https://xata.io/docs/api-reference/db/db_branch_name/tables/table_name/data/record_id/column/column_name/file#download-content-from-a-file-column
153
161
Path: /db/{db_branch_name}/tables/{table_name}/data/{record_id}/column/{column_name}/file
154
162
Method: GET
155
163
Response status codes:
@@ -159,6 +167,7 @@ def get(
159
167
- 401: Authentication Error
160
168
- 404: Example response
161
169
- 5XX: Unexpected Error
170
+ - default: Unexpected Error
162
171
Response: */*
163
172
164
173
:param table_name: str The Table name
@@ -167,7 +176,7 @@ def get(
167
176
:param db_name: str = None The name of the database to query. Default: database name from the client.
168
177
:param branch_name: str = None The name of the branch to query. Default: branch name from the client.
169
178
170
- :return ApiResponse
179
+ :returns ApiResponse
171
180
"""
172
181
db_branch_name = self .client .get_db_branch_name (db_name , branch_name )
173
182
url_path = f"/db/{ db_branch_name } /tables/{ table_name } /data/{ record_id } /column/{ column_name } /file"
@@ -186,6 +195,7 @@ def put(
186
195
"""
187
196
Uploads the file content to the given file column
188
197
198
+ Reference: https://xata.io/docs/api-reference/db/db_branch_name/tables/table_name/data/record_id/column/column_name/file#upload-content-to-a-file-column
189
199
Path: /db/{db_branch_name}/tables/{table_name}/data/{record_id}/column/{column_name}/file
190
200
Method: PUT
191
201
Response status codes:
@@ -196,27 +206,30 @@ def put(
196
206
- 404: Example response
197
207
- 422: Example response
198
208
- 5XX: Unexpected Error
209
+ - default: Unexpected Error
199
210
200
211
:param table_name: str The Table name
201
212
:param record_id: str The Record name
202
213
:param column_name: str The Column name
203
- :param data: bytes
214
+ :param data: bytes content
215
+ :param content_type: str Default: "application/octet-stream"
204
216
:param db_name: str = None The name of the database to query. Default: database name from the client.
205
217
:param branch_name: str = None The name of the branch to query. Default: branch name from the client.
206
218
207
- :return ApiResponse
219
+ :returns ApiResponse
208
220
"""
209
221
db_branch_name = self .client .get_db_branch_name (db_name , branch_name )
210
222
url_path = f"/db/{ db_branch_name } /tables/{ table_name } /data/{ record_id } /column/{ column_name } /file"
211
223
headers = {"content-type" : content_type }
212
- return self .request ("PUT" , url_path , headers , data = data )
224
+ return self .request ("PUT" , url_path , headers , data = data , override_base_url = self . get_upload_base_url () )
213
225
214
226
def delete (
215
227
self , table_name : str , record_id : str , column_name : str , db_name : str = None , branch_name : str = None
216
228
) -> ApiResponse :
217
229
"""
218
230
Deletes a file referred in a file column
219
231
232
+ Reference: https://xata.io/docs/api-reference/db/db_branch_name/tables/table_name/data/record_id/column/column_name/file#remove-the-content-from-a-file-column
220
233
Path: /db/{db_branch_name}/tables/{table_name}/data/{record_id}/column/{column_name}/file
221
234
Method: DELETE
222
235
Response status codes:
@@ -225,14 +238,15 @@ def delete(
225
238
- 401: Authentication Error
226
239
- 404: Example response
227
240
- 5XX: Unexpected Error
241
+ - default: Unexpected Error
228
242
229
243
:param table_name: str The Table name
230
244
:param record_id: str The Record name
231
245
:param column_name: str The Column name
232
246
:param db_name: str = None The name of the database to query. Default: database name from the client.
233
247
:param branch_name: str = None The name of the branch to query. Default: branch name from the client.
234
248
235
- :return ApiResponse
249
+ :returns ApiResponse
236
250
"""
237
251
db_branch_name = self .client .get_db_branch_name (db_name , branch_name )
238
252
url_path = f"/db/{ db_branch_name } /tables/{ table_name } /data/{ record_id } /column/{ column_name } /file"
0 commit comments