Skip to content

Commit

Permalink
squashme: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
olevski committed Jul 12, 2024
1 parent 559f07e commit 00ef3ba
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 102 deletions.
113 changes: 45 additions & 68 deletions components/renku_data_services/session/api.spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,10 @@ servers:
paths:
/environments:
get:
summary: Get all environments
parameters:
- in: query
name: owner_type
schema:
$ref: "#/components/schemas/EnvironmentOwnerType"
description: Filter the environments by the owner type.
summary: Get all global environments
responses:
"200":
description: List of environments
description: List of global environments
content:
application/json:
schema:
Expand All @@ -30,7 +24,7 @@ paths:
tags:
- environments
post:
summary: Create a new session environment
summary: Create a new global session environment
description: Requires admin permissions
requestBody:
required: true
Expand All @@ -51,7 +45,7 @@ paths:
- environments
/environments/{environment_id}:
get:
summary: Get a session environment
summary: Get a global session environment
parameters:
- in: path
name: environment_id
Expand All @@ -76,7 +70,7 @@ paths:
tags:
- environments
patch:
summary: Update specific fields of an existing session environment
summary: Update specific fields of an existing global session environment
description: Requires admin permissions
parameters:
- in: path
Expand Down Expand Up @@ -108,7 +102,7 @@ paths:
tags:
- environments
delete:
summary: Remove a session environment
summary: Remove a global session environment
parameters:
- in: path
name: environment_id
Expand Down Expand Up @@ -182,7 +176,7 @@ paths:
tags:
- session_launchers
patch:
summary: Update specific fields of an existing session
summary: Update specific fields of an existing session launcher
parameters:
- in: path
name: launcher_id
Expand Down Expand Up @@ -270,10 +264,6 @@ components:
$ref: "#/components/schemas/ContainerImage"
default_url:
$ref: "#/components/schemas/DefaultUrl"
owner_type:
$ref: "#/components/schemas/EnvironmentOwnerType"
owner_id:
$ref: "#/components/schemas/EnvironmentOwnerId"
uid:
$ref: "#/components/schemas/EnvironmentUid"
gid:
Expand All @@ -284,8 +274,6 @@ components:
$ref: "#/components/schemas/EnvironmentMountDirectory"
port:
$ref: "#/components/schemas/EnvironmentPort"
visibility:
$ref: "#/components/schemas/EnvironmentVisibility"
required:
- id
- name
Expand All @@ -298,9 +286,6 @@ components:
- uid
- gid
- default_url
- owner_type
- owner_id
- visibility
example:
id: 01AN4Z79ZS6XX96588FDX0H099
name: JupyterLab environment
Expand All @@ -313,10 +298,29 @@ components:
mount_directory: /home/jovyan/work
uid: 1000
gid: 1000
owner_type: user
ownerId: 4fcd155c-fef5-48de-87f7-2facab8bf4c2
visibility: private
EnvironmentGetInLauncher:
allOf:
- $ref: "#/components/schemas/Environment"
- type: object
properties:
environment_kind:
$ref: "#/components/schemas/EnvironmentKind"
required:
- environment_kind
example:
environment_kind: global_environment
EnvironmentPostInLauncher:
allOf:
- $ref: "#/components/schemas/EnvironmentPost"
- type: object
properties:
environment_kind:
$ref: "#/components/schemas/EnvironmentKind"
required:
- environment_kind
example:
environment_kind: global_environment
EnvironmentPost:
description: Data required to create a session environment
type: object
properties:
Expand Down Expand Up @@ -350,26 +354,19 @@ components:
allOf:
- $ref: "#/components/schemas/EnvironmentPort"
- default: 8080
visibility:
allOf:
- $ref: "#/components/schemas/EnvironmentVisibility"
- default: private
required:
- name
- container_image
EnvironmentPost:
EnvironmentPatchInLauncher:
allOf:
- $ref: "#/components/schemas/EnvironmentPostInLauncher"
- $ref: "#/components/schemas/EnvironmentPatch"
- type: object
properties:
owner_id:
$ref: "#/components/schemas/EnvironmentOwnerId"
owner_type:
$ref: "#/components/schemas/EnvironmentOwnerType"
required:
- owner_id
- owner_type
EnvironmentPatchInLauncher:
environment_kind:
$ref: "#/components/schemas/EnvironmentKind"
example:
environment_kind: global_environment
EnvironmentPatch:
type: object
description: Update a session environment
additionalProperties: false
Expand All @@ -392,15 +389,6 @@ components:
$ref: "#/components/schemas/EnvironmentMountDirectory"
port:
$ref: "#/components/schemas/EnvironmentPort"
EnvironmentPatch:
allOf:
- $ref: "#/components/schemas/EnvironmentPatchInLauncher"
- type: object
properties:
owner_id:
$ref: "#/components/schemas/EnvironmentOwnerId"
owner_type:
$ref: "#/components/schemas/EnvironmentOwnerType"
SessionLaunchersList:
description: A list of Renku session launchers
type: array
Expand All @@ -422,7 +410,7 @@ components:
description:
$ref: "#/components/schemas/Description"
environment:
$ref: "#/components/schemas/Environment"
$ref: "#/components/schemas/EnvironmentGetInLauncher"
required:
- id
- project_id
Expand All @@ -440,16 +428,14 @@ components:
name: Rstudio
creation_date: "2023-11-01T17:32:28Z"
description: JupyterLab session environment
environment_kind: global_environment
container_image: rocker/rstudio
default_url: "/rstudio"
port: 8080
working_directory: /home/rstudio/work
mount_directory: /home/rstudio/work
uid: 1000
gid: 1000
owner_type: project
ownerId: 01AN4Z79ZS5XN0F25N3DB94T4R
visibility: private
SessionLauncherPost:
description: Data required to create a session launcher
type: object
Expand Down Expand Up @@ -510,6 +496,13 @@ components:
$ref: "#/components/schemas/EnvironmentId"
required:
- id
EnvironmentKind:
description: Kind of environment to use
type: string
enum:
- global_environment
- container_image
example: container_image
EnvironmentId:
description: Id of the environment to use
type: string
Expand Down Expand Up @@ -565,22 +558,6 @@ components:
type: string
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
minLength: 1
EnvironmentOwnerType:
type: string
enum:
- user
- group
- project
- platform
description: The owner of the environment which is used to enforce authorization on it
EnvironmentOwnerId:
type: string
description: The id of the entity that owns the environment
EnvironmentVisibility:
type: string
enum:
- public
- private
ErrorResponse:
type: object
properties:
Expand Down
53 changes: 19 additions & 34 deletions components/renku_data_services/session/apispec.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# generated by datamodel-codegen:
# filename: api.spec.yaml
# timestamp: 2024-07-10T15:10:10+00:00
# timestamp: 2024-07-12T08:53:46+00:00

from __future__ import annotations

Expand All @@ -12,16 +12,9 @@
from renku_data_services.session.apispec_base import BaseAPISpec


class EnvironmentOwnerType(Enum):
user = "user"
group = "group"
project = "project"
platform = "platform"


class EnvironmentVisibility(Enum):
public = "public"
private = "private"
class EnvironmentKind(Enum):
global_environment = "global_environment"
container_image = "container_image"


class Error(BaseAPISpec):
Expand Down Expand Up @@ -71,10 +64,6 @@ class Environment(BaseAPISpec):
example="/lab",
max_length=200,
)
owner_type: EnvironmentOwnerType
owner_id: str = Field(
..., description="The id of the entity that owns the environment"
)
uid: int = Field(
..., description="The user ID used to run the session", gt=0, le=65535
)
Expand All @@ -95,10 +84,13 @@ class Environment(BaseAPISpec):
gt=0,
le=65535,
)
visibility: EnvironmentVisibility


class EnvironmentPostInLauncher(BaseAPISpec):
class EnvironmentGetInLauncher(Environment):
environment_kind: EnvironmentKind


class EnvironmentPost(BaseAPISpec):
name: str = Field(
...,
description="Renku session name",
Expand Down Expand Up @@ -141,17 +133,9 @@ class EnvironmentPostInLauncher(BaseAPISpec):
gt=0,
le=65535,
)
visibility: Optional[EnvironmentVisibility] = None


class EnvironmentPost(EnvironmentPostInLauncher):
owner_id: str = Field(
..., description="The id of the entity that owns the environment"
)
owner_type: EnvironmentOwnerType


class EnvironmentPatchInLauncher(BaseAPISpec):
class EnvironmentPatch(BaseAPISpec):
model_config = ConfigDict(
extra="forbid",
)
Expand Down Expand Up @@ -199,13 +183,6 @@ class EnvironmentPatchInLauncher(BaseAPISpec):
)


class EnvironmentPatch(EnvironmentPatchInLauncher):
owner_id: Optional[str] = Field(
None, description="The id of the entity that owns the environment"
)
owner_type: Optional[EnvironmentOwnerType] = None


class SessionLauncher(BaseAPISpec):
id: str = Field(
...,
Expand Down Expand Up @@ -236,7 +213,7 @@ class SessionLauncher(BaseAPISpec):
description: Optional[str] = Field(
None, description="A description for the resource", max_length=500
)
environment: Environment
environment: EnvironmentGetInLauncher


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


class EnvironmentPostInLauncher(EnvironmentPost):
environment_kind: EnvironmentKind


class EnvironmentPatchInLauncher(EnvironmentPatch):
environment_kind: Optional[EnvironmentKind] = None


class SessionLaunchersList(RootModel[List[SessionLauncher]]):
root: List[SessionLauncher] = Field(
..., description="A list of Renku session launchers", min_length=0
Expand Down

0 comments on commit 00ef3ba

Please sign in to comment.