Search in sources :

Example 16 with GenerateLink

use of org.eclipse.che.api.core.rest.annotations.GenerateLink in project che by eclipse.

the class SshService method createPair.

@POST
@Consumes(APPLICATION_JSON)
@GenerateLink(rel = Constants.LINK_REL_CREATE_PAIR)
@ApiOperation(value = "Create a new ssh pair", notes = "This operation can be performed only by authorized user," + "this user will be the owner of the created ssh pair")
@ApiResponses({ @ApiResponse(code = 204, message = "The ssh pair successfully created"), @ApiResponse(code = 400, message = "Missed required parameters, parameters are not valid"), @ApiResponse(code = 409, message = "Conflict error occurred during the ssh pair creation" + "(e.g. The Ssh pair with such name and service already exists)"), @ApiResponse(code = 500, message = "Internal server error occurred") })
public void createPair(@ApiParam(value = "The ssh pair to create", required = true) SshPairDto sshPair) throws BadRequestException, ServerException, ConflictException {
    requiredNotNull(sshPair, "Ssh pair required");
    requiredNotNull(sshPair.getService(), "Service name required");
    requiredNotNull(sshPair.getName(), "Name required");
    if (sshPair.getPublicKey() == null && sshPair.getPrivateKey() == null) {
        throw new BadRequestException("Key content was not provided.");
    }
    sshManager.createPair(new SshPairImpl(getCurrentUserId(), sshPair));
}
Also used : SshPairImpl(org.eclipse.che.api.ssh.server.model.impl.SshPairImpl) BadRequestException(org.eclipse.che.api.core.BadRequestException) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) ApiOperation(io.swagger.annotations.ApiOperation) GenerateLink(org.eclipse.che.api.core.rest.annotations.GenerateLink) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

GenerateLink (org.eclipse.che.api.core.rest.annotations.GenerateLink)16 ApiOperation (io.swagger.annotations.ApiOperation)14 ApiResponses (io.swagger.annotations.ApiResponses)13 Consumes (javax.ws.rs.Consumes)13 Produces (javax.ws.rs.Produces)11 POST (javax.ws.rs.POST)10 Path (javax.ws.rs.Path)9 StackImpl (org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl)5 SshPairImpl (org.eclipse.che.api.ssh.server.model.impl.SshPairImpl)3 ArrayList (java.util.ArrayList)2 DELETE (javax.ws.rs.DELETE)2 PUT (javax.ws.rs.PUT)2 FileItem (org.apache.commons.fileupload.FileItem)2 BadRequestException (org.eclipse.che.api.core.BadRequestException)2 NotFoundException (org.eclipse.che.api.core.NotFoundException)2 StackIcon (org.eclipse.che.api.workspace.server.stack.image.StackIcon)2 NewProjectConfigDto (org.eclipse.che.api.workspace.shared.dto.NewProjectConfigDto)2 ProjectConfigDto (org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto)2 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1