@DELETE @Path("/{id}/environment/{name}") @ApiOperation( value = "Remove the environment from the workspace", notes = "This operation can be performed only by the workspace owner") @ApiResponses({ @ApiResponse(code = 204, message = "The environment successfully removed"), @ApiResponse(code = 403, message = "The user does not have access remove the environment"), @ApiResponse(code = 404, message = "The workspace not found"), @ApiResponse(code = 500, message = "Internal server error occurred") }) public void deleteEnvironment( @ApiParam("The workspace id") @PathParam("id") String id, @ApiParam("The name of the environment") @PathParam("name") String envName) throws ServerException, BadRequestException, NotFoundException, ConflictException, ForbiddenException { final WorkspaceImpl workspace = workspaceManager.getWorkspace(id); if (workspace.getConfig().getEnvironments().remove(envName) != null) { doUpdate(id, workspace); } }
@DELETE @Path("/{id}/project/{path:.*}") @ApiOperation( value = "Remove the project from the workspace", notes = "This operation can be performed only by the workspace owner") @ApiResponses({ @ApiResponse(code = 204, message = "The project successfully removed"), @ApiResponse(code = 403, message = "The user does not have access remove the project"), @ApiResponse(code = 404, message = "The workspace not found"), @ApiResponse(code = 500, message = "Internal server error occurred") }) public void deleteProject( @ApiParam("The workspace id") @PathParam("id") String id, @ApiParam("The name of the project to remove") @PathParam("path") String path) throws ServerException, BadRequestException, NotFoundException, ConflictException, ForbiddenException { final WorkspaceImpl workspace = workspaceManager.getWorkspace(id); final String normalizedPath = path.startsWith("/") ? path : '/' + path; if (workspace .getConfig() .getProjects() .removeIf(project -> project.getPath().equals(normalizedPath))) { doUpdate(id, workspace); } }
@DELETE @Path("/{id}/command/{name}") @ApiOperation( value = "Remove the command from the workspace", notes = "This operation can be performed only by the workspace owner") @ApiResponses({ @ApiResponse(code = 204, message = "The command successfully removed"), @ApiResponse(code = 403, message = "The user does not have access delete the command"), @ApiResponse(code = 404, message = "The workspace not found"), @ApiResponse(code = 500, message = "Internal server error occurred") }) public void deleteCommand( @ApiParam("The id of the workspace") @PathParam("id") String id, @ApiParam("The name of the command to remove") @PathParam("name") String commandName) throws ServerException, BadRequestException, NotFoundException, ConflictException, ForbiddenException { WorkspaceImpl workspace = workspaceManager.getWorkspace(id); if (workspace .getConfig() .getCommands() .removeIf(command -> command.getName().equals(commandName))) { doUpdate(id, workspace); } }
@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"); WorkspaceImpl workspace = workspaceManager.getWorkspace(id); workspace.getConfig().getCommands().add(new CommandImpl(newCommand)); return asDtoWithLinksAndToken(doUpdate(id, workspace)); }
@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)); return asDtoWithLinksAndToken(doUpdate(id, workspace)); }
ForbiddenException { requiredNotNull(update, "Command update"); WorkspaceImpl workspace = workspaceManager.getWorkspace(id); List<CommandImpl> commands = workspace.getConfig().getCommands(); if (!commands.removeIf(cmd -> cmd.getName().equals(cmdName))) {
isNullOrEmpty(includeInternalServers) || Boolean.parseBoolean(includeInternalServers); return filterServers( asDtoWithLinksAndToken(workspaceManager.getWorkspace(key)), bIncludeInternalServers);
ForbiddenException { requiredNotNull(update, "Project config"); final WorkspaceImpl workspace = workspaceManager.getWorkspace(id); final List<ProjectConfigImpl> projects = workspace.getConfig().getProjects(); final String normalizedPath = path.startsWith("/") ? path : '/' + path;
@POST @Path("/{id}/environment") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation( value = "Add a new environment to the workspace", 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 add the environment"), @ApiResponse(code = 404, message = "The workspace not found"), @ApiResponse(code = 409, message = "Environment with such name already exists"), @ApiResponse(code = 500, message = "Internal server error occurred") }) public WorkspaceDto addEnvironment( @ApiParam("The workspace id") @PathParam("id") String id, @ApiParam(value = "The new environment", required = true) EnvironmentDto newEnvironment, @ApiParam(value = "The name of the environment", required = true) @QueryParam("name") String envName) throws ServerException, BadRequestException, NotFoundException, ConflictException, ForbiddenException { requiredNotNull(newEnvironment, "New environment"); requiredNotNull(envName, "New environment name"); relativizeRecipeLinks(newEnvironment); WorkspaceImpl workspace = workspaceManager.getWorkspace(id); workspace.getConfig().getEnvironments().put(envName, new EnvironmentImpl(newEnvironment)); return asDtoWithLinksAndToken(doUpdate(id, workspace)); }
requiredNotNull(update, "Environment description"); relativizeRecipeLinks(update); final WorkspaceImpl workspace = workspaceManager.getWorkspace(id); EnvironmentImpl previous = workspace.getConfig().getEnvironments().put(envName, new EnvironmentImpl(update));
final WorkspaceImpl workspace = workspaceManager.getWorkspace(key); try { checkAccountPermissions(workspace.getNamespace(), AccountOperation.MANAGE_WORKSPACES);