Skip to content

Commit 9ea5d8d

Browse files
authored
♻️ Enhancement/storage refactoring part 1 (ITISFoundation#3077)
1 parent 4ef961e commit 9ea5d8d

File tree

28 files changed

+193
-294
lines changed

28 files changed

+193
-294
lines changed

api/specs/storage/openapi.yaml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,12 @@ paths:
214214
default:
215215
$ref: "#/components/responses/DefaultErrorResponse"
216216

217-
/locations/{location_id}/files/{fileId}/metadata:
217+
/locations/{location_id}/files/{file_id}/metadata:
218218
get:
219219
summary: Get file metadata
220220
operationId: get_file_metadata
221221
parameters:
222-
- name: fileId
222+
- name: file_id
223223
in: path
224224
required: true
225225
schema:
@@ -247,7 +247,7 @@ paths:
247247
summary: Update file metadata
248248
operationId: update_file_meta_data
249249
parameters:
250-
- name: fileId
250+
- name: file_id
251251
in: path
252252
required: true
253253
schema:
@@ -272,12 +272,12 @@ paths:
272272
default:
273273
$ref: "#/components/responses/DefaultErrorResponse"
274274

275-
/locations/{location_id}/files/{fileId}:
275+
/locations/{location_id}/files/{file_id}:
276276
get:
277277
summary: Gets download link for file at location
278278
operationId: download_file
279279
parameters:
280-
- name: fileId
280+
- name: file_id
281281
in: path
282282
required: true
283283
schema:
@@ -312,10 +312,10 @@ paths:
312312
default:
313313
$ref: "#/components/responses/DefaultErrorResponse"
314314
put:
315-
summary: Returns upload link or performs copy operation to datcore
315+
summary: Returns upload object
316316
operationId: upload_file
317317
parameters:
318-
- name: fileId
318+
- name: file_id
319319
in: path
320320
required: true
321321
schema:
@@ -330,16 +330,6 @@ paths:
330330
required: true
331331
schema:
332332
type: string
333-
- name: extra_location
334-
in: query
335-
required: false
336-
schema:
337-
type: string
338-
- name: extra_source
339-
in: query
340-
required: false
341-
schema:
342-
type: string
343333
- name: link_type
344334
in: query
345335
required: false
@@ -362,7 +352,7 @@ paths:
362352
summary: Deletes file
363353
operationId: delete_file
364354
parameters:
365-
- name: fileId
355+
- name: file_id
366356
in: path
367357
required: true
368358
schema:
@@ -379,7 +369,7 @@ paths:
379369
type: string
380370
responses:
381371
"204":
382-
description: everything is OK, but there is no content to return
372+
description: everything is OK
383373
default:
384374
$ref: "#/components/responses/DefaultErrorResponse"
385375

api/specs/webserver/openapi-storage.yaml

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,14 @@ paths:
120120
default:
121121
$ref: "#/components/responses/DefaultErrorResponse"
122122

123-
/storage/locations/{location_id}/files/{fileId}:
123+
/storage/locations/{location_id}/files/{file_id}:
124124
get:
125125
summary: Returns download link for requested file
126126
tags:
127127
- storage
128128
operationId: download_file
129129
parameters:
130-
- name: fileId
130+
- name: file_id
131131
in: path
132132
required: true
133133
schema:
@@ -141,12 +141,12 @@ paths:
141141
"200":
142142
$ref: "#/components/responses/PresignedLink_200"
143143
put:
144-
summary: Returns upload link or performs copy operation to datcore
144+
summary: Returns upload link
145145
tags:
146146
- storage
147147
operationId: upload_file
148148
parameters:
149-
- name: fileId
149+
- name: file_id
150150
in: path
151151
required: true
152152
schema:
@@ -156,16 +156,6 @@ paths:
156156
required: true
157157
schema:
158158
type: string
159-
- name: extra_location
160-
in: query
161-
required: false
162-
schema:
163-
type: string
164-
- name: extra_source
165-
in: query
166-
required: false
167-
schema:
168-
type: string
169159
responses:
170160
"200":
171161
$ref: "#/components/responses/PresignedLink_200"
@@ -175,7 +165,7 @@ paths:
175165
- storage
176166
operationId: delete_file
177167
parameters:
178-
- name: fileId
168+
- name: file_id
179169
in: path
180170
required: true
181171
schema:
@@ -189,14 +179,14 @@ paths:
189179
"204":
190180
description: ""
191181

192-
/storage/locations/{location_id}/files/{fileId}/metadata:
182+
/storage/locations/{location_id}/files/{file_id}/metadata:
193183
get:
194184
summary: Get File Metadata
195185
tags:
196186
- storage
197187
operationId: get_file_metadata
198188
parameters:
199-
- name: fileId
189+
- name: file_id
200190
in: path
201191
required: true
202192
schema:
@@ -215,7 +205,7 @@ paths:
215205
- storage
216206
operationId: update_file_meta_data
217207
parameters:
218-
- name: fileId
208+
- name: file_id
219209
in: path
220210
required: true
221211
schema:

api/specs/webserver/openapi.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@ paths:
144144
/storage/locations/{location_id}/files/metadata:
145145
$ref: "./openapi-storage.yaml#/paths/~1storage~1locations~1{location_id}~1files~1metadata"
146146

147-
/storage/locations/{location_id}/files/{fileId}:
148-
$ref: "./openapi-storage.yaml#/paths/~1storage~1locations~1{location_id}~1files~1{fileId}"
147+
/storage/locations/{location_id}/files/{file_id}:
148+
$ref: "./openapi-storage.yaml#/paths/~1storage~1locations~1{location_id}~1files~1{file_id}"
149149

150-
/storage/locations/{location_id}/files/{fileId}/metadata:
151-
$ref: "./openapi-storage.yaml#/paths/~1storage~1locations~1{location_id}~1files~1{fileId}~1metadata"
150+
/storage/locations/{location_id}/files/{file_id}/metadata:
151+
$ref: "./openapi-storage.yaml#/paths/~1storage~1locations~1{location_id}~1files~1{file_id}~1metadata"
152152

153153
/storage/locations/{location_id}/datasets/{dataset_id}/metadata:
154154
$ref: "./openapi-storage.yaml#/paths/~1storage~1locations~1{location_id}~1datasets~1{dataset_id}~1metadata"

packages/models-library/src/models_library/api_schemas_storage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class Config:
9090

9191

9292
# /locations/{location_id}/files/metadata:
93-
# /locations/{location_id}/files/{fileId}/metadata:
93+
# /locations/{location_id}/files/{file_id}/metadata:
9494
class FileMetaData(BaseModel):
9595
file_uuid: Optional[str] = Field(
9696
description="Unique identifier for a file, like bucket_name/project_id/node_id/file_name = /bucket_name/object_name",
@@ -189,7 +189,7 @@ class FileMetaDataArray(BaseModel):
189189
__root__: List[FileMetaData] = []
190190

191191

192-
# /locations/{location_id}/files/{fileId}
192+
# /locations/{location_id}/files/{file_id}
193193

194194

195195
class PresignedLink(BaseModel):

services/storage/src/simcore_service_storage/access_layer.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
import logging
4141
from dataclasses import dataclass
42-
from typing import Dict, List, Optional
42+
from typing import Optional
4343
from uuid import UUID
4444

4545
import sqlalchemy as sa
@@ -89,15 +89,15 @@ def __str__(self):
8989
return "Error in {}: {} [{}]".format(self.identifier, self.reason, self.details)
9090

9191

92-
async def _get_user_groups_ids(conn: SAConnection, user_id: int) -> List[int]:
92+
async def _get_user_groups_ids(conn: SAConnection, user_id: int) -> list[int]:
9393
stmt = sa.select([user_to_groups.c.gid]).where(user_to_groups.c.uid == user_id)
9494
rows = await (await conn.execute(stmt)).fetchall()
9595
user_group_ids = [g.gid for g in rows]
9696
return user_group_ids
9797

9898

9999
def _aggregate_access_rights(
100-
access_rights: Dict[str, Dict], group_ids: List[int]
100+
access_rights: dict[str, dict], group_ids: list[int]
101101
) -> AccessRights:
102102
try:
103103
prj_access = {"read": False, "write": False, "delete": False}
@@ -118,12 +118,12 @@ def _aggregate_access_rights(
118118

119119
async def list_projects_access_rights(
120120
conn: SAConnection, user_id: int
121-
) -> Dict[ProjectID, AccessRights]:
121+
) -> dict[ProjectID, AccessRights]:
122122
"""
123123
Returns access-rights of user (user_id) over all OWNED or SHARED projects
124124
"""
125125

126-
user_group_ids: List[int] = await _get_user_groups_ids(conn, user_id)
126+
user_group_ids: list[int] = await _get_user_groups_ids(conn, user_id)
127127

128128
smt = text(
129129
f"""\
@@ -164,7 +164,7 @@ async def get_project_access_rights(
164164
"""
165165
Returns access-rights of user (user_id) over a project resource (project_id)
166166
"""
167-
user_group_ids: List[int] = await _get_user_groups_ids(conn, user_id)
167+
user_group_ids: list[int] = await _get_user_groups_ids(conn, user_id)
168168

169169
stmt = text(
170170
f"""\
@@ -281,7 +281,7 @@ async def get_file_access_rights(
281281
# HELPERS -----------------------------------------------
282282

283283

284-
async def get_readable_project_ids(conn: SAConnection, user_id: int) -> List[ProjectID]:
284+
async def get_readable_project_ids(conn: SAConnection, user_id: int) -> list[ProjectID]:
285285
"""Returns a list of projects where user has granted read-access"""
286286
projects_access_rights = await list_projects_access_rights(conn, int(user_id))
287287
return [pid for pid, access in projects_access_rights.items() if access.read]

services/storage/src/simcore_service_storage/api/v0/openapi.yaml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,12 @@ paths:
208208
$ref: '#/components/schemas/FileMetaDataArrayEnveloped'
209209
default:
210210
$ref: '#/components/responses/DefaultErrorResponse'
211-
'/locations/{location_id}/files/{fileId}/metadata':
211+
'/locations/{location_id}/files/{file_id}/metadata':
212212
get:
213213
summary: Get file metadata
214214
operationId: get_file_metadata
215215
parameters:
216-
- name: fileId
216+
- name: file_id
217217
in: path
218218
required: true
219219
schema:
@@ -241,7 +241,7 @@ paths:
241241
summary: Update file metadata
242242
operationId: update_file_meta_data
243243
parameters:
244-
- name: fileId
244+
- name: file_id
245245
in: path
246246
required: true
247247
schema:
@@ -265,12 +265,12 @@ paths:
265265
$ref: '#/components/schemas/FileMetaEnvelope'
266266
default:
267267
$ref: '#/components/responses/DefaultErrorResponse'
268-
'/locations/{location_id}/files/{fileId}':
268+
'/locations/{location_id}/files/{file_id}':
269269
get:
270270
summary: Gets download link for file at location
271271
operationId: download_file
272272
parameters:
273-
- name: fileId
273+
- name: file_id
274274
in: path
275275
required: true
276276
schema:
@@ -304,10 +304,10 @@ paths:
304304
default:
305305
$ref: '#/components/responses/DefaultErrorResponse'
306306
put:
307-
summary: Returns upload link or performs copy operation to datcore
307+
summary: Returns upload object
308308
operationId: upload_file
309309
parameters:
310-
- name: fileId
310+
- name: file_id
311311
in: path
312312
required: true
313313
schema:
@@ -322,16 +322,6 @@ paths:
322322
required: true
323323
schema:
324324
type: string
325-
- name: extra_location
326-
in: query
327-
required: false
328-
schema:
329-
type: string
330-
- name: extra_source
331-
in: query
332-
required: false
333-
schema:
334-
type: string
335325
- name: link_type
336326
in: query
337327
required: false
@@ -354,7 +344,7 @@ paths:
354344
summary: Deletes file
355345
operationId: delete_file
356346
parameters:
357-
- name: fileId
347+
- name: file_id
358348
in: path
359349
required: true
360350
schema:
@@ -371,7 +361,7 @@ paths:
371361
type: string
372362
responses:
373363
'204':
374-
description: 'everything is OK, but there is no content to return'
364+
description: everything is OK
375365
default:
376366
$ref: '#/components/responses/DefaultErrorResponse'
377367
'/simcore-s3:access':

0 commit comments

Comments
 (0)