
com.hubspot.singularity.config.UIConfiguration Maven / Gradle / Ivy
package com.hubspot.singularity.config;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.NotEmpty;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Optional;
import com.google.common.base.Strings;
import com.hubspot.singularity.config.shell.ShellCommandDescriptor;
public class UIConfiguration {
public static enum RootUrlMode {
UI_REDIRECT,
INDEX_CATCHALL,
DISABLED;
public static RootUrlMode parse(String value) {
checkNotNull(value, "value is null");
value = value.toUpperCase(Locale.ENGLISH);
for (RootUrlMode rootUrlMode : RootUrlMode.values()) {
String name = rootUrlMode.name();
if (name.equals(value) || name.replace("_", "").equals(value)) {
return rootUrlMode;
}
}
throw new IllegalArgumentException("Value '" + value + "' unknown");
}
}
@NotEmpty
@JsonProperty
private String title = "Singularity";
@JsonProperty
@NotNull
private Optional navColor = Optional.absent();
@JsonProperty
private String baseUrl;
@NotEmpty
private String runningTaskLogPath = "stdout";
@NotEmpty
private String finishedTaskLogPath = "stdout";
@JsonProperty
@NotNull
private boolean showTaskDiskResource = false;
@JsonProperty
@NotNull
private List shellCommands = Collections.emptyList();
private boolean hideNewDeployButton = false;
private boolean hideNewRequestButton = false;
/**
* If true, the root of the server (http://.../singularity/) will open the UI. Otherwise,
* the UI URI (http://.../singularity/ui/) must be used.
*/
@JsonProperty
private String rootUrlMode = RootUrlMode.INDEX_CATCHALL.name();
@JsonProperty
@NotNull
private Optional taskS3LogOmitPrefix = Optional.absent();
@NotEmpty
private String timestampFormat = "lll";
@NotEmpty
private String timestampWithSecondsFormat = "lll:ss";
@JsonProperty
@NotNull
private Optional redirectOnUnauthorizedUrl = Optional.absent();
@JsonProperty
@NotNull
private Optional extraScript = Optional.absent();
public boolean isHideNewDeployButton() {
return hideNewDeployButton;
}
public void setHideNewDeployButton(boolean hideNewDeployButton) {
this.hideNewDeployButton = hideNewDeployButton;
}
public boolean isHideNewRequestButton() {
return hideNewRequestButton;
}
public void setHideNewRequestButton(boolean hideNewRequestButton) {
this.hideNewRequestButton = hideNewRequestButton;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Optional getBaseUrl() {
return Optional.fromNullable(Strings.emptyToNull(baseUrl));
}
public void setBaseUrl(String baseUrl) {
this.baseUrl = baseUrl;
}
public Optional getNavColor() {
return navColor;
}
public void setNavColor(Optional navColor) {
this.navColor = navColor;
}
@Valid
public RootUrlMode getRootUrlMode() {
return RootUrlMode.parse(rootUrlMode);
}
/**
* Supports 'uiRedirect', 'indexCatchall' and 'disabled'.
*
*
* - uiRedirect - UI is served off /ui path and index redirects there.
* - indexCatchall - UI is served off / using a catchall resource.
* - disabled> - UI is served off /ui> and the root resource is not served at all.
*
*
* @param rootUrlMode A valid root url mode.
*/
public void setRootUrlMode(String rootUrlMode) {
this.rootUrlMode = rootUrlMode;
}
public void setRunningTaskLogPath(String runningTaskLogPath) {
this.runningTaskLogPath = runningTaskLogPath;
}
public void setFinishedTaskLogPath(String finishedTaskLogPath) {
this.finishedTaskLogPath = finishedTaskLogPath;
}
public List getShellCommands() {
return shellCommands;
}
public boolean isShowTaskDiskResource() { return showTaskDiskResource; }
public void setShowTaskDiskResource(boolean showTaskDiskResource) { this.showTaskDiskResource = showTaskDiskResource; }
public void setShellCommands(List shellCommands) {
this.shellCommands = shellCommands;
}
public String getRunningTaskLogPath() {
return runningTaskLogPath;
}
public String getFinishedTaskLogPath() {
return finishedTaskLogPath;
}
public Optional getTaskS3LogOmitPrefix() {
return taskS3LogOmitPrefix;
}
public void setTaskS3LogOmitPrefix(Optional taskS3LogOmitPrefix) {
this.taskS3LogOmitPrefix = taskS3LogOmitPrefix;
}
public String getTimestampFormat() {
return timestampFormat;
}
public void setTimestampFormat(String timestampFormat) {
this.timestampFormat = timestampFormat;
}
public String getTimestampWithSecondsFormat() {
return timestampWithSecondsFormat;
}
public void setTimestampWithSecondsFormat(String timestampWithSecondsFormat) {
this.timestampWithSecondsFormat = timestampWithSecondsFormat;
}
public Optional getRedirectOnUnauthorizedUrl() {
return redirectOnUnauthorizedUrl;
}
public void setRedirectOnUnauthorizedUrl(Optional redirectOnUnauthorizedUrl) {
this.redirectOnUnauthorizedUrl = redirectOnUnauthorizedUrl;
}
public Optional getExtraScript() {
return extraScript;
}
public void setExtraScript(Optional extraScript) {
this.extraScript = extraScript;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy