xpipe/openapi.yaml

418 lines
15 KiB
YAML
Raw Normal View History

2024-06-04 07:53:33 +12:00
openapi: 3.0.1
info:
title: XPipe API Documentation
2024-06-05 02:48:42 +12:00
description: |
The XPipe API provides programmatic access to XPipes features.
The XPipe application will start up an HTTP server that can be used to send requests.
You can change the port of it in the settings menu.
Note that this server is HTTP-only for now as it runs only on localhost. HTTPS requests are not accepted.
2024-06-10 01:40:09 +12:00
This allows you to programmatically manage remote systems.
2024-06-05 02:48:42 +12:00
To start off, you can query connections based on various filters.
With the matched connections, you can start remote shell sessions for each one and run arbitrary commands in them.
You get the command exit code and output as a response, allowing you to adapt your control flow based on command outputs.
2024-06-10 01:40:09 +12:00
Any kind of passwords and other secrets are automatically provided by XPipe when establishing a shell connection.
If a required password is not stored and is set to be dynamically prompted, the running XPipe application will ask you to enter any required passwords.
2024-06-05 02:48:42 +12:00
You can quickly get started by either using this page as an API reference or alternatively import the [OpenAPI definition file](/openapi.yaml) into your API client of choice.
See the authentication handshake below on how to authenticate prior to sending requests.
2024-06-04 07:53:33 +12:00
termsOfService: https://docs.xpipe.io/terms-of-service
contact:
name: XPipe - Contact us
url: mailto:hello@xpipe.io
version: "10.0"
externalDocs:
description: XPipe - Plans and pricing
url: https://xpipe.io/pricing
servers:
2024-06-15 21:12:06 +12:00
- url: http://localhost:21723
2024-06-05 02:48:42 +12:00
description: XPipe Daemon API
2024-06-04 07:53:33 +12:00
paths:
/handshake:
post:
2024-06-05 02:48:42 +12:00
summary: Establish a new API session
description: |
Prior to sending requests to the API, you first have to establish a new API session via the handshake endpoint.
In the response you will receive a session token that you can use to authenticate during this session.
This is done so that the daemon knows what kind of clients are connected and can manage individual capabilities for clients.
Note that for development you can also turn off the required authentication in the XPipe settings menu, allowing you to send unauthenticated requests.
2024-06-04 07:53:33 +12:00
operationId: handshake
2024-06-05 02:48:42 +12:00
security: []
2024-06-04 07:53:33 +12:00
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/HandshakeRequest'
examples:
standard:
summary: Standard handshake
2024-06-05 02:48:42 +12:00
value: { "auth": { "type": "ApiKey", "key": "<API key>" }, "client": { "type": "Api", "name": "My client name" } }
2024-06-04 07:53:33 +12:00
local:
summary: Local application handshake
2024-06-05 02:48:42 +12:00
value: { "auth": { "type": "Local", "authFileContent": "<Contents of the local file $TEMP/xpipe_auth>" }, "client": { "type": "Api", "name": "My client name" } }
2024-06-04 07:53:33 +12:00
responses:
200:
description: The handshake was successful. The returned token can be used for authentication in this session. The token is valid as long as XPipe is running.
content:
application/json:
schema:
$ref: '#/components/schemas/HandshakeResponse'
400:
$ref: '#/components/responses/BadRequest'
500:
$ref: '#/components/responses/InternalServerError'
/connection/query:
post:
summary: Query connections
2024-06-05 02:48:42 +12:00
description: |
Queries all connections using various filters.
The filters support globs and can match the category names and connection names.
All matching is case insensitive.
2024-06-04 07:53:33 +12:00
operationId: connectionQuery
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ConnectionQueryRequest'
examples:
all:
summary: All
2024-06-05 02:48:42 +12:00
value: { "categoryFilter": "*", "connectionFilter": "*", "typeFilter": "*" }
2024-06-04 07:53:33 +12:00
simple:
summary: Simple filter
2024-06-05 02:48:42 +12:00
value: { "categoryFilter": "default", "connectionFilter": "local machine", "typeFilter": "*" }
2024-06-04 07:53:33 +12:00
globs:
summary: Globs
2024-06-05 02:48:42 +12:00
value: { "categoryFilter": "*", "connectionFilter": "*/podman/*", "typeFilter": "*" }
2024-06-04 07:53:33 +12:00
responses:
200:
description: The query was successful. The body contains all matched connections.
content:
application/json:
schema:
$ref: '#/components/schemas/ConnectionQueryResponse'
2024-06-05 02:48:42 +12:00
examples:
standard:
summary: Matched connections
value: { "found": [ { "uuid": "f0ec68aa-63f5-405c-b178-9a4454556d6b", "category": ["default"] ,
"connection": ["local machine"], "type": "local" },
{ "uuid": "e1462ddc-9beb-484c-bd91-bb666027e300", "category": ["default", "category 1"],
"connection": ["ssh system", "shell environments", "bash"], "type": "shellEnvironment" } ] }
2024-06-04 07:53:33 +12:00
400:
$ref: '#/components/responses/BadRequest'
401:
$ref: '#/components/responses/Unauthorized'
403:
$ref: '#/components/responses/Forbidden'
404:
$ref: '#/components/responses/NotFound'
500:
$ref: '#/components/responses/InternalServerError'
2024-06-05 02:48:42 +12:00
/shell/start:
2024-06-04 07:53:33 +12:00
post:
2024-06-05 02:48:42 +12:00
summary: Start shell connection
description: |
Starts a new shell session for a connection. If an existing shell session is already running for that connection, this operation will do nothing.
Note that there are a variety of possible errors that can occur here when establishing the shell connection.
These errors will be returned with the HTTP return code 500.
operationId: shellStart
2024-06-04 07:53:33 +12:00
requestBody:
required: true
content:
application/json:
schema:
2024-06-05 02:48:42 +12:00
$ref: '#/components/schemas/ShellStartRequest'
examples:
local:
summary: Start local shell
value: { "uuid": "f0ec68aa-63f5-405c-b178-9a4454556d6b" }
responses:
200:
description: The operation was successful. The shell session was started.
400:
$ref: '#/components/responses/BadRequest'
401:
$ref: '#/components/responses/Unauthorized'
403:
$ref: '#/components/responses/Forbidden'
404:
$ref: '#/components/responses/NotFound'
500:
$ref: '#/components/responses/InternalServerError'
/shell/stop:
post:
summary: Stop shell connection
description: |
Stops an existing shell session for a connection.
This operation will return once the shell has exited.
If the shell is busy or stuck, you might have to work with timeouts to account for these cases.
operationId: shellStop
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ShellStopRequest'
examples:
local:
summary: Stop local shell
value: { "uuid": "f0ec68aa-63f5-405c-b178-9a4454556d6b" }
responses:
200:
description: The operation was successful. The shell session was stopped.
400:
$ref: '#/components/responses/BadRequest'
401:
$ref: '#/components/responses/Unauthorized'
403:
$ref: '#/components/responses/Forbidden'
404:
$ref: '#/components/responses/NotFound'
500:
$ref: '#/components/responses/InternalServerError'
/shell/exec:
post:
summary: Execute command in a shell session
description: |
Runs a command in an active shell session and waits for it to finish. The exit code and output will be returned in the response.
Note that a variety of different errors can occur when executing the command.
If the command finishes, even with an error code, a normal HTTP 200 response will be returned.
However, if any other error occurs like the shell not responding or exiting unexpectedly, an HTTP 500 response will be returned.
operationId: shellExec
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ShellExecRequest'
examples:
user:
summary: echo $USER
value: { "uuid": "f0ec68aa-63f5-405c-b178-9a4454556d6b", "command": "echo $USER" }
invalid:
summary: invalid
value: { "uuid": "f0ec68aa-63f5-405c-b178-9a4454556d6b", "command": "invalid" }
2024-06-04 07:53:33 +12:00
responses:
200:
2024-06-05 02:48:42 +12:00
description: The operation was successful. The shell command finished.
content:
application/json:
schema:
$ref: '#/components/schemas/ShellExecResponse'
examples:
user:
summary: echo $USER
value: { "exitCode": 0, "stdout": "root", "stderr": "" }
fail:
summary: invalid
value: { "exitCode": 127, "stdout": "", "stderr": "invalid: command not found" }
2024-06-04 07:53:33 +12:00
400:
$ref: '#/components/responses/BadRequest'
401:
$ref: '#/components/responses/Unauthorized'
403:
$ref: '#/components/responses/Forbidden'
404:
$ref: '#/components/responses/NotFound'
500:
$ref: '#/components/responses/InternalServerError'
components:
schemas:
2024-06-05 02:48:42 +12:00
ShellStartRequest:
type: object
properties:
connection:
type: string
description: The connection uuid
required:
- connection
ShellStopRequest:
type: object
properties:
connection:
type: string
description: The connection uuid
required:
- connection
ShellExecRequest:
type: object
properties:
connection:
type: string
description: The connection uuid
command:
type: string
description: The command to execute
required:
- connection
- command
ShellExecResponse:
type: object
properties:
exitCode:
type: integer
description: The exit code of the command
stdout:
type: string
description: The stdout output of the command
stderr:
type: string
description: The stderr output of the command
required:
- exitCode
- stdout
- stderr
2024-06-04 07:53:33 +12:00
ConnectionQueryRequest:
type: object
properties:
categoryFilter:
type: string
2024-06-05 02:48:42 +12:00
description: The filter string to match categories. Categories are delimited by / if they are hierarchical. The filter supports globs.
2024-06-04 07:53:33 +12:00
connectionFilter:
type: string
2024-06-05 02:48:42 +12:00
description: The filter string to match connection names. Connection names are delimited by / if they are hierarchical. The filter supports globs.
2024-06-04 07:53:33 +12:00
typeFilter:
type: string
2024-06-05 02:48:42 +12:00
description: The filter string to connection types. Every unique type of connection like SSH or docker has its own type identifier that you can match. The filter supports globs.
2024-06-04 07:53:33 +12:00
required:
2024-06-05 02:48:42 +12:00
- categoryFilter
- connectionFilter
- typeFilter
2024-06-04 07:53:33 +12:00
ConnectionQueryResponse:
type: object
properties:
found:
type: array
description: The found connections
items:
type: object
properties:
uuid:
type: string
description: The unique id of the connection
category:
2024-06-05 02:48:42 +12:00
type: array
description: The full category path as an array
items:
type: string
description: Individual category name
2024-06-04 07:53:33 +12:00
connection:
2024-06-05 02:48:42 +12:00
type: array
description: The full connection name path as an array
items:
type: string
description: Individual connection name
2024-06-04 07:53:33 +12:00
type:
type: string
description: The type identifier of the connection
required:
2024-06-05 02:48:42 +12:00
- uuid
- category
- connection
- type
2024-06-04 07:53:33 +12:00
required:
2024-06-05 02:48:42 +12:00
- found
2024-06-04 07:53:33 +12:00
HandshakeRequest:
type: object
properties:
auth:
$ref: '#/components/schemas/AuthMethod'
client:
$ref: '#/components/schemas/ClientInformation'
required:
2024-06-05 02:48:42 +12:00
- auth
- client
2024-06-04 07:53:33 +12:00
HandshakeResponse:
type: object
properties:
2024-06-05 02:48:42 +12:00
sessionToken:
2024-06-04 07:53:33 +12:00
type: string
description: The generated bearer token that can be used for authentication in this session
required:
2024-06-05 02:48:42 +12:00
- sessionToken
2024-06-04 07:53:33 +12:00
AuthMethod:
type: object
discriminator:
propertyName: type
properties:
type:
type: string
required:
2024-06-05 02:48:42 +12:00
- type
2024-06-04 07:53:33 +12:00
oneOf:
2024-06-05 02:48:42 +12:00
- $ref: '#/components/schemas/ApiKey'
- $ref: '#/components/schemas/Local'
2024-06-04 07:53:33 +12:00
ApiKey:
description: API key authentication
allOf:
2024-06-05 02:48:42 +12:00
- $ref: '#/components/schemas/AuthMethod'
- type: object
properties:
key:
type: string
description: The API key
required:
- key
2024-06-04 07:53:33 +12:00
Local:
description: Authentication method for local applications. Uses file system access as proof of authentication.
allOf:
2024-06-05 02:48:42 +12:00
- $ref: '#/components/schemas/AuthMethod'
- type: object
properties:
authFileContent:
type: string
description: The contents of the local file $TEMP/xpipe_auth. This file is automatically generated when XPipe starts.
required:
- authFileContent
2024-06-04 07:53:33 +12:00
ClientInformation:
type: object
discriminator:
propertyName: type
properties:
type:
type: string
required:
2024-06-05 02:48:42 +12:00
- type
2024-06-04 07:53:33 +12:00
ApiClientInformation:
description: Provides information about the client that connected to the XPipe API.
allOf:
2024-06-05 02:48:42 +12:00
- $ref: '#/components/schemas/ClientInformation'
- type: object
properties:
name:
type: string
description: The name of the client.
required:
- name
2024-06-04 07:53:33 +12:00
responses:
Success:
description: The action was successfully performed.
BadRequest:
description: Bad request. Please check error message and your parameters.
Unauthorized:
description: Authorization failed. Please supply a `Bearer` token via
the `Authorization` header.
Forbidden:
description: Authorization failed. Please supply a valid `Bearer` token via
the `Authorization` header.
NotFound:
description: The requested resource could not be found.
InternalServerError:
description: Internal error.
securitySchemes:
2024-06-05 02:48:42 +12:00
bearerAuth:
type: http
scheme: bearer
description: The bearer token used is the session token that you receive from the handshake exchange.
security:
- bearerAuth: []