@Override public int hashCode() { int hash = 7; hash = 31 * hash + Objects.hashCode(id); hash = 31 * hash + Objects.hashCode(name); hash = 31 * hash + Objects.hashCode(description); hash = 31 * hash + Objects.hashCode(defaultEnv); hash = 31 * hash + getCommands().hashCode(); hash = 31 * hash + getProjects().hashCode(); hash = 31 * hash + getEnvironments().hashCode(); hash = 31 * hash + getAttributes().hashCode(); return hash; }
@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); } }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof WorkspaceConfigImpl)) { return false; } final WorkspaceConfigImpl that = (WorkspaceConfigImpl) obj; return Objects.equals(id, that.id) && Objects.equals(name, that.name) && Objects.equals(description, that.description) && Objects.equals(defaultEnv, that.defaultEnv) && getCommands().equals(that.getCommands()) && getProjects().equals(that.getProjects()) && getEnvironments().equals(that.getEnvironments()) && getAttributes().equals(that.getAttributes()); }
@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)); }
final WorkspaceImpl workspace = workspaceManager.getWorkspace(id); EnvironmentImpl previous = workspace.getConfig().getEnvironments().put(envName, new EnvironmentImpl(update)); if (previous == null) { throw new NotFoundException(
activeWorkspace .getConfig() .getEnvironments() .get(activeWorkspace.getRuntime().getActiveEnv()); if (startingEnvironment != null) {
private String getValidatedEnvironmentName(WorkspaceImpl workspace, @Nullable String envName) throws NotFoundException, ServerException { if (envName != null && !workspace.getConfig().getEnvironments().containsKey(envName)) { throw new NotFoundException( format( "Workspace '%s:%s' doesn't contain environment '%s'", workspace.getNamespace(), workspace.getConfig().getName(), envName)); } envName = firstNonNull(envName, workspace.getConfig().getDefaultEnv()); if (envName == null && SidecarToolingWorkspaceUtil.isSidecarBasedWorkspace( workspace.getConfig().getAttributes())) { // Sidecar-based workspaces are allowed not to have any environments return null; } // validate environment in advance if (envName == null) { throw new NotFoundException( format( "Workspace %s:%s can't use null environment", workspace.getNamespace(), workspace.getConfig().getName())); } try { runtimes.validate(workspace.getConfig().getEnvironments().get(envName)); } catch (InfrastructureException | ValidationException e) { throw new ServerException(e); } return envName; }