-
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 #165 from CSCfi/CSCTTV-3986-3987-3988-3994-3995-39…
…98-search-after-endpoints CSCTTV 3986 3987 3988 3994 3995 3998 export endpoints
- Loading branch information
Showing
38 changed files
with
518 additions
and
69 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
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
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
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
56 changes: 56 additions & 0 deletions
56
aspnetcore/src/Interface/Controllers/FundingDecisionExportController.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,56 @@ | ||
using CSC.PublicApi.Interface.Services; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using ResearchFi.FundingDecision; | ||
using ResearchFi.Query; | ||
using Serilog; | ||
|
||
namespace CSC.PublicApi.Interface.Controllers; | ||
|
||
[ApiController] | ||
[ApiVersion(ApiVersion)] | ||
[Route("v{version:apiVersion}/funding-decisions-export")] | ||
|
||
public class FundingDecisionExportController : ControllerBase | ||
{ | ||
private const string ApiVersion = "1.0"; | ||
private readonly ILogger<FundingDecisionExportController> _logger; | ||
private readonly IFundingDecisionService _service; | ||
private readonly IDiagnosticContext _diagnosticContext; | ||
|
||
public FundingDecisionExportController( | ||
ILogger<FundingDecisionExportController> logger, | ||
IFundingDecisionService service, | ||
IDiagnosticContext diagnosticContext) | ||
{ | ||
_logger = logger; | ||
_service = service; | ||
_diagnosticContext = diagnosticContext; | ||
_diagnosticContext.Set(ApiConstants.LogResourceType_PropertyName, ApiConstants.LogResourceType_FundingDecision); | ||
} | ||
|
||
/// <summary> | ||
/// Endpoint for bypassing the limit of 10000 records for funding decisions. | ||
/// </summary> | ||
/// <param name="fundingDecisionQueryParameters">The query parameters for filtering the results.</param> | ||
/// <returns>Paged search result as a collection of <see cref="FundingDecision"/> objects.</returns> | ||
/// <response code="200">Ok.</response> | ||
/// <response code="401">Unauthorized.</response> | ||
/// <response code="403">Forbidden.</response> | ||
[HttpGet(Name = "GetFundingDecisionExport")] | ||
[MapToApiVersion(ApiVersion)] | ||
[Authorize(Policy = ApiPolicies.FundingDecision.Read)] | ||
[Produces(ApiConstants.ContentTypeJson)] | ||
[Consumes(ApiConstants.ContentTypeJson)] | ||
[ProducesResponseType(typeof(IEnumerable<FundingDecision>), StatusCodes.Status200OK)] | ||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] | ||
[ProducesResponseType(typeof(void),StatusCodes.Status403Forbidden)] | ||
public async Task<IEnumerable<FundingDecision>> Get([FromQuery] GetFundingDecisionQueryParameters fundingDecisionQueryParameters, [FromQuery] SearchAfterQueryParameters searchAfterQueryParameters) | ||
{ | ||
var (fundingDecisions, searchAfterResult) = await _service.GetFundingDecisionsSearchAfter(fundingDecisionQueryParameters, searchAfterQueryParameters); | ||
|
||
ResponseHelper.AddPaginationResponseHeadersSearchAfter(HttpContext, searchAfterResult); | ||
|
||
return fundingDecisions; | ||
} | ||
} |
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
Oops, something went wrong.