|
| 1 | +package de.remsfal.core.api.project; |
| 2 | + |
| 3 | +import de.remsfal.core.api.ProjectEndpoint; |
| 4 | +import de.remsfal.core.validation.PatchValidation; |
| 5 | +import de.remsfal.core.validation.PostValidation; |
| 6 | +import de.remsfal.core.validation.UUID; |
| 7 | +import jakarta.validation.Valid; |
| 8 | +import jakarta.validation.constraints.NotNull; |
| 9 | +import jakarta.validation.groups.ConvertGroup; |
| 10 | +import jakarta.ws.rs.core.MediaType; |
| 11 | +import jakarta.ws.rs.core.Response; |
| 12 | + |
| 13 | +import jakarta.ws.rs.Consumes; |
| 14 | +import jakarta.ws.rs.Path; |
| 15 | +import jakarta.ws.rs.GET; |
| 16 | +import jakarta.ws.rs.POST; |
| 17 | +import jakarta.ws.rs.DELETE; |
| 18 | +import jakarta.ws.rs.PATCH; |
| 19 | +import jakarta.ws.rs.PathParam; |
| 20 | +import jakarta.ws.rs.Produces; |
| 21 | + |
| 22 | + |
| 23 | +import org.eclipse.microprofile.openapi.annotations.Operation; |
| 24 | +import org.eclipse.microprofile.openapi.annotations.headers.Header; |
| 25 | +import org.eclipse.microprofile.openapi.annotations.parameters.Parameter; |
| 26 | +import org.eclipse.microprofile.openapi.annotations.responses.APIResponse; |
| 27 | + |
| 28 | +import de.remsfal.core.json.project.CommercialJson; |
| 29 | + |
| 30 | +/** |
| 31 | + * Endpoint for managing Commercial properties within buildings. |
| 32 | + */ |
| 33 | +@Path(ProjectEndpoint.CONTEXT + "/" + ProjectEndpoint.VERSION + "/" |
| 34 | + + ProjectEndpoint.SERVICE + "/{projectId}/" + PropertyEndpoint.SERVICE |
| 35 | + + "/{propertyId}/" + BuildingEndpoint.SERVICE |
| 36 | + + "/{buildingId}/" + CommercialEndpoint.SERVICE) |
| 37 | +public interface CommercialEndpoint { |
| 38 | + |
| 39 | + String SERVICE = "commercials"; |
| 40 | + |
| 41 | + @POST |
| 42 | + @Consumes(MediaType.APPLICATION_JSON) |
| 43 | + @Operation(summary = "Create a new commercial unit.") |
| 44 | + @APIResponse(responseCode = "201", description = "Commercial unit created successfully", |
| 45 | + headers = @Header(name = "Location", description = "URL of the new commercial")) |
| 46 | + Response createCommercial( |
| 47 | + @Parameter(description = "ID of the project", required = true) |
| 48 | + @PathParam("projectId") @NotNull @UUID String projectId, |
| 49 | + @Parameter(description = "ID of the building", required = true) |
| 50 | + @PathParam("buildingId") @NotNull @UUID String buildingId, |
| 51 | + @Parameter(description = "Commercial unit information", required = true) |
| 52 | + @Valid @ConvertGroup(to = PostValidation.class) CommercialJson commercial |
| 53 | + ); |
| 54 | + |
| 55 | + @GET |
| 56 | + @Path("/{commercialId}") |
| 57 | + @Produces(MediaType.APPLICATION_JSON) |
| 58 | + @Operation(summary = "Retrieve information about a commercial unit.") |
| 59 | + @APIResponse(responseCode = "404", description = "The commercial unit does not exist") |
| 60 | + @APIResponse(responseCode = "401", description = "No user authentication provided via session cookie") |
| 61 | + CommercialJson getCommercial( |
| 62 | + @Parameter(description = "ID of the project", required = true) |
| 63 | + @PathParam("projectId") @NotNull @UUID String projectId, |
| 64 | + @Parameter(description = "ID of the building", required = true) |
| 65 | + @PathParam("buildingId") @NotNull @UUID String buildingId, |
| 66 | + @Parameter(description = "ID of the commercial unit", required = true) |
| 67 | + @PathParam("commercialId") @NotNull @UUID String commercialId |
| 68 | + ); |
| 69 | + |
| 70 | + @PATCH |
| 71 | + @Path("/{commercialId}") |
| 72 | + @Consumes(MediaType.APPLICATION_JSON) |
| 73 | + @Produces(MediaType.APPLICATION_JSON) |
| 74 | + @Operation(summary = "Update information of a commercial unit") |
| 75 | + @APIResponse(responseCode = "401", description = "No user authentication provided via session cookie") |
| 76 | + @APIResponse(responseCode = "404", description = "The commercial unit does not exist") |
| 77 | + CommercialJson updateCommercial( |
| 78 | + @Parameter(description = "ID of the project", required = true) |
| 79 | + @PathParam("projectId") @NotNull @UUID String projectId, |
| 80 | + @Parameter(description = "ID of the building", required = true) |
| 81 | + @PathParam("buildingId") @NotNull @UUID String buildingId, |
| 82 | + @Parameter(description = "ID of the commercial unit", required = true) |
| 83 | + @PathParam("commercialId") @NotNull @UUID String commercialId, |
| 84 | + @Parameter(description = "Commercial unit object with information", required = true) |
| 85 | + @Valid @ConvertGroup(to = PatchValidation.class) CommercialJson commercial |
| 86 | + ); |
| 87 | + |
| 88 | + @DELETE |
| 89 | + @Path("/{commercialId}") |
| 90 | + @Operation(summary = "Delete an existing commercial unit") |
| 91 | + @APIResponse(responseCode = "204", description = "The commercial unit was deleted successfully") |
| 92 | + @APIResponse(responseCode = "401", description = "No user authentication provided via session cookie") |
| 93 | + void deleteCommercial( |
| 94 | + @Parameter(description = "ID of the project", required = true) |
| 95 | + @PathParam("projectId") @NotNull @UUID String projectId, |
| 96 | + @Parameter(description = "ID of the building", required = true) |
| 97 | + @PathParam("buildingId") @NotNull @UUID String buildingId, |
| 98 | + @Parameter(description = "ID of the commercial unit", required = true) |
| 99 | + @PathParam("commercialId") @NotNull @UUID String commercialId |
| 100 | + ); |
| 101 | +} |
0 commit comments