use of com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet in project halyard by spinnaker.
the class MasterController method deleteMaster.
@RequestMapping(value = "/{masterName:.+}", method = RequestMethod.DELETE)
DaemonTask<Halconfig, Void> deleteMaster(@PathVariable String deploymentName, @PathVariable String ciName, @PathVariable String masterName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity) {
UpdateRequestBuilder builder = new UpdateRequestBuilder();
builder.setUpdate(() -> masterService.deleteMaster(deploymentName, ciName, masterName));
builder.setSeverity(severity);
Supplier<ProblemSet> doValidate = ProblemSet::new;
if (validate) {
doValidate = () -> masterService.validateAllMasters(deploymentName, ciName);
}
builder.setValidate(doValidate);
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Delete the " + masterName + " master");
}
use of com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet in project halyard by spinnaker.
the class MasterController method addMaster.
@RequestMapping(value = "/", method = RequestMethod.POST)
DaemonTask<Halconfig, Void> addMaster(@PathVariable String deploymentName, @PathVariable String ciName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawMaster) {
Master master = objectMapper.convertValue(rawMaster, Cis.translateMasterType(ciName));
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> master.stageLocalFiles(configPath));
builder.setSeverity(severity);
builder.setUpdate(() -> masterService.addMaster(deploymentName, ciName, master));
Supplier<ProblemSet> doValidate = ProblemSet::new;
if (validate) {
doValidate = () -> masterService.validateMaster(deploymentName, ciName, master.getName());
}
builder.setValidate(doValidate);
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Add the " + master.getName() + " master");
}
use of com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet in project halyard by spinnaker.
the class NotificationController method setEnabled.
@RequestMapping(value = "/{notificationName:.+}/enabled", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setEnabled(@PathVariable String deploymentName, @PathVariable String notificationName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody boolean enabled) {
UpdateRequestBuilder builder = new UpdateRequestBuilder();
builder.setUpdate(() -> notificationService.setEnabled(deploymentName, notificationName, enabled));
builder.setSeverity(severity);
Supplier<ProblemSet> doValidate = ProblemSet::new;
if (validate) {
doValidate = () -> notificationService.validateNotification(deploymentName, notificationName);
}
builder.setValidate(doValidate);
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
return DaemonTaskHandler.submitTask(builder::build, "Edit " + notificationName + " settings");
}
use of com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet in project halyard by spinnaker.
the class ProviderController method setEnabled.
@RequestMapping(value = "/{providerName:.+}/enabled", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setEnabled(@PathVariable String deploymentName, @PathVariable String providerName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody boolean enabled) {
UpdateRequestBuilder builder = new UpdateRequestBuilder();
builder.setUpdate(() -> providerService.setEnabled(deploymentName, providerName, enabled));
builder.setSeverity(severity);
Supplier<ProblemSet> doValidate = ProblemSet::new;
if (validate) {
doValidate = () -> providerService.validateProvider(deploymentName, providerName);
}
builder.setValidate(doValidate);
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
return DaemonTaskHandler.submitTask(builder::build, "Edit the " + providerName + " provider");
}
use of com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet in project halyard by spinnaker.
the class SecurityController method setUiSecurity.
@RequestMapping(value = "/ui/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setUiSecurity(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawUiSecurity) {
UiSecurity uiSecurity = objectMapper.convertValue(rawUiSecurity, UiSecurity.class);
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> uiSecurity.stageLocalFiles(configPath));
builder.setSeverity(severity);
builder.setUpdate(() -> securityService.setUiSecurity(deploymentName, uiSecurity));
builder.setValidate(ProblemSet::new);
if (validate) {
builder.setValidate(() -> securityService.validateUiSecurity(deploymentName));
}
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit UI security settings");
}
Aggregations