mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-09-19 22:01:12 +00:00
api fixes
This commit is contained in:
parent
1702d716cd
commit
2b684c9e5e
|
@ -1,15 +1,11 @@
|
||||||
package io.xpipe.app.beacon.impl;
|
package io.xpipe.app.beacon.impl;
|
||||||
|
|
||||||
|
import com.sun.net.httpserver.HttpExchange;
|
||||||
import io.xpipe.app.storage.DataStorage;
|
import io.xpipe.app.storage.DataStorage;
|
||||||
import io.xpipe.app.storage.DataStoreEntry;
|
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.beacon.api.ConnectionQueryExchange;
|
||||||
import io.xpipe.core.store.StorePath;
|
import io.xpipe.core.store.StorePath;
|
||||||
|
|
||||||
import com.sun.net.httpserver.HttpExchange;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
@ -20,6 +16,7 @@ public class ConnectionQueryExchangeImpl extends ConnectionQueryExchange {
|
||||||
public Object handle(HttpExchange exchange, Request msg) {
|
public Object handle(HttpExchange exchange, Request msg) {
|
||||||
var catMatcher = Pattern.compile(toRegex("all connections/" + msg.getCategoryFilter()));
|
var catMatcher = Pattern.compile(toRegex("all connections/" + msg.getCategoryFilter()));
|
||||||
var conMatcher = Pattern.compile(toRegex(msg.getConnectionFilter()));
|
var conMatcher = Pattern.compile(toRegex(msg.getConnectionFilter()));
|
||||||
|
var typeMatcher = Pattern.compile(toRegex(msg.getTypeFilter()));
|
||||||
|
|
||||||
List<DataStoreEntry> found = new ArrayList<>();
|
List<DataStoreEntry> found = new ArrayList<>();
|
||||||
for (DataStoreEntry storeEntry : DataStorage.get().getStoreEntries()) {
|
for (DataStoreEntry storeEntry : DataStorage.get().getStoreEntries()) {
|
||||||
|
@ -44,6 +41,10 @@ public class ConnectionQueryExchangeImpl extends ConnectionQueryExchange {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!typeMatcher.matcher(storeEntry.getProvider().getId()).matches()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
found.add(storeEntry);
|
found.add(storeEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
24
openapi.yaml
24
openapi.yaml
|
@ -103,10 +103,10 @@ paths:
|
||||||
examples:
|
examples:
|
||||||
standard:
|
standard:
|
||||||
summary: Matched connections
|
summary: Matched connections
|
||||||
value: { "found": [ { "uuid": "f0ec68aa-63f5-405c-b178-9a4454556d6b", "category": ["default"] ,
|
value: { "found": [ { "connection": "f0ec68aa-63f5-405c-b178-9a4454556d6b", "category": ["default"] ,
|
||||||
"connection": ["local machine"], "type": "local" },
|
"name": ["local machine"], "type": "local" },
|
||||||
{ "uuid": "e1462ddc-9beb-484c-bd91-bb666027e300", "category": ["default", "category 1"],
|
{ "connection": "e1462ddc-9beb-484c-bd91-bb666027e300", "category": ["default", "category 1"],
|
||||||
"connection": ["ssh system", "shell environments", "bash"], "type": "shellEnvironment" } ] }
|
"name": ["ssh system", "shell environments", "bash"], "type": "shellEnvironment" } ] }
|
||||||
'400':
|
'400':
|
||||||
$ref: '#/components/responses/BadRequest'
|
$ref: '#/components/responses/BadRequest'
|
||||||
'401':
|
'401':
|
||||||
|
@ -135,7 +135,7 @@ paths:
|
||||||
examples:
|
examples:
|
||||||
local:
|
local:
|
||||||
summary: Start local shell
|
summary: Start local shell
|
||||||
value: { "uuid": "f0ec68aa-63f5-405c-b178-9a4454556d6b" }
|
value: { "connection": "f0ec68aa-63f5-405c-b178-9a4454556d6b" }
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: The operation was successful. The shell session was started.
|
description: The operation was successful. The shell session was started.
|
||||||
|
@ -167,7 +167,7 @@ paths:
|
||||||
examples:
|
examples:
|
||||||
local:
|
local:
|
||||||
summary: Stop local shell
|
summary: Stop local shell
|
||||||
value: { "uuid": "f0ec68aa-63f5-405c-b178-9a4454556d6b" }
|
value: { "connection": "f0ec68aa-63f5-405c-b178-9a4454556d6b" }
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: The operation was successful. The shell session was stopped.
|
description: The operation was successful. The shell session was stopped.
|
||||||
|
@ -200,10 +200,10 @@ paths:
|
||||||
examples:
|
examples:
|
||||||
user:
|
user:
|
||||||
summary: echo $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:
|
invalid:
|
||||||
summary: invalid
|
summary: invalid
|
||||||
value: { "uuid": "f0ec68aa-63f5-405c-b178-9a4454556d6b", "command": "invalid" }
|
value: { "connection": "f0ec68aa-63f5-405c-b178-9a4454556d6b", "command": "invalid" }
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: The operation was successful. The shell command finished.
|
description: The operation was successful. The shell command finished.
|
||||||
|
@ -299,7 +299,7 @@ components:
|
||||||
items:
|
items:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
uuid:
|
connection:
|
||||||
type: string
|
type: string
|
||||||
description: The unique id of the connection
|
description: The unique id of the connection
|
||||||
category:
|
category:
|
||||||
|
@ -308,7 +308,7 @@ components:
|
||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
description: Individual category name
|
description: Individual category name
|
||||||
connection:
|
name:
|
||||||
type: array
|
type: array
|
||||||
description: The full connection name path as an array
|
description: The full connection name path as an array
|
||||||
items:
|
items:
|
||||||
|
@ -318,9 +318,9 @@ components:
|
||||||
type: string
|
type: string
|
||||||
description: The type identifier of the connection
|
description: The type identifier of the connection
|
||||||
required:
|
required:
|
||||||
- uuid
|
|
||||||
- category
|
|
||||||
- connection
|
- connection
|
||||||
|
- category
|
||||||
|
- name
|
||||||
- type
|
- type
|
||||||
required:
|
required:
|
||||||
- found
|
- found
|
||||||
|
|
Loading…
Reference in a new issue