public async Task <IActionResult> CreateJobTaskDefinitions(int projectId, int jobId, [FromBody] List <CreateJobTaskDefinitionDto> newTasks) { // exclude additional configs since it may contain secret values var requestBodyToLog = newTasks.Select(t => new CreateJobTaskDefinitionDto { Name = t.Name, Configs = t.Configs, Provider = t.Provider, Sequence = t.Sequence, Type = t.Type }).ToList(); _logger.LogRequest("Creating job task definitions in job {jobId} in project {projectId}. Request body: {@requestBodyToLog}", jobId, projectId, requestBodyToLog); try { var entities = _mapper.Map <List <JobTaskDefinition> >(newTasks); await _jobDefinitionService.AddJobTaskDefinitions(jobId, entities); var newTasksResponse = _mapper.Map <List <JobTaskDefinitionDto> >(entities); _logger.LogResponse("Job task definitions in job {jobId} in project {projectId} created. Response body: {@newTasksResponse}", jobId, projectId, newTasksResponse); return(CreatedAtRoute("GetJobTaskDefinitions", new { projectId, jobId, }, newTasksResponse)); } catch (DuplicateJobTaskDefinitionException dupTaskEx) { _logger.LogWarning(dupTaskEx, "Duplicate task name"); return(BadRequest(dupTaskEx.Message)); } catch (InvalidTaskProviderTypeException providerTypeEx) { _logger.LogWarning(providerTypeEx, "Invalid provider type"); return(BadRequest(providerTypeEx.Message)); } catch (JobDefinitionNotFoundException modEx) { _logger.LogWarning(modEx, "Job definition not found"); return(BadRequest(modEx.Message)); } catch (TaskProviderNotInstalledException provEx) { _logger.LogWarning(provEx, "Provider not installed"); return(BadRequest(provEx.Message)); } catch (ExternalServiceRequiredException esrEx) { _logger.LogWarning(esrEx, "External service required"); return(BadRequest(esrEx.Message)); } catch (ExternalServiceNotFoundException esnfEx) { _logger.LogWarning(esnfEx, "External service not found"); return(BadRequest(esnfEx.Message)); } catch (IncorrectExternalServiceTypeException iestEx) { _logger.LogWarning(iestEx, "Incorrect external service type"); return(BadRequest(iestEx.Message)); } catch (JobTaskDefinitionTypeException taskEx) { _logger.LogWarning(taskEx, "Incorrect task definition type"); return(BadRequest(taskEx.Message)); } catch (TaskConfigRequiredException tcEx) { _logger.LogWarning(tcEx, "Incorrect task config"); return(BadRequest(tcEx.Message)); } catch (TaskProviderAdditionalConfigRequiredException acReqEx) { _logger.LogWarning(acReqEx, "Incorrect task additional config"); return(BadRequest(acReqEx.Message)); } catch (TaskProviderAdditionalConfigAllowedValuesException avEx) { _logger.LogWarning(avEx, "Incorrect task additional config"); return(BadRequest(avEx.Message)); } }