Skip to content

Commit

Permalink
feat: add road presigned endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
jvandaal authored Jan 14, 2025
1 parent 1019a5d commit c629990
Show file tree
Hide file tree
Showing 10 changed files with 220 additions and 13 deletions.
6 changes: 3 additions & 3 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ nuget Be.Vlaanderen.Basisregisters.AddressRegistry.Api.Oslo
nuget Be.Vlaanderen.Basisregisters.AddressRegistry.Api.BackOffice.Abstractions 4.32.0 copy_content_to_output_dir: always
nuget Be.Vlaanderen.Basisregisters.ParcelRegistry.Api.Oslo 5.12.0 copy_content_to_output_dir: always
nuget Be.Vlaanderen.Basisregisters.ParcelRegistry.Api.BackOffice.Abstractions 5.12.0 copy_content_to_output_dir: always
nuget Be.Vlaanderen.Basisregisters.RoadRegistry.BackOffice 4.7.0 copy_content_to_output_dir: always
nuget Be.Vlaanderen.Basisregisters.RoadRegistry.BackOffice.Api 4.7.0 copy_content_to_output_dir: always
nuget Be.Vlaanderen.Basisregisters.RoadRegistry.BackOffice.Abstractions 4.7.0 copy_content_to_output_dir: always
nuget Be.Vlaanderen.Basisregisters.RoadRegistry.BackOffice 4.18.1 copy_content_to_output_dir: always
nuget Be.Vlaanderen.Basisregisters.RoadRegistry.BackOffice.Api 4.18.1 copy_content_to_output_dir: always
nuget Be.Vlaanderen.Basisregisters.RoadRegistry.BackOffice.Abstractions 4.18.1 copy_content_to_output_dir: always
nuget Be.Vlaanderen.Basisregisters.IntegrationDb.SuspiciousCases.Api.Abstractions 2.1.0 copy_content_to_output_dir: always

nuget Be.Vlaanderen.Basisregisters.Build.Pipeline 7.2.5
Expand Down
10 changes: 5 additions & 5 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ NUGET
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)
Be.Vlaanderen.Basisregisters.MessageHandling.AwsSqs.Simple (5.0.1) - copy_content_to_output_dir: always
Be.Vlaanderen.Basisregisters.MessageHandling.AwsSqs.Simple (5.2) - copy_content_to_output_dir: always
AWSSDK.Core (>= 3.7.302.15)
AWSSDK.SQS (>= 3.7.300.54)
Microsoft.Extensions.Logging (>= 8.0)
Expand All @@ -270,7 +270,7 @@ NUGET
CsvHelper (>= 31.0.2)
Be.Vlaanderen.Basisregisters.ProblemDetails (9.0)
System.Reflection.Metadata (>= 8.0)
Be.Vlaanderen.Basisregisters.RoadRegistry.BackOffice (4.7) - copy_content_to_output_dir: always
Be.Vlaanderen.Basisregisters.RoadRegistry.BackOffice (4.18.1) - copy_content_to_output_dir: always
Amazon.Lambda.Core (>= 2.2)
AWSSDK.DynamoDBv2 (>= 3.7.302)
Be.Vlaanderen.Basisregisters.AggregateSource (>= 9.0.1)
Expand All @@ -279,7 +279,7 @@ NUGET
Be.Vlaanderen.Basisregisters.EventHandling.Autofac (>= 5.0)
Be.Vlaanderen.Basisregisters.Generators.Guid.Deterministic (>= 4.0)
Be.Vlaanderen.Basisregisters.GrAr.Provenance (>= 21.14)
Be.Vlaanderen.Basisregisters.MessageHandling.AwsSqs.Simple (>= 5.0.1)
Be.Vlaanderen.Basisregisters.MessageHandling.AwsSqs.Simple (>= 5.2)
Be.Vlaanderen.Basisregisters.Shaperon (>= 10.0.2)
Be.Vlaanderen.Basisregisters.Shaperon.Geometries (>= 10.0.2)
DotSpatial.Projections (>= 4.0.656)
Expand All @@ -301,11 +301,11 @@ NUGET
Polly (>= 8.3.1)
SqlStreamStore (>= 1.2)
System.IdentityModel.Tokens.Jwt (>= 7.4.1)
Be.Vlaanderen.Basisregisters.RoadRegistry.BackOffice.Abstractions (4.7) - copy_content_to_output_dir: always
Be.Vlaanderen.Basisregisters.RoadRegistry.BackOffice.Abstractions (4.18.1) - copy_content_to_output_dir: always
Be.Vlaanderen.Basisregisters.BlobStore (>= 4.0)
MediatR.Contracts (>= 2.0.1)
Microsoft.Net.Http.Headers (>= 8.0.3)
Be.Vlaanderen.Basisregisters.RoadRegistry.BackOffice.Api (4.7) - copy_content_to_output_dir: always
Be.Vlaanderen.Basisregisters.RoadRegistry.BackOffice.Api (4.18.1) - copy_content_to_output_dir: always
AspNetCore.HealthChecks.SqlServer (>= 8.0)
AWSSDK.Core (>= 3.7.302.20)
Be.Vlaanderen.Basisregisters.Api (>= 23.1)
Expand Down
1 change: 1 addition & 0 deletions src/Public.Api/Infrastructure/Swagger/ApiOrder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public static class Road
public const int RoadUpload = ChangeFeed + 40;
public const int Organization = ChangeFeed + 50;
public const int RoadSegment = ChangeFeed + 60;
public const int RoadGrb = ChangeFeed + 70;
}

public const int Extract = Road.ChangeFeed + 100;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
namespace Public.Api.Road.Extracts
{
using System.Threading;
using System.Threading.Tasks;
using Be.Vlaanderen.Basisregisters.Api;
using Be.Vlaanderen.Basisregisters.Api.Exceptions;
using Common.Infrastructure.Controllers.Attributes;
using Infrastructure;
using Microsoft.AspNetCore.Mvc;
using RestSharp;
using RoadRegistry.BackOffice.Api.Extracts;
using System.Threading;
using System.Threading.Tasks;
using RoadRegistry.BackOffice.Abstractions.Extracts;

public partial class ExtractController
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ namespace Public.Api.Road.Extracts.V2
using Be.Vlaanderen.Basisregisters.Api;
using Be.Vlaanderen.Basisregisters.Api.Exceptions;
using Common.Infrastructure.Controllers.Attributes;
using Infrastructure;
using Microsoft.AspNetCore.Mvc;
using Public.Api.Infrastructure;
using RestSharp;
using RoadRegistry.BackOffice.Api.Extracts;
using RoadRegistry.BackOffice.Abstractions.Extracts;

public partial class ExtractControllerV2
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace Public.Api.Road.Extracts.V2
{
using System.Threading;
using System.Threading.Tasks;
using Be.Vlaanderen.Basisregisters.Api;
using Be.Vlaanderen.Basisregisters.Api.Exceptions;
using Common.Infrastructure.Controllers.Attributes;
using Common.Infrastructure.Extensions;
using Infrastructure;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using RestSharp;

public partial class ExtractControllerV2
{
[ApiKeyAuth("Road", AllowAuthorizationHeader = true)]
[HttpGet("wegen/extract/download/{downloadId}/presignedurl")]
public async Task<ActionResult> GetDownloadPreSignedUrlForExtract(
[FromRoute]string downloadId,
[FromServices] IActionContextAccessor actionContextAccessor,
[FromServices] ProblemDetailsHelper problemDetailsHelper,
CancellationToken cancellationToken = default)
{
var value = await GetFromBackendWithBadRequestAsync(
AcceptType.Json,
BackendRequest,
CreateDefaultHandleBadRequest(),
problemDetailsHelper,
cancellationToken: cancellationToken);

return new BackendResponseResult(value, BackendResponseResultOptions.ForBackOffice());

RestRequest BackendRequest() => new RestRequest("extracts/download/{downloadId}/presignedurl", Method.Get)
.AddParameter("downloadId", downloadId, ParameterType.UrlSegment)
.AddHeaderAuthorization(actionContextAccessor);
}
}
}
45 changes: 45 additions & 0 deletions src/Public.Api/Road/Grb/V2/GrbController-ExtractByContour.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
namespace Public.Api.Road.Grb.V2
{
using System.Threading;
using System.Threading.Tasks;
using Be.Vlaanderen.Basisregisters.Api;
using Be.Vlaanderen.Basisregisters.Api.Exceptions;
using Common.Infrastructure.Extensions;
using Infrastructure;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using RestSharp;
using RoadRegistry.BackOffice.Abstractions.Extracts;
using ProblemDetails = Be.Vlaanderen.Basisregisters.BasicApiProblem.ProblemDetails;

public partial class GrbControllerV2
{
[ProducesResponseType(typeof(DownloadExtractResponseBody), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status403Forbidden)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status429TooManyRequests)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)]
[HttpPost("wegen/grb/extracts/bycontour", Name = nameof(ExtractByContour))]
public async Task<IActionResult> ExtractByContour(
[FromBody] DownloadExtractRequestBody body,
[FromServices] IActionContextAccessor actionContextAccessor,
[FromServices] ProblemDetailsHelper problemDetailsHelper,
CancellationToken cancellationToken = default)
{
var value = await GetFromBackendWithBadRequestAsync(
AcceptType.Json,
BackendRequest,
CreateDefaultHandleBadRequest(),
problemDetailsHelper,
cancellationToken: cancellationToken);

return new BackendResponseResult(value, BackendResponseResultOptions.ForBackOffice());

RestRequest BackendRequest() => new RestRequest("grb/extracts/bycontour", Method.Post)
.AddJsonBodyOrEmpty(body)
.AddHeaderAuthorization(actionContextAccessor);
}
}
}
46 changes: 46 additions & 0 deletions src/Public.Api/Road/Grb/V2/GrbController-UploadForDownload.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
namespace Public.Api.Road.Grb.V2
{
using System.Threading;
using System.Threading.Tasks;
using Be.Vlaanderen.Basisregisters.Api;
using Be.Vlaanderen.Basisregisters.Api.Exceptions;
using Common.Infrastructure.Extensions;
using Infrastructure;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using RestSharp;
using RoadRegistry.BackOffice.Abstractions.Jobs;
using ProblemDetails = Be.Vlaanderen.Basisregisters.BasicApiProblem.ProblemDetails;

public partial class GrbControllerV2
{
[ProducesResponseType(typeof(GetPresignedUploadUrlResponse), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status403Forbidden)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status429TooManyRequests)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)]
[HttpPost("wegen/grb/download/{downloadId}/upload", Name = nameof(UploadForDownload))]
public async Task<IActionResult> UploadForDownload(
[FromRoute] string downloadId,
[FromServices] IActionContextAccessor actionContextAccessor,
[FromServices] ProblemDetailsHelper problemDetailsHelper,
CancellationToken cancellationToken = default)
{
var value = await GetFromBackendWithBadRequestAsync(
AcceptType.Json,
BackendRequest,
CreateDefaultHandleBadRequest(),
problemDetailsHelper,
cancellationToken: cancellationToken);

return new BackendResponseResult(value, BackendResponseResultOptions.ForBackOffice());

RestRequest BackendRequest() => new RestRequest("grb/download/{downloadId}/upload", Method.Post)
.AddParameter("downloadId", downloadId, ParameterType.UrlSegment)
.AddHeaderAuthorization(actionContextAccessor);
}
}
}
39 changes: 39 additions & 0 deletions src/Public.Api/Road/Grb/V2/GrbController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace Public.Api.Road.Grb.V2
{
using Asp.Versioning;
using Autofac.Features.AttributeFilters;
using Be.Vlaanderen.Basisregisters.Api;
using Common.Infrastructure;
using Common.Infrastructure.Controllers.Attributes;
using FeatureToggle;
using Infrastructure.Configuration;
using Infrastructure.Swagger;
using Infrastructure.Version;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.Extensions.Logging;
using RestSharp;

[ApiVersion(Version.V2)]
[AdvertiseApiVersions(Version.CurrentAdvertised)]
[ApiRoute("")]
[ApiExplorerSettings(GroupName = "Grb")]
[ApiOrder(ApiOrder.Road.RoadGrb)]
[ApiKeyAuth("Road", AllowAuthorizationHeader = true)]
public partial class GrbControllerV2 : RoadRegistryApiController<GrbControllerV2>
{
protected override string NotFoundExceptionMessage => "Onbestaande upload.";
protected override string GoneExceptionMessage => "Verwijderde upload.";

public GrbControllerV2(
IHttpContextAccessor httpContextAccessor,
IActionContextAccessor actionContextAccessor,
[KeyFilter(RegistryKeys.Road)] RestClient restClient,
[KeyFilter(RegistryKeys.Road)] IFeatureToggle cacheToggle,
ConnectionMultiplexerProvider redis,
ILogger<GrbControllerV2> logger)
: base(httpContextAccessor, redis, logger, restClient, cacheToggle, actionContextAccessor)
{ }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace Public.Api.Road.Uploads.V2
{
using System.Threading;
using System.Threading.Tasks;
using Be.Vlaanderen.Basisregisters.Api;
using Be.Vlaanderen.Basisregisters.Api.Exceptions;
using Common.Infrastructure.Controllers.Attributes;
using Common.Infrastructure.Extensions;
using Infrastructure;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using RestSharp;

public partial class UploadControllerV2
{
[ApiKeyAuth("Road", AllowAuthorizationHeader = true)]
[HttpGet("wegen/upload/{identifier}/presignedurl")]
public async Task<ActionResult> GetDownloadPreSignedUrlForUpload(
[FromRoute]string identifier,
[FromServices] IActionContextAccessor actionContextAccessor,
[FromServices] ProblemDetailsHelper problemDetailsHelper,
CancellationToken cancellationToken = default)
{
var value = await GetFromBackendWithBadRequestAsync(
AcceptType.Json,
BackendRequest,
CreateDefaultHandleBadRequest(),
problemDetailsHelper,
cancellationToken: cancellationToken);

return new BackendResponseResult(value, BackendResponseResultOptions.ForBackOffice());

RestRequest BackendRequest() => new RestRequest("upload/{identifier}/presignedurl", Method.Get)
.AddParameter("identifier", identifier, ParameterType.UrlSegment)
.AddHeaderAuthorization(actionContextAccessor);
}
}
}

0 comments on commit c629990

Please sign in to comment.