Search in sources :

Example 16 with ApiResponses

use of io.swagger.annotations.ApiResponses in project che by eclipse.

the class WorkspaceService method getByKey.

@GET
@Path("/{key:.*}")
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Get the workspace by the composite key", notes = "Composite key can be just workspace ID or in the " + "namespace:workspace_name form, where namespace is optional (e.g :workspace_name is valid key too." + "namespace/workspace_name form, where namespace can contain '/' character.")
@ApiResponses({ @ApiResponse(code = 200, message = "The response contains requested workspace entity"), @ApiResponse(code = 404, message = "The workspace with specified id does not exist"), @ApiResponse(code = 403, message = "The user is not workspace owner"), @ApiResponse(code = 500, message = "Internal server error occurred") })
public WorkspaceDto getByKey(@ApiParam(value = "Composite key", examples = @Example({ @ExampleProperty("workspace12345678"), @ExampleProperty("namespace/workspace_name"), @ExampleProperty("namespace_part_1/namespace_part_2/workspace_name") })) @PathParam("key") String key) throws NotFoundException, ServerException, ForbiddenException, BadRequestException {
    validateKey(key);
    final WorkspaceImpl workspace = workspaceManager.getWorkspace(key);
    return linksInjector.injectLinks(asDto(workspace), getServiceContext());
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 17 with ApiResponses

use of io.swagger.annotations.ApiResponses in project che by eclipse.

the class WorkspaceService method create.

@POST
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@GenerateLink(rel = LINK_REL_CREATE_WORKSPACE)
@ApiOperation(value = "Create a new workspace based on the configuration", notes = "This operation can be performed only by authorized user," + "this user will be the owner of the created workspace", response = WorkspaceConfigDto.class)
@ApiResponses({ @ApiResponse(code = 201, message = "The workspace successfully created"), @ApiResponse(code = 400, message = "Missed required parameters, parameters are not valid"), @ApiResponse(code = 403, message = "The user does not have access to create a new workspace"), @ApiResponse(code = 409, message = "Conflict error occurred during the workspace creation" + "(e.g. The workspace with such name already exists)"), @ApiResponse(code = 500, message = "Internal server error occurred") })
public Response create(@ApiParam(value = "The configuration to create the new workspace", required = true) WorkspaceConfigDto config, @ApiParam(value = "Workspace attribute defined in 'attrName:attrValue' format. " + "The first ':' is considered as attribute name and value separator", examples = @Example({ @ExampleProperty("stackId:stack123"), @ExampleProperty("attrName:value-with:colon") })) @QueryParam("attribute") List<String> attrsList, @ApiParam("If true then the workspace will be immediately " + "started after it is successfully created") @QueryParam("start-after-create") @DefaultValue("false") Boolean startAfterCreate, @ApiParam("Namespace where workspace should be created") @QueryParam("namespace") String namespace) throws ConflictException, ServerException, BadRequestException, ForbiddenException, NotFoundException {
    requiredNotNull(config, "Workspace configuration");
    final Map<String, String> attributes = parseAttrs(attrsList);
    validator.validateAttributes(attributes);
    validator.validateConfig(config);
    relativizeRecipeLinks(config);
    if (namespace == null) {
        namespace = EnvironmentContext.getCurrent().getSubject().getUserName();
    }
    final WorkspaceImpl workspace = workspaceManager.createWorkspace(config, namespace, attributes);
    if (startAfterCreate) {
        workspaceManager.startWorkspace(workspace.getId(), null, false);
    }
    return Response.status(201).entity(linksInjector.injectLinks(asDto(workspace), getServiceContext())).build();
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) GenerateLink(org.eclipse.che.api.core.rest.annotations.GenerateLink) ApiResponses(io.swagger.annotations.ApiResponses)

Example 18 with ApiResponses

use of io.swagger.annotations.ApiResponses in project che by eclipse.

the class StackService method uploadIcon.

@POST
@Path("/{id}/icon")
@Consumes(MULTIPART_FORM_DATA)
@Produces(TEXT_PLAIN)
@GenerateLink(rel = LINK_REL_UPLOAD_ICON)
@ApiOperation(value = "Upload icon for required stack", notes = "This operation can be performed only by authorized stack owner")
@ApiResponses({ @ApiResponse(code = 200, message = "Image was successfully uploaded"), @ApiResponse(code = 400, message = "Missed required parameters, parameters are not valid"), @ApiResponse(code = 403, message = "The user does not have access upload image for stack with required id"), @ApiResponse(code = 404, message = "The stack doesn't exist"), @ApiResponse(code = 500, message = "Internal server error occurred") })
public Response uploadIcon(@ApiParam("The image for stack") final Iterator<FileItem> formData, @ApiParam("The stack id") @PathParam("id") final String id) throws NotFoundException, ServerException, BadRequestException, ForbiddenException, ConflictException {
    if (formData.hasNext()) {
        FileItem fileItem = formData.next();
        StackIcon stackIcon = new StackIcon(fileItem.getName(), fileItem.getContentType(), fileItem.get());
        StackImpl stack = stackDao.getById(id);
        stack.setStackIcon(stackIcon);
        stackDao.update(stack);
    }
    return Response.ok().build();
}
Also used : FileItem(org.apache.commons.fileupload.FileItem) StackImpl(org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl) StackIcon(org.eclipse.che.api.workspace.server.stack.image.StackIcon) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) GenerateLink(org.eclipse.che.api.core.rest.annotations.GenerateLink) ApiResponses(io.swagger.annotations.ApiResponses)

Example 19 with ApiResponses

use of io.swagger.annotations.ApiResponses in project che by eclipse.

the class StackService method createStack.

@POST
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@GenerateLink(rel = LINK_REL_CREATE_STACK)
@ApiOperation(value = "Create a new stack", notes = "This operation can be performed only by authorized user", response = StackDto.class)
@ApiResponses({ @ApiResponse(code = 201, message = "The stack successfully created"), @ApiResponse(code = 400, message = "Missed required parameters, parameters are not valid"), @ApiResponse(code = 403, message = "The user does not have access to create a new stack"), @ApiResponse(code = 409, message = "Conflict error occurred during the stack creation" + "(e.g. The stack with such name already exists)"), @ApiResponse(code = 500, message = "Internal server error occurred") })
public Response createStack(@ApiParam("The new stack") final StackDto stackDto) throws ApiException {
    stackValidator.check(stackDto);
    final String userId = EnvironmentContext.getCurrent().getSubject().getUserId();
    final StackImpl newStack = StackImpl.builder().generateId().setName(stackDto.getName()).setDescription(stackDto.getDescription()).setScope(stackDto.getScope()).setCreator(userId).setTags(stackDto.getTags()).setWorkspaceConfig(stackDto.getWorkspaceConfig()).setSource(stackDto.getSource()).setComponents(stackDto.getComponents()).build();
    stackDao.create(newStack);
    return Response.status(CREATED).entity(asStackDto(newStack)).build();
}
Also used : StackImpl(org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) GenerateLink(org.eclipse.che.api.core.rest.annotations.GenerateLink) ApiResponses(io.swagger.annotations.ApiResponses)

Example 20 with ApiResponses

use of io.swagger.annotations.ApiResponses in project che by eclipse.

the class StackService method updateStack.

@PUT
@Path("/{id}")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@GenerateLink(rel = LINK_REL_UPDATE_STACK)
@ApiOperation(value = "Update the stack by replacing all the existing data (exclude field \"creator\") with update")
@ApiResponses({ @ApiResponse(code = 200, message = "The stack successfully updated"), @ApiResponse(code = 400, message = "Missed required parameters, parameters are not valid"), @ApiResponse(code = 403, message = "The user does not have access to update the stack"), @ApiResponse(code = 409, message = "Conflict error occurred during stack update" + "(e.g. Stack with such name already exists)"), @ApiResponse(code = 500, message = "Internal server error occurred") })
public StackDto updateStack(@ApiParam(value = "The stack update", required = true) final StackDto updateDto, @ApiParam(value = "The stack id", required = true) @PathParam("id") final String id) throws ApiException {
    stackValidator.check(updateDto);
    final StackImpl stack = stackDao.getById(id);
    StackImpl stackForUpdate = StackImpl.builder().setId(id).setName(updateDto.getName()).setDescription(updateDto.getDescription()).setScope(updateDto.getScope()).setCreator(stack.getCreator()).setTags(updateDto.getTags()).setWorkspaceConfig(updateDto.getWorkspaceConfig()).setSource(updateDto.getSource()).setComponents(updateDto.getComponents()).build();
    return asStackDto(stackDao.update(stackForUpdate));
}
Also used : StackImpl(org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) ApiOperation(io.swagger.annotations.ApiOperation) GenerateLink(org.eclipse.che.api.core.rest.annotations.GenerateLink) PUT(javax.ws.rs.PUT) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

ApiResponses (io.swagger.annotations.ApiResponses)498 ApiOperation (io.swagger.annotations.ApiOperation)495 Path (javax.ws.rs.Path)319 Produces (javax.ws.rs.Produces)221 Timed (com.codahale.metrics.annotation.Timed)193 GET (javax.ws.rs.GET)167 POST (javax.ws.rs.POST)119 TimedResource (org.killbill.commons.metrics.TimedResource)111 Consumes (javax.ws.rs.Consumes)108 Counted (com.codahale.metrics.annotation.Counted)107 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)94 PUT (javax.ws.rs.PUT)66 UUID (java.util.UUID)62 DELETE (javax.ws.rs.DELETE)62 AuditEvent (org.graylog2.audit.jersey.AuditEvent)59 TenantContext (org.killbill.billing.util.callcontext.TenantContext)58 RestException (com.yahoo.pulsar.broker.web.RestException)54 ApiResponse (io.swagger.annotations.ApiResponse)53 CallContext (org.killbill.billing.util.callcontext.CallContext)51 URI (java.net.URI)50