Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add road individual endpoint toggles #884

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions src/Common/FeatureToggles/RoadToggles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,121 @@ public RoadJobsToggle(IDynamicFeatureToggleService? dynamicFeatureToggleService)
: base(dynamicFeatureToggleService)
{ }
}

public sealed class RoadDownloadGetForEditorToggle : KeyedFeatureToggleBase, IKeyedFeatureToggle
{
public override string Key => "RoadDownloadGetForEditor";

public RoadDownloadGetForEditorToggle(IDynamicFeatureToggleService? dynamicFeatureToggleService)
: base(dynamicFeatureToggleService)
{ }
}

public sealed class RoadDownloadGetForProductToggle : KeyedFeatureToggleBase, IKeyedFeatureToggle
{
public override string Key => "RoadDownloadGetForProduct";

public RoadDownloadGetForProductToggle(IDynamicFeatureToggleService? dynamicFeatureToggleService)
: base(dynamicFeatureToggleService)
{ }
}

public sealed class RoadExtractCreateJobToggle : KeyedFeatureToggleBase, IKeyedFeatureToggle
{
public override string Key => "RoadExtractCreateJob";

public RoadExtractCreateJobToggle(IDynamicFeatureToggleService? dynamicFeatureToggleService)
: base(dynamicFeatureToggleService)
{ }
}

public sealed class RoadExtractDownloadRequestsToggle : KeyedFeatureToggleBase, IKeyedFeatureToggle
{
public override string Key => "RoadExtractDownloadRequests";

public RoadExtractDownloadRequestsToggle(IDynamicFeatureToggleService? dynamicFeatureToggleService)
: base(dynamicFeatureToggleService)
{ }
}

public sealed class RoadExtractDownloadRequestsByContourToggle : KeyedFeatureToggleBase, IKeyedFeatureToggle
{
public override string Key => "RoadExtractDownloadRequestsByContour";

public RoadExtractDownloadRequestsByContourToggle(IDynamicFeatureToggleService? dynamicFeatureToggleService)
: base(dynamicFeatureToggleService)
{ }
}

public sealed class RoadExtractDownloadRequestsByFileToggle : KeyedFeatureToggleBase, IKeyedFeatureToggle
{
public override string Key => "RoadExtractDownloadRequestsByFile";

public RoadExtractDownloadRequestsByFileToggle(IDynamicFeatureToggleService? dynamicFeatureToggleService)
: base(dynamicFeatureToggleService)
{ }
}

public sealed class RoadExtractDownloadRequestsByNisCodeToggle : KeyedFeatureToggleBase, IKeyedFeatureToggle
{
public override string Key => "RoadExtractDownloadRequestsByNisCode";

public RoadExtractDownloadRequestsByNisCodeToggle(IDynamicFeatureToggleService? dynamicFeatureToggleService)
: base(dynamicFeatureToggleService)
{ }
}

public sealed class RoadExtractGetDownloadToggle : KeyedFeatureToggleBase, IKeyedFeatureToggle
{
public override string Key => "RoadExtractGetDownload";

public RoadExtractGetDownloadToggle(IDynamicFeatureToggleService? dynamicFeatureToggleService)
: base(dynamicFeatureToggleService)
{ }
}

public sealed class RoadExtractGetOverlappingTransactionZonesGeoJsonToggle : KeyedFeatureToggleBase, IKeyedFeatureToggle
{
public override string Key => "RoadExtractGetOverlappingTransactionZonesGeoJson";

public RoadExtractGetOverlappingTransactionZonesGeoJsonToggle(IDynamicFeatureToggleService? dynamicFeatureToggleService)
: base(dynamicFeatureToggleService)
{ }
}

public sealed class RoadExtractGetStatusToggle : KeyedFeatureToggleBase, IKeyedFeatureToggle
{
public override string Key => "RoadExtractGetStatus";

public RoadExtractGetStatusToggle(IDynamicFeatureToggleService? dynamicFeatureToggleService)
: base(dynamicFeatureToggleService)
{ }
}

public sealed class RoadExtractGetTransactionZonesGeoJsonToggle : KeyedFeatureToggleBase, IKeyedFeatureToggle
{
public override string Key => "RoadExtractGetTransactionZonesGeoJson";

public RoadExtractGetTransactionZonesGeoJsonToggle(IDynamicFeatureToggleService? dynamicFeatureToggleService)
: base(dynamicFeatureToggleService)
{ }
}

public sealed class RoadGrbExtractByContourToggle : KeyedFeatureToggleBase, IKeyedFeatureToggle
{
public override string Key => "RoadGrbExtractByContour";

public RoadGrbExtractByContourToggle(IDynamicFeatureToggleService? dynamicFeatureToggleService)
: base(dynamicFeatureToggleService)
{ }
}

