Skip to content

Commit

Permalink
Merge pull request #170 from games-on-whales/dev-wolfapi
Browse files Browse the repository at this point in the history
Dev wolfapi
  • Loading branch information
ABeltramo authored Feb 1, 2025
2 parents 3fd4a01 + 7a68f72 commit 20a2505
Show file tree
Hide file tree
Showing 10 changed files with 504 additions and 35 deletions.
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

0 comments on commit 20a2505

Please sign in to comment.