diff --git a/paket.dependencies b/paket.dependencies index 03c392d1..7a68bcc5 100644 --- a/paket.dependencies +++ b/paket.dependencies @@ -24,8 +24,8 @@ nuget Be.Vlaanderen.Basisregisters.StreetNameRegistry.Api.Oslo 4.5.1 c nuget Be.Vlaanderen.Basisregisters.StreetNameRegistry.Api.BackOffice.Abstractions 4.5.1 copy_content_to_output_dir: always nuget Be.Vlaanderen.Basisregisters.BuildingRegistry.Api.Oslo 4.10.1 copy_content_to_output_dir: always nuget Be.Vlaanderen.Basisregisters.BuildingRegistry.Api.BackOffice.Abstractions 4.10.1 copy_content_to_output_dir: always -nuget Be.Vlaanderen.Basisregisters.AddressRegistry.Api.Oslo 4.7.0 copy_content_to_output_dir: always -nuget Be.Vlaanderen.Basisregisters.AddressRegistry.Api.BackOffice.Abstractions 4.7.0 copy_content_to_output_dir: always +nuget Be.Vlaanderen.Basisregisters.AddressRegistry.Api.Oslo 4.17.0 copy_content_to_output_dir: always +nuget Be.Vlaanderen.Basisregisters.AddressRegistry.Api.BackOffice.Abstractions 4.17.0 copy_content_to_output_dir: always nuget Be.Vlaanderen.Basisregisters.ParcelRegistry.Api.Oslo 5.5.3 copy_content_to_output_dir: always nuget Be.Vlaanderen.Basisregisters.ParcelRegistry.Api.BackOffice.Abstractions 5.5.3 copy_content_to_output_dir: always nuget Be.Vlaanderen.Basisregisters.RoadRegistry.BackOffice 4.3.0 copy_content_to_output_dir: always @@ -40,11 +40,11 @@ nuget Be.Vlaanderen.Basisregisters.AggregateSource.ExplicitRouting 9.0.1 nuget Be.Vlaanderen.Basisregisters.Auth.AcmIdm 2.0.0 nuget Be.Vlaanderen.Basisregisters.Api 23.1.0 -nuget Be.Vlaanderen.Basisregisters.GrAr.Common 21.7.0 -nuget Be.Vlaanderen.Basisregisters.GrAr.Edit 21.7.0 -nuget Be.Vlaanderen.Basisregisters.GrAr.Legacy 21.7.0 -nuget Be.Vlaanderen.Basisregisters.GrAr.Provenance 21.7.0 -nuget Be.Vlaanderen.Basisregisters.GrAr.Import 21.7.0 +nuget Be.Vlaanderen.Basisregisters.GrAr.Common 21.14.1 +nuget Be.Vlaanderen.Basisregisters.GrAr.Edit 21.14.1 +nuget Be.Vlaanderen.Basisregisters.GrAr.Legacy 21.14.1 +nuget Be.Vlaanderen.Basisregisters.GrAr.Provenance 21.14.1 +nuget Be.Vlaanderen.Basisregisters.GrAr.Import 21.14.1 nuget Be.Vlaanderen.Basisregisters.EventHandling 5.0.0 nuget Be.Vlaanderen.Basisregisters.ProblemDetails 9.0.0 diff --git a/paket.lock b/paket.lock index e95c0b80..f4d9e5db 100644 --- a/paket.lock +++ b/paket.lock @@ -42,11 +42,11 @@ NUGET System.Security.Cryptography.ProtectedData (>= 4.7) System.Text.Json (>= 4.7.2) System.Threading.Tasks.Extensions (>= 4.5.4) - Be.Vlaanderen.Basisregisters.AddressRegistry.Api.BackOffice.Abstractions (4.7) - copy_content_to_output_dir: always + Be.Vlaanderen.Basisregisters.AddressRegistry.Api.BackOffice.Abstractions (4.17) - copy_content_to_output_dir: always Be.Vlaanderen.Basisregisters.Api (>= 23.1) MediatR.Contracts (>= 2.0.1) - Be.Vlaanderen.Basisregisters.AddressRegistry.Api.Oslo (4.7) - copy_content_to_output_dir: always - Be.Vlaanderen.Basisregisters.GrAr.Legacy (>= 21.5) + Be.Vlaanderen.Basisregisters.AddressRegistry.Api.Oslo (4.17) - copy_content_to_output_dir: always + Be.Vlaanderen.Basisregisters.GrAr.Legacy (>= 21.14.1) MediatR.Contracts (>= 2.0.1) Be.Vlaanderen.Basisregisters.AggregateSource (9.0.1) Be.Vlaanderen.Basisregisters.Utilities.HashCodeCalculator (>= 4.0) @@ -210,14 +210,14 @@ NUGET Autofac.Extensions.DependencyInjection (>= 9.0) Be.Vlaanderen.Basisregisters.EventHandling (5.0) Be.Vlaanderen.Basisregisters.Generators.Guid.Deterministic (4.0) - Be.Vlaanderen.Basisregisters.GrAr.Common (21.7) + Be.Vlaanderen.Basisregisters.GrAr.Common (21.14.1) Be.Vlaanderen.Basisregisters.AggregateSource (>= 9.0.1) Be.Vlaanderen.Basisregisters.CommandHandling (>= 9.0.1) NetTopologySuite (>= 2.5) NodaTime (>= 3.1.11) - Be.Vlaanderen.Basisregisters.GrAr.Edit (21.7) + Be.Vlaanderen.Basisregisters.GrAr.Edit (21.14.1) NetTopologySuite (>= 2.5) - Be.Vlaanderen.Basisregisters.GrAr.Import (21.7) + Be.Vlaanderen.Basisregisters.GrAr.Import (21.14.1) Autofac (>= 8.0) Be.Vlaanderen.Basisregisters.AggregateSource.SqlStreamStore (>= 9.0.1) Be.Vlaanderen.Basisregisters.CommandHandling (>= 9.0.1) @@ -232,14 +232,14 @@ NUGET Serilog (>= 3.1.1) Serilog.Extensions.Logging (>= 8.0) System.Threading.Tasks.Dataflow (>= 8.0) - Be.Vlaanderen.Basisregisters.GrAr.Legacy (21.7) - Be.Vlaanderen.Basisregisters.GrAr.Common (21.7) + Be.Vlaanderen.Basisregisters.GrAr.Legacy (21.14.1) + Be.Vlaanderen.Basisregisters.GrAr.Common (21.14.1) Be.Vlaanderen.Basisregisters.Utilities.Rfc3339DateTimeOffset (>= 4.0) Newtonsoft.Json (>= 13.0.3) - Be.Vlaanderen.Basisregisters.GrAr.Provenance (21.7) + Be.Vlaanderen.Basisregisters.GrAr.Provenance (21.14.1) Be.Vlaanderen.Basisregisters.CommandHandling (>= 9.0.1) Be.Vlaanderen.Basisregisters.Crab (>= 4.0) - Be.Vlaanderen.Basisregisters.GrAr.Common (21.7) + Be.Vlaanderen.Basisregisters.GrAr.Common (21.14.1) Microsoft.CSharp (>= 4.7) Be.Vlaanderen.Basisregisters.IntegrationDb.SuspiciousCases.Api.Abstractions (2.1) - copy_content_to_output_dir: always Be.Vlaanderen.Basisregisters.Api (>= 23.1) diff --git a/src/Common/Infrastructure/EndpointType.cs b/src/Common/Infrastructure/EndpointType.cs index 26472a53..2fcb777f 100644 --- a/src/Common/Infrastructure/EndpointType.cs +++ b/src/Common/Infrastructure/EndpointType.cs @@ -5,6 +5,7 @@ public enum EndpointType Legacy, Sync, BackOffice, - Oslo + Oslo, + Json } } diff --git a/src/Common/Infrastructure/FeatureToggles.cs b/src/Common/Infrastructure/FeatureToggles.cs index b977f36c..dadf700e 100644 --- a/src/Common/Infrastructure/FeatureToggles.cs +++ b/src/Common/Infrastructure/FeatureToggles.cs @@ -219,6 +219,13 @@ public class CorrectRemovalAddressToggle : IFeatureToggle public CorrectRemovalAddressToggle(bool featureEnabled) => FeatureEnabled = featureEnabled; } + public class SearchAddressesToggle : IFeatureToggle + { + public bool FeatureEnabled { get; } + + public SearchAddressesToggle(bool featureEnabled) => FeatureEnabled = featureEnabled; + } + public class ReaddressStreetNameAddressesToggle : IFeatureToggle { public bool FeatureEnabled { get; } diff --git a/src/Public.Api/Address/Oslo/AddressController-AddressMatch.cs b/src/Public.Api/Address/Oslo/AddressController-AddressMatch.cs index d7de2910..a9cae1fe 100644 --- a/src/Public.Api/Address/Oslo/AddressController-AddressMatch.cs +++ b/src/Public.Api/Address/Oslo/AddressController-AddressMatch.cs @@ -6,6 +6,8 @@ namespace Public.Api.Address.Oslo using AddressRegistry.Api.Oslo.AddressMatch.Responses; using Be.Vlaanderen.Basisregisters.Api.Exceptions; using Be.Vlaanderen.Basisregisters.GrAr.Legacy; + using Common.Infrastructure; + using Common.Infrastructure.Controllers.Attributes; using Infrastructure; using Infrastructure.Swagger; using Microsoft.AspNetCore.Http; @@ -39,6 +41,7 @@ public partial class AddressOsloController /// Als er een interne fout is opgetreden. [HttpGet("adresmatch", Name = nameof(AddressMatchV2))] [ApiOrder(ApiOrder.Address.V2 + 4)] + [ApiProduces(EndpointType.Oslo)] [ProducesResponseType(typeof(AddressMatchOsloCollection), StatusCodes.Status200OK)] [ProducesResponseType(typeof(Be.Vlaanderen.Basisregisters.BasicApiProblem.ValidationProblemDetails), StatusCodes.Status400BadRequest)] [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status403Forbidden)] diff --git a/src/Public.Api/Address/Oslo/AddressController-Count.cs b/src/Public.Api/Address/Oslo/AddressController-Count.cs index 690c3035..80d279b8 100644 --- a/src/Public.Api/Address/Oslo/AddressController-Count.cs +++ b/src/Public.Api/Address/Oslo/AddressController-Count.cs @@ -7,6 +7,7 @@ namespace Public.Api.Address.Oslo using Be.Vlaanderen.Basisregisters.Api.Exceptions; using Be.Vlaanderen.Basisregisters.GrAr.Legacy; using Common.Infrastructure; + using Common.Infrastructure.Controllers.Attributes; using Infrastructure; using Infrastructure.Swagger; using Marvin.Cache.Headers; @@ -38,6 +39,7 @@ public partial class AddressOsloController /// Als er een interne fout is opgetreden. [HttpGet("adressen/totaal-aantal", Name = nameof(CountAddressesV2))] [ApiOrder(ApiOrder.Address.V2 + 3)] + [ApiProduces(EndpointType.Oslo)] [ApiExplorerSettings(IgnoreApi = true)] [ProducesResponseType(typeof(TotaalAantalResponse), StatusCodes.Status200OK)] [ProducesResponseType(typeof(Be.Vlaanderen.Basisregisters.BasicApiProblem.ValidationProblemDetails), StatusCodes.Status400BadRequest)] diff --git a/src/Public.Api/Address/Oslo/AddressController-Get.cs b/src/Public.Api/Address/Oslo/AddressController-Get.cs index 347c521b..d530dbca 100644 --- a/src/Public.Api/Address/Oslo/AddressController-Get.cs +++ b/src/Public.Api/Address/Oslo/AddressController-Get.cs @@ -6,6 +6,7 @@ namespace Public.Api.Address.Oslo using Be.Vlaanderen.Basisregisters.Api.ETag; using Be.Vlaanderen.Basisregisters.Api.Exceptions; using Common.Infrastructure; + using Common.Infrastructure.Controllers.Attributes; using Infrastructure; using Infrastructure.Swagger; using Marvin.Cache.Headers; @@ -36,6 +37,7 @@ public partial class AddressOsloController /// Als er een interne fout is opgetreden. [HttpGet("adressen/{objectId}", Name = nameof(GetAddressV2))] [ApiOrder(ApiOrder.Address.V2 + 1)] + [ApiProduces(EndpointType.Oslo)] [ProducesResponseType(typeof(AddressDetailOsloResponse), StatusCodes.Status200OK)] [ProducesResponseType(typeof(void), StatusCodes.Status304NotModified)] [ProducesResponseType(typeof(Be.Vlaanderen.Basisregisters.BasicApiProblem.ValidationProblemDetails), StatusCodes.Status400BadRequest)] diff --git a/src/Public.Api/Address/Oslo/AddressController-List.cs b/src/Public.Api/Address/Oslo/AddressController-List.cs index c6091cd3..dc0b8c69 100644 --- a/src/Public.Api/Address/Oslo/AddressController-List.cs +++ b/src/Public.Api/Address/Oslo/AddressController-List.cs @@ -7,6 +7,7 @@ namespace Public.Api.Address.Oslo using Be.Vlaanderen.Basisregisters.Api.Exceptions; using Be.Vlaanderen.Basisregisters.GrAr.Legacy; using Common.Infrastructure; + using Common.Infrastructure.Controllers.Attributes; using Infrastructure; using Infrastructure.Configuration; using Infrastructure.Swagger; @@ -51,6 +52,7 @@ public partial class AddressOsloController /// Als er een interne fout is opgetreden. [HttpGet("adressen", Name = nameof(ListAddressesV2))] [ApiOrder(ApiOrder.Address.V2 + 2)] + [ApiProduces(EndpointType.Oslo)] [ProducesResponseType(typeof(AddressListOsloResponse), StatusCodes.Status200OK)] [ProducesResponseType(typeof(Be.Vlaanderen.Basisregisters.BasicApiProblem.ValidationProblemDetails), StatusCodes.Status400BadRequest)] [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status403Forbidden)] diff --git a/src/Public.Api/Address/Oslo/AddressController-Search.cs b/src/Public.Api/Address/Oslo/AddressController-Search.cs new file mode 100644 index 00000000..759bf09f --- /dev/null +++ b/src/Public.Api/Address/Oslo/AddressController-Search.cs @@ -0,0 +1,106 @@ +namespace Public.Api.Address.Oslo +{ + using System.Threading; + using System.Threading.Tasks; + using AddressRegistry.Api.Oslo.Address.Search; + using Be.Vlaanderen.Basisregisters.Api.Exceptions; + using Common.Infrastructure; + using Common.Infrastructure.Controllers.Attributes; + 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; + + public partial class AddressOsloController + { + private const int MaxSearchLimit = 50; + private const int DefaultSearchLimit = 10; + + /// + /// Zoeken naar adressen of straatnamen via een query. + /// + /// De zoek query. + /// Limiteer de zoek query in een te zoeken gemeente- of postnaam (optioneel). + /// Aantal instanties dat teruggegeven wordt. Maximaal kunnen er 50 worden teruggegeven. Wanneer limit niet wordt meegegeven dan default 10 instanties (optioneel). + /// + /// + /// + /// + /// Als de opvraging van de zoekopdracht gelukt is. + /// Als uw verzoek foutieve data bevat. + /// Als u niet beschikt over de correcte rechten om deze actie uit te voeren. + /// Als het gevraagde formaat niet beschikbaar is. + /// Als het aantal requests per seconde de limiet overschreven heeft. + /// Als er een interne fout is opgetreden. + [HttpGet("adressen/zoeken", Name = nameof(SearchAddresses))] + [ApiOrder(ApiOrder.Address.V2 + 5)] + [ApiProduces(EndpointType.Json)] + [ProducesResponseType(typeof(AddressSearchResponse), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(Be.Vlaanderen.Basisregisters.BasicApiProblem.ValidationProblemDetails), StatusCodes.Status400BadRequest)] + [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status403Forbidden)] + [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status429TooManyRequests)] + [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)] + [SwaggerResponseHeader(StatusCodes.Status200OK, "ETag", "string", "De ETag van de response.")] + [SwaggerResponseHeader(StatusCodes.Status200OK, "x-correlation-id", "string", "Correlatie identificator van de response.")] + [SwaggerResponseExample(StatusCodes.Status200OK, typeof(AddressSearchResponseExamples))] + [SwaggerResponseExample(StatusCodes.Status400BadRequest, typeof(BadRequestResponseExamplesV2))] + [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 SearchAddresses( + [FromQuery] string? query, + [FromQuery] string? municipalityOrPostalName, + [FromQuery] int? limit, + [FromServices] SearchAddressesToggle searchAddressesToggle, + [FromServices] IActionContextAccessor actionContextAccessor, + [FromServices] IOptions responseOptions, + CancellationToken cancellationToken = default) + { + if (!searchAddressesToggle.FeatureEnabled) + { + return NotFound(); + } + + limit = int.Max(MaxSearchLimit, limit ?? DefaultSearchLimit); + var contentFormat = DetermineFormat(actionContextAccessor.ActionContext); + + RestRequest BackendRequest() => CreateBackendListRequest( + limit, + query, + municipalityOrPostalName); + + var value = await GetFromBackendAsync( + contentFormat.ContentType, + BackendRequest, + CreateDefaultHandleBadRequest(), + cancellationToken); + + return BackendListResponseResult.Create(value, Request.Query, responseOptions.Value.VolgendeUrl); + } + + private static RestRequest CreateBackendListRequest( + int? limit, + string? query, + string? municipalityOrPostalName) + { + var filter = new AddressSearchFilter + { + Query = query, + MunicipalityOrPostalName = municipalityOrPostalName + }; + + return new RestRequest("adressen/zoeken") + .AddPagination(0, limit) + .AddFiltering(filter); + } + } +} diff --git a/src/Public.Api/Address/Oslo/AddressOsloController.cs b/src/Public.Api/Address/Oslo/AddressOsloController.cs index 05a7b332..ce4cb68c 100755 --- a/src/Public.Api/Address/Oslo/AddressOsloController.cs +++ b/src/Public.Api/Address/Oslo/AddressOsloController.cs @@ -5,7 +5,6 @@ namespace Public.Api.Address.Oslo using Be.Vlaanderen.Basisregisters.Api; using Common.Infrastructure; using Common.Infrastructure.Controllers; - using Common.Infrastructure.Controllers.Attributes; using FeatureToggle; using Infrastructure.Configuration; using Infrastructure.Swagger; @@ -20,7 +19,6 @@ namespace Public.Api.Address.Oslo [AdvertiseApiVersions(Version.V2)] [ApiRoute("")] [ApiExplorerSettings(GroupName = "Adressen")] - [ApiProduces(EndpointType.Oslo)] public partial class AddressOsloController : RegistryApiController { protected override string NotFoundExceptionMessage => "Onbestaand adres."; diff --git a/src/Public.Api/Infrastructure/Configuration/FeatureToggleOptions.cs b/src/Public.Api/Infrastructure/Configuration/FeatureToggleOptions.cs index f8059cbe..3335ff12 100644 --- a/src/Public.Api/Infrastructure/Configuration/FeatureToggleOptions.cs +++ b/src/Public.Api/Infrastructure/Configuration/FeatureToggleOptions.cs @@ -37,6 +37,7 @@ public class FeatureToggleOptions public bool CorrectRegularizationAddress { get; set; } public bool CorrectDeregulationAddress { get; set; } public bool CorrectRemovalAddress { get; set; } + public bool SearchAddresses { get; set; } public bool ReaddressStreetNameAddresses { get; set; } public bool PlanBuilding { get; set; } diff --git a/src/Public.Api/Infrastructure/Startup.cs b/src/Public.Api/Infrastructure/Startup.cs index 0ac7310b..09d57820 100644 --- a/src/Public.Api/Infrastructure/Startup.cs +++ b/src/Public.Api/Infrastructure/Startup.cs @@ -351,6 +351,7 @@ public IServiceProvider ConfigureServices(IServiceCollection services) .AddSingleton(c => new CorrectRegularizationAddressToggle(c.GetRequiredService>().Value.CorrectRegularizationAddress)) .AddSingleton(c => new CorrectDeregulationAddressToggle(c.GetRequiredService>().Value.CorrectDeregulationAddress)) .AddSingleton(c => new CorrectRemovalAddressToggle(c.GetRequiredService>().Value.CorrectRemovalAddress)) + .AddSingleton(c => new SearchAddressesToggle(c.GetRequiredService>().Value.SearchAddresses)) .AddSingleton(c => new ReaddressStreetNameAddressesToggle(c.GetRequiredService>().Value.ReaddressStreetNameAddresses)) .AddSingleton(c => new PlanBuildingToggle(c.GetRequiredService>().Value.PlanBuilding)) diff --git a/src/Public.Api/appsettings.json b/src/Public.Api/appsettings.json index 45210c7f..cdbb9903 100755 --- a/src/Public.Api/appsettings.json +++ b/src/Public.Api/appsettings.json @@ -443,6 +443,7 @@ "CorrectDeregulationAddress": false, "CorrectRemovalAddress": false, "ReaddressStreetNameAddresses": false, + "SearchAddresses": false, "PlanBuilding": false, "MergeBuilding": false,