use of com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder in project halyard by spinnaker.
the class PubsubController method setEnabled.
@RequestMapping(value = "/{pubsubName:.+}/enabled", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setEnabled(@PathVariable String deploymentName, @PathVariable String pubsubName, @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(() -> pubsubService.setEnabled(deploymentName, pubsubName, enabled));
builder.setSeverity(severity);
Supplier<ProblemSet> doValidate = ProblemSet::new;
if (validate) {
doValidate = () -> pubsubService.validatePubsub(deploymentName, pubsubName);
}
builder.setValidate(doValidate);
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
return DaemonTaskHandler.submitTask(builder::build, "Edit the " + pubsubName + " pubsub");
}
use of com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder in project halyard by spinnaker.
the class SubscriptionController method deleteSubscription.
@RequestMapping(value = "/subscription/{subscriptionName:.+}", method = RequestMethod.DELETE)
DaemonTask<Halconfig, Void> deleteSubscription(@PathVariable String deploymentName, @PathVariable String pubsubName, @PathVariable String subscriptionName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity) {
UpdateRequestBuilder builder = new UpdateRequestBuilder();
builder.setUpdate(() -> subscriptionService.deleteSubscription(deploymentName, pubsubName, subscriptionName));
builder.setSeverity(severity);
Supplier<ProblemSet> doValidate = ProblemSet::new;
if (validate) {
doValidate = () -> subscriptionService.validateAllSubscriptions(deploymentName, pubsubName);
}
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 " + subscriptionName + " subscription");
}
use of com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder in project halyard by spinnaker.
the class SubscriptionController method addSubscription.
@RequestMapping(value = "/", method = RequestMethod.POST)
DaemonTask<Halconfig, Void> addSubscription(@PathVariable String deploymentName, @PathVariable String pubsubName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawSubscription) {
Subscription subscription = objectMapper.convertValue(rawSubscription, Pubsubs.translateSubscriptionType(pubsubName));
UpdateRequestBuilder builder = new UpdateRequestBuilder();
builder.setSeverity(severity);
builder.setUpdate(() -> subscriptionService.addSubscription(deploymentName, pubsubName, subscription));
Supplier<ProblemSet> doValidate = ProblemSet::new;
if (validate) {
doValidate = () -> subscriptionService.validateSubscription(deploymentName, pubsubName, subscription.getName());
}
builder.setValidate(doValidate);
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
return DaemonTaskHandler.submitTask(builder::build, "Add the " + subscription.getName() + " subscription");
}
use of com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder in project halyard by spinnaker.
the class DeploymentEnvironmentController method setDeploymentEnvironment.
@RequestMapping(value = "/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setDeploymentEnvironment(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawDeploymentEnvironment) {
DeploymentEnvironment deploymentEnvironment = objectMapper.convertValue(rawDeploymentEnvironment, DeploymentEnvironment.class);
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> deploymentEnvironment.stageLocalFiles(configPath));
builder.setUpdate(() -> deploymentEnvironmentService.setDeploymentEnvironment(deploymentName, deploymentEnvironment));
builder.setSeverity(severity);
if (validate) {
builder.setValidate(() -> deploymentEnvironmentService.validateDeploymentEnvironment(deploymentName));
} else {
builder.setValidate(ProblemSet::new);
}
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit the deployment environment");
}
use of com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder 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");
}
Aggregations