public sealed class RoadGrbUploadForDownloadToggle : KeyedFeatureToggleBase, IKeyedFeatureToggle
{
public override string Key => "RoadGrbUploadForDownload";

public RoadGrbUploadForDownloadToggle(IDynamicFeatureToggleService? dynamicFeatureToggleService)
: base(dynamicFeatureToggleService)
{ }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@ namespace Public.Api.Road.Downloads
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Common.FeatureToggles;

public partial class DownloadController
{
[HttpGet("wegen/download/voor-editor")]
public async Task<IActionResult> GetForEditor(
[FromServices] ProblemDetailsHelper problemDetailsHelper,
[FromServices] RoadDownloadGetForEditorToggle toggle,
CancellationToken cancellationToken = default)
{
HttpRequestMessage BackendRequest() =>
CreateBackendHttpRequestMessage(HttpMethod.Get, "download/for-editor");
if (!toggle.FeatureEnabled)
{
return NotFound();
}

var response = await GetFromBackendWithBadRequestAsync(
_httpClient,
Expand All @@ -26,6 +30,9 @@ HttpRequestMessage BackendRequest() =>
);

return response.ToActionResult();

HttpRequestMessage BackendRequest() =>
CreateBackendHttpRequestMessage(HttpMethod.Get, "download/for-editor");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@ namespace Public.Api.Road.Downloads
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Common.FeatureToggles;

public partial class DownloadController
{
[HttpGet("wegen/download/voor-product/{datum}")]
public async Task<IActionResult> GetForProduct(
[FromRoute] string datum,
[FromServices] ProblemDetailsHelper problemDetailsHelper,
[FromServices] RoadDownloadGetForProductToggle toggle,
CancellationToken cancellationToken = default)
{
HttpRequestMessage BackendRequest() =>
CreateBackendHttpRequestMessage(HttpMethod.Get, $"download/for-product/{datum}");
if (!toggle.FeatureEnabled)
{
return NotFound();
}

var response = await GetFromBackendWithBadRequestAsync(
_httpClient,
Expand All @@ -27,6 +31,9 @@ HttpRequestMessage BackendRequest() =>
);

return response.ToActionResult();

HttpRequestMessage BackendRequest() =>
CreateBackendHttpRequestMessage(HttpMethod.Get, $"download/for-product/{datum}");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@ namespace Public.Api.Road.Downloads.V2
using System.Threading;
using System.Threading.Tasks;
using Be.Vlaanderen.Basisregisters.Api.Exceptions;
using Common.FeatureToggles;
using Infrastructure;
using Microsoft.AspNetCore.Mvc;
using Public.Api.Infrastructure;

public partial class DownloadControllerV2
{
[HttpGet("wegen/download/voor-editor")]
public async Task<IActionResult> GetForEditorV2(
[FromServices] ProblemDetailsHelper problemDetailsHelper,
[FromServices] RoadDownloadGetForEditorToggle toggle,
CancellationToken cancellationToken = default)
{
HttpRequestMessage BackendRequest() =>
CreateBackendHttpRequestMessage(HttpMethod.Get, "download/for-editor");
if (!toggle.FeatureEnabled)
{
return NotFound();
}

var response = await GetFromBackendWithBadRequestAsync(
_httpClient,
Expand All @@ -26,6 +30,9 @@ HttpRequestMessage BackendRequest() =>
);

return response.ToActionResult();

HttpRequestMessage BackendRequest() =>
CreateBackendHttpRequestMessage(HttpMethod.Get, "download/for-editor");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@ namespace Public.Api.Road.Downloads.V2
using System.Threading;
using System.Threading.Tasks;
using Be.Vlaanderen.Basisregisters.Api.Exceptions;
using Common.FeatureToggles;
using Infrastructure;
using Microsoft.AspNetCore.Mvc;
using Public.Api.Infrastructure;

public partial class DownloadControllerV2
{
[HttpGet("wegen/download/voor-product/{datum}")]
public async Task<IActionResult> GetForProductV2(
[FromRoute] string datum,
[FromServices] ProblemDetailsHelper problemDetailsHelper,
[FromServices] RoadDownloadGetForProductToggle toggle,
CancellationToken cancellationToken = default)
{
HttpRequestMessage BackendRequest() =>
CreateBackendHttpRequestMessage(HttpMethod.Get, $"download/for-product/{datum}");
if (!toggle.FeatureEnabled)
{
return NotFound();
}

var response = await GetFromBackendWithBadRequestAsync(
_httpClient,
Expand All @@ -27,6 +31,9 @@ HttpRequestMessage BackendRequest() =>
);

return response.ToActionResult();

HttpRequestMessage BackendRequest() =>
CreateBackendHttpRequestMessage(HttpMethod.Get, $"download/for-product/{datum}");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ namespace Public.Api.Road.Extracts
using System.Threading.Tasks;
using Be.Vlaanderen.Basisregisters.Api.Exceptions;
using Common.FeatureToggles;
using Common.Infrastructure;
using Common.Infrastructure.Extensions;
using Infrastructure;
using Microsoft.AspNetCore.Http;
Expand All @@ -26,7 +25,7 @@ public async Task<IActionResult> RoadExtractCreateJob(
[FromRoute] string downloadId,
[FromServices] IActionContextAccessor actionContextAccessor,
[FromServices] ProblemDetailsHelper problemDetailsHelper,
[FromServices] RoadJobsToggle featureToggle,
[FromServices] RoadExtractCreateJobToggle featureToggle,
CancellationToken cancellationToken = default)
{
if (!featureToggle.FeatureEnabled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace Public.Api.Road.Extracts
using System.Threading.Tasks;
using Be.Vlaanderen.Basisregisters.Api;
using Be.Vlaanderen.Basisregisters.Api.Exceptions;
using Common.FeatureToggles;
using Common.Infrastructure.Controllers.Attributes;
using Infrastructure;
using Microsoft.AspNetCore.Mvc;
Expand All @@ -17,11 +18,13 @@ public partial class ExtractController
public async Task<ActionResult> PostDownloadRequest(
[FromBody]DownloadExtractRequestBody body,
[FromServices] ProblemDetailsHelper problemDetailsHelper,
[FromServices] RoadExtractDownloadRequestsToggle toggle,
CancellationToken cancellationToken = default)
{
RestRequest BackendRequest() =>
CreateBackendRestRequest(Method.Get, "extracts/downloadrequests")
.AddParameter(nameof(body), body, ParameterType.RequestBody);
if (!toggle.FeatureEnabled)
{
return NotFound();
}

var response = await GetFromBackendWithBadRequestAsync(
AcceptType.Json,
Expand All @@ -31,6 +34,10 @@ RestRequest BackendRequest() =>
cancellationToken: cancellationToken);

return new BackendResponseResult(response);

RestRequest BackendRequest() =>
CreateBackendRestRequest(Method.Get, "extracts/downloadrequests")
.AddParameter(nameof(body), body, ParameterType.RequestBody);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Public.Api.Road.Extracts
using RoadRegistry.BackOffice.Api.Extracts;
using System.Threading;
using System.Threading.Tasks;
using Common.FeatureToggles;

public partial class ExtractController
{
Expand All @@ -17,11 +18,13 @@ public partial class ExtractController
public async Task<ActionResult> PostDownloadRequestByContour(
[FromBody] DownloadExtractByContourRequestBody body,
[FromServices] ProblemDetailsHelper problemDetailsHelper,
[FromServices] RoadExtractDownloadRequestsByContourToggle toggle,
CancellationToken cancellationToken = default)
{
RestRequest BackendRequest() =>
CreateBackendRestRequest(Method.Post, "extracts/downloadrequests/bycontour")
.AddJsonBodyOrEmpty(body);
if (!toggle.FeatureEnabled)
{
return NotFound();
}

var response = await GetFromBackendWithBadRequestAsync(
AcceptType.Json,
Expand All @@ -31,6 +34,10 @@ RestRequest BackendRequest() =>
cancellationToken: cancellationToken);

return new BackendResponseResult(response);

RestRequest BackendRequest() =>
CreateBackendRestRequest(Method.Post, "extracts/downloadrequests/bycontour")
.AddJsonBodyOrEmpty(body);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Public.Api.Road.Extracts
using RoadRegistry.BackOffice.Api.Extracts;
using System.Threading;
using System.Threading.Tasks;
using Common.FeatureToggles;

public partial class ExtractController
{
Expand All @@ -17,11 +18,13 @@ public partial class ExtractController
public async Task<ActionResult> PostDownloadRequestByFile(
[FromBody] DownloadExtractByFileRequestBody body,
[FromServices] ProblemDetailsHelper problemDetailsHelper,
[FromServices] RoadExtractDownloadRequestsByFileToggle toggle,
CancellationToken cancellationToken = default)
{
RestRequest BackendRequest() =>
CreateBackendRestRequest(Method.Post, "extracts/downloadrequests/byfile")
.AddJsonBodyOrEmpty(body);
if (!toggle.FeatureEnabled)
{
return NotFound();
}

var response = await GetFromBackendWithBadRequestAsync(
AcceptType.Json,
Expand All @@ -31,6 +34,10 @@ RestRequest BackendRequest() =>
cancellationToken: cancellationToken);

return new BackendResponseResult(response);

RestRequest BackendRequest() =>
CreateBackendRestRequest(Method.Post, "extracts/downloadrequests/byfile")
.AddJsonBodyOrEmpty(body);
}
}
}
Loading
Loading