use of com.netflix.spinnaker.halyard.config.model.v1.security.ApiSecurity in project halyard by spinnaker.
the class ApiSecurityEditCommand method executeThis.
@Override
protected void executeThis() {
String currentDeployment = getCurrentDeployment();
ApiSecurity apiSecurity = new OperationHandler<ApiSecurity>().setOperation(Daemon.getApiSecurity(currentDeployment, false)).setFailureMesssage("Failed to load API security settings.").get();
int originalHash = apiSecurity.hashCode();
apiSecurity.setOverrideBaseUrl(isSet(overrideBaseUrl) ? overrideBaseUrl : apiSecurity.getOverrideBaseUrl());
apiSecurity.setCorsAccessPattern(isSet(corsAccessPattern) ? corsAccessPattern : apiSecurity.getCorsAccessPattern());
if (originalHash == apiSecurity.hashCode()) {
AnsiUi.failure("No changes supplied.");
return;
}
new OperationHandler<Void>().setOperation(Daemon.setApiSecurity(currentDeployment, !noValidate, apiSecurity)).setFailureMesssage("Failed to edit API security settings.").setFailureMesssage("Successfully updated API security settings.").get();
}
use of com.netflix.spinnaker.halyard.config.model.v1.security.ApiSecurity in project halyard by spinnaker.
the class SecurityController method setApiSecurity.
@RequestMapping(value = "/api/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setApiSecurity(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawApiSecurity) {
ApiSecurity apiSecurity = objectMapper.convertValue(rawApiSecurity, ApiSecurity.class);
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> apiSecurity.stageLocalFiles(configPath));
builder.setSeverity(severity);
builder.setUpdate(() -> securityService.setApiSecurity(deploymentName, apiSecurity));
builder.setValidate(ProblemSet::new);
if (validate) {
builder.setValidate(() -> securityService.validateApiSecurity(deploymentName));
}
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit API security settings");
}
Aggregations