-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #168 from CSCfi/qa
Export endpoints
- Loading branch information
Showing
44 changed files
with
534 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
aspnetcore/src/ApiModels/Query/SearchAfterQueryParameters.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
namespace ResearchFi.Query; | ||
|
||
/// <summary> | ||
/// Vientiin liittyvät tiedot. | ||
/// </summary> | ||
public class SearchAfterQueryParameters | ||
{ | ||
private const int DefaultPageSize = 50; | ||
private const int MaximumPageSize = 1000; | ||
private int _pageSize = DefaultPageSize; | ||
private long? _nextPageToken = null; | ||
|
||
/// <summary> | ||
/// Number of results on page. Optional. Default value 50. Maximum permissible value 1000. | ||
/// </summary> | ||
public int PageSize | ||
{ | ||
get => _pageSize; | ||
set => _pageSize = value < 1 ? DefaultPageSize : (value > MaximumPageSize ? MaximumPageSize : value); | ||
} | ||
|
||
/// <summary> | ||
/// Value from previous query response header "x-next-page-token". Leave empty in the first query. | ||
/// </summary> | ||
public long? NextPageToken | ||
{ | ||
get => _nextPageToken; | ||
set => _nextPageToken = value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace CSC.PublicApi.ElasticService; | ||
|
||
public class SearchAfterResult | ||
{ | ||
public long? SearchAfter { get; } | ||
public int PageSize { get; } | ||
public SearchAfterResult(long? searchAfter, int pageSize) | ||
{ | ||
SearchAfter = searchAfter; | ||
PageSize = pageSize; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
aspnetcore/src/Interface/Controllers/FundingCallExportController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using CSC.PublicApi.Interface.Services; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using ResearchFi.FundingCall; | ||
using ResearchFi.Query; | ||
using Serilog; | ||
|
||
namespace CSC.PublicApi.Interface.Controllers; | ||
|
||
[ApiController] | ||
[ApiVersion(ApiConstants.ApiVersion1)] | ||
[Route("v{version:apiVersion}/funding-calls-export")] | ||
public class FundingCallExportController : ControllerBase | ||
{ | ||
private readonly ILogger<FundingCallExportController> _logger; | ||
private readonly IFundingCallService _service; | ||
private readonly IDiagnosticContext _diagnosticContext; | ||
|
||
public FundingCallExportController( | ||
ILogger<FundingCallExportController> logger, | ||
IFundingCallService service, | ||
IDiagnosticContext diagnosticContext) | ||
{ | ||
_logger = logger; | ||
_service = service; | ||
_diagnosticContext = diagnosticContext; | ||
_diagnosticContext.Set(ApiConstants.LogResourceType_PropertyName, ApiConstants.LogResourceType_FundingCall); | ||
} | ||
|
||
/// <summary> | ||
/// Endpoint for bypassing the limit of 10000 records for funding calls. | ||
/// </summary> | ||
/// <param name="fundingCallQueryParameters">The query parameters for filtering the results.</param> | ||
/// <returns>Paged search result as a collection of <see cref="FundingCall"/> objects.</returns> | ||
/// <response code="200">Ok.</response> | ||
/// <response code="401">Unauthorized.</response> | ||
/// <response code="403">Forbidden.</response> | ||
[HttpGet(Name = "GetFundingCallExport")] | ||
[MapToApiVersion(ApiConstants.ApiVersion1)] | ||
[Authorize(Policy = ApiPolicies.FundingCall.Read)] | ||
[Produces(ApiConstants.ContentTypeJson)] | ||
[Consumes(ApiConstants.ContentTypeJson)] | ||
[ProducesResponseType(typeof(IEnumerable<FundingCall>), StatusCodes.Status200OK)] | ||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] | ||
[ProducesResponseType(typeof(void),StatusCodes.Status403Forbidden)] | ||
public async Task<IEnumerable<FundingCall>> Get([FromQuery] GetFundingCallQueryParameters fundingCallQueryParameters, [FromQuery] SearchAfterQueryParameters searchAfterQueryParameters) | ||
{ | ||
var (fundingCalls, searchAfterResult) = await _service.GetFundingCallsSearchAfter(fundingCallQueryParameters, searchAfterQueryParameters); | ||
|
||
ResponseHelper.AddPaginationResponseHeadersSearchAfter(HttpContext, searchAfterResult); | ||
|
||
return fundingCalls; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.