forked from wrenn/python-sdk
Updated SDK to match v0.1.1
This commit is contained in:
557
api/openapi.yaml
557
api/openapi.yaml
@ -2,7 +2,7 @@ openapi: "3.1.0"
|
||||
info:
|
||||
title: Wrenn API
|
||||
description: MicroVM-based code execution platform API.
|
||||
version: "0.1.0"
|
||||
version: "0.1.2"
|
||||
|
||||
servers:
|
||||
- url: http://localhost:8080
|
||||
@ -16,6 +16,10 @@ paths:
|
||||
summary: Create a new account
|
||||
operationId: signup
|
||||
tags: [auth]
|
||||
description: |
|
||||
Creates an inactive user account and sends an activation email.
|
||||
The user must activate their account within 30 minutes.
|
||||
Does not return a JWT — the user must activate first, then sign in.
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
@ -24,11 +28,11 @@ paths:
|
||||
$ref: "#/components/schemas/SignupRequest"
|
||||
responses:
|
||||
"201":
|
||||
description: Account created
|
||||
description: Account created, activation email sent
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/AuthResponse"
|
||||
$ref: "#/components/schemas/SignupResponse"
|
||||
"400":
|
||||
description: Invalid request (bad email, short password)
|
||||
content:
|
||||
@ -36,7 +40,39 @@ paths:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
"409":
|
||||
description: Email already registered
|
||||
description: Email already registered or signup cooldown active
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
|
||||
/v1/auth/activate:
|
||||
post:
|
||||
summary: Activate account via email token
|
||||
operationId: activate
|
||||
tags: [auth]
|
||||
description: |
|
||||
Consumes the activation token sent via email and activates the user account.
|
||||
Creates a default team and returns a JWT to log the user in.
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
required: [token]
|
||||
properties:
|
||||
token:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: Account activated, JWT issued
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/AuthResponse"
|
||||
"400":
|
||||
description: Invalid or expired token
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
@ -175,6 +211,252 @@ paths:
|
||||
"302":
|
||||
description: Redirect to frontend with token or error
|
||||
|
||||
/v1/me:
|
||||
get:
|
||||
summary: Get current user profile
|
||||
operationId: getMe
|
||||
tags: [account]
|
||||
security:
|
||||
- bearerAuth: []
|
||||
responses:
|
||||
"200":
|
||||
description: User profile
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/MeResponse"
|
||||
|
||||
patch:
|
||||
summary: Update display name
|
||||
operationId: updateName
|
||||
tags: [account]
|
||||
security:
|
||||
- bearerAuth: []
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
required: [name]
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 100
|
||||
responses:
|
||||
"200":
|
||||
description: Name updated, new JWT issued
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/AuthResponse"
|
||||
"400":
|
||||
description: Invalid name
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
|
||||
delete:
|
||||
summary: Delete current account
|
||||
operationId: deleteAccount
|
||||
tags: [account]
|
||||
security:
|
||||
- bearerAuth: []
|
||||
description: |
|
||||
Soft-deletes the account (sets status=deleted, deleted_at=now).
|
||||
The account is permanently removed after 15 days. Blocked if the user
|
||||
owns any team that has other members.
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
required: [confirmation]
|
||||
properties:
|
||||
confirmation:
|
||||
type: string
|
||||
description: Must match the user's email address (case-insensitive)
|
||||
responses:
|
||||
"204":
|
||||
description: Account scheduled for deletion
|
||||
"400":
|
||||
description: Confirmation does not match email
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
"409":
|
||||
description: User owns teams with other members
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
|
||||
/v1/me/password:
|
||||
post:
|
||||
summary: Change or add password
|
||||
operationId: changePassword
|
||||
tags: [account]
|
||||
security:
|
||||
- bearerAuth: []
|
||||
description: |
|
||||
For users with an existing password: requires `current_password` and `new_password`.
|
||||
For OAuth-only users adding a password: requires `new_password` and `confirm_password`.
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/ChangePasswordRequest"
|
||||
responses:
|
||||
"204":
|
||||
description: Password updated
|
||||
"400":
|
||||
description: Invalid request (short password, mismatch, etc.)
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
"401":
|
||||
description: Current password is incorrect
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
|
||||
/v1/me/password/reset:
|
||||
post:
|
||||
summary: Request a password reset email
|
||||
operationId: requestPasswordReset
|
||||
tags: [account]
|
||||
description: |
|
||||
Sends a password reset link to the given email. Always returns 200
|
||||
regardless of whether the email exists, to prevent account enumeration.
|
||||
The reset token expires in 15 minutes.
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
required: [email]
|
||||
properties:
|
||||
email:
|
||||
type: string
|
||||
format: email
|
||||
responses:
|
||||
"204":
|
||||
description: Request accepted (email sent if account exists)
|
||||
|
||||
/v1/me/password/reset/confirm:
|
||||
post:
|
||||
summary: Confirm password reset
|
||||
operationId: confirmPasswordReset
|
||||
tags: [account]
|
||||
description: |
|
||||
Consumes a password reset token and sets a new password. The token is
|
||||
single-use and expires after 15 minutes.
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
required: [token, new_password]
|
||||
properties:
|
||||
token:
|
||||
type: string
|
||||
description: Raw reset token from the email link
|
||||
new_password:
|
||||
type: string
|
||||
minLength: 8
|
||||
responses:
|
||||
"204":
|
||||
description: Password reset successful
|
||||
"400":
|
||||
description: Invalid or expired token, or password too short
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
|
||||
/v1/me/providers/{provider}/connect:
|
||||
parameters:
|
||||
- name: provider
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
enum: [github]
|
||||
description: OAuth provider name
|
||||
|
||||
get:
|
||||
summary: Initiate OAuth provider link
|
||||
operationId: connectProvider
|
||||
tags: [account]
|
||||
security:
|
||||
- bearerAuth: []
|
||||
description: |
|
||||
Sets OAuth state and link cookies, then returns the provider's
|
||||
authorization URL. The frontend navigates to this URL to start the
|
||||
OAuth flow. On callback, the provider is linked to the current account
|
||||
(not a new registration).
|
||||
responses:
|
||||
"200":
|
||||
description: Authorization URL
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
auth_url:
|
||||
type: string
|
||||
format: uri
|
||||
"404":
|
||||
description: Provider not found or not configured
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
|
||||
/v1/me/providers/{provider}:
|
||||
parameters:
|
||||
- name: provider
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
enum: [github]
|
||||
description: OAuth provider name
|
||||
|
||||
delete:
|
||||
summary: Disconnect an OAuth provider
|
||||
operationId: disconnectProvider
|
||||
tags: [account]
|
||||
security:
|
||||
- bearerAuth: []
|
||||
description: |
|
||||
Unlinks the OAuth provider from the current account. Blocked if this
|
||||
is the user's only login method (no password and no other providers).
|
||||
responses:
|
||||
"204":
|
||||
description: Provider disconnected
|
||||
"400":
|
||||
description: Cannot disconnect last login method
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
"404":
|
||||
description: Provider not connected
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
|
||||
/v1/api-keys:
|
||||
post:
|
||||
summary: Create an API key
|
||||
@ -639,6 +921,38 @@ paths:
|
||||
"400":
|
||||
$ref: "#/components/responses/BadRequest"
|
||||
|
||||
/v1/capsules/usage:
|
||||
get:
|
||||
summary: Get daily CPU and RAM usage for your team
|
||||
operationId: getCapsuleUsage
|
||||
tags: [capsules]
|
||||
security:
|
||||
- apiKeyAuth: []
|
||||
parameters:
|
||||
- name: from
|
||||
in: query
|
||||
required: false
|
||||
schema:
|
||||
type: string
|
||||
format: date
|
||||
description: Start date (YYYY-MM-DD). Defaults to 30 days ago.
|
||||
- name: to
|
||||
in: query
|
||||
required: false
|
||||
schema:
|
||||
type: string
|
||||
format: date
|
||||
description: End date (YYYY-MM-DD). Defaults to today.
|
||||
responses:
|
||||
"200":
|
||||
description: Daily usage data for the team
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/UsageResponse"
|
||||
"400":
|
||||
$ref: "#/components/responses/BadRequest"
|
||||
|
||||
/v1/capsules/{id}:
|
||||
parameters:
|
||||
- name: id
|
||||
@ -699,11 +1013,17 @@ paths:
|
||||
$ref: "#/components/schemas/ExecRequest"
|
||||
responses:
|
||||
"200":
|
||||
description: Command output
|
||||
description: Command output (foreground exec)
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/ExecResponse"
|
||||
"202":
|
||||
description: Background process started
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/BackgroundExecResponse"
|
||||
"404":
|
||||
description: Capsule not found
|
||||
content:
|
||||
@ -717,6 +1037,122 @@ paths:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
|
||||
/v1/capsules/{id}/processes:
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
|
||||
get:
|
||||
summary: List running processes
|
||||
operationId: listProcesses
|
||||
tags: [capsules]
|
||||
security:
|
||||
- apiKeyAuth: []
|
||||
description: |
|
||||
Returns all running processes inside the capsule, including background
|
||||
processes and any processes started by templates or init scripts.
|
||||
responses:
|
||||
"200":
|
||||
description: Process list
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/ProcessListResponse"
|
||||
"404":
|
||||
description: Capsule not found
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
"409":
|
||||
description: Capsule not running
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
|
||||
/v1/capsules/{id}/processes/{selector}:
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
- name: selector
|
||||
in: path
|
||||
required: true
|
||||
description: Process PID (numeric) or tag (string)
|
||||
schema:
|
||||
type: string
|
||||
|
||||
delete:
|
||||
summary: Kill a process
|
||||
operationId: killProcess
|
||||
tags: [capsules]
|
||||
security:
|
||||
- apiKeyAuth: []
|
||||
parameters:
|
||||
- name: signal
|
||||
in: query
|
||||
required: false
|
||||
description: Signal to send (SIGKILL or SIGTERM, default SIGKILL)
|
||||
schema:
|
||||
type: string
|
||||
enum: [SIGKILL, SIGTERM]
|
||||
default: SIGKILL
|
||||
responses:
|
||||
"204":
|
||||
description: Process killed
|
||||
"404":
|
||||
description: Capsule or process not found
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
"409":
|
||||
description: Capsule not running
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
|
||||
/v1/capsules/{id}/processes/{selector}/stream:
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
- name: selector
|
||||
in: path
|
||||
required: true
|
||||
description: Process PID (numeric) or tag (string)
|
||||
schema:
|
||||
type: string
|
||||
|
||||
get:
|
||||
summary: Stream process output via WebSocket
|
||||
operationId: connectProcess
|
||||
tags: [capsules]
|
||||
security:
|
||||
- apiKeyAuth: []
|
||||
description: |
|
||||
Opens a WebSocket connection to stream stdout/stderr from a running
|
||||
background process. The selector can be a numeric PID or a string tag.
|
||||
|
||||
Server sends JSON messages:
|
||||
- `{"type": "start", "pid": 42}` — connected to process
|
||||
- `{"type": "stdout", "data": "..."}` — stdout output
|
||||
- `{"type": "stderr", "data": "..."}` — stderr output
|
||||
- `{"type": "exit", "exit_code": 0}` — process exited
|
||||
- `{"type": "error", "data": "..."}` — error message
|
||||
responses:
|
||||
"101":
|
||||
description: WebSocket upgrade
|
||||
|
||||
/v1/capsules/{id}/ping:
|
||||
parameters:
|
||||
- name: id
|
||||
@ -1264,7 +1700,6 @@ paths:
|
||||
PTY data (input and output) is base64-encoded because it contains raw
|
||||
terminal bytes (escape sequences, control codes) that are not valid UTF-8.
|
||||
|
||||
Sessions have a 120-second inactivity timeout (reset on input/resize).
|
||||
Sessions persist across WebSocket disconnections — the process keeps
|
||||
running in the capsule. Use the `tag` from the "started" response to
|
||||
reconnect later.
|
||||
@ -1956,6 +2391,13 @@ components:
|
||||
password:
|
||||
type: string
|
||||
|
||||
SignupResponse:
|
||||
type: object
|
||||
properties:
|
||||
message:
|
||||
type: string
|
||||
description: Confirmation message instructing user to check email
|
||||
|
||||
AuthResponse:
|
||||
type: object
|
||||
properties:
|
||||
@ -2022,6 +2464,28 @@ components:
|
||||
after this duration of inactivity (no exec or ping). 0 means
|
||||
no auto-pause.
|
||||
|
||||
UsageResponse:
|
||||
type: object
|
||||
properties:
|
||||
from:
|
||||
type: string
|
||||
format: date
|
||||
to:
|
||||
type: string
|
||||
format: date
|
||||
points:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
date:
|
||||
type: string
|
||||
format: date
|
||||
cpu_minutes:
|
||||
type: number
|
||||
ram_mb_minutes:
|
||||
type: number
|
||||
|
||||
CapsuleStats:
|
||||
type: object
|
||||
properties:
|
||||
@ -2153,6 +2617,56 @@ components:
|
||||
timeout_sec:
|
||||
type: integer
|
||||
default: 30
|
||||
description: Timeout in seconds (foreground exec only, default 30)
|
||||
background:
|
||||
type: boolean
|
||||
default: false
|
||||
description: If true, starts the process in the background and returns immediately with a PID and tag (HTTP 202)
|
||||
tag:
|
||||
type: string
|
||||
description: Optional user-chosen tag for the background process. Auto-generated if omitted. Only used when background is true.
|
||||
envs:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: string
|
||||
description: Environment variables for the process (background exec only)
|
||||
cwd:
|
||||
type: string
|
||||
description: Working directory for the process (background exec only)
|
||||
|
||||
BackgroundExecResponse:
|
||||
type: object
|
||||
properties:
|
||||
sandbox_id:
|
||||
type: string
|
||||
cmd:
|
||||
type: string
|
||||
pid:
|
||||
type: integer
|
||||
tag:
|
||||
type: string
|
||||
|
||||
ProcessEntry:
|
||||
type: object
|
||||
properties:
|
||||
pid:
|
||||
type: integer
|
||||
tag:
|
||||
type: string
|
||||
cmd:
|
||||
type: string
|
||||
args:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
|
||||
ProcessListResponse:
|
||||
type: object
|
||||
properties:
|
||||
processes:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/ProcessEntry"
|
||||
|
||||
ExecResponse:
|
||||
type: object
|
||||
@ -2609,6 +3123,37 @@ components:
|
||||
nullable: true
|
||||
description: Webhook secret. Only returned on creation, never again.
|
||||
|
||||
MeResponse:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
email:
|
||||
type: string
|
||||
format: email
|
||||
has_password:
|
||||
type: boolean
|
||||
description: Whether the user has a password set (false for OAuth-only accounts)
|
||||
providers:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
description: List of linked OAuth provider names (e.g. ["github"])
|
||||
|
||||
ChangePasswordRequest:
|
||||
type: object
|
||||
required: [new_password]
|
||||
properties:
|
||||
current_password:
|
||||
type: string
|
||||
description: Required when changing an existing password
|
||||
new_password:
|
||||
type: string
|
||||
minLength: 8
|
||||
confirm_password:
|
||||
type: string
|
||||
description: Required when adding a password to an OAuth-only account (must match new_password)
|
||||
|
||||
Error:
|
||||
type: object
|
||||
properties:
|
||||
|
||||
Reference in New Issue
Block a user