/// <summary> /// Gets the schema from a sample data generated within 30 seconds as default /// </summary> /// <param name="storageConnectionString">storageConnectionString</param> /// <param name="samplesPath">samplesPath</param> /// <param name="userId">userId</param> /// <param name="flowId">flowId</param> /// <param name="seconds">seconds is the duration of time</param> /// <returns>Returns ApiResult with schema Result object</returns> public async Task <SchemaResult> GetSchemaAsync(string storageConnectionString, string samplesPath, string userId, string flowId, int seconds = _DefaultDuration) { // Get sample events EventsData eventsData = await _messageBus.GetSampleEvents(seconds <= 0?_DefaultDuration : seconds); List <EventRaw> events = eventsData.Events; _logger.LogInformation($"Event count = {events.Count}"); if (events.Count < 1) { throw new Exception("Can't capture any data from the data source."); } // Save sample events SaveSample(storageConnectionString, samplesPath, userId, flowId, eventsData.EventsJson); _logger.LogInformation($"successful save to {samplesPath}"); // Get schema //log schemaResult.schema.length and count of errors SchemaResult schemaResult = GetSchemaHelper(events); _logger.LogInformation($"schemaResult.schema.length: {schemaResult.Schema.Length} and count of errors: {schemaResult.Errors.Count}"); return(schemaResult); }