@ApiOperation(value = "Initiate a canary pipeline with CanaryConfig provided")
@RequestMapping(consumes = "application/json", method = RequestMethod.POST)
public CanaryExecutionResponse initiateCanaryWithConfig(@RequestParam(required = false) final String application,
@RequestParam(required = false) final String parentPipelineExecutionId,
@RequestParam(required = false) final String metricsAccountName,
@RequestParam(required = false) final String storageAccountName,
@ApiParam @RequestBody final CanaryAdhocExecutionRequest canaryAdhocExecutionRequest) throws JsonProcessingException {
String resolvedMetricsAccountName = CredentialsHelper.resolveAccountByNameOrType(metricsAccountName,
AccountCredentials.Type.METRICS_STORE,
accountCredentialsRepository);
String resolvedStorageAccountName = CredentialsHelper.resolveAccountByNameOrType(storageAccountName,
AccountCredentials.Type.OBJECT_STORE,
accountCredentialsRepository);
if (canaryAdhocExecutionRequest.getCanaryConfig() == null) {
throw new IllegalArgumentException("canaryConfig must be provided for ad-hoc requests");
}
if (canaryAdhocExecutionRequest.getExecutionRequest() == null) {
throw new IllegalArgumentException("executionRequest must be provided for ad-hoc requests");
}
return executionMapper.buildExecution(Optional.ofNullable(application).orElse(AD_HOC),
parentPipelineExecutionId,
AD_HOC,
canaryAdhocExecutionRequest.getCanaryConfig(),
null,
resolvedMetricsAccountName,
resolvedStorageAccountName,
canaryAdhocExecutionRequest.getExecutionRequest());
}