use of io.swagger.annotations.ApiOperation in project che by eclipse.
the class FactoryService method getFactoryJson.
@GET
@Path("/workspace/{ws-id}")
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Construct factory from workspace", notes = "This call returns a Factory.json that is used to create a factory")
@ApiResponses({ @ApiResponse(code = 200, message = "Response contains requested factory JSON"), @ApiResponse(code = 400, message = "Missed required parameters, parameters are not valid"), @ApiResponse(code = 404, message = "Workspace not found"), @ApiResponse(code = 500, message = "Internal server error") })
public Response getFactoryJson(@ApiParam(value = "Workspace identifier") @PathParam("ws-id") String wsId, @ApiParam(value = "Project path") @QueryParam("path") String path) throws BadRequestException, NotFoundException, ServerException {
final WorkspaceImpl workspace = workspaceManager.getWorkspace(wsId);
excludeProjectsWithoutLocation(workspace, path);
final FactoryDto factoryDto = DtoFactory.newDto(FactoryDto.class).withV("4.0").withWorkspace(org.eclipse.che.api.workspace.server.DtoConverter.asDto(workspace.getConfig()));
return Response.ok(factoryDto, APPLICATION_JSON).header(CONTENT_DISPOSITION, "attachment; filename=factory.json").build();
}
use of io.swagger.annotations.ApiOperation in project che by eclipse.
the class WorkspaceService method updateCommand.
@PUT
@Path("/{id}/command/{name}")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Update the workspace command by replacing the command with a new one", notes = "This operation can be performed only by the workspace owner")
@ApiResponses({ @ApiResponse(code = 200, message = "The command 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 or the command not found"), @ApiResponse(code = 409, message = "The Command with such name already exists"), @ApiResponse(code = 500, message = "Internal server error occurred") })
public WorkspaceDto updateCommand(@ApiParam("The workspace id") @PathParam("id") String id, @ApiParam("The name of the command") @PathParam("name") String cmdName, @ApiParam(value = "The command update", required = true) CommandDto update) throws ServerException, BadRequestException, NotFoundException, ConflictException, ForbiddenException {
requiredNotNull(update, "Command update");
final WorkspaceImpl workspace = workspaceManager.getWorkspace(id);
final List<CommandImpl> commands = workspace.getConfig().getCommands();
if (!commands.removeIf(cmd -> cmd.getName().equals(cmdName))) {
throw new NotFoundException(format("Workspace '%s' doesn't contain command '%s'", id, cmdName));
}
commands.add(new CommandImpl(update));
validator.validateConfig(workspace.getConfig());
return linksInjector.injectLinks(asDto(workspaceManager.updateWorkspace(workspace.getId(), workspace)), getServiceContext());
}
use of io.swagger.annotations.ApiOperation 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.ApiOperation 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.ApiOperation 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());
}
Aggregations