Skip to content

Commit 1a9d3ca

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 4ce7d6f commit 1a9d3ca

2 files changed

Lines changed: 412 additions & 2 deletions

File tree

components/renku_data_services/notebooks/api.spec.yaml

Lines changed: 305 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,158 @@ components:
723876
- renku.io/projectName
724877
- renku.io/repository
725878
type: object
879+
SessionPostRequest:
880+
properties:
881+
project_id:
882+
$ref: "#/components/schemas/Ulid"
883+
launcher_id:
884+
$ref: "#/components/schemas/Ulid"
885+
storage:
886+
default: 1
887+
type: integer
888+
description: The size of disk storage for the session, in gigabytes
889+
resource_class_id:
890+
default:
891+
nullable: true
892+
type: integer
893+
required:
894+
- project_id
895+
- launcher_id
896+
type: object
897+
SessionResponse:
898+
properties:
899+
image:
900+
type: string
901+
name:
902+
type: string
903+
resources:
904+
"$ref": "#/components/schemas/SessionResources"
905+
started:
906+
format: date-time
907+
nullable: true
908+
type: string
909+
status:
910+
"$ref": "#/components/schemas/SessionStatus"
911+
url:
912+
type: string
913+
project_id:
914+
$ref: "#/components/schemas/Ulid"
915+
launcher_id:
916+
$ref: "#/components/schemas/Ulid"
917+
resource_class_id:
918+
type: integer
919+
required:
920+
- image
921+
- name
922+
- resources
923+
- started
924+
- status
925+
- url
926+
- project_id
927+
- launcher_id
928+
- resource_class_id
929+
type: object
930+
SessionListResponse:
931+
items:
932+
"$ref": "#/components/schemas/SessionResponse"
933+
type: array
934+
SessionPatchRequest:
935+
properties:
936+
resource_class_id:
937+
type: integer
938+
state:
939+
enum:
940+
- running
941+
- hibernated
942+
type: string
943+
SessionStatus:
944+
properties:
945+
details:
946+
items:
947+
"$ref": "#/components/schemas/SessionStatusDetail"
948+
type: array
949+
message:
950+
type: string
951+
state:
952+
enum:
953+
- running
954+
- starting
955+
- stopping
956+
- failed
957+
- hibernated
958+
type: string
959+
will_hibernate_at:
960+
format: date-time
961+
nullable: true
962+
type: string
963+
will_delete_at:
964+
format: date-time
965+
nullable: true
966+
type: string
967+
required:
968+
- details
969+
- readyNumContainers
970+
- state
971+
- totalNumContainers
972+
type: object
973+
SessionStatusDetail:
974+
properties:
975+
status:
976+
enum:
977+
- ready
978+
- waiting
979+
- executing
980+
- failed
981+
type: string
982+
step:
983+
type: string
984+
required:
985+
- status
986+
- step
987+
type: object
988+
SessionResources:
989+
properties:
990+
requests:
991+
"$ref": "#/components/schemas/SessionResourcesRequests"
992+
type: object
993+
SessionResourcesRequests:
994+
properties:
995+
cpu:
996+
type: number
997+
description: Fractional CPUs
998+
gpu:
999+
type: integer
1000+
description: Number of GPUs used
1001+
default: 0
1002+
memory:
1003+
type: integer
1004+
description: Ammount of RAM for the session, in gigabytes
1005+
storage:
1006+
type: integer
1007+
description: The size of disk storage for the session, in gigabytes
1008+
required:
1009+
- cpu
1010+
- memory
1011+
- storage
1012+
example:
1013+
cpu: 1.5
1014+
memory: 1
1015+
storage: 40
1016+
gpu: 0
1017+
type: object
1018+
SessionLogsResponse:
1019+
type: object
1020+
additionalProperties:
1021+
type: string
1022+
example:
1023+
"container-A": "Log line 1\nLog line 2"
1024+
"container-B": "Log line 1\nLog line 2"
1025+
Ulid:
1026+
description: ULID identifier
1027+
type: string
1028+
minLength: 26
1029+
maxLength: 26
1030+
pattern: "^[A-Z0-9]{26}$" # This is case-insensitive
7261031
responses:
7271032
Error:
7281033
description: The schema for all 4xx and 5xx responses

0 commit comments

Comments
 (0)