Exemple #1
0
        public async Task <JobSettingsViewModel> JobSettings([FromBody] JobSettings settings)
        {
            // Verify that we have correct CRON's
            foreach (var propertyInfo in settings.GetType()
                     .GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                if (propertyInfo.Name.Equals("Id", StringComparison.CurrentCultureIgnoreCase))
                {
                    continue;
                }
                var expression = (string)propertyInfo.GetValue(settings, null);

                try
                {
                    var r = CrontabSchedule.TryParse(expression);
                    if (r == null)
                    {
                        return(new JobSettingsViewModel
                        {
                            Message = $"{propertyInfo.Name} does not have a valid CRON Expression"
                        });
                    }
                }
                catch (Exception)
                {
                    return(new JobSettingsViewModel
                    {
                        Message = $"{propertyInfo.Name} does not have a valid CRON Expression"
                    });
                }
            }
            var result = await Save(settings);

            return(new JobSettingsViewModel
            {
                Result = result
            });
        }
Exemple #2
0
        /// <summary>
        /// Submit name entity extraction job for processing Start name entity extraction. The extraction is done on the previously texts. The settings supplied with the job in the request body are used for the name entity extraction. You can only submit the job after a new Job is created with status INPUTS_UPLOADED or resubmit an existing Job with status ERROR. In all cases the job Id in the path must match the jobId in the request.
        /// </summary>
        /// <exception cref="Sphereon.SDK.Extraction.Named.Entity.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="jobid">jobid</param>
        /// <param name="settings">settings</param>
        /// <returns>ApiResponse of Job</returns>
        public ApiResponse <Job> SubmitJobWithHttpInfo(string jobid, JobSettings settings)
        {
            // verify the required parameter 'jobid' is set
            if (jobid == null)
            {
                throw new ApiException(400, "Missing required parameter 'jobid' when calling NamedEntityExtractionApi->SubmitJob");
            }
            // verify the required parameter 'settings' is set
            if (settings == null)
            {
                throw new ApiException(400, "Missing required parameter 'settings' when calling NamedEntityExtractionApi->SubmitJob");
            }

            var    localVarPath         = "/extraction/name/entity/jobs/{jobid}";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new Dictionary <String, String>();
            var    localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json"
            };
            String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json;charset=UTF-8"
            };
            String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (jobid != null)
            {
                localVarPathParams.Add("jobid", Configuration.ApiClient.ParameterToString(jobid));                // path parameter
            }
            if (settings != null && settings.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(settings); // http body (model) parameter
            }
            else
            {
                localVarPostBody = settings; // byte array
            }

            // authentication (oauth2schema) required
            // oauth required
            if (!String.IsNullOrEmpty(Configuration.AccessToken))
            {
                localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken;
            }

            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)Configuration.ApiClient.CallApi(localVarPath,
                                                                                            Method.PUT, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("SubmitJob", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <Job>(localVarStatusCode,
                                         localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                         (Job)Configuration.ApiClient.Deserialize(localVarResponse, typeof(Job))));
        }