Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev wolfapi #170

Merged
merged 20 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
73b4796
Add unpair client to API
salty2011 Jan 23, 2025
3c15b3d
FIX: Remove duplicate field definition
salty2011 Jan 23, 2025
6b2d470
refactor: improve error handling in UnpairClient endpoint
salty2011 Jan 23, 2025
ddc5d51
fix: update client ID retrieval in UnpairClient endpoint to use optio…
salty2011 Jan 23, 2025
d3ac867
feat: add Unpair Client endpoint to the API with request and response…
salty2011 Jan 23, 2025
c28b2e8
Updating Spec so its referenced in the doc
salty2011 Jan 23, 2025
f3ece3f
fix: setting api doc's to light mode as darkmode is broken currently
salty2011 Jan 23, 2025
23e35ca
fix: change api endoint PairedClient to output ClientID as string ins…
salty2011 Jan 25, 2025
b938c0c
Add updating of client app_state_folder and settings
salty2011 Jan 27, 2025
43ebd1c
removed duplicate function and corrected logic for looking up client
salty2011 Jan 27, 2025
7039c19
refactor: Move PartialClientSettings to data-structures and update fu…
salty2011 Jan 29, 2025
d4653bf
refactor: Update client lookup and settings update logic with immer::box
salty2011 Jan 29, 2025
9f231a3
refactor: Simplify client settings update with direct value extraction
salty2011 Jan 29, 2025
6603c4b
fix: compilation error, automatic clang format
ABeltramo Jan 29, 2025
2fbd419
fix: refactored update client settings method and API call
ABeltramo Jan 29, 2025
4d1655f
fix: properly merge updated client, added unit tests for the new methods
ABeltramo Jan 29, 2025
581f410
feat: changing client config update to allow settings to be optional.…
salty2011 Jan 30, 2025
4f25091
fix: compilation error, exposing all client data in the APIs, correct…
ABeltramo Jan 31, 2025
bfb7dd5
fix: avoid dangling pair requests
ABeltramo Jan 31, 2025
7a68f72
docs: updated API spec, removed dark mode
ABeltramo Jan 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion docs/modules/dev/pages/api.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
= Wolf API

Wolf exposes a REST API that allows you to interact with the platform programmatically. +
The API can be accessed only via UNIX sockets, you can control the exact path by setting the `WOLF_SOCKET_PATH` environment variable. If you want to access the socket from outside the container, you should mount the socket to the host machine, ex: `-e WOLF_SOCKET_PATH=/var/run/wolf/wolf.sock` and `-v /var/run/wolf:/var/run/wolf` will allow you to access the socket from the host machine at `/var/run/wolf/wolf.sock`.
The API can be accessed only via UNIX sockets, you can control the exact path by setting the `WOLF_SOCKET_PATH` environment variable.
If you want to access the socket from outside the container, you should mount the socket to the host machine, ex: `-e WOLF_SOCKET_PATH=/var/run/wolf/wolf.sock` and `-v /var/run/wolf:/var/run/wolf` will allow you to access the socket from the host machine at `/var/run/wolf/wolf.sock`.

You can test out the API using the `curl` command, for example, to get the OpenAPI specification you can run:

Expand Down Expand Up @@ -66,5 +67,16 @@ curl localhost:8080/api/v1/openapi-schema
type="application/json">
include::{includedir}/spec.json[]
</script>
<!-- see: https://github.com/scalar/scalar/blob/main/documentation/configuration.md -->
<script>
var configuration = {
darkMode: false,
forceDarkModeState: 'light',
hideDarkModeToggle: true
}

document.getElementById('api-reference').dataset.configuration =
JSON.stringify(configuration)
</script>
<script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
++++
249 changes: 245 additions & 4 deletions docs/modules/dev/partials/spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,65 @@
}
}
},
"/api/v1/clients/settings": {
"post": {
"summary": "Update client settings",
"description": "Update a client's settings including app state folder and client-specific settings",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/wolf__api__UpdateClientSettingsRequest"
}
}
},
"description": "",
"required": true
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/wolf__api__GenericSuccessResponse"
}
}
},
"description": ""
},
"400": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/wolf__api__GenericErrorResponse"
}
}
},
"description": ""
},
"404": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/wolf__api__GenericErrorResponse"
}
}
},
"description": ""
},
"500": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/wolf__api__GenericErrorResponse"
}
}
},
"description": ""
}
}
}
},
"/api/v1/pair/client": {
"post": {
"summary": "Pair a client",
Expand Down Expand Up @@ -448,6 +507,45 @@
}
}
}
},
"/api/v1/unpair/client": {
"post": {
"summary": "Unpair a client",
"description": "",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/wolf__api__UnpairClientRequest"
}
}
},
"description": "",
"required": true
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/wolf__api__GenericSuccessResponse"
}
}
},
"description": ""
},
"500": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/wolf__api__GenericErrorResponse"
}
}
},
"description": ""
}
}
}
}
},
"components": {
Expand Down Expand Up @@ -640,12 +738,16 @@
"type": "string"
},
"client_id": {
"type": "integer"
"type": "string"
},
"settings": {
"$ref": "#/components/schemas/wolf__config__ClientSettings"
}
},
"required": [
"app_state_folder",
"client_id"
"client_id",
"settings"
]
},
"wolf__api__PairedClientsResponse": {
Expand All @@ -666,13 +768,104 @@
"success"
]
},
"wolf__api__PartialClientSettings": {
"type": "object",
"properties": {
"controllers_override": {
"anyOf": [
{
"type": "array",
"items": {
"type": "string",
"enum": [
"XBOX",
"PS",
"NINTENDO",
"AUTO"
]
}
},
{
"type": "null"
}
]
},
"h_scroll_acceleration": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
]
},
"mouse_acceleration": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
]
},
"run_gid": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
]
},
"run_uid": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
]
},
"v_scroll_acceleration": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
]
}
},
"required": []
},
"wolf__api__PendingPairClient": {
"type": "object",
"properties": {
"client_ip": {
"type": "string",
"description": "The IP of the remote Moonlight client"
},
"pair_secret": {
"type": "string"
}
},
"required": [
"client_ip",
"pair_secret"
]
},
"wolf__api__PendingPairRequestsResponse": {
"type": "object",
"properties": {
"requests": {
"type": "array",
"items": {
"$ref": "#/components/schemas/wolf__api__PairRequest"
"$ref": "#/components/schemas/wolf__api__PendingPairClient"
}
},
"success": {
Expand Down Expand Up @@ -803,6 +996,54 @@
"session_id"
]
},
"wolf__api__UnpairClientRequest": {
"type": "object",
"properties": {
"client_id": {
"type": "string",
"description": "The client ID to unpair"
}
},
"required": [
"client_id"
]
},
"wolf__api__UpdateClientSettingsRequest": {
"type": "object",
"properties": {
"app_state_folder": {
"description": "New app state folder path (optional)",
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"client_id": {
"type": "string",
"description": "The client ID to identify the client (derived from certificate)"
},
"settings": {
"description": "Client settings to update (only specified fields will be updated)",
"anyOf": [
{
"$ref": "#/components/schemas/wolf__api__PartialClientSettings"
},
{
"type": "null"
}
]
}
},
"required": [
"app_state_folder",
"client_id",
"settings"
]
},
"wolf__config__AppCMD__tagged": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1128,4 +1369,4 @@
}
}
}
}
}
Loading
Loading