use of com.netflix.spinnaker.halyard.core.problem.v1.Problem.Severity in project halyard by spinnaker.
the class SecurityController method setSecurity.
@RequestMapping(value = "/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setSecurity(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawSecurity) {
Security security = objectMapper.convertValue(rawSecurity, Security.class);
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> security.stageLocalFiles(configPath));
builder.setSeverity(severity);
builder.setUpdate(() -> securityService.setSecurity(deploymentName, security));
builder.setValidate(ProblemSet::new);
if (validate) {
builder.setValidate(() -> securityService.validateSecurity(deploymentName));
}
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit security settings");
}
use of com.netflix.spinnaker.halyard.core.problem.v1.Problem.Severity in project halyard by spinnaker.
the class SecurityController method setSpringSSlEnabled.
@RequestMapping(value = "/api/ssl/enabled/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setSpringSSlEnabled(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody boolean enabled) {
UpdateRequestBuilder builder = new UpdateRequestBuilder();
builder.setSeverity(severity);
builder.setUpdate(() -> securityService.setSpringSslEnabled(deploymentName, enabled));
builder.setValidate(ProblemSet::new);
if (validate) {
builder.setValidate(() -> securityService.validateSpringSsl(deploymentName));
}
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
return DaemonTaskHandler.submitTask(builder::build, "Edit API SSL settings");
}
use of com.netflix.spinnaker.halyard.core.problem.v1.Problem.Severity in project halyard by spinnaker.
the class SecurityController method setAuthnMethod.
@RequestMapping(value = "/authn/{methodName:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setAuthnMethod(@PathVariable String deploymentName, @PathVariable String methodName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawMethod) {
AuthnMethod method = objectMapper.convertValue(rawMethod, AuthnMethod.translateAuthnMethodName(methodName));
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> method.stageLocalFiles(configPath));
builder.setSeverity(severity);
builder.setUpdate(() -> securityService.setAuthnMethod(deploymentName, method));
builder.setValidate(ProblemSet::new);
if (validate) {
builder.setValidate(() -> securityService.validateAuthnMethod(deploymentName, methodName));
}
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit " + methodName + " authentication settings");
}
use of com.netflix.spinnaker.halyard.core.problem.v1.Problem.Severity in project halyard by spinnaker.
the class ArtifactAccountController method setArtifactAccount.
@RequestMapping(value = "/account/{accountName:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setArtifactAccount(@PathVariable String deploymentName, @PathVariable String providerName, @PathVariable String accountName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawArtifactAccount) {
ArtifactAccount account = objectMapper.convertValue(rawArtifactAccount, Artifacts.translateArtifactAccountType(providerName));
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> account.stageLocalFiles(configPath));
builder.setUpdate(() -> accountService.setArtifactAccount(deploymentName, providerName, accountName, account));
builder.setSeverity(severity);
Supplier<ProblemSet> doValidate = ProblemSet::new;
if (validate) {
doValidate = () -> accountService.validateArtifactAccount(deploymentName, providerName, account.getName());
}
builder.setValidate(doValidate);
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit the " + accountName + " artifact account");
}
use of com.netflix.spinnaker.halyard.core.problem.v1.Problem.Severity in project halyard by spinnaker.
the class ArtifactAccountController method deleteArtifactAccount.
@RequestMapping(value = "/account/{accountName:.+}", method = RequestMethod.DELETE)
DaemonTask<Halconfig, Void> deleteArtifactAccount(@PathVariable String deploymentName, @PathVariable String providerName, @PathVariable String accountName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity) {
UpdateRequestBuilder builder = new UpdateRequestBuilder();
builder.setUpdate(() -> accountService.deleteArtifactAccount(deploymentName, providerName, accountName));
builder.setSeverity(severity);
Supplier<ProblemSet> doValidate = ProblemSet::new;
if (validate) {
doValidate = () -> accountService.validateAllArtifactAccounts(deploymentName, providerName);
}
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 " + accountName + " artifact account");
}
Aggregations