use of com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder in project halyard by spinnaker.
the class FeaturesController method setFeatures.
@RequestMapping(value = "/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setFeatures(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawFeatures) {
Features features = objectMapper.convertValue(rawFeatures, Features.class);
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> features.stageLocalFiles(configPath));
builder.setUpdate(() -> featuresService.setFeatures(deploymentName, features));
builder.setSeverity(severity);
Supplier<ProblemSet> doValidate = ProblemSet::new;
if (validate) {
doValidate = () -> featuresService.validateFeatures(deploymentName);
}
builder.setValidate(doValidate);
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit features");
}
use of com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder in project halyard by spinnaker.
the class MetricStoresController method setMetricStore.
@RequestMapping(value = "/{metricStoreType:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setMetricStore(@PathVariable String deploymentName, @PathVariable String metricStoreType, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawMetricStore) {
MetricStore metricStore = objectMapper.convertValue(rawMetricStore, MetricStores.translateMetricStoreType(metricStoreType));
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path stagingPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> metricStore.stageLocalFiles(stagingPath));
builder.setSeverity(severity);
builder.setUpdate(() -> metricStoresService.setMetricStore(deploymentName, metricStore));
builder.setValidate(ProblemSet::new);
if (validate) {
builder.setValidate(() -> metricStoresService.validateMetricStore(deploymentName, metricStoreType));
}
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(stagingPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit " + metricStoreType + " metric store");
}
use of com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder in project halyard by spinnaker.
the class MetricStoresController method setMetricStores.
@RequestMapping(value = "/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setMetricStores(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawMetricStores) {
MetricStores metricStores = objectMapper.convertValue(rawMetricStores, MetricStores.class);
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> metricStores.stageLocalFiles(configPath));
builder.setSeverity(severity);
builder.setUpdate(() -> metricStoresService.setMetricStores(deploymentName, metricStores));
builder.setValidate(ProblemSet::new);
if (validate) {
builder.setValidate(() -> metricStoresService.validateMetricStores(deploymentName));
}
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit all metric stores");
}
use of com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder in project halyard by spinnaker.
the class MetricStoresController method setMethodEnabled.
@RequestMapping(value = "/{metricStoreType:.+}/enabled/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setMethodEnabled(@PathVariable String deploymentName, @PathVariable String metricStoreType, @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(() -> metricStoresService.setMetricStoreEnabled(deploymentName, metricStoreType, enabled));
builder.setSeverity(severity);
builder.setValidate(ProblemSet::new);
if (validate) {
builder.setValidate(() -> metricStoresService.validateMetricStore(deploymentName, metricStoreType));
}
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
return DaemonTaskHandler.submitTask(builder::build, "Edit " + metricStoreType + " metric store");
}
use of com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder in project halyard by spinnaker.
the class PersistentStorageController method setPersistentStorage.
@RequestMapping(value = "/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setPersistentStorage(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawPersistentStorage) {
PersistentStorage persistentStorage = objectMapper.convertValue(rawPersistentStorage, PersistentStorage.class);
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> persistentStorage.stageLocalFiles(configPath));
builder.setUpdate(() -> persistentStorageService.setPersistentStorage(deploymentName, persistentStorage));
builder.setSeverity(severity);
Supplier<ProblemSet> doValidate = ProblemSet::new;
if (validate) {
doValidate = () -> persistentStorageService.validatePersistentStorage(deploymentName);
}
builder.setValidate(doValidate);
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit persistent storage settings");
}
Aggregations