WIP: system api

This commit is contained in:
Wlad 2020-10-31 11:34:28 +01:00
parent f156793e1b
commit ad84cf0120
9 changed files with 121 additions and 9 deletions

14
TODO.md
View File

@ -70,13 +70,13 @@
- [x] Fetch template data
- [ ] Model: Config
- [ ] Slicing TBD [link](https://docs.octoprint.org/en/master/api/slicing.html)
- [ ] System [link](https://docs.octoprint.org/en/master/api/system.html)
- [ ] List all registered system commands
- [ ] List all registered system commands for a source
- [ ] Execute a registed system command
- [ ] Model: List all response
- [ ] Model: Client command definitions
- [ ] Model: Command definition
- [x] System [link](https://docs.octoprint.org/en/master/api/system.html)
- [x] List all registered system commands
- [x] List all registered system commands for a source
- [x] Execute a registed system command
- [x] Model: List all response
- [x] Model: Client command definitions
- [x] Model: Command definition
- [ ] Timelapse [link](https://docs.octoprint.org/en/master/api/timelapse.html)
- [ ] Retrieve a list of timelapses and the current config
- [ ] Delete a timelapse

View File

@ -0,0 +1,4 @@
in: path
name: source
description: >-
The source for which to list commands, currently either core or custom

View File

@ -0,0 +1,25 @@
type: object
description: >-
System command
properties:
name:
type: string
description: >-
The name of the command to display in the System menu.
action:
type: string
description: >-
An identifier to refer to the command programmatically. The special action string divider signifies a divider in the menu.
confirm:
type: string
description: >-
If present and set, this text will be displayed to the user in a confirmation dialog they have to acknowledge in order to really execute the command.
source:
type: string
description: >-
Source of the command definition, currently either core (for system actions defined by OctoPrint itself) or custom (for custom system commands defined by the user through config.yaml).
resource:
type: string
format: url
description: >-
The URL of the command to use for executing it.

View File

@ -0,0 +1,18 @@
allOf:
- $ref: ./ClientCmd.yaml
- type: object
description: >-
The full command definition is not available via the API.
properties:
command:
type: string
description: >-
The full command line to execute for the command.
async:
type: boolean
description: >-
Whether to execute the command asynchronously or wait for its result before responding to the HTTP execution request.
ignore:
type: boolean
description: >-
Whether to ignore the return code of the commands execution.

View File

@ -79,5 +79,14 @@ paths:
$ref: paths/printerprofiles/{identifier}-post.yaml
delete:
$ref: paths/printerprofiles/{identifier}-delete.yaml
/system/commands:
get:
$ref: paths/system/commands/get.yaml
/system/commands/{source}:
get:
$ref: paths/system/commands/{source}-get.yaml
/system/commands/{source}/{action}:
post:
$ref: paths/system/commands/{source}-{action}-post.yaml

View File

@ -1,5 +1,5 @@
summary: Retrieve current settings
operation: getSettings
operationId: getSettings
description: >-
Retrieves the current configuration of OctoPrint.
responses:

View File

@ -0,0 +1,17 @@
summary: List all registered system commands
operationId: getSystemCmds
description: >-
Retrieves all configured system commands.
responses:
"200":
description: >-
All available system commands.
content:
application/json:
schema:
type: object
properties:
core:
type: array
items:
$ref: ../../../components/schemas/system/ClientCmd.yaml

View File

@ -0,0 +1,16 @@
summary: List all registered system commands for a source
operationId: getSystemSourceCmds
description: >-
Retrieves the configured system commands for the specified source.
parameters:
- $ref: ../../../components/parameters/systemCmdSource.yaml
responses:
"200":
description: >-
All available system commands.
content:
application/json:
schema:
type: array
items:
$ref: ../../../components/schemas/system/ClientCmd.yaml

View File

@ -0,0 +1,23 @@
summary: Execute a registered system command
operationId: executeSysCmd
description: >-
Execute the system command action defined in source.
parameters:
- $ref: ../../../components/parameters/systemCmdSource.yaml
- in: path
name: action
description: >-
The identifier of the command, action from its definition
responses:
"204":
description: >-
Command executed
"400":
description: >-
If a divider is supposed to be executed or if the request is malformed otherwise
"404":
description: >-
If the command could not be found for source and action
"500":
description: >-
If the command didnt define a command to execute, the command returned a non-zero return code and ignore was not true or some other internal server error occurred