diff --git a/notebook/services/api/api.yaml b/notebook/services/api/api.yaml index 1c8b7c9ec0..5a9fad0f6f 100644 --- a/notebook/services/api/api.yaml +++ b/notebook/services/api/api.yaml @@ -2,7 +2,7 @@ swagger: '2.0' info: title: Jupyter Notebook API description: Notebook API - version: "4" + version: "5" contact: name: Jupyter Project url: jupyter.org @@ -14,7 +14,7 @@ consumes: - application/json parameters: kernel: - name: kernel + name: kernel_id required: true in: path description: kernel uuid @@ -27,8 +27,315 @@ parameters: 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 + section_name: + name: section_name + required: true + in: path + description: Name of config section + 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 + parameters: + - $ref: "#/parameters/path" + - $ref: "#/parameters/checkpoint_id" + tags: + - contents + responses: + 204: + description: Checkpoint restored + 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 + parameters: + - $ref: "#/parameters/path" + - $ref: "#/parameters/checkpoint_id" + tags: + - contents + responses: + 204: + description: Checkpoint deleted /sessions/{session}: parameters: - $ref: '#/parameters/session' @@ -42,7 +349,7 @@ paths: schema: $ref: '#/definitions/Session' patch: - summary: This can be used to rename the notebook, or move it to a new directory. + summary: "This can be used to rename the notebook, or move it to a new directory." tags: - sessions parameters: @@ -74,7 +381,7 @@ paths: 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) + 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 @@ -88,7 +395,7 @@ paths: items: $ref: '#/definitions/Session' post: - summary: Create a new session, or return an existing session if a session for the notebook path already exists + summary: "Create a new session, or return an existing session if a session for the notebook path already exists" tags: - sessions parameters: @@ -110,7 +417,7 @@ paths: properties: name: type: string - description: Kernel spec name, defaults to default kernel spec + description: "Kernel spec name, defaults to default kernel spec" responses: 201: description: Session created or returned @@ -160,12 +467,14 @@ paths: responses: 201: description: Kernel started + schema: + $ref: '#/definitions/Kernel' headers: Location: - description: URL for kernel commands + description: Model for started kernel type: string format: url - /kernels/{kernel}: + /kernels/{kernel_id}: parameters: - $ref: '#/parameters/kernel' get: @@ -184,7 +493,7 @@ paths: responses: 204: description: Kernel deleted - /kernels/{kernel}/interrupt: + /kernels/{kernel_id}/interrupt: parameters: - $ref: '#/parameters/kernel' post: @@ -194,7 +503,7 @@ paths: responses: 204: description: Kernel interrupted - /kernels/{kernel}/restart: + /kernels/{kernel_id}/restart: parameters: - $ref: '#/parameters/kernel' post: @@ -214,7 +523,7 @@ paths: /kernelspecs: get: - summary: List kernel specs + summary: Get kernel specs tags: - kernelspecs responses: @@ -227,42 +536,36 @@ paths: type: string description: Default kernel name kernelspecs: - type: array - items: + type: object + additionalProperties: $ref: '#/definitions/KernelSpec' - /kernelspecs/{kernel}: - parameters: - - $ref: '#/parameters/kernel' + /config/{section_name}: get: - summary: Kernel information + summary: Get a configuration section by name + parameters: + - $ref: "#/parameters/section_name" tags: - - kernelspecs + - config responses: 200: - description: The contents of kernel.json + description: Configuration object schema: - $ref: '#/definitions/KernelSpec' - 404: - description: Kernel spec not found - /kernelspecs/{kernel}/{filename}: - get: - summary: Retrieve a file from the kernel directory + type: object + patch: + summary: Update a configuration section by name tags: - - kernelspecs + - config parameters: - - name: kernel - in: path - description: Kernel uuid - type: string - required: true - - name: filename - in: path - description: filename - type: string - required: true + - $ref: "#/parameters/section_name" + - name: configuration + in: body + schema: + type: object responses: 200: - description: file + description: Configuration object + schema: + type: object definitions: KernelSpec: @@ -301,12 +604,12 @@ definitions: 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. + 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. + 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. @@ -359,7 +662,64 @@ definitions: 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