Skip to content

Commit 56fa19f

Browse files
Crowayorpiske
authored andcommitted
Create ExceptionMappers and align Tools Service
1 parent 0612ce5 commit 56fa19f

File tree

31 files changed

+576
-477
lines changed

31 files changed

+576
-477
lines changed

api/src/main/java/ai/wanaku/api/exceptions/WanakuException.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package ai.wanaku.api.exceptions;
22

3-
public class WanakuException extends Exception {
3+
public class WanakuException extends RuntimeException {
44
public WanakuException() {
55
}
66

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package ai.wanaku.server.quarkus.api.v1.models;
1+
package ai.wanaku.api.types;
22

33
public record WanakuError(String message) {
44
public WanakuError() {
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package ai.wanaku.server.quarkus.api.v1.models;
1+
package ai.wanaku.api.types;
22

33
public record WanakuResponse<T>(WanakuError error, T data) {
44
public WanakuResponse() {

cli/src/main/java/ai/wanaku/cli/main/commands/resources/ResourcesList.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void run() {
2525
.baseUri(URI.create(host))
2626
.build(ResourcesService.class);
2727

28-
List<ResourceReference> list = resourcesService.list();
28+
List<ResourceReference> list = resourcesService.list().getEntity().data();
2929
PrettyPrinter.printResources(list);
3030
}
3131
}

cli/src/main/java/ai/wanaku/cli/main/commands/targets/resources/ResourcesLinkedList.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class ResourcesLinkedList extends AbstractTargetsList {
1414
public void run() {
1515
initService();
1616

17-
Map<String, Service> list = linkService.resourcesList();
17+
Map<String, Service> list = linkService.resourcesList().data();
1818
PrettyPrinter.printTargets(list);
1919
}
2020
}

cli/src/main/java/ai/wanaku/cli/main/commands/targets/tools/ToolsLinkedList.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class ToolsLinkedList extends AbstractTargetsList {
1414
public void run() {
1515
initService();
1616

17-
Map<String, Service> list = linkService.toolsList();
17+
Map<String, Service> list = linkService.toolsList().data();
1818
PrettyPrinter.printTargets(list);
1919
}
2020
}

cli/src/main/java/ai/wanaku/cli/main/commands/tools/ToolsList.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void run() {
2727
.baseUri(URI.create(host))
2828
.build(ToolsService.class);
2929

30-
List<ToolReference> list = toolsService.list();
30+
List<ToolReference> list = toolsService.list().getEntity().data();
3131
PrettyPrinter.printTools(list);
3232
}
3333

cli/src/main/java/ai/wanaku/cli/main/services/LinkService.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.Map;
44

5+
import ai.wanaku.api.types.WanakuResponse;
56
import jakarta.ws.rs.Consumes;
67
import jakarta.ws.rs.GET;
78
import jakarta.ws.rs.PUT;
@@ -29,7 +30,7 @@ public interface LinkService {
2930
@Path("/tools/list")
3031
@GET
3132
@Consumes(MediaType.TEXT_PLAIN)
32-
Map<String, Service> toolsList();
33+
WanakuResponse<Map<String, Service>> toolsList();
3334

3435
@Path("/tools/configure/{service}")
3536
@PUT
@@ -49,7 +50,7 @@ public interface LinkService {
4950
@Path("/resources/list")
5051
@GET
5152
@Consumes(MediaType.TEXT_PLAIN)
52-
Map<String, Service> resourcesList();
53+
WanakuResponse<Map<String, Service>> resourcesList();
5354

5455
@Path("/resources/configure/{service}")
5556
@PUT

cli/src/main/java/ai/wanaku/cli/main/services/ResourcesService.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.List;
44

5+
import ai.wanaku.api.types.WanakuResponse;
56
import jakarta.ws.rs.GET;
67
import jakarta.ws.rs.POST;
78
import jakarta.ws.rs.PUT;
@@ -12,6 +13,7 @@
1213
import jakarta.ws.rs.core.Response;
1314

1415
import ai.wanaku.api.types.ResourceReference;
16+
import org.jboss.resteasy.reactive.RestResponse;
1517

1618
@Path("/api/v1/resources")
1719
public interface ResourcesService {
@@ -24,7 +26,7 @@ public interface ResourcesService {
2426
@Path("/list")
2527
@GET
2628
@Produces(MediaType.APPLICATION_JSON)
27-
List<ResourceReference> list();
29+
RestResponse<WanakuResponse<List<ResourceReference>>> list();
2830

2931
@Path("/remove")
3032
@PUT

cli/src/main/java/ai/wanaku/cli/main/services/ToolsService.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.List;
44

5+
import ai.wanaku.api.types.WanakuResponse;
56
import jakarta.ws.rs.GET;
67
import jakarta.ws.rs.POST;
78
import jakarta.ws.rs.PUT;
@@ -12,6 +13,7 @@
1213
import jakarta.ws.rs.core.Response;
1314

1415
import ai.wanaku.api.types.ToolReference;
16+
import org.jboss.resteasy.reactive.RestResponse;
1517

1618
@Path("/api/v1/tools")
1719
public interface ToolsService {
@@ -24,7 +26,7 @@ public interface ToolsService {
2426
@Path("/list")
2527
@GET
2628
@Produces(MediaType.APPLICATION_JSON)
27-
List<ToolReference> list();
29+
RestResponse<WanakuResponse<List<ToolReference>>> list();
2830

2931
@Path("/remove")
3032
@PUT

0 commit comments

Comments
 (0)