use of com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder 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.DaemonResponse.UpdateRequestBuilder 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.DaemonResponse.UpdateRequestBuilder 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.DaemonResponse.UpdateRequestBuilder 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");
}
use of com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder in project halyard by spinnaker.
the class SecurityController method setRoleProvider.
@RequestMapping(value = "/authz/groupMembership/{roleProviderName:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setRoleProvider(@PathVariable String deploymentName, @PathVariable String roleProviderName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawProvider) {
RoleProvider roleProvider = objectMapper.convertValue(rawProvider, GroupMembership.translateRoleProviderType(roleProviderName));
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> roleProvider.stageLocalFiles(configPath));
builder.setSeverity(severity);
builder.setUpdate(() -> securityService.setRoleProvider(deploymentName, roleProvider));
builder.setValidate(ProblemSet::new);
if (validate) {
builder.setValidate(() -> securityService.validateRoleProvider(deploymentName, roleProviderName));
}
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit " + roleProviderName + " group membership settings");
}
Aggregations