mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-09-26 18:35:43 +00:00
Api improvements
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package io.xpipe.app.beacon.impl;
|
||||
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
import io.xpipe.app.issue.ErrorEvent;
|
||||
import io.xpipe.app.storage.DataStorage;
|
||||
import io.xpipe.app.storage.DataStoreCategory;
|
||||
import io.xpipe.app.storage.DataStoreEntry;
|
||||
import io.xpipe.beacon.api.CategoryAddExchange;
|
||||
import io.xpipe.beacon.api.ConnectionAddExchange;
|
||||
import io.xpipe.core.util.ValidationException;
|
||||
|
||||
public class CategoryAddExchangeImpl extends CategoryAddExchange {
|
||||
|
||||
@Override
|
||||
public Object handle(HttpExchange exchange, Request msg) throws Throwable {
|
||||
var cat = DataStoreCategory.createNew(msg.getParent(), msg.getName());
|
||||
DataStorage.get().addStoreCategory(cat);
|
||||
return Response.builder().category(cat.getUuid()).build();
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,9 @@ public class ConnectionAddExchangeImpl extends ConnectionAddExchange {
|
||||
}
|
||||
|
||||
var entry = DataStoreEntry.createNew(msg.getName(), msg.getData());
|
||||
if (msg.getCategory() != null) {
|
||||
entry.setCategoryUuid(msg.getCategory());
|
||||
}
|
||||
try {
|
||||
DataStorage.get().addStoreEntryInProgress(entry);
|
||||
if (msg.getValidate()) {
|
||||
|
||||
@@ -132,6 +132,7 @@ open module io.xpipe.app {
|
||||
ConnectionInfoExchangeImpl,
|
||||
ConnectionRemoveExchangeImpl,
|
||||
ConnectionAddExchangeImpl,
|
||||
CategoryAddExchangeImpl,
|
||||
ConnectionBrowseExchangeImpl,
|
||||
ConnectionTerminalExchangeImpl,
|
||||
ConnectionToggleExchangeImpl,
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package io.xpipe.beacon.api;
|
||||
|
||||
import io.xpipe.beacon.BeaconInterface;
|
||||
import io.xpipe.core.store.DataStore;
|
||||
import lombok.Builder;
|
||||
import lombok.NonNull;
|
||||
import lombok.Value;
|
||||
import lombok.extern.jackson.Jacksonized;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class CategoryAddExchange extends BeaconInterface<CategoryAddExchange.Request> {
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return "/category/add";
|
||||
}
|
||||
|
||||
@Jacksonized
|
||||
@Builder
|
||||
@Value
|
||||
public static class Request {
|
||||
@NonNull
|
||||
String name;
|
||||
|
||||
@NonNull
|
||||
UUID parent;
|
||||
}
|
||||
|
||||
@Jacksonized
|
||||
@Builder
|
||||
@Value
|
||||
public static class Response {
|
||||
@NonNull
|
||||
UUID category;
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,8 @@ public class ConnectionAddExchange extends BeaconInterface<ConnectionAddExchange
|
||||
|
||||
@NonNull
|
||||
Boolean validate;
|
||||
|
||||
UUID category;
|
||||
}
|
||||
|
||||
@Jacksonized
|
||||
|
||||
@@ -40,6 +40,7 @@ open module io.xpipe.beacon {
|
||||
ConnectionInfoExchange,
|
||||
ConnectionRemoveExchange,
|
||||
ConnectionAddExchange,
|
||||
CategoryAddExchange,
|
||||
ConnectionBrowseExchange,
|
||||
ConnectionTerminalExchange,
|
||||
ConnectionToggleExchange,
|
||||
|
||||
+62
-2
@@ -24,7 +24,7 @@ info:
|
||||
contact:
|
||||
name: XPipe - Contact us
|
||||
url: mailto:hello@xpipe.io
|
||||
version: "13.0"
|
||||
version: "14.0"
|
||||
externalDocs:
|
||||
description: XPipe - Plans and pricing
|
||||
url: https://xpipe.io/pricing
|
||||
@@ -203,6 +203,43 @@ paths:
|
||||
$ref: '#/components/responses/Forbidden'
|
||||
'500':
|
||||
$ref: '#/components/responses/InternalServerError'
|
||||
/category/add:
|
||||
post:
|
||||
summary: Add new category
|
||||
description: |
|
||||
Creates a new empty category in the vault.
|
||||
|
||||
New categories always need a parent as it's not allowed to create root categories.
|
||||
operationId: categoryAd
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CategoryAddRequest'
|
||||
examples:
|
||||
simple:
|
||||
summary: Add new category
|
||||
value: { "name": "my category", "parent": "97458c07-75c0-4f9d-a06e-92d8cdf67c40" }
|
||||
responses:
|
||||
'200':
|
||||
description: The request was successful. The category was added.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CategoryAddResponse'
|
||||
examples:
|
||||
standard:
|
||||
summary: Category information
|
||||
value: { "category": "36ad9716-a209-4f7f-9814-078d3349280c" }
|
||||
'400':
|
||||
$ref: '#/components/responses/BadRequest'
|
||||
'401':
|
||||
$ref: '#/components/responses/Unauthorized'
|
||||
'403':
|
||||
$ref: '#/components/responses/Forbidden'
|
||||
'500':
|
||||
$ref: '#/components/responses/InternalServerError'
|
||||
/connection/remove:
|
||||
post:
|
||||
summary: Remove connection
|
||||
@@ -844,10 +881,13 @@ components:
|
||||
description: The connection name
|
||||
data:
|
||||
type: object
|
||||
description: The raw connection store data. Schemas for connection types are not documented but you can find the connection data of your existing connections in the xpipe vault.
|
||||
description: The raw connection store data. Schemas for connection types are not documented, but you can find the connection data of your existing connections in the xpipe vault.
|
||||
validate:
|
||||
type: boolean
|
||||
description: Whether to perform a connection validation before adding it, i.e., probe the connection first. If validation is enabled and fails, the connection will not be added
|
||||
category:
|
||||
type: string
|
||||
description: The category uuid to put the connection in. If not specified, the default category will be used
|
||||
required:
|
||||
- name
|
||||
- data
|
||||
@@ -860,6 +900,26 @@ components:
|
||||
description: The connection uuid
|
||||
required:
|
||||
- connection
|
||||
CategoryAddRequest:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description: The category name
|
||||
parent:
|
||||
type: string
|
||||
description: The parent category uuid to put the new category in
|
||||
required:
|
||||
- name
|
||||
- parent
|
||||
CategoryAddResponse:
|
||||
type: object
|
||||
properties:
|
||||
category:
|
||||
type: string
|
||||
description: The category uuid
|
||||
required:
|
||||
- category
|
||||
ConnectionRemoveRequest:
|
||||
type: object
|
||||
properties:
|
||||
|
||||
Reference in New Issue
Block a user