From 581e03ac5b8bf70fc7de003e18b4e9ebbf0495e7 Mon Sep 17 00:00:00 2001 From: Bernd Hufmann Date: Mon, 15 Jul 2024 11:19:05 -0400 Subject: [PATCH] server: Skeleton code for configuration service per data provider Includes also swagger doc updates. [Added] Skeleton code for configuration service per data provider Signed-off-by: Bernd Hufmann --- .../core/model/CreationConfiguration.java | 24 ++++ .../jersey/rest/core/model/DataProvider.java | 12 ++ .../OutputConfigurationQueryParameters.java | 29 +++++ .../OutputConfigurationQueryParameters.java | 59 +++++++++ .../core/services/DataProviderService.java | 122 ++++++++++++++++++ .../rest/core/services/EndpointConstants.java | 1 + .../services/TraceServerOpenApiResource.java | 2 + 7 files changed, 249 insertions(+) create mode 100644 trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/CreationConfiguration.java create mode 100644 trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/OutputConfigurationQueryParameters.java create mode 100644 trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/views/OutputConfigurationQueryParameters.java diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/CreationConfiguration.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/CreationConfiguration.java new file mode 100644 index 000000000..c881bbcbb --- /dev/null +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/CreationConfiguration.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2023 Ericsson + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 which + * accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +package org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * Contributes to the model used for TSP swagger-core annotations. + */ +@NonNullByDefault +@Schema(allOf = Configuration.class) +public interface CreationConfiguration extends Configuration { +} diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/DataProvider.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/DataProvider.java index 436f4a7b8..6c17205d7 100644 --- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/DataProvider.java +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/DataProvider.java @@ -51,4 +51,16 @@ enum ProviderType { */ @Schema(description = "Describes the output provider's features") String getDescription(); + + /** + * @return optional parent Id + */ + @Schema(required = false, description = "Optional parent Id for grouping purposes for example of derived data providers.") + String getParentId(); + + /** + * @return the input configuration used to create this data provider. + */ + @Schema(required = false, description = "Optional input configuration used to create this derived data provider.") + CreationConfiguration getCreationConfiguration(); } diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/OutputConfigurationQueryParameters.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/OutputConfigurationQueryParameters.java new file mode 100644 index 000000000..e22dfc55b --- /dev/null +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/OutputConfigurationQueryParameters.java @@ -0,0 +1,29 @@ +/********************************************************************** + * Copyright (c) 2023 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License 2.0 which + * accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + **********************************************************************/ + +package org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model; + +import org.eclipse.jdt.annotation.NonNull; + +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * Contributes to the model used for TSP swagger-core annotations. + */ +@Schema(allOf = ConfigurationQueryParameters.class) +public interface OutputConfigurationQueryParameters extends ConfigurationQueryParameters { + + /** + * @return The configuration type ID + */ + @Schema(required = true, description = "The configuration source type ID.") + @NonNull String getTypeId(); +} diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/views/OutputConfigurationQueryParameters.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/views/OutputConfigurationQueryParameters.java new file mode 100644 index 000000000..577809384 --- /dev/null +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/views/OutputConfigurationQueryParameters.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2024 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License 2.0 which + * accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +package org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views; + +import org.eclipse.jdt.annotation.Nullable; + +import com.fasterxml.jackson.databind.JsonNode; + +/** + * Definition of a parameters object received by the server from a client for configurations to create + * data providers. + */ +public class OutputConfigurationQueryParameters extends ConfigurationQueryParameters { + + private @Nullable String typeId; + + /** + * Constructor for Jackson + */ + public OutputConfigurationQueryParameters() { + super(); + } + + /** + * Constructor. + * + * @param parameters + * json object + * @param typeId + * the configuration source type ID + */ + public OutputConfigurationQueryParameters(JsonNode parameters, String typeId) { + super(parameters); + this.typeId = typeId; + } + + /** + * Gets the configuration source type ID. + * @return the configuration source type ID + */ + public String getTypeId() { + return this.typeId; + } + + @SuppressWarnings("nls") + @Override + public String toString() { + return "OutputConfigurationQueryParameters [parameters=" + super.getParameters().toString() + ", typeId=" + typeId + "]"; + } +} diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/DataProviderService.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/DataProviderService.java index 61ed78c9d..bc0befa2a 100644 --- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/DataProviderService.java +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/DataProviderService.java @@ -12,6 +12,9 @@ package org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services; import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.ANN; +import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.CFG_CREATE_DESC; +import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.CFG_KEYS_DESC; +import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.CFG_TYPE_ID; import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.COLUMNS; import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.COLUMNS_EX; import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.CONSISTENT_PARENT; @@ -45,7 +48,9 @@ import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.MISSING_OUTPUTID; import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.MISSING_PARAMETERS; import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.NO_PROVIDER; +import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.NO_SUCH_CONFIGURATION; import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.NO_SUCH_TRACE; +import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.OCG; import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.ONE_OF; import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.OUTPUT_ID; import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.PROVIDER_NOT_FOUND; @@ -79,6 +84,7 @@ import java.util.logging.Logger; import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; @@ -115,6 +121,7 @@ import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.XYResponse; import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.XYTreeResponse; import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views.GenericView; +import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views.OutputConfigurationQueryParameters; import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views.QueryParameters; import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views.TableColumnHeader; import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views.TreeModelWrapper; @@ -1129,6 +1136,31 @@ public Response getStyles( } } + /** + * Query the data provider for a list of available configuration source + * types. + * + * @param expUUID + * desired experiment UUID + * @param outputId + * Output ID for the data provider to query + * @return list of available configuration source types + */ + @GET + @Path("/{outputId}/configTypes/") + @Tag(name = OCG) + @Produces(MediaType.APPLICATION_JSON) + @Operation(summary = "Get the list of configuration source types defined on the server for a given output and experiment", responses = { + @ApiResponse(responseCode = "200", description = "Returns a list of configuration source types", content = @Content(array = @ArraySchema(schema = @Schema(implementation = org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.ConfigurationSourceType.class)))), + @ApiResponse(responseCode = "404", description = PROVIDER_NOT_FOUND, content = @Content(schema = @Schema(implementation = String.class))), + }) + public Response getConfigurationTypes( + @Parameter(description = EXP_UUID) @PathParam("expUUID") UUID expUUID, + @Parameter(description = OUTPUT_ID) @PathParam("outputId") String outputId + ) { + return Response.status(Status.NOT_IMPLEMENTED).entity("Get all configuration types for a given output").build(); //$NON-NLS-1$ + } + private static Response validateParameters(String outputId, QueryParameters queryParameters) { if (outputId == null) { return Response.status(Status.BAD_REQUEST).entity(MISSING_OUTPUTID).build(); @@ -1138,4 +1170,94 @@ private static Response validateParameters(String outputId, QueryParameters quer } return null; } + + /** + * Query the provider to get one selected configuration source type. + * + * @param expUUID + * desired experiment UUID + * @param outputId + * Output ID for the data provider to query + * @param typeId + * the configuration source type ID + * @return a configuration source type + */ + @GET + @Path("/{outputId}/configTypes/{typeId}") + @Tag(name = OCG) + @Produces(MediaType.APPLICATION_JSON) + @Operation(summary = "Get a single configuration source type defined on the server for a given data provider and experiment.", responses = { + @ApiResponse(responseCode = "200", description = "Returns a single configuration source type", content = @Content(schema = @Schema(implementation = org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.ConfigurationSourceType.class))), + @ApiResponse(responseCode = "404", description = PROVIDER_NOT_FOUND, content = @Content(schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "404", description = NO_SUCH_CONFIGURATION, content = @Content(schema = @Schema(implementation = String.class))), + }) + public Response getConfigurationType( + @Parameter(description = EXP_UUID) @PathParam("expUUID") UUID expUUID, + @Parameter(description = OUTPUT_ID) @PathParam("outputId") String outputId, + @Parameter(description = CFG_TYPE_ID) @PathParam("typeId") String typeId) { + return Response.status(Status.NOT_IMPLEMENTED).entity("Get a configuration type for a given output").build(); //$NON-NLS-1$ + } + + /** + * POST a custom configuration to the data provider to create derived data + * providers. + * + * @param expUUID + * desired experiment UUID + * @param outputId + * Output ID for the data provider to query + * @param typeId + * the configuration source type ID + * @param queryParameters + * the query parameters used to create a data provider + * @return a list of data provider descriptors + */ + @POST + @Path("/{outputId}") + @Tag(name = OCG) + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Operation(summary = "Get the list of outputs for this configuration", responses = { + @ApiResponse(responseCode = "200", description = "Returns a list of output provider descriptors", content = @Content(array = @ArraySchema(schema = @Schema(implementation = DataProvider.class)))), + @ApiResponse(responseCode = "400", description = INVALID_PARAMETERS, content = @Content(schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "404", description = PROVIDER_NOT_FOUND, content = @Content(schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "404", description = NO_SUCH_CONFIGURATION, content = @Content(schema = @Schema(implementation = String.class))), + }) + public Response createDataProvider( + @Parameter(description = EXP_UUID) @PathParam("expUUID") UUID expUUID, + @Parameter(description = OUTPUT_ID) @PathParam("outputId") String outputId, + @RequestBody(description = CFG_CREATE_DESC + " " + CFG_KEYS_DESC, content = { + @Content(schema = @Schema(implementation = org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.OutputConfigurationQueryParameters.class)) + }, required = true) OutputConfigurationQueryParameters queryParameters) { + return Response.status(Status.NOT_IMPLEMENTED).entity("POST a configuration to a given output to create derived output").build(); //$NON-NLS-1$ + } + + /** + * DELETE a derived data provider from created by a given data provider + * + * @param expUUID + * desired experiment UUID + * @param outputId + * Output ID for the data provider to query + * @param derivedOutputId + * Output ID for the data provider to delete + * @return status and the deleted configuration instance, if successful + */ + @DELETE + @Path("/{outputId}/{derivedOutputId}") + @Tag(name = OCG) + @Produces(MediaType.APPLICATION_JSON) + @Operation(summary = "Delete a configuration instance of a given configuration source type", responses = { + @ApiResponse(responseCode = "200", description = "The derived data provider (and it's configuration) was successfully deleted", content = @Content(schema = @Schema(implementation = org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.Configuration.class))), + @ApiResponse(responseCode = "404", description = PROVIDER_NOT_FOUND, content = @Content(schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "404", description = NO_SUCH_CONFIGURATION, content = @Content(schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "500", description = "Internal trace-server error while trying to delete output", content = @Content(schema = @Schema(implementation = String.class))) + }) + public Response deleteDerivedOutput( + @Parameter(description = EXP_UUID) @PathParam("expUUID") UUID expUUID, + @Parameter(description = OUTPUT_ID) @PathParam("outputId") String outputId, + @Parameter(description = OUTPUT_ID) @PathParam("derivedOutputId") String derivedOutputId) { + return Response.status(Status.NOT_IMPLEMENTED).entity("DELETE derived output").build(); //$NON-NLS-1$ + } + } diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/EndpointConstants.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/EndpointConstants.java index 870b93717..7bdbdefb6 100644 --- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/EndpointConstants.java +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/EndpointConstants.java @@ -84,6 +84,7 @@ public final class EndpointConstants { static final String DT = "Data Tree"; //$NON-NLS-1$ static final String EXP = "Experiments"; //$NON-NLS-1$ static final String IDF = "Identifier"; //$NON-NLS-1$ + static final String OCG = "Output Configurations"; //$NON-NLS-1$ static final String STY = "Styles"; //$NON-NLS-1$ static final String TGR = "TimeGraph"; //$NON-NLS-1$ static final String TRA = "Traces"; //$NON-NLS-1$ diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/TraceServerOpenApiResource.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/TraceServerOpenApiResource.java index 215e32d98..e01bada96 100644 --- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/TraceServerOpenApiResource.java +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/TraceServerOpenApiResource.java @@ -21,6 +21,7 @@ import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.IDF; import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.LICENSE; import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.LICENSE_URL; +import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.OCG; import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.SERVER; import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.STY; import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.TERMS; @@ -52,6 +53,7 @@ @Tag(name = DT, description = "Query data tree models (e.g. for statistics)."), @Tag(name = EXP, description = "Manage experiments on your server; an experiment represents a collection of traces, which can produce output models."), @Tag(name = IDF, description = "Retrieve information about the server and the system it is running on."), + @Tag(name = OCG, description = "Manage configuration source types and configurations for given outputs."), @Tag(name = STY, description = "Retrieve styles for different outputs."), @Tag(name = TGR, description = "Query Time Graph models."), @Tag(name = TRA, description = "Manage physical traces on your server."),