forked from jupyter/services
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrest_api.yaml
713 lines (709 loc) · 20 KB
/
rest_api.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
swagger: '2.0'
info:
title: Jupyter Notebook API
description: Notebook API
version: "4"
contact:
name: Jupyter Project
url: jupyter.org
# will be prefixed to all paths
basePath: /api
produces:
- application/json
consumes:
- application/json
parameters:
kernel:
name: kernel
required: true
in: path
description: kernel uuid
type: string
format: uuid
session:
name: session
required: true
in: path
description: session uuid
type: string
format: uuid
path:
name: path
required: true
in: path
description: file path
type: string
checkpoint_id:
name: checkpoint_id
required: true
in: path
description: Checkpoint id for a file
type: string
paths:
/contents/{path}:
parameters:
- $ref: '#/parameters/path'
get:
summary: Get contents of file or directory
description: "A client can optionally specify a type and/or format argument via URL parameter. When given, the Contents service shall return a model in the requested type and/or format. If the request cannot be satisfied, e.g. type=text is requested, but the file is binary, then the request shall fail with 400 and have a JSON response containing a 'reason' field, with the value 'bad format' or 'bad type', depending on what was requested."
tags:
- contents
parameters:
- name: type
in: query
description: File type ('file', 'directory')
type: string
enum:
- file
- directory
- name: format
in: query
description: "How file content should be returned ('text', 'base64')"
type: string
enum:
- text
- base64
- name: content
in: query
description: "Return content (0 for no content, 1 for return content)"
type: integer
responses:
404:
description: No item found
400:
description: Bad request
schema:
type: object
properties:
error:
type: string
description: Error condition
reason:
type: string
description: Explanation of error reason
200:
description: Contents of file or directory
headers:
Last-Modified:
description: Last modified date for file
type: string
format: dateTime
schema:
$ref: '#/definitions/Contents'
500:
description: Model key error
post:
summary: Create a new file in the specified path
description: "A POST to /api/contents/path creates a New untitled, empty file or directory. A POST to /api/contents/path with body {'copy_from': '/path/to/OtherNotebook.ipynb'} creates a new copy of OtherNotebook in path."
tags:
- contents
parameters:
- name: model
in: body
description: Path of file to copy
schema:
type: object
properties:
copy_from:
type: string
ext:
type: string
type:
type: string
responses:
201:
description: File created
headers:
Location:
description: URL for the new file
type: string
format: url
schema:
$ref: '#/definitions/Contents'
404:
description: No item found
400:
description: Bad request
schema:
type: object
properties:
error:
type: string
description: Error condition
reason:
type: string
description: Explanation of error reason
patch:
summary: Rename a file or directory without re-uploading content
tags:
- contents
parameters:
- name: path
in: body
required: true
description: New path for file or directory.
schema:
type: object
properties:
path:
type: string
format: path
description: New path for file or directory
responses:
200:
description: Path updated
headers:
Location:
description: Updated URL for the file or directory
type: string
format: url
schema:
$ref: '#/definitions/Contents'
400:
description: No data provided
schema:
type: object
properties:
error:
type: string
description: Error condition
reason:
type: string
description: Explanation of error reason
put:
summary: Save or upload file.
description: "Saves the file in the location specified by name and path. PUT is very similar to POST, but the requester specifies the name, whereas with POST, the server picks the name."
tags:
- contents
parameters:
- name: model
in: body
description: New path for file or directory
schema:
type: object
properties:
name:
type: string
description: The new filename if changed
path:
type: string
description: New path for file or directory
type:
type: string
description: Path dtype ('notebook', 'file', 'directory')
format:
type: string
description: File format ('json', 'text', 'base64')
content:
type: string
description: The actual body of the document excluding directory type
responses:
200:
description: File saved
headers:
Location:
description: Updated URL for the file or directory
type: string
format: url
schema:
$ref: '#/definitions/Contents'
201:
description: Path created
headers:
Location:
description: URL for the file or directory
type: string
format: url
schema:
$ref: '#/definitions/Contents'
400:
description: No data provided
schema:
type: object
properties:
error:
type: string
description: Error condition
reason:
type: string
description: Explanation of error reason
delete:
summary: Delete a file in the given path
tags:
- contents
responses:
204:
description: File deleted
headers:
Location:
description: URL for the removed file
type: string
format: url
/contents/{path}/checkpoints:
parameters:
- $ref: '#/parameters/path'
get:
summary: Get a list of checkpoints for a file
description: List checkpoints for a given file. There will typically be zero or one results.
tags:
- contents
responses:
404:
description: No item found
400:
description: Bad request
schema:
type: object
properties:
error:
type: string
description: Error condition
reason:
type: string
description: Explanation of error reason
200:
description: List of checkpoints for a file
schema:
type: array
items:
$ref: '#/definitions/Checkpoints'
500:
description: Model key error
post:
summary: Create a new checkpoint for a file
description: "Create a new checkpoint with the current state of a file. With the default FileContentsManager, only one checkpoint is supported, so creating new checkpoints clobbers existing ones."
tags:
- contents
responses:
201:
description: Checkpoint created
headers:
Location:
description: URL for the checkpoint
type: string
format: url
schema:
$ref: '#/definitions/Checkpoints'
404:
description: No item found
400:
description: Bad request
schema:
type: object
properties:
error:
type: string
description: Error condition
reason:
type: string
description: Explanation of error reason
/contents/{path}/checkpoints/{checkpoint_id}:
post:
summary: Restore a file to a particular checkpointed state
tags:
- contents
responses:
204:
description: Checkpoint created
400:
description: Bad request
schema:
type: object
properties:
error:
type: string
description: Error condition
reason:
type: string
description: Explanation of error reason
delete:
summary: Delete a checkpoint
tags:
- contents
responses:
204:
description: Checkpoint deleted
/sessions/{session}:
parameters:
- $ref: '#/parameters/session'
get:
summary: Get session
tags:
- sessions
responses:
200:
description: Session
schema:
$ref: '#/definitions/Session'
patch:
summary: "This can be used to rename the notebook, or move it to a new directory."
tags:
- sessions
parameters:
- name: model
in: body
required: true
schema:
type: object
properties:
notebook:
type: object
properties:
path:
type: string
format: path
description: new path for notebook
responses:
200:
description: Session
schema:
$ref: '#/definitions/Session'
400:
description: No data provided
delete:
summary: Delete a session
tags:
- sessions
responses:
204:
description: Session (and kernel) were deleted
410:
description: "Kernel was deleted before the session, and the session was *not* deleted (TODO - check to make sure session wasn't deleted)"
/sessions:
get:
summary: List available sessions
tags:
- sessions
responses:
200:
description: List of current sessions
schema:
type: array
items:
$ref: '#/definitions/Session'
post:
summary: "Create a new session, or return an existing session if a session for the notebook path already exists"
tags:
- sessions
parameters:
- name: session
in: body
schema:
type: object
properties:
notebook:
type: object
required:
- path
properties:
path:
type: string
description: path to notebook file
kernel:
type: object
properties:
name:
type: string
description: "Kernel spec name, defaults to default kernel spec"
responses:
201:
description: Session created or returned
schema:
$ref: '#/definitions/Session'
headers:
Location:
description: URL for session commands
type: string
format: url
501:
description: Kernel not available
schema:
type: object
description: error message
properties:
message:
type: string
short_message:
type: string
/kernels:
get:
summary: List the JSON data for all kernels that are currently running
tags:
- kernels
responses:
200:
description: List of currently-running kernel uuids
schema:
type: array
items:
$ref: '#/definitions/Kernel'
post:
summary: Start a kernel and return the uuid
tags:
- kernels
parameters:
- name: name
in: body
description: Kernel spec name (defaults to default kernel spec for server)
schema:
type: object
properties:
name:
type: string
responses:
201:
description: Kernel started
schema:
$ref: '#/definitions/Kernel'
headers:
Location:
description: Model for started kernel
type: string
format: url
/kernels/{kernel_id}:
parameters:
- $ref: '#/parameters/kernel'
get:
summary: Get kernel information
tags:
- kernels
responses:
200:
description: Kernel information
schema:
$ref: '#/definitions/Kernel'
delete:
summary: Kill a kernel and delete the kernel id
tags:
- kernels
responses:
204:
description: Kernel deleted
/kernels/{kernel_id}/interrupt:
parameters:
- $ref: '#/parameters/kernel'
post:
summary: Interrupt a kernel
tags:
- kernels
responses:
204:
description: Kernel interrupted
/kernels/{kernel_id}/restart:
parameters:
- $ref: '#/parameters/kernel'
post:
summary: Restart a kernel
tags:
- kernels
responses:
200:
description: Kernel interrupted
headers:
Location:
description: URL for kernel commands
type: string
format: url
schema:
$ref: '#/definitions/Kernel'
/kernelspecs:
get:
summary: Get kernel specs
tags:
- kernelspecs
responses:
200:
description: Kernel specs
schema:
type: object
properties:
default:
type: string
description: Default kernel name
kernelspecs:
type: object
additionalProperties:
$ref: '#/definitions/KernelSpec'
/config/{section_name}:
get:
summary: Get a configuration section by name
tags:
- config
responses:
200:
description: Configuration object
schema:
type: object
patch:
summary: Update a configuration section by name
tags:
- config
parameters:
- name: configuration
in: body
schema:
type: object
responses:
200:
description: Configuration object
schema:
type: object
definitions:
KernelSpec:
description: Kernel spec (contents of kernel.json)
properties:
name:
type: string
description: Unique name for kernel
spec:
$ref: '#/definitions/KernelSpecFile'
description: Kernel spec json file
resources:
type: object
properties:
kernel.js:
type: string
format: filename
description: path for kernel.js file
kernel.css:
type: string
format: filename
description: path for kernel.css file
logo-*:
type: string
format: filename
description: path for logo file. Logo filenames are of the form `logo-widthxheight`
KernelSpecFile:
description: Kernel spec json file
required:
- argv
- display_name
- language
properties:
language:
type: string
description: The programming language which this kernel runs. This will be stored in notebook metadata.
argv:
type: array
description: "A list of command line arguments used to start the kernel. The text `{connection_file}` in any argument will be replaced with the path to the connection file."
items:
type: string
display_name:
type: string
description: "The kernel's name as it should be displayed in the UI. Unlike the kernel name used in the API, this can contain arbitrary unicode characters."
codemirror_mode:
type: string
description: Codemirror mode. Can be a string *or* an valid Codemirror mode object. This defaults to the string from the `language` property.
env:
type: object
description: A dictionary of environment variables to set for the kernel. These will be added to the current environment variables.
additionalProperties:
type: string
help_links:
type: array
description: Help items to be displayed in the help menu in the notebook UI.
items:
type: object
required:
- text
- url
properties:
text:
type: string
description: menu item link text
url:
type: string
format: URL
description: menu item link url
Kernel:
description: Kernel information
required:
- id
- name
properties:
id:
type: string
format: uuid
description: uuid of kernel
name:
type: string
description: kernel spec name
Session:
description: A session
type: object
properties:
id:
type: string
format: uuid
notebook:
type: object
properties:
path:
type: string
description: path to notebook
kernel:
$ref: '#/definitions/Kernel'
Contents:
description: "A contents object. The content and format keys may be null if content is not contained. If type is 'file', then the mimetype will be null."
type: object
required:
- type
- name
- path
- writable
- created
- last_modified
- mimetype
- format
- content
properties:
name:
type: string
description: "Name of file or directory, equivalent to the last part of the path"
path:
type: string
description: Full path for file or directory
type:
type: string
description: Type of content
enum:
- directory
- file
- notebook
writable:
type: boolean
description: indicates whether the requester has permission to edit the file
created:
type: string
description: Creation timestamp
format: dateTime
last_modified:
type: string
description: Last modified timestamp
format: dateTime
mimetype:
type: string
description: "The mimetype of a file. If content is not null, and type is 'file', this will contain the mimetype of the file, otherwise this will be null."
content:
type: string
description: "The content, if requested (otherwise null). Will be an array if type is 'directory'"
format:
type: string
description: Format of content (one of null, 'text', 'base64', 'json')
Checkpoints:
description: A checkpoint object.
type: object
required:
- id
- last_modified
properties:
id:
type: string
description: Unique id for the checkpoint.
last_modified:
type: string
description: Last modified timestamp
format: dateTime
Config:
description: A configuration object.
type: object