Skip to content

Commit 86b8962

Browse files
committed
squashme: address comments
1 parent 559f07e commit 86b8962

2 files changed

Lines changed: 64 additions & 103 deletions

File tree

components/renku_data_services/session/api.spec.yaml

Lines changed: 45 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,10 @@ servers:
1111
paths:
1212
/environments:
1313
get:
14-
summary: Get all environments
15-
parameters:
16-
- in: query
17-
name: owner_type
18-
schema:
19-
$ref: "#/components/schemas/EnvironmentOwnerType"
20-
description: Filter the environments by the owner type.
14+
summary: Get all global environments
2115
responses:
2216
"200":
23-
description: List of environments
17+
description: List of global environments
2418
content:
2519
application/json:
2620
schema:
@@ -30,7 +24,7 @@ paths:
3024
tags:
3125
- environments
3226
post:
33-
summary: Create a new session environment
27+
summary: Create a new global session environment
3428
description: Requires admin permissions
3529
requestBody:
3630
required: true
@@ -51,7 +45,7 @@ paths:
5145
- environments
5246
/environments/{environment_id}:
5347
get:
54-
summary: Get a session environment
48+
summary: Get a global session environment
5549
parameters:
5650
- in: path
5751
name: environment_id
@@ -76,7 +70,7 @@ paths:
7670
tags:
7771
- environments
7872
patch:
79-
summary: Update specific fields of an existing session environment
73+
summary: Update specific fields of an existing global session environment
8074
description: Requires admin permissions
8175
parameters:
8276
- in: path
@@ -108,7 +102,7 @@ paths:
108102
tags:
109103
- environments
110104
delete:
111-
summary: Remove a session environment
105+
summary: Remove a global session environment
112106
parameters:
113107
- in: path
114108
name: environment_id
@@ -182,7 +176,7 @@ paths:
182176
tags:
183177
- session_launchers
184178
patch:
185-
summary: Update specific fields of an existing session
179+
summary: Update specific fields of an existing session launcher
186180
parameters:
187181
- in: path
188182
name: launcher_id
@@ -270,10 +264,6 @@ components:
270264
$ref: "#/components/schemas/ContainerImage"
271265
default_url:
272266
$ref: "#/components/schemas/DefaultUrl"
273-
owner_type:
274-
$ref: "#/components/schemas/EnvironmentOwnerType"
275-
owner_id:
276-
$ref: "#/components/schemas/EnvironmentOwnerId"
277267
uid:
278268
$ref: "#/components/schemas/EnvironmentUid"
279269
gid:
@@ -284,23 +274,17 @@ components:
284274
$ref: "#/components/schemas/EnvironmentMountDirectory"
285275
port:
286276
$ref: "#/components/schemas/EnvironmentPort"
287-
visibility:
288-
$ref: "#/components/schemas/EnvironmentVisibility"
289277
required:
290278
- id
291279
- name
292280
- creation_date
293281
- container_image
294-
- official
295282
- port
296283
- working_directory
297284
- mount_directory
298285
- uid
299286
- gid
300287
- default_url
301-
- owner_type
302-
- owner_id
303-
- visibility
304288
example:
305289
id: 01AN4Z79ZS6XX96588FDX0H099
306290
name: JupyterLab environment
@@ -313,10 +297,29 @@ components:
313297
mount_directory: /home/jovyan/work
314298
uid: 1000
315299
gid: 1000
316-
owner_type: user
317-
ownerId: 4fcd155c-fef5-48de-87f7-2facab8bf4c2
318-
visibility: private
300+
EnvironmentGetInLauncher:
301+
allOf:
302+
- $ref: "#/components/schemas/Environment"
303+
- type: object
304+
properties:
305+
environment_kind:
306+
$ref: "#/components/schemas/EnvironmentKind"
307+
required:
308+
- environment_kind
309+
example:
310+
environment_kind: global_environment
319311
EnvironmentPostInLauncher:
312+
allOf:
313+
- $ref: "#/components/schemas/EnvironmentPost"
314+
- type: object
315+
properties:
316+
environment_kind:
317+
$ref: "#/components/schemas/EnvironmentKind"
318+
required:
319+
- environment_kind
320+
example:
321+
environment_kind: global_environment
322+
EnvironmentPost:
320323
description: Data required to create a session environment
321324
type: object
322325
properties:
@@ -350,26 +353,19 @@ components:
350353
allOf:
351354
- $ref: "#/components/schemas/EnvironmentPort"
352355
- default: 8080
353-
visibility:
354-
allOf:
355-
- $ref: "#/components/schemas/EnvironmentVisibility"
356-
- default: private
357356
required:
358357
- name
359358
- container_image
360-
EnvironmentPost:
359+
EnvironmentPatchInLauncher:
361360
allOf:
362-
- $ref: "#/components/schemas/EnvironmentPostInLauncher"
361+
- $ref: "#/components/schemas/EnvironmentPatch"
363362
- type: object
364363
properties:
365-
owner_id:
366-
$ref: "#/components/schemas/EnvironmentOwnerId"
367-
owner_type:
368-
$ref: "#/components/schemas/EnvironmentOwnerType"
369-
required:
370-
- owner_id
371-
- owner_type
372-
EnvironmentPatchInLauncher:
364+
environment_kind:
365+
$ref: "#/components/schemas/EnvironmentKind"
366+
example:
367+
environment_kind: global_environment
368+
EnvironmentPatch:
373369
type: object
374370
description: Update a session environment
375371
additionalProperties: false
@@ -392,15 +388,6 @@ components:
392388
$ref: "#/components/schemas/EnvironmentMountDirectory"
393389
port:
394390
$ref: "#/components/schemas/EnvironmentPort"
395-
EnvironmentPatch:
396-
allOf:
397-
- $ref: "#/components/schemas/EnvironmentPatchInLauncher"
398-
- type: object
399-
properties:
400-
owner_id:
401-
$ref: "#/components/schemas/EnvironmentOwnerId"
402-
owner_type:
403-
$ref: "#/components/schemas/EnvironmentOwnerType"
404391
SessionLaunchersList:
405392
description: A list of Renku session launchers
406393
type: array
@@ -422,7 +409,7 @@ components:
422409
description:
423410
$ref: "#/components/schemas/Description"
424411
environment:
425-
$ref: "#/components/schemas/Environment"
412+
$ref: "#/components/schemas/EnvironmentGetInLauncher"
426413
required:
427414
- id
428415
- project_id
@@ -440,16 +427,14 @@ components:
440427
name: Rstudio
441428
creation_date: "2023-11-01T17:32:28Z"
442429
description: JupyterLab session environment
430+
environment_kind: global_environment
443431
container_image: rocker/rstudio
444432
default_url: "/rstudio"
445433
port: 8080
446434
working_directory: /home/rstudio/work
447435
mount_directory: /home/rstudio/work
448436
uid: 1000
449437
gid: 1000
450-
owner_type: project
451-
ownerId: 01AN4Z79ZS5XN0F25N3DB94T4R
452-
visibility: private
453438
SessionLauncherPost:
454439
description: Data required to create a session launcher
455440
type: object
@@ -510,6 +495,13 @@ components:
510495
$ref: "#/components/schemas/EnvironmentId"
511496
required:
512497
- id
498+
EnvironmentKind:
499+
description: Kind of environment to use
500+
type: string
501+
enum:
502+
- global_environment
503+
- container_image
504+
example: container_image
513505
EnvironmentId:
514506
description: Id of the environment to use
515507
type: string
@@ -565,22 +557,6 @@ components:
565557
type: string
566558
description: The location where the persistent storage for the session will be mounted, usually it should be identical to or a parent of the working directory
567559
minLength: 1
568-
EnvironmentOwnerType:
569-
type: string
570-
enum:
571-
- user
572-
- group
573-
- project
574-
- platform
575-
description: The owner of the environment which is used to enforce authorization on it
576-
EnvironmentOwnerId:
577-
type: string
578-
description: The id of the entity that owns the environment
579-
EnvironmentVisibility:
580-
type: string
581-
enum:
582-
- public
583-
- private
584560
ErrorResponse:
585561
type: object
586562
properties:

components/renku_data_services/session/apispec.py

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: api.spec.yaml
3-
# timestamp: 2024-07-10T15:10:10+00:00
3+
# timestamp: 2024-07-12T08:57:02+00:00
44

55
from __future__ import annotations
66

@@ -12,16 +12,9 @@
1212
from renku_data_services.session.apispec_base import BaseAPISpec
1313

1414

15-
class EnvironmentOwnerType(Enum):
16-
user = "user"
17-
group = "group"
18-
project = "project"
19-
platform = "platform"
20-
21-
22-
class EnvironmentVisibility(Enum):
23-
public = "public"
24-
private = "private"
15+
class EnvironmentKind(Enum):
16+
global_environment = "global_environment"
17+
container_image = "container_image"
2518

2619

2720
class Error(BaseAPISpec):
@@ -71,10 +64,6 @@ class Environment(BaseAPISpec):
7164
example="/lab",
7265
max_length=200,
7366
)
74-
owner_type: EnvironmentOwnerType
75-
owner_id: str = Field(
76-
..., description="The id of the entity that owns the environment"
77-
)
7867
uid: int = Field(
7968
..., description="The user ID used to run the session", gt=0, le=65535
8069
)
@@ -95,10 +84,13 @@ class Environment(BaseAPISpec):
9584
gt=0,
9685
le=65535,
9786
)
98-
visibility: EnvironmentVisibility
9987

10088

101-
class EnvironmentPostInLauncher(BaseAPISpec):
89+
class EnvironmentGetInLauncher(Environment):
90+
environment_kind: EnvironmentKind
91+
92+
93+
class EnvironmentPost(BaseAPISpec):
10294
name: str = Field(
10395
...,
10496
description="Renku session name",
@@ -141,17 +133,9 @@ class EnvironmentPostInLauncher(BaseAPISpec):
141133
gt=0,
142134
le=65535,
143135
)
144-
visibility: Optional[EnvironmentVisibility] = None
145-
146-
147-
class EnvironmentPost(EnvironmentPostInLauncher):
148-
owner_id: str = Field(
149-
..., description="The id of the entity that owns the environment"
150-
)
151-
owner_type: EnvironmentOwnerType
152136

153137

154-
class EnvironmentPatchInLauncher(BaseAPISpec):
138+
class EnvironmentPatch(BaseAPISpec):
155139
model_config = ConfigDict(
156140
extra="forbid",
157141
)
@@ -199,13 +183,6 @@ class EnvironmentPatchInLauncher(BaseAPISpec):
199183
)
200184

201185

202-
class EnvironmentPatch(EnvironmentPatchInLauncher):
203-
owner_id: Optional[str] = Field(
204-
None, description="The id of the entity that owns the environment"
205-
)
206-
owner_type: Optional[EnvironmentOwnerType] = None
207-
208-
209186
class SessionLauncher(BaseAPISpec):
210187
id: str = Field(
211188
...,
@@ -236,7 +213,7 @@ class SessionLauncher(BaseAPISpec):
236213
description: Optional[str] = Field(
237214
None, description="A description for the resource", max_length=500
238215
)
239-
environment: Environment
216+
environment: EnvironmentGetInLauncher
240217

241218

242219
class EnvironmentIdOnlyPatch(BaseAPISpec):
@@ -261,6 +238,14 @@ class EnvironmentList(RootModel[List[Environment]]):
261238
root: List[Environment] = Field(..., description="A list of session environments")
262239

263240

241+
class EnvironmentPostInLauncher(EnvironmentPost):
242+
environment_kind: EnvironmentKind
243+
244+
245+
class EnvironmentPatchInLauncher(EnvironmentPatch):
246+
environment_kind: Optional[EnvironmentKind] = None
247+
248+
264249
class SessionLaunchersList(RootModel[List[SessionLauncher]]):
265250
root: List[SessionLauncher] = Field(
266251
..., description="A list of Renku session launchers", min_length=0

0 commit comments

Comments
 (0)