use of com.netflix.spinnaker.halyard.config.model.v1.node.Account in project halyard by spinnaker.
the class ArtifactAccountController method addArtifactAccount.
@RequestMapping(value = "/", method = RequestMethod.POST)
DaemonTask<Halconfig, Void> addArtifactAccount(@PathVariable String deploymentName, @PathVariable String providerName, @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.setSeverity(severity);
builder.setUpdate(() -> accountService.addArtifactAccount(deploymentName, providerName, account));
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, "Add the " + account.getName() + " artifact account");
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.Account in project halyard by spinnaker.
the class CanaryController method setCanaryAccount.
@RequestMapping(value = "/{serviceIntegrationName:.+}/accounts/account/{accountName:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setCanaryAccount(@PathVariable String deploymentName, @PathVariable String serviceIntegrationName, @PathVariable String accountName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawCanaryAccount) {
AbstractCanaryAccount canaryAccount = objectMapper.convertValue(rawCanaryAccount, Canary.translateCanaryAccountType(serviceIntegrationName));
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> canaryAccount.stageLocalFiles(configPath));
builder.setUpdate(() -> canaryAccountService.setAccount(deploymentName, serviceIntegrationName, accountName, canaryAccount));
builder.setSeverity(severity);
Supplier<ProblemSet> doValidate = ProblemSet::new;
if (validate) {
doValidate = () -> canaryService.validateCanary(deploymentName);
}
builder.setValidate(doValidate);
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit the " + accountName + " canary account");
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.Account in project halyard by spinnaker.
the class CanaryController method addCanaryAccount.
@RequestMapping(value = "/{serviceIntegrationName:.+}/accounts/", method = RequestMethod.POST)
DaemonTask<Halconfig, Void> addCanaryAccount(@PathVariable String deploymentName, @PathVariable String serviceIntegrationName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawCanaryAccount) {
AbstractCanaryAccount canaryAccount = objectMapper.convertValue(rawCanaryAccount, Canary.translateCanaryAccountType(serviceIntegrationName));
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> canaryAccount.stageLocalFiles(configPath));
builder.setSeverity(severity);
builder.setUpdate(() -> canaryAccountService.addAccount(deploymentName, serviceIntegrationName, canaryAccount));
Supplier<ProblemSet> doValidate = ProblemSet::new;
if (validate) {
doValidate = () -> canaryService.validateCanary(deploymentName);
}
builder.setValidate(doValidate);
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Add the " + canaryAccount.getName() + " canary account to " + serviceIntegrationName + " service integration");
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.Account in project halyard by spinnaker.
the class AccountController method newAccountOptions.
@RequestMapping(value = "/options", method = RequestMethod.POST)
DaemonTask<Halconfig, List<String>> newAccountOptions(@PathVariable String deploymentName, @PathVariable String providerName, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody DaemonOptions rawAccountOptions) {
String fieldName = rawAccountOptions.getField();
Account account = objectMapper.convertValue(rawAccountOptions.getResource(), Providers.translateAccountType(providerName));
DaemonResponse.UpdateOptionsRequestBuilder builder = new DaemonResponse.UpdateOptionsRequestBuilder();
String accountName = account.getName();
builder.setUpdate(() -> accountService.addAccount(deploymentName, providerName, account));
builder.setFieldOptionsResponse(() -> accountService.getAccountOptions(deploymentName, providerName, accountName, fieldName));
builder.setSeverity(severity);
return DaemonTaskHandler.submitTask(builder::build, "Get " + fieldName + " options");
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.Account in project halyard by spinnaker.
the class ArtifactAccountService method deleteArtifactAccount.
public void deleteArtifactAccount(String deploymentName, String providerName, String accountName) {
ArtifactProvider provider = artifactProviderService.getArtifactProvider(deploymentName, providerName);
boolean removed = provider.getAccounts().removeIf(account -> ((ArtifactAccount) account).getName().equals(accountName));
if (!removed) {
throw new HalException(new ConfigProblemBuilder(Severity.FATAL, "Artifact account \"" + accountName + "\" wasn't found").build());
}
}
Aggregations