Skip to content

Commit 3da7dc0

Browse files
committed
feat: add new apispec for the new amalthea sessions
This will be used only in Renku v2 with the new Amalthea operator.
1 parent d6ba37c commit 3da7dc0

File tree

2 files changed

+426
-2
lines changed

2 files changed

+426
-2
lines changed

components/renku_data_services/notebooks/api.spec.yaml

Lines changed: 315 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,159 @@ paths:
244244
description: The server exists but could not be successfully hibernated.
245245
tags:
246246
- notebooks
247+
"/sessions":
248+
post:
249+
summary: Launch a new session
250+
requestBody:
251+
required: true
252+
content:
253+
application/json:
254+
schema:
255+
$ref: "#/components/schemas/SessionPostRequest"
256+
responses:
257+
"201":
258+
description: The session was created
259+
content:
260+
application/json:
261+
schema:
262+
$ref: "#/components/schemas/SessionResponse"
263+
"200":
264+
description: The session already exists
265+
content:
266+
application/json:
267+
schema:
268+
$ref: "#/components/schemas/SessionResponse"
269+
default:
270+
$ref: "#/components/responses/Error"
271+
tags:
272+
- sessions
273+
get:
274+
summary: Get a list of all sessions for a user
275+
responses:
276+
"200":
277+
description: Information about the sessions
278+
content:
279+
application/json:
280+
schema:
281+
$ref: "#/components/schemas/SessionListResponse"
282+
default:
283+
$ref: "#/components/responses/Error"
284+
tags:
285+
- sessions
286+
"/sessions/{session_id}":
287+
get:
288+
summary: Get information about a specific session
289+
parameters:
290+
- description: The id of the session
291+
in: path
292+
name: session_id
293+
required: true
294+
schema:
295+
type: string
296+
responses:
297+
"200":
298+
description: Information about the session
299+
content:
300+
application/json:
301+
schema:
302+
$ref: "#/components/schemas/SessionResponse"
303+
default:
304+
$ref: "#/components/responses/Error"
305+
tags:
306+
- sessions
307+
delete:
308+
parameters:
309+
- description: The id of the session that should be deleted
310+
in: path
311+
name: session_id
312+
required: true
313+
schema:
314+
type: string
315+
summary: Fully remove a session
316+
responses:
317+
"204":
318+
description: The session was deleted or it never existed in the first place
319+
default:
320+
$ref: "#/components/responses/Error"
321+
tags:
322+
- sessions
323+
patch:
324+
summary: Patch a session
325+
parameters:
326+
- description: The id of the session
327+
in: path
328+
name: session_id
329+
required: true
330+
schema:
331+
type: string
332+
requestBody:
333+
required: true
334+
content:
335+
application/json:
336+
schema:
337+
$ref: "#/components/schemas/SessionPatchRequest"
338+
responses:
339+
"200":
340+
description: The session was patched
341+
content:
342+
application/json:
343+
schema:
344+
$ref: "#/components/schemas/SessionResponse"
345+
default:
346+
$ref: "#/components/responses/Error"
347+
tags:
348+
- sessions
349+
"/sessions/{session_id}/logs":
350+
get:
351+
summary: Get all logs from a specific session
352+
parameters:
353+
- description: The id of the session
354+
in: path
355+
name: session_id
356+
required: true
357+
schema:
358+
type: string
359+
- description: The maximum number of most-recent lines to return for each container
360+
in: query
361+
name: max_lines
362+
required: false
363+
schema:
364+
type: integer
365+
default: 250
366+
responses:
367+
"200":
368+
description: The session logs
369+
content:
370+
application/json:
371+
schema:
372+
$ref: "#/components/schemas/SessionLogsResponse"
373+
default:
374+
$ref: "#/components/responses/Error"
375+
tags:
376+
- sessions
377+
"/sessions/images":
378+
get:
379+
summary: Check if a session image exists
380+
parameters:
381+
- description: The Docker image URL (tag included) that should be fetched.
382+
in: query
383+
name: image_url
384+
required: true
385+
schema:
386+
type: string
387+
responses:
388+
"200":
389+
description: The docker image can be found
390+
"404":
391+
description: The docker image cannot be found or the user does not have permissions to access it
392+
content:
393+
application/json:
394+
schema:
395+
$ref: "#/components/schemas/ErrorResponse"
396+
default:
397+
$ref: "#/components/responses/Error"
398+
tags:
399+
- sessions
247400
components:
248401
schemas:
249402
BoolServerOptionsChoice:
@@ -723,6 +876,168 @@ components:
723876
- renku.io/projectName
724877
- renku.io/repository
725878
type: object
879+
SessionPostRequest:
880+
properties:
881+
launcher_id:
882+
$ref: "#/components/schemas/Ulid"
883+
disk_storage:
884+
default: 1
885+
type: integer
886+
description: The size of disk storage for the session, in gigabytes
887+
resource_class_id:
888+
default:
889+
nullable: true
890+
type: integer
891+
cloudstorage:
892+
$ref: "#/components/schemas/SessionCloudStoragePostList"
893+
required:
894+
- launcher_id
895+
type: object
896+
SessionResponse:
897+
properties:
898+
image:
899+
type: string
900+
name:
901+
type: string
902+
resources:
903+
"$ref": "#/components/schemas/SessionResources"
904+
started:
905+
format: date-time
906+
nullable: true
907+
type: string
908+
status:
909+
"$ref": "#/components/schemas/SessionStatus"
910+
url:
911+
type: string
912+
project_id:
913+
$ref: "#/components/schemas/Ulid"
914+
launcher_id:
915+
$ref: "#/components/schemas/Ulid"
916+
resource_class_id:
917+
type: integer
918+
required:
919+
- image
920+
- name
921+
- resources
922+
- started
923+
- status
924+
- url
925+
- project_id
926+
- launcher_id
927+
- resource_class_id
928+
type: object
929+
SessionListResponse:
930+
items:
931+
"$ref": "#/components/schemas/SessionResponse"
932+
type: array
933+
SessionPatchRequest:
934+
properties:
935+
resource_class_id:
936+
type: integer
937+
state:
938+
enum:
939+
- running
940+
- hibernated
941+
type: string
942+
SessionStatus:
943+
properties:
944+
message:
945+
type: string
946+
state:
947+
enum:
948+
- running
949+
- starting
950+
- stopping
951+
- failed
952+
- hibernated
953+
type: string
954+
will_hibernate_at:
955+
format: date-time
956+
nullable: true
957+
type: string
958+
will_delete_at:
959+
format: date-time
960+
nullable: true
961+
type: string
962+
ready_containers:
963+
type: integer
964+
minimum: 0
965+
total_containers:
966+
type: integer
967+
minimum: 0
968+
required:
969+
- state
970+
- ready_containers
971+
- total_containers
972+
type: object
973+
SessionResources:
974+
properties:
975+
requests:
976+
"$ref": "#/components/schemas/SessionResourcesRequests"
977+
type: object
978+
SessionResourcesRequests:
979+
properties:
980+
cpu:
981+
type: number
982+
description: Fractional CPUs
983+
gpu:
984+
type: integer
985+
description: Number of GPUs used
986+
default: 0
987+
memory:
988+
type: integer
989+
description: Ammount of RAM for the session, in gigabytes
990+
storage:
991+
type: integer
992+
description: The size of disk storage for the session, in gigabytes
993+
required:
994+
- cpu
995+
- memory
996+
- storage
997+
example:
998+
cpu: 1.5
999+
memory: 1
1000+
storage: 40
1001+
gpu: 0
1002+
type: object
1003+
SessionLogsResponse:
1004+
type: object
1005+
additionalProperties:
1006+
type: string
1007+
example:
1008+
"container-A": "Log line 1\nLog line 2"
1009+
"container-B": "Log line 1\nLog line 2"
1010+
Ulid:
1011+
description: ULID identifier
1012+
type: string
1013+
minLength: 26
1014+
maxLength: 26
1015+
pattern: "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
1016+
SessionCloudStoragePostList:
1017+
type: array
1018+
items:
1019+
"$ref": "#/components/schemas/SessionCloudStoragePost"
1020+
SessionCloudStoragePost:
1021+
type: object
1022+
properties:
1023+
configuration:
1024+
type: object
1025+
additionalProperties: true
1026+
readonly:
1027+
type: boolean
1028+
default: true
1029+
source_path:
1030+
type: string
1031+
target_path:
1032+
type: string
1033+
storage_id:
1034+
allOf:
1035+
- "$ref": "#/components/schemas/Ulid"
1036+
- description: If the storage_id is provided then this config must replace an existing storage config in the session
1037+
required:
1038+
- configuration
1039+
- source_path
1040+
- target_path
7261041
responses:
7271042
Error:
7281043
description: The schema for all 4xx and 5xx responses

0 commit comments

Comments
 (0)