use of io.swagger.annotations.ApiResponses in project che by eclipse.
the class WorkspaceService method addProject.
@POST
@Path("/{id}/project")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Adds a new project to the workspace", notes = "This operation can be performed only by the workspace owner")
@ApiResponses({ @ApiResponse(code = 200, message = "The project successfully added to the workspace"), @ApiResponse(code = 400, message = "Missed required parameters, parameters are not valid"), @ApiResponse(code = 403, message = "The user does not have access to add the project"), @ApiResponse(code = 404, message = "The workspace not found"), @ApiResponse(code = 409, message = "Any conflict error occurs"), @ApiResponse(code = 500, message = "Internal server error occurred") })
public WorkspaceDto addProject(@ApiParam("The workspace id") @PathParam("id") String id, @ApiParam(value = "The new project", required = true) ProjectConfigDto newProject) throws ServerException, BadRequestException, NotFoundException, ConflictException, ForbiddenException {
requiredNotNull(newProject, "New project config");
final WorkspaceImpl workspace = workspaceManager.getWorkspace(id);
workspace.getConfig().getProjects().add(new ProjectConfigImpl(newProject));
validator.validateConfig(workspace.getConfig());
return linksInjector.injectLinks(asDto(workspaceManager.updateWorkspace(id, workspace)), getServiceContext());
}
use of io.swagger.annotations.ApiResponses in project che by eclipse.
the class WorkspaceService method addCommand.
@POST
@Path("/{id}/command")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Update the workspace by adding a new command to it", notes = "This operation can be performed only by the workspace owner")
@ApiResponses({ @ApiResponse(code = 200, message = "The workspace 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 workspace"), @ApiResponse(code = 404, message = "The workspace not found"), @ApiResponse(code = 409, message = "The command with such name already exists"), @ApiResponse(code = 500, message = "Internal server error occurred") })
public WorkspaceDto addCommand(@ApiParam("The workspace id") @PathParam("id") String id, @ApiParam(value = "The new workspace command", required = true) CommandDto newCommand) throws ServerException, BadRequestException, NotFoundException, ConflictException, ForbiddenException {
requiredNotNull(newCommand, "Command");
final WorkspaceImpl workspace = workspaceManager.getWorkspace(id);
workspace.getConfig().getCommands().add(new CommandImpl(newCommand));
validator.validateConfig(workspace.getConfig());
return linksInjector.injectLinks(asDto(workspaceManager.updateWorkspace(workspace.getId(), workspace)), getServiceContext());
}
use of io.swagger.annotations.ApiResponses in project che by eclipse.
the class WorkspaceService method updateEnvironment.
@PUT
@Path("/{id}/environment/{name}")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Update the workspace environment by replacing it with a new one", notes = "This operation can be performed only by the workspace owner")
@ApiResponses({ @ApiResponse(code = 200, message = "The environment 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 environment"), @ApiResponse(code = 404, message = "The workspace or the environment not found"), @ApiResponse(code = 500, message = "Internal server error occurred") })
public WorkspaceDto updateEnvironment(@ApiParam("The workspace id") @PathParam("id") String id, @ApiParam("The name of the environment") @PathParam("name") String envName, @ApiParam(value = "The environment update", required = true) EnvironmentDto update) throws ServerException, BadRequestException, NotFoundException, ConflictException, ForbiddenException {
requiredNotNull(update, "Environment description");
relativizeRecipeLinks(update);
final WorkspaceImpl workspace = workspaceManager.getWorkspace(id);
EnvironmentImpl previous = workspace.getConfig().getEnvironments().put(envName, new EnvironmentImpl(update));
if (previous == null) {
throw new NotFoundException(format("Workspace '%s' doesn't contain environment '%s'", id, envName));
}
validator.validateConfig(workspace.getConfig());
return linksInjector.injectLinks(asDto(workspaceManager.updateWorkspace(id, workspace)), getServiceContext());
}
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());
}
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();
}
Aggregations