1 package org.apache.archiva.rest.api.services.v2;
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
21 import io.swagger.v3.oas.annotations.Operation;
22 import io.swagger.v3.oas.annotations.Parameter;
23 import io.swagger.v3.oas.annotations.headers.Header;
24 import io.swagger.v3.oas.annotations.media.Content;
25 import io.swagger.v3.oas.annotations.media.Schema;
26 import io.swagger.v3.oas.annotations.parameters.RequestBody;
27 import io.swagger.v3.oas.annotations.responses.ApiResponse;
28 import io.swagger.v3.oas.annotations.security.SecurityRequirement;
29 import org.apache.archiva.components.rest.model.PagedResult;
30 import org.apache.archiva.redback.authorization.RedbackAuthorization;
31 import org.apache.archiva.rest.api.model.v2.RepositoryGroup;
32 import org.apache.archiva.security.common.ArchivaRoleConstants;
34 import javax.ws.rs.Consumes;
35 import javax.ws.rs.DELETE;
36 import javax.ws.rs.DefaultValue;
37 import javax.ws.rs.GET;
38 import javax.ws.rs.POST;
39 import javax.ws.rs.PUT;
40 import javax.ws.rs.Path;
41 import javax.ws.rs.PathParam;
42 import javax.ws.rs.Produces;
43 import javax.ws.rs.QueryParam;
44 import javax.ws.rs.core.Response;
45 import java.util.List;
47 import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
48 import static org.apache.archiva.rest.api.services.v2.RestConfiguration.DEFAULT_PAGE_LIMIT;
51 * Endpoint for repository groups that combine multiple repositories into a single virtual repository.
53 * @author Olivier Lamy
54 * @author Martin Stockhammer
57 @Path( "/repository_groups" )
58 @Schema( name = "RepositoryGroups", description = "Managing of repository groups or virtual repositories" )
59 public interface RepositoryGroupService
63 @Produces( {APPLICATION_JSON} )
64 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
65 @Operation( summary = "Returns all repository group entries.",
67 @Parameter( name = "q", description = "Search term" ),
68 @Parameter( name = "offset", description = "The offset of the first element returned" ),
69 @Parameter( name = "limit", description = "Maximum number of items to return in the response" ),
70 @Parameter( name = "orderBy", description = "List of attribute used for sorting (key, value)" ),
71 @Parameter( name = "order", description = "The sort order. Either ascending (asc) or descending (desc)" )
75 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
79 @ApiResponse( responseCode = "200",
80 description = "If the list could be returned",
81 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = PagedResult.class ) )
83 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
84 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
87 PagedResult<RepositoryGroup> getRepositoriesGroups( @QueryParam( "q" ) @DefaultValue( "" ) String searchTerm,
88 @QueryParam( "offset" ) @DefaultValue( "0" ) Integer offset,
89 @QueryParam( "limit" ) @DefaultValue( value = DEFAULT_PAGE_LIMIT ) Integer limit,
90 @QueryParam( "orderBy" ) @DefaultValue( "id" ) List<String> orderBy,
91 @QueryParam( "order" ) @DefaultValue( "asc" ) String order )
92 throws ArchivaRestServiceException;
96 @Produces( {APPLICATION_JSON} )
97 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
98 @Operation( summary = "Returns a single repository group configuration.",
100 @SecurityRequirement(
101 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
105 @ApiResponse( responseCode = "200",
106 description = "If the configuration is returned",
107 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = RepositoryGroup.class ) )
109 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
110 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
111 @ApiResponse( responseCode = "404", description = "The repository group with the given id does not exist",
112 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
115 RepositoryGroup getRepositoryGroup( @PathParam( "id" ) String repositoryGroupId )
116 throws ArchivaRestServiceException;
120 @Consumes( {APPLICATION_JSON} )
121 @Produces( {APPLICATION_JSON} )
122 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
123 @Operation( summary = "Creates a new group entry.",
125 @RequestBody( required = true, description = "The configuration of the repository group.",
126 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = RepositoryGroup.class ) )
130 @SecurityRequirement(
131 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
135 @ApiResponse( responseCode = "201",
136 description = "If the repository group was created",
137 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = RepositoryGroup.class ) )
139 @ApiResponse( responseCode = "303", description = "The repository group exists already",
141 @Header( name = "Location", description = "The URL of existing group", schema = @Schema( type = "string" ) )
144 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
145 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
146 @ApiResponse( responseCode = "422", description = "The body data is not valid",
147 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
150 RepositoryGroup addRepositoryGroup( RepositoryGroup repositoryGroup )
151 throws ArchivaRestServiceException;
155 @Consumes( {APPLICATION_JSON} )
156 @Produces( {APPLICATION_JSON} )
157 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
158 @Operation( summary = "Returns all repository group entries.",
160 @RequestBody( required = true, description = "The configuration of the repository group.",
161 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = RepositoryGroup.class ) )
165 @SecurityRequirement(
166 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
170 @ApiResponse( responseCode = "200",
171 description = "If the group is returned",
172 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = RepositoryGroup.class ) )
174 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
175 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
176 @ApiResponse( responseCode = "404", description = "The group with the given id does not exist",
177 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
178 @ApiResponse( responseCode = "422", description = "The body data is not valid",
179 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
182 RepositoryGroup updateRepositoryGroup( @PathParam( "id" ) String groupId, RepositoryGroup repositoryGroup )
183 throws ArchivaRestServiceException;
187 @Produces( {APPLICATION_JSON} )
188 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
189 @Operation( summary = "Deletes the repository group entry with the given id.",
191 @SecurityRequirement(
192 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
196 @ApiResponse( responseCode = "200",
197 description = "If the group was deleted"
199 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to delete the group",
200 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
201 @ApiResponse( responseCode = "404", description = "The group with the given id does not exist",
202 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
205 Response deleteRepositoryGroup( @PathParam( "id" ) String repositoryGroupId )
206 throws ArchivaRestServiceException;
208 @Path( "{id}/repositories/{repositoryId}" )
210 @Produces( {APPLICATION_JSON} )
211 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
212 @Operation( summary = "Adds the repository with the given id to the repository group.",
214 @SecurityRequirement(
215 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
219 @ApiResponse( responseCode = "200",
220 description = "If the repository was added or if it was already part of the group"
222 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to delete the group",
223 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
224 @ApiResponse( responseCode = "404", description = "The group with the given id does not exist",
225 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
228 RepositoryGroup addRepositoryToGroup( @PathParam( "id" ) String repositoryGroupId,
229 @PathParam( "repositoryId" ) String repositoryId )
230 throws ArchivaRestServiceException;
232 @Path( "{id}/repositories/{repositoryId}" )
234 @Produces( {APPLICATION_JSON} )
235 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
236 @Operation( summary = "Removes the repository with the given id from the repository group.",
238 @SecurityRequirement(
239 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
243 @ApiResponse( responseCode = "200",
244 description = "If the repository was removed."
246 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to delete the group",
247 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
248 @ApiResponse( responseCode = "404", description = "The group with the given id does not exist, or the repository was not part of the group.",
249 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
252 RepositoryGroup deleteRepositoryFromGroup( @PathParam( "id" ) String repositoryGroupId,
253 @PathParam( "repositoryId" ) String repositoryId )
254 throws ArchivaRestServiceException;