WIP: update file api

This commit is contained in:
Wlad 2020-10-23 21:54:31 +02:00
parent 8e0bc68ba9
commit ab1140f04f
14 changed files with 300 additions and 2 deletions

View File

@ -12,9 +12,9 @@
- [x] Version
- [x] Connection Handling
- [ ] File Operations [link](https://docs.octoprint.org/en/master/api/files.html)
- [ ] Retrieve all files
- [x] Retrieve all files
- [ ] Retrieve files from specific location
- [ ] Upload file or create folder
- [x] Upload file or create folder
- [ ] Retrieve a specific files or folders information
- [ ] Issue a file command
- [ ] Delete file

View File

View File

@ -0,0 +1,4 @@
type: object
properties:
files:
type: s

View File

@ -1 +1,30 @@
type: object
properties:
length:
type: number
volume:
type: number
dimensions:
type: object
properties:
depth:
type: number
height:
type: number
width:
type: number
printingArea:
type: object
properties:
maxX:
type: number
maxY:
type: number
maxZ:
type: number
minX:
type: number
minY:
type: number
minZ:
type: number

View File

@ -0,0 +1,55 @@
type: object
description: The estimated usage of filament
properties:
length:
type: number
description: >-
The length of filament used, in mm
volume:
type: number
description: >-
The volume of filament used, in cm³
dimensions:
type: object
description: >-
Information regarding the size of the printed model
properties:
depth:
type: number
description: >-
The depth of the printed model, in mm
height:
type: number
description: >-
The height of the printed model, in mm
width:
type: number
description: >-
The width of the printed model, in mm
printingArea:
type: object
properties:
maxX:
type: number
description: >-
The maximum X coordinate of the printed model, in mm
maxY:
type: number
description: >-
The maximum Y coordinate of the printed model, in mm
maxZ:
type: number
description: >-
The maximum Z coordinate of the printed model, in mm
minX:
type: number
description: >-
The minimum X coordinate of the printed model, in mm
minY:
type: number
description: >-
The minimum Y coordinate of the printed model, in mm
minZ:
type: number
description: >-
The minimum Z coordinate of the printed model, in mm

View File

@ -0,0 +1,21 @@
type: object
required:
- origin
properties:
origin:
type: string
description: The size of the file in bytes. Only available for local files or sdcard files if the printer supports file sizes for sd card files.
enum:
- local
- sdcard
hash:
type: string
size:
type: number
date:
type: number
format: date-time
refs:
$ref: ./Reference.yaml
gcodeAnalysis:
$ref: ./GCodeAnalysis.yaml

View File

@ -0,0 +1,8 @@
type: object
properties:
estimatedPrintTime:
type: number
description: >-
The estimated print time of the file, in seconds
filament:
$ref: "./Filament.yaml"

View File

@ -0,0 +1,30 @@
type: object
properties:
name:
type: string
description: The name of the file without path. E.g. “file.gco” for a file “file.gco” located anywhere in the file system. Currently this will always fit into ASCII.
display:
type: string
description: >-
The name of the file without the path, this time potentially with non-ASCII unicode characters. E.g. “a turtle 🐢.gco” for a file “a_turtle_turtle.gco” located anywhere in the file system.
path:
type: string
description: >-
The path to the file within the location. E.g. “folder/subfolder/file.gco” for a file “file.gco” located within “folder” and “subfolder” relative to the root of the location. Currently this will always fit into ASCII.
type:
type: string
enum:
- model
- machinecode
- folder
description: >-
Type of file. model or machinecode. Or folder if its a folder, in which case the children node will be populated
typePath:
type: array
items:
type: string
oneOf:
- $ref: "./File"
- $ref: "./Folder"
discriminator:
propertyName: type

View File

@ -0,0 +1,13 @@
type: object
properties:
resource:
type: string
format: url
download:
type: string
format: url
model:
type: string
format: url
required:
- resource

View File

@ -21,5 +21,11 @@ paths:
$ref: paths/connection.yaml
/printer:
$ref: paths/printer.yaml
/files/local:
$ref: paths/files/local.yaml
/files/sdcard:
$ref: paths/files/sdcard.yaml
/files:
$ref: paths/files/get.yaml
/printer/tool:
$ref: paths/printer@tool.yaml

View File

@ -0,0 +1,16 @@
get:
summary: Retrieve all files
operationId: getAllFiles
description: >-
Retrieve information regarding all files currently available and regarding the disk space still available locally in the system.
By default only returns the files and folders in the root directory. If the query parameter `recursive` is provided and set to `true`, returns all files and folders.
parameters:
- in: query
name: recursive
description: If set to true, return all files and folders recursively. Otherwise only return items on same level.
required: false
schema:
type: string
responses:
"200":
description: Returns a Retrieve response

View File

@ -0,0 +1,58 @@
post:
summary: Upload file or create folder
operationId: uploadToLocal
description: Upload a file to the selected location or create a new empty folder on it.
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
file:
description: The file to upload, including a valid
type: string
format: binary
path:
description: >-
The path within the location to upload the file to or create the folder in (without the future filename or foldername - basically the parent folder). If unset will be taken from the provided files name or foldername and default to the root folder of the location.
type: string
format: uri
select:
type: boolean
description: >-
Whether to select the file directly after upload (true) or not (false). Optional, defaults to false. Ignored when creating a folder.
print:
type: boolean
description: >-
Whether to start printing the file directly after upload (true) or not (false). If set, select is implicitly true as well. Optional, defaults to false. Ignored when creating a folder.
userdata:
type: string
description: >-
An optional string that if specified will be interpreted as JSON and then saved along with the file as metadata (metadata key userdata). Ignored when creating a folder.
foldername:
type: string
description: >-
The name of the folder to create. Ignored when uploading a file.
responses:
"201":
description: Created
"400":
description: >-
If no file or foldername are included in the request, userdata was provided but could not be parsed as JSON or the request is otherwise invalid.
"404":
description: >-
If location is neither local nor sdcard or trying to upload to SD card and SD card support is disabled
"409":
description: >-
If the upload of the file would override the file that is currently being printed or if an upload to SD card was requested and the printer is either not operational or currently busy with a print job.
"415":
description: >-
If the file is neither a gcode nor an stl file (or it is an stl file but slicing support is disabled)
"500":
description: >-
If the upload failed internally

View File

@ -0,0 +1,58 @@
post:
summary: Upload file or create folder
operationId: uploadToSdCard
description: Upload a file to the selected location or create a new empty folder on it.
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
file:
description: The file to upload, including a valid
type: string
format: binary
path:
description: >-
The path within the location to upload the file to or create the folder in (without the future filename or foldername - basically the parent folder). If unset will be taken from the provided files name or foldername and default to the root folder of the location.
type: string
format: uri
select:
type: boolean
description: >-
Whether to select the file directly after upload (true) or not (false). Optional, defaults to false. Ignored when creating a folder.
print:
type: boolean
description: >-
Whether to start printing the file directly after upload (true) or not (false). If set, select is implicitly true as well. Optional, defaults to false. Ignored when creating a folder.
userdata:
type: string
description: >-
An optional string that if specified will be interpreted as JSON and then saved along with the file as metadata (metadata key userdata). Ignored when creating a folder.
foldername:
type: string
description: >-
The name of the folder to create. Ignored when uploading a file.
responses:
"201":
description: Created
"400":
description: >-
If no file or foldername are included in the request, userdata was provided but could not be parsed as JSON or the request is otherwise invalid.
"404":
description: >-
If location is neither local nor sdcard or trying to upload to SD card and SD card support is disabled
"409":
description: >-
If the upload of the file would override the file that is currently being printed or if an upload to SD card was requested and the printer is either not operational or currently busy with a print job.
"415":
description: >-
If the file is neither a gcode nor an stl file (or it is an stl file but slicing support is disabled)
"500":
description: >-
If the upload failed internally