api fixes

This commit is contained in:
crschnick 2024-06-17 11:36:55 +00:00
parent 1702d716cd
commit 2b684c9e5e
2 changed files with 18 additions and 17 deletions

View file

@ -1,15 +1,11 @@
package io.xpipe.app.beacon.impl;
import com.sun.net.httpserver.HttpExchange;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.beacon.BeaconClientException;
import io.xpipe.beacon.BeaconServerException;
import io.xpipe.beacon.api.ConnectionQueryExchange;
import io.xpipe.core.store.StorePath;
import com.sun.net.httpserver.HttpExchange;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
@ -20,6 +16,7 @@ public class ConnectionQueryExchangeImpl extends ConnectionQueryExchange {
public Object handle(HttpExchange exchange, Request msg) {
var catMatcher = Pattern.compile(toRegex("all connections/" + msg.getCategoryFilter()));
var conMatcher = Pattern.compile(toRegex(msg.getConnectionFilter()));
var typeMatcher = Pattern.compile(toRegex(msg.getTypeFilter()));
List<DataStoreEntry> found = new ArrayList<>();
for (DataStoreEntry storeEntry : DataStorage.get().getStoreEntries()) {
@ -44,6 +41,10 @@ public class ConnectionQueryExchangeImpl extends ConnectionQueryExchange {
continue;
}
if (!typeMatcher.matcher(storeEntry.getProvider().getId()).matches()) {
continue;
}
found.add(storeEntry);
}

View file

@ -103,10 +103,10 @@ paths:
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" } ] }
value: { "found": [ { "connection": "f0ec68aa-63f5-405c-b178-9a4454556d6b", "category": ["default"] ,
"name": ["local machine"], "type": "local" },
{ "connection": "e1462ddc-9beb-484c-bd91-bb666027e300", "category": ["default", "category 1"],
"name": ["ssh system", "shell environments", "bash"], "type": "shellEnvironment" } ] }
'400':
$ref: '#/components/responses/BadRequest'
'401':
@ -135,7 +135,7 @@ paths:
examples:
local:
summary: Start local shell
value: { "uuid": "f0ec68aa-63f5-405c-b178-9a4454556d6b" }
value: { "connection": "f0ec68aa-63f5-405c-b178-9a4454556d6b" }
responses:
'200':
description: The operation was successful. The shell session was started.
@ -167,7 +167,7 @@ paths:
examples:
local:
summary: Stop local shell
value: { "uuid": "f0ec68aa-63f5-405c-b178-9a4454556d6b" }
value: { "connection": "f0ec68aa-63f5-405c-b178-9a4454556d6b" }
responses:
'200':
description: The operation was successful. The shell session was stopped.
@ -200,10 +200,10 @@ paths:
examples:
user:
summary: echo $USER
value: { "uuid": "f0ec68aa-63f5-405c-b178-9a4454556d6b", "command": "echo $USER" }
value: { "connection": "f0ec68aa-63f5-405c-b178-9a4454556d6b", "command": "echo $USER" }
invalid:
summary: invalid
value: { "uuid": "f0ec68aa-63f5-405c-b178-9a4454556d6b", "command": "invalid" }
value: { "connection": "f0ec68aa-63f5-405c-b178-9a4454556d6b", "command": "invalid" }
responses:
'200':
description: The operation was successful. The shell command finished.
@ -299,7 +299,7 @@ components:
items:
type: object
properties:
uuid:
connection:
type: string
description: The unique id of the connection
category:
@ -308,7 +308,7 @@ components:
items:
type: string
description: Individual category name
connection:
name:
type: array
description: The full connection name path as an array
items:
@ -318,9 +318,9 @@ components:
type: string
description: The type identifier of the connection
required:
- uuid
- category
- connection
- category
- name
- type
required:
- found