-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
304 additions
and
4 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
9 changes: 9 additions & 0 deletions
9
src/Public.Api/Infrastructure/Configuration/SuspiciousCasesOptionsV2.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,9 @@ | ||
namespace Public.Api.Infrastructure.Configuration | ||
{ | ||
using Basisregisters.IntegrationDb.SuspiciousCases.Api.Abstractions; | ||
|
||
public class SuspiciousCasesOptionsV2 : ResponseOptions, IRegistryOptions | ||
{ | ||
public SyndicationOptions Syndication { get; set; } | ||
} | ||
} |
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
116 changes: 116 additions & 0 deletions
116
src/Public.Api/SuspiciousCases/SuspiciousCasesController-Detail.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,116 @@ | ||
namespace Public.Api.SuspiciousCases | ||
{ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Basisregisters.IntegrationDb.SuspiciousCases.Api.Abstractions.Detail; | ||
using Be.Vlaanderen.Basisregisters.Api.Exceptions; | ||
using Common.Infrastructure; | ||
using Common.Infrastructure.Extensions; | ||
using Infrastructure; | ||
using Infrastructure.Configuration; | ||
using Infrastructure.Swagger; | ||
using Marvin.Cache.Headers; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.Infrastructure; | ||
using Microsoft.Extensions.Options; | ||
using RestSharp; | ||
using Swashbuckle.AspNetCore.Filters; | ||
using ProblemDetails = Be.Vlaanderen.Basisregisters.BasicApiProblem.ProblemDetails; | ||
using ValidationProblemDetails = Be.Vlaanderen.Basisregisters.BasicApiProblem.ValidationProblemDetails; | ||
|
||
public partial class SuspiciousCasesController | ||
{ | ||
/// <summary> | ||
/// Vraag een verdacht geval op. | ||
/// </summary> | ||
/// <param name="type">Het type van het verdachte geval.</param> | ||
/// <param name="offset">Nulgebaseerde index van de eerste instantie die teruggegeven wordt.</param> | ||
/// <param name="limit">Aantal instanties dat teruggegeven wordt.</param> | ||
/// <param name="nisCode">Filter op de NIS-code van het verdacht geval.</param> | ||
/// <param name="actionContextAccessor"></param> | ||
/// <param name="problemDetailsHelper"></param> | ||
/// <param name="responseOptions"></param> | ||
/// <param name="suspiciousCasesToggle"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <response code="200">Als de opvraging van het verdacht geval gelukt is.</response> | ||
/// <response code="400">Als uw verzoek foutieve data bevat.</response> | ||
/// <response code="401">Als u niet geauthenticeerd bent om deze actie uit te voeren.</response> | ||
/// <response code="403">Als u niet beschikt over de correcte rechten om deze actie uit te voeren.</response> | ||
/// <response code="406">Als het gevraagde formaat niet beschikbaar is.</response> | ||
/// <response code="429">Als het aantal requests per seconde de limiet overschreven heeft.</response> | ||
/// <response code="500">Als er een interne fout is opgetreden.</response> | ||
[HttpGet("verdachte-gevallen/{type}", Name = nameof(DetailSuspiciousCases))] | ||
[ApiOrder(ApiOrder.SuspiciousCases + 2)] | ||
[ProducesResponseType(typeof(SuspiciousCasesDetailResponse), StatusCodes.Status200OK)] | ||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)] | ||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status401Unauthorized)] | ||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status403Forbidden)] | ||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status429TooManyRequests)] | ||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)] | ||
[SwaggerResponseExample(StatusCodes.Status200OK, typeof(SuspiciousCasesDetailResponseExample))] | ||
[SwaggerResponseExample(StatusCodes.Status400BadRequest, typeof(BadRequestResponseExamplesV2))] | ||
[SwaggerResponseExample(StatusCodes.Status401Unauthorized, typeof(UnauthorizedOAuthResponseExamplesV2))] | ||
[SwaggerResponseExample(StatusCodes.Status403Forbidden, typeof(ForbiddenResponseExamplesV2))] | ||
[SwaggerResponseExample(StatusCodes.Status429TooManyRequests, typeof(TooManyRequestsResponseExamplesV2))] | ||
[SwaggerResponseExample(StatusCodes.Status500InternalServerError, typeof(InternalServerErrorResponseExamplesV2))] | ||
[HttpCacheValidation(NoCache = true, MustRevalidate = true, ProxyRevalidate = true)] | ||
[HttpCacheExpiration(CacheLocation = CacheLocation.Private, MaxAge = DefaultListCaching, NoStore = true, NoTransform = true)] | ||
public async Task<IActionResult> DetailSuspiciousCases( | ||
[FromRoute] int type, | ||
[FromQuery] int? offset, | ||
[FromQuery] int? limit, | ||
[FromQuery] string nisCode, | ||
[FromServices] IActionContextAccessor actionContextAccessor, | ||
[FromServices] ProblemDetailsHelper problemDetailsHelper, | ||
[FromServices] IOptions<SuspiciousCasesOptionsV2> responseOptions, | ||
[FromServices] DetailSuspiciousCasesToggle suspiciousCasesToggle, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
if (!suspiciousCasesToggle.FeatureEnabled) | ||
{ | ||
return NotFound(); | ||
} | ||
|
||
var contentFormat = DetermineFormat(actionContextAccessor.ActionContext); | ||
|
||
RestRequest BackendRequest() => CreateBackendDetailRequest( | ||
type, | ||
offset, | ||
limit, | ||
nisCode, | ||
actionContextAccessor); | ||
|
||
var nextUrl = responseOptions.Value.SuspiciousCasesTypeNextUrl.Replace("{type}", type.ToString()); | ||
|
||
var value = await GetFromBackendWithBadRequestAsync( | ||
contentFormat.ContentType, | ||
BackendRequest, | ||
CreateDefaultHandleBadRequest(), | ||
problemDetailsHelper, | ||
cancellationToken: cancellationToken); | ||
|
||
|
||
return BackendListResponseResult.Create(value, Request.Query, nextUrl); | ||
} | ||
|
||
private static RestRequest CreateBackendDetailRequest( | ||
int type, | ||
int? offset, | ||
int? limit, | ||
string nisCode, | ||
IActionContextAccessor actionContextAccessor) | ||
{ | ||
var filter = new SuspiciousCasesDetailFilter | ||
{ | ||
NisCode = nisCode, | ||
}; | ||
|
||
return new RestRequest("verdachte-gevallen/{type}") | ||
.AddParameter("type", type, ParameterType.UrlSegment) | ||
.AddPagination(offset, limit) | ||
.AddFiltering(filter) | ||
.AddHeaderAuthorization(actionContextAccessor); | ||
} | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
src/Public.Api/SuspiciousCases/SuspiciousCasesController-List.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,95 @@ | ||
namespace Public.Api.SuspiciousCases | ||
{ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Basisregisters.IntegrationDb.SuspiciousCases.Api.Abstractions.List; | ||
using Be.Vlaanderen.Basisregisters.Api.Exceptions; | ||
using Common.Infrastructure; | ||
using Common.Infrastructure.Extensions; | ||
using Infrastructure; | ||
using Infrastructure.Swagger; | ||
using Marvin.Cache.Headers; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.Infrastructure; | ||
using RestSharp; | ||
using Swashbuckle.AspNetCore.Filters; | ||
using ProblemDetails = Be.Vlaanderen.Basisregisters.BasicApiProblem.ProblemDetails; | ||
using ValidationProblemDetails = Be.Vlaanderen.Basisregisters.BasicApiProblem.ValidationProblemDetails; | ||
|
||
public partial class SuspiciousCasesController | ||
{ | ||
/// <summary> | ||
/// Vraag een lijst met verdachte gevallen op. | ||
/// </summary> | ||
/// <param name="nisCode">Filter op de NIS-code van het verdachte geval.</param> | ||
/// <param name="actionContextAccessor"></param> | ||
/// <param name="problemDetailsHelper"></param> | ||
/// <param name="suspiciousCasesToggle"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <response code="200">Als de opvraging van een lijst met verdachte gevallen gelukt is.</response> | ||
/// <response code="400">Als uw verzoek foutieve data bevat.</response> | ||
/// <response code="401">Als u niet geauthenticeerd bent om deze actie uit te voeren.</response> | ||
/// <response code="403">Als u niet beschikt over de correcte rechten om deze actie uit te voeren.</response> | ||
/// <response code="406">Als het gevraagde formaat niet beschikbaar is.</response> | ||
/// <response code="429">Als het aantal requests per seconde de limiet overschreven heeft.</response> | ||
/// <response code="500">Als er een interne fout is opgetreden.</response> | ||
[HttpGet("verdachte-gevallen", Name = nameof(ListSuspiciousCases))] | ||
[ApiOrder(ApiOrder.SuspiciousCases + 1)] | ||
[ProducesResponseType(typeof(SuspiciousCasesListResponse), StatusCodes.Status200OK)] | ||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)] | ||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status401Unauthorized)] | ||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status403Forbidden)] | ||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status429TooManyRequests)] | ||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)] | ||
[SwaggerResponseExample(StatusCodes.Status200OK, typeof(SuspiciousCasesListResponseExample))] | ||
[SwaggerResponseExample(StatusCodes.Status400BadRequest, typeof(BadRequestResponseExamplesV2))] | ||
[SwaggerResponseExample(StatusCodes.Status401Unauthorized, typeof(UnauthorizedOAuthResponseExamplesV2))] | ||
[SwaggerResponseExample(StatusCodes.Status403Forbidden, typeof(ForbiddenResponseExamplesV2))] | ||
[SwaggerResponseExample(StatusCodes.Status429TooManyRequests, typeof(TooManyRequestsResponseExamplesV2))] | ||
[SwaggerResponseExample(StatusCodes.Status500InternalServerError, typeof(InternalServerErrorResponseExamplesV2))] | ||
[HttpCacheValidation(NoCache = true, MustRevalidate = true, ProxyRevalidate = true)] | ||
[HttpCacheExpiration(CacheLocation = CacheLocation.Private, MaxAge = DefaultListCaching, NoStore = true, NoTransform = true)] | ||
public async Task<IActionResult> ListSuspiciousCases( | ||
[FromQuery] string nisCode, | ||
[FromServices] IActionContextAccessor actionContextAccessor, | ||
[FromServices] ProblemDetailsHelper problemDetailsHelper, | ||
[FromServices] ListSuspiciousCasesToggle suspiciousCasesToggle, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
if (!suspiciousCasesToggle.FeatureEnabled) | ||
{ | ||
return NotFound(); | ||
} | ||
|
||
var contentFormat = DetermineFormat(actionContextAccessor.ActionContext); | ||
|
||
RestRequest BackendRequest() => CreateBackendListRequest( | ||
nisCode, | ||
actionContextAccessor); | ||
|
||
var value = await GetFromBackendWithBadRequestAsync( | ||
contentFormat.ContentType, | ||
BackendRequest, | ||
CreateDefaultHandleBadRequest(), | ||
problemDetailsHelper, | ||
cancellationToken: cancellationToken); | ||
|
||
return new BackendResponseResult(value); | ||
} | ||
|
||
private static RestRequest CreateBackendListRequest( | ||
string nisCode, | ||
IActionContextAccessor actionContextAccessor) | ||
{ | ||
var filter = new SuspiciousCasesListFilter | ||
{ | ||
NisCode = nisCode, | ||
}; | ||
|
||
return new RestRequest("verdachte-gevallen") | ||
.AddFiltering(filter) | ||
.AddHeaderAuthorization(actionContextAccessor); | ||
} | ||
} | ||
} |
Oops, something went wrong.