public void setCanaryEnabled(String deploymentName, boolean enabled) { Canary canary = getCanary(deploymentName); canary.setEnabled(enabled); }
@RequestMapping(value = "/enabled/", method = RequestMethod.PUT) DaemonTask<Halconfig, Void> setEnabled(@PathVariable String deploymentName, @ModelAttribute ValidationSettings validationSettings, @RequestBody boolean enabled) { return GenericEnableDisableRequest.builder(halconfigParser) .updater(e -> canaryService.setCanaryEnabled(deploymentName, e)) .validator(() -> canaryService.validateCanary(deploymentName)) .description("Edit canary settings") .build() .execute(validationSettings, enabled); }
@RequestMapping(value = "/", method = RequestMethod.GET) DaemonTask<Halconfig, Canary> getCanary(@PathVariable String deploymentName, @ModelAttribute ValidationSettings validationSettings) { return GenericGetRequest.<Canary>builder() .getter(() -> canaryService.getCanary(deploymentName)) .validator(() -> canaryService.validateCanary(deploymentName)) .description("Get all canary settings") .build() .execute(validationSettings); }
@RequestMapping(value = "/", method = RequestMethod.PUT) DaemonTask<Halconfig, Void> setCanary(@PathVariable String deploymentName, @ModelAttribute ValidationSettings validationSettings, @RequestBody Canary canary) { return GenericUpdateRequest.<Canary>builder(halconfigParser) .stagePath(halconfigDirectoryStructure.getStagingPath(deploymentName)) .updater(c -> canaryService.setCanary(deploymentName, c)) .validator(() -> canaryService.validateCanary(deploymentName)) .description("Edit canary analysis settings") .build() .execute(validationSettings, canary); }
public Canary getCanary(String deploymentName) { NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setCanary(); return lookupService.getSingularNodeOrDefault(filter, Canary.class, Canary::new, n -> setCanary(deploymentName, n)); }
@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); }
public Canary getCanary(String deploymentName) { NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setCanary(); return lookupService.getSingularNodeOrDefault(filter, Canary.class, Canary::new, n -> setCanary(deploymentName, n)); }
@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); }
public void setCanaryEnabled(String deploymentName, boolean enabled) { Canary canary = getCanary(deploymentName); canary.setEnabled(enabled); }
@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); } }
private AbstractCanaryServiceIntegration getServiceIntegration(String deploymentName, String serviceIntegrationName) { Canary canary = canaryService.getCanary(deploymentName); return canary.getServiceIntegrations() .stream() .filter(s -> s.getName().equals(serviceIntegrationName)) .findFirst() .orElseThrow(() -> new IllegalArgumentException("Canary service integration " + serviceIntegrationName + " not found.")); }
@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); }
private AbstractCanaryServiceIntegration getServiceIntegration(String deploymentName, String serviceIntegrationName) { Canary canary = canaryService.getCanary(deploymentName); return canary.getServiceIntegrations() .stream() .filter(s -> s.getName().equals(serviceIntegrationName)) .findFirst() .orElseThrow(() -> new IllegalArgumentException("Canary service integration " + serviceIntegrationName + " not found.")); }