diff --git a/src/main/java/io/cryostat/graphql/GraphQL.java b/src/main/java/io/cryostat/graphql/GraphQL.java new file mode 100644 index 000000000..ce96dc567 --- /dev/null +++ b/src/main/java/io/cryostat/graphql/GraphQL.java @@ -0,0 +1,47 @@ +/* + * Copyright The Cryostat Authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.cryostat.graphql; + +import java.net.URI; + +import jakarta.annotation.security.RolesAllowed; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.core.Response; +import org.jboss.resteasy.reactive.RestResponse; + +@Path("") +public class GraphQL { + + @GET + @Path("/api/v2.2/graphql") + @RolesAllowed("write") + public Response redirectGet() throws Exception { + return Response.status(RestResponse.Status.PERMANENT_REDIRECT) + .location(URI.create("/api/v3/graphql")) + .build(); + } + + @POST + @Path("/api/v2.2/graphql") + @RolesAllowed("write") + public Response redirectPost() throws Exception { + return Response.status(RestResponse.Status.PERMANENT_REDIRECT) + .location(URI.create("/api/v3/graphql")) + .build(); + } +} diff --git a/src/main/java/io/cryostat/graphql/RootNode.java b/src/main/java/io/cryostat/graphql/RootNode.java new file mode 100644 index 000000000..bb10017db --- /dev/null +++ b/src/main/java/io/cryostat/graphql/RootNode.java @@ -0,0 +1,32 @@ +/* + * Copyright The Cryostat Authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.cryostat.graphql; + +import io.cryostat.discovery.DiscoveryNode; + +import org.eclipse.microprofile.graphql.Description; +import org.eclipse.microprofile.graphql.GraphQLApi; +import org.eclipse.microprofile.graphql.Query; + +@GraphQLApi +public class RootNode { + + @Query("rootNode") + @Description("Get the root target discovery node") + public DiscoveryNode getRootNode() { + return DiscoveryNode.getUniverse(); + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 6381edd25..04c568593 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -41,6 +41,9 @@ quarkus.smallrye-openapi.info-contact-url=https://cryostat.io quarkus.smallrye-openapi.info-license-name=Apache 2.0 quarkus.smallrye-openapi.info-license-url=https://github.com/cryostatio/cryostat3/blob/main/LICENSE +quarkus.smallrye-graphql.root-path=/api/v3/graphql +quarkus.smallrye-graphql.http.get.enabled=true + quarkus.http.access-log.enabled=true quarkus.log.category."io.quarkus.http.access-log".level=DEBUG quarkus.http.enable-compression=true