Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add REST endpoint for get repository #62

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private void ensureProxyOrGroup(final Repository repository) throws Incompatible
}
}

private Repository getEditableRepositoryOrThrow(@Nonnull final String name)
public Repository getEditableRepositoryOrThrow(@Nonnull final String name)
throws RepositoryNotFoundException
{
Repository repository = repositoryManager.get(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ public Response deleteRepository(@PathParam("repositoryName") final String repos
return Response.status(isDeleted ? NO_CONTENT : NOT_FOUND).build();
}

@Override
@GET
@Path("/{repositoryName}")
@RequiresAuthentication
public AbstractApiRepository getRepository(@PathParam("repositoryName") final String repositoryName) {
try {
return convert(authorizingRepositoryManager.getEditableRepositoryOrThrow(repositoryName));
astoltz marked this conversation as resolved.
Show resolved Hide resolved
} catch (RepositoryNotFoundException e) {
log.debug("Repository not found '{}'", repositoryName, e);
throw new WebApplicationMessageException(NOT_FOUND, "\"" + e.getMessage() + "\"", APPLICATION_JSON);
}
}

@Override
@RequiresAuthentication
@GET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ public interface RepositoriesApiResourceDoc
Response deleteRepository(@ApiParam(value = "Name of the repository to delete") final String repositoryName)
throws Exception;

@ApiOperation("Get repository")
@ApiResponses(value = {@ApiResponse(code = 200, message = "Repository returned", response = AbstractApiRepository.class),
@ApiResponse(code = 401, message = AUTHENTICATION_REQUIRED),
@ApiResponse(code = 403, message = INSUFFICIENT_PERMISSIONS),
@ApiResponse(code = 404, message = REPOSITORY_NOT_FOUND)})
AbstractApiRepository getRepository(@ApiParam(value = "Name of the repository to fetch") final String repositoryName) throws RepositoryNotFoundException;

@ApiOperation("List repositories")
@ApiResponses(value = {@ApiResponse(code = 200, message = "Repositories list returned"),
@ApiResponse(code = 401, message = AUTHENTICATION_REQUIRED),
Expand Down