Skip to content

Commit 5a81d16

Browse files
committed
feat: add new apispec for the new amalthea sessions (#360)
1 parent 92fbdcd commit 5a81d16

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

0 commit comments

Comments
 (0)