From 2b684c9e5e57ea5ca6cc23d939a4c260c57e3389 Mon Sep 17 00:00:00 2001 From: crschnick Date: Mon, 17 Jun 2024 11:36:55 +0000 Subject: [PATCH] api fixes --- .../impl/ConnectionQueryExchangeImpl.java | 11 +++++---- openapi.yaml | 24 +++++++++---------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/beacon/impl/ConnectionQueryExchangeImpl.java b/app/src/main/java/io/xpipe/app/beacon/impl/ConnectionQueryExchangeImpl.java index eeabbb079..1d3da1539 100644 --- a/app/src/main/java/io/xpipe/app/beacon/impl/ConnectionQueryExchangeImpl.java +++ b/app/src/main/java/io/xpipe/app/beacon/impl/ConnectionQueryExchangeImpl.java @@ -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 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); } diff --git a/openapi.yaml b/openapi.yaml index fc2e0e1c7..97d092fd6 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -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