public void addAccount(String deploymentName, String serviceIntegrationName, AbstractCanaryAccount newCanaryAccount) { AbstractCanaryServiceIntegration serviceIntegration = getServiceIntegration(deploymentName, serviceIntegrationName); serviceIntegration.getAccounts().add(newCanaryAccount); }
@RequestMapping(value = "/{serviceIntegrationName:.+}/accounts/account/{accountName:.+}", method = RequestMethod.GET) DaemonTask<Halconfig, AbstractCanaryAccount> getCanaryAccount(@PathVariable String deploymentName, @PathVariable String serviceIntegrationName, @PathVariable String accountName, @ModelAttribute ValidationSettings validationSettings) { return GenericGetRequest.<AbstractCanaryAccount>builder() .getter(() -> canaryAccountService.getCanaryAccount(deploymentName, serviceIntegrationName, accountName)) .validator(() -> canaryService.validateCanary(deploymentName)) .description("Get " + accountName + " canary account") .build() .execute(validationSettings); }
@RequestMapping(value = "/{serviceIntegrationName:.+}/accounts/account/{accountName:.+}", method = RequestMethod.PUT) DaemonTask<Halconfig, Void> setCanaryAccount(@PathVariable String deploymentName, @PathVariable String serviceIntegrationName, @PathVariable String accountName, @ModelAttribute ValidationSettings validationSettings, @RequestBody Object rawCanaryAccount) { AbstractCanaryAccount canaryAccount = objectMapper.convertValue( rawCanaryAccount, Canary.translateCanaryAccountType(serviceIntegrationName) ); return GenericUpdateRequest.<AbstractCanaryAccount>builder(halconfigParser) .stagePath(halconfigDirectoryStructure.getStagingPath(deploymentName)) .updater(c -> canaryAccountService.setAccount(deploymentName, serviceIntegrationName, accountName, c)) .validator(() -> canaryService.validateCanary(deploymentName)) .description("Edit the " + accountName + " canary account") .build() .execute(validationSettings, canaryAccount); }
@RequestMapping(value = "/{serviceIntegrationName:.+}/accounts/account/{accountName:.+}", method = RequestMethod.DELETE) DaemonTask<Halconfig, Void> deleteCanaryAccount(@PathVariable String deploymentName, @PathVariable String serviceIntegrationName, @PathVariable String accountName, @ModelAttribute ValidationSettings validationSettings) { return GenericDeleteRequest.builder(halconfigParser) .stagePath(halconfigDirectoryStructure.getStagingPath(deploymentName)) .deleter(() -> canaryAccountService.deleteAccount(deploymentName, serviceIntegrationName, accountName)) .validator(() -> canaryService.validateCanary(deploymentName)) .description("Delete the " + accountName + " canary account") .build() .execute(validationSettings); } }
@RequestMapping(value = "/{serviceIntegrationName:.+}/accounts/", method = RequestMethod.POST) DaemonTask<Halconfig, Void> addCanaryAccount(@PathVariable String deploymentName, @PathVariable String serviceIntegrationName, @ModelAttribute ValidationSettings validationSettings, @RequestBody Object rawCanaryAccount) { AbstractCanaryAccount canaryAccount = objectMapper.convertValue( rawCanaryAccount, Canary.translateCanaryAccountType(serviceIntegrationName) ); return GenericUpdateRequest.<AbstractCanaryAccount>builder(halconfigParser) .stagePath(halconfigDirectoryStructure.getStagingPath(deploymentName)) .updater(c -> canaryAccountService.addAccount(deploymentName, serviceIntegrationName, c)) .validator(() -> canaryService.validateCanary(deploymentName)) .description("Add the " + canaryAccount.getName() + " canary account to " + serviceIntegrationName + " service integration") .build() .execute(validationSettings, canaryAccount); }
public void addAccount(String deploymentName, String serviceIntegrationName, AbstractCanaryAccount newCanaryAccount) { AbstractCanaryServiceIntegration serviceIntegration = getServiceIntegration(deploymentName, serviceIntegrationName); serviceIntegration.getAccounts().add(newCanaryAccount); }
public void setAccount(String deploymentName, String serviceIntegrationName, String accountName, AbstractCanaryAccount newAccount) { AbstractCanaryServiceIntegration serviceIntegration = getServiceIntegration(deploymentName, serviceIntegrationName); for (int i = 0; i < serviceIntegration.getAccounts().size(); i++) { AbstractCanaryAccount account = (AbstractCanaryAccount)serviceIntegration.getAccounts().get(i); if (account.getNodeName().equals(accountName)) { serviceIntegration.getAccounts().set(i, newAccount); return; } } throw new HalException(new ConfigProblemBuilder(Severity.FATAL, "Canary account \"" + accountName + "\" wasn't found").build()); }
public void setAccount(String deploymentName, String serviceIntegrationName, String accountName, AbstractCanaryAccount newAccount) { AbstractCanaryServiceIntegration serviceIntegration = getServiceIntegration(deploymentName, serviceIntegrationName); for (int i = 0; i < serviceIntegration.getAccounts().size(); i++) { AbstractCanaryAccount account = (AbstractCanaryAccount)serviceIntegration.getAccounts().get(i); if (account.getNodeName().equals(accountName)) { serviceIntegration.getAccounts().set(i, newAccount); return; } } throw new HalException(new ConfigProblemBuilder(Severity.FATAL, "Canary account \"" + accountName + "\" wasn't found").build()); }
public void deleteAccount(String deploymentName, String serviceIntegrationName, String accountName) { AbstractCanaryServiceIntegration serviceIntegration = getServiceIntegration(deploymentName, serviceIntegrationName); boolean removed = serviceIntegration.getAccounts().removeIf(account -> ((AbstractCanaryAccount)account).getName().equals(accountName)); if (!removed) { throw new HalException(new ConfigProblemBuilder(Severity.FATAL, "Canary account \"" + accountName + "\" wasn't found").build()); } }
public void deleteAccount(String deploymentName, String serviceIntegrationName, String accountName) { AbstractCanaryServiceIntegration serviceIntegration = getServiceIntegration(deploymentName, serviceIntegrationName); boolean removed = serviceIntegration.getAccounts().removeIf(account -> ((AbstractCanaryAccount)account).getName().equals(accountName)); if (!removed) { throw new HalException(new ConfigProblemBuilder(Severity.FATAL, "Canary account \"" + accountName + "\" wasn't found").build()); } }
public AbstractCanaryAccount getCanaryAccount(String deploymentName, String serviceIntegrationName, String accountName) { AbstractCanaryServiceIntegration serviceIntegration = getServiceIntegration(deploymentName, serviceIntegrationName); List<AbstractCanaryAccount> matchingAccounts = (List<AbstractCanaryAccount>)serviceIntegration.getAccounts() .stream() .filter(a -> (((AbstractCanaryAccount)a).getName().equals(accountName))) .collect(Collectors.toList()); switch (matchingAccounts.size()) { case 0: throw new ConfigNotFoundException(new ConfigProblemBuilder( Severity.FATAL, "No account with name \"" + accountName + "\" was found") .setRemediation("Check if this account was defined in another service integration, or create a new one").build()); case 1: return matchingAccounts.get(0); default: throw new IllegalConfigException(new ConfigProblemBuilder( Severity.FATAL, "More than one account named \"" + accountName + "\" was found") .setRemediation("Manually delete/rename duplicate canary accounts with name \"" + accountName + "\" in your halconfig file").build()); } }
public AbstractCanaryAccount getCanaryAccount(String deploymentName, String serviceIntegrationName, String accountName) { AbstractCanaryServiceIntegration serviceIntegration = getServiceIntegration(deploymentName, serviceIntegrationName); List<AbstractCanaryAccount> matchingAccounts = (List<AbstractCanaryAccount>)serviceIntegration.getAccounts() .stream() .filter(a -> (((AbstractCanaryAccount)a).getName().equals(accountName))) .collect(Collectors.toList()); switch (matchingAccounts.size()) { case 0: throw new ConfigNotFoundException(new ConfigProblemBuilder( Severity.FATAL, "No account with name \"" + accountName + "\" was found") .setRemediation("Check if this account was defined in another service integration, or create a new one").build()); case 1: return matchingAccounts.get(0); default: throw new IllegalConfigException(new ConfigProblemBuilder( Severity.FATAL, "More than one account named \"" + accountName + "\" was found") .setRemediation("Manually delete/rename duplicate canary accounts with name \"" + accountName + "\" in your halconfig file").build()); } }