public MicrosoftGraphProxyConfigTestInitializer(string graphVersion) { UtilityService.UtilityFunctions.CheckArgumentNullOrEmpty(graphVersion, nameof(graphVersion)); _configuration = new ConfigurationBuilder() .AddJsonFile(Path.Join(Environment.CurrentDirectory, "TestFiles", "appsettingstest.json")) .Build(); GraphProxyConfigs = new MicrosoftGraphProxyConfigs() { GraphProxyBaseUrl = _configuration[ChangesServiceConstants.GraphProxyBaseUrlConfigPath], GraphProxyRelativeUrl = _configuration[ChangesServiceConstants.GraphProxyRelativeUrlConfigPath], GraphProxyAuthorization = _configuration[ChangesServiceConstants.GraphProxyAuthorization], GraphVersion = graphVersion }; }
public async Task <IActionResult> GetChangesAsync( [FromQuery] string requestUrl = null, [FromQuery] string workload = null, [FromQuery] double daysRange = 0, [FromQuery] DateTime?startDate = null, // yyyy-MM-ddTHH:mm:ss [FromQuery] DateTime?endDate = null, // yyyy-MM-ddTHH:mm:ss [FromQuery] int page = 1, [FromQuery] int?pageLimit = null, [FromQuery] string graphVersion = "v1.0") { try { // Options for searching, filtering and paging the changelog data var searchOptions = new ChangeLogSearchOptions(requestUrl: requestUrl, workload: workload, daysRange: daysRange, startDate: startDate, endDate: endDate) { Page = page, PageLimit = pageLimit }; // Get the requested culture info. var cultureFeature = HttpContext.Features.Get <IRequestCultureFeature>(); var cultureInfo = cultureFeature.RequestCulture.Culture; // Fetch the changelog records var changeLog = await _changesStore.FetchChangeLogRecordsAsync(cultureInfo); // Filter the changelog records if (changeLog.ChangeLogs.Any()) { // Configs for fetching workload names from given requestUrl var graphProxyConfigs = new MicrosoftGraphProxyConfigs() { GraphProxyBaseUrl = _configuration[ChangesServiceConstants.GraphProxyBaseUrlConfigPath], GraphProxyRelativeUrl = _configuration[ChangesServiceConstants.GraphProxyRelativeUrlConfigPath], GraphProxyAuthorization = _configuration[ChangesServiceConstants.GraphProxyAuthorization], GraphVersion = graphVersion }; changeLog = ChangesService.Services.ChangesService .FilterChangeLogRecords(changeLog, searchOptions, graphProxyConfigs, _httpClientUtility); } else { // No records return(NoContent()); } if (!changeLog.ChangeLogs.Any()) { // Filtered items yielded no result return(NotFound()); } return(Ok(changeLog)); } catch (InvalidOperationException ex) { return(new JsonResult(ex.Message) { StatusCode = StatusCodes.Status400BadRequest }); } catch (ArgumentException ex) { return(new JsonResult(ex.Message) { StatusCode = StatusCodes.Status404NotFound }); } catch (Exception ex) { return(new JsonResult(ex.Message) { StatusCode = StatusCodes.Status500InternalServerError }); } }