diff --git a/docs/hop-user-manual/modules/ROOT/nav.adoc b/docs/hop-user-manual/modules/ROOT/nav.adoc index 4842f19f34d..2abab308b89 100644 --- a/docs/hop-user-manual/modules/ROOT/nav.adoc +++ b/docs/hop-user-manual/modules/ROOT/nav.adoc @@ -441,6 +441,7 @@ under the License. ** xref:hop-server/rest-api.adoc[REST api] ** xref:hop-server/web-service.adoc[Web Service] * xref:hop-tools/index.adoc[Hop Tools] +* xref:hop-rest/index.adoc[Hop REST Web Application] ** xref:hop-tools/hop-conf/hop-conf.adoc[hop-conf] ** xref:hop-tools/hop-encrypt.adoc[hop-encrypt] ** xref:hop-tools/hop-gui.adoc[hop-gui] diff --git a/docs/hop-user-manual/modules/ROOT/pages/hop-rest/index.adoc b/docs/hop-user-manual/modules/ROOT/pages/hop-rest/index.adoc index 1e1fc02b993..0ae6138bbdd 100644 --- a/docs/hop-user-manual/modules/ROOT/pages/hop-rest/index.adoc +++ b/docs/hop-user-manual/modules/ROOT/pages/hop-rest/index.adoc @@ -24,12 +24,38 @@ under the License. == Description -The Hop REST web application is deployed as a WAR file `hop-rest-.war`. You can put this archive in the `webapps` folder of your favorite server (e.g. Apache Tomcat). We suggest that you rename it to `hop.war` or that you unzip it in a `hop` folder. +The Hop REST web application is deployed as a WAR file `hop-rest-.war`. +You can put this archive in the `webapps` folder of your favorite server (e.g. Apache Tomcat). +We suggest that you rename it to `hop.war` or that you unzip it in a `hop` folder. == The base URL When deployed under a `webapps/hop` folder you will get the services, detailed below, under the base URL of `/hop/api/v1/`. +== Configuration + +When the web application starts it will look for an environment variable called `HOP_REST_CONFIG_FOLDER` to determine where it will look for a file called `hop-rest.properties`. +This file can contain the following properties to determine the configuration of the application: + +[cols="1,2"] +|=== +|Property|Description + +|`logLevel` +|The logging level to use, one of `NOTHING`, `ERROR`, `MINIMAL`, +`BASIC`, `DETAILED`, `DEBUG`, or `ROWLEVEL`. + +|`metadataExportFile` +|The metadata to use for the web application in the form of a single JSON 'export' file. Use the GUI tools menu or `sh hop-conf.sh --export-metadata` to export metadata to a single file. + +|`environmentName` +|In case the `projects` plugin is available it will enable this environment and the underlying project (to be configured on the system, point to a configuration with `HOP_CONFIG_FOLDER`) before starting the application. + +|`projectName` +|In case the `projects` plugin is available it will enable this project (to be configured on the system, point to a configuration with `HOP_CONFIG_FOLDER`) before starting the application. + +|=== + == Metadata services The metadata services are deployed under sub-path `metadata/`. @@ -130,6 +156,29 @@ The metadata services are deployed under sub-path `metadata/`. |=== +=== Delete a metadata element + +[cols="1,2"] +|=== +|Type +|`DELETE` + +|Path +|`metadata/{key}/{name}` + +|Arguments +|`key` : the key of the metadata type to save. `name` : the name of the metadata element to delete. + +|Produces +|`application/json` + +|Example call +|`curl -X DELETE http://localhost:8080/hop/api/v1/metadata/pipeline-run-configuration/Flink/` + +|Output +|`Flink` + +|=== == Plugins services @@ -226,8 +275,6 @@ The body to post can contain the following options (see also: the example above) * `variables`: a map with variables (or parameters) with their names and values * `bodyContent`: this will be set as a variable using the body content variable option in the Web Service metadata. - - == Execution Information Location services The execution information location services are deployed under sub-path `location/`. diff --git a/rest/src/main/java/org/apache/hop/rest/v1/resources/MetadataResource.java b/rest/src/main/java/org/apache/hop/rest/v1/resources/MetadataResource.java index 2dc08ff169d..0abe4387325 100644 --- a/rest/src/main/java/org/apache/hop/rest/v1/resources/MetadataResource.java +++ b/rest/src/main/java/org/apache/hop/rest/v1/resources/MetadataResource.java @@ -20,6 +20,7 @@ import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonParser; +import jakarta.ws.rs.DELETE; import jakarta.ws.rs.GET; import jakarta.ws.rs.POST; import jakarta.ws.rs.Path; @@ -128,4 +129,30 @@ public Response saveElement(@PathParam("key") String key, String metadataJson) return getServerError("Error saving element of type " + key, e, true); } } + + /** + * Save a metadata element + * + * @param key The key of the type of metadata to delete + * @param elementName The name of the element to delete + * @return + * @throws HopException + */ + @DELETE + @Path("/{key}/{elementName}") + @Produces(MediaType.APPLICATION_JSON) + public Response deleteElement( + @PathParam("key") String key, @PathParam("elementName") String elementName) + throws HopException { + try { + IHopMetadataProvider provider = hop.getMetadataProvider(); + Class metadataClass = provider.getMetadataClassForKey(key); + IHopMetadataSerializer serializer = provider.getSerializer(metadataClass); + serializer.delete(elementName); + return Response.ok().entity(elementName).build(); + } catch (Exception e) { + return getServerError( + "Error deleting element of type " + key + " with name " + elementName, e, true); + } + } }