-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: API: migrate from Fusion Portal API to Fusion Apps API (#811)
Co-authored-by: kjetilhau <[email protected]>
- Loading branch information
Showing
83 changed files
with
951 additions
and
1,150 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
--- | ||
"fusion-project-portal": major | ||
--- | ||
- **BREAKING CHANGE**: Migrate from the deprecated Fusion Portal API (for apps) to the new and separate Fusion Apps API. | ||
This results in breaking changes in the API contract. The reason for this is model changes in the new Fusion Apps API. And we prefer modelling 1-1 as best as possible instead of introducing remapping etc. on our end. | ||
- **BREAKING CHANGE**: Removal of the Fusion Portal Proxy. We no longer provide endpoints for this on the API. All calls to get bundles and app information from Fusion shall go through the ClientBackend | ||
- Fixed more tests | ||
- Refactoring has been done in multiple locations |
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
18 changes: 9 additions & 9 deletions
18
backend/src/Equinor.ProjectExecutionPortal.Application/Cache/FusionAppsCache.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
6 changes: 3 additions & 3 deletions
6
backend/src/Equinor.ProjectExecutionPortal.Application/Cache/IFusionAppsCache.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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
using Equinor.ProjectExecutionPortal.FusionPortalApi.Apps.Models; | ||
using Fusion.Integration.Apps.Abstractions.Models; | ||
|
||
namespace Equinor.ProjectExecutionPortal.Application.Cache; | ||
|
||
public interface IFusionAppsCache | ||
{ | ||
Task<List<FusionPortalAppInformation>> GetFusionApps(); | ||
Task<List<App>> GetFusionApps(); | ||
|
||
Task<FusionPortalAppInformation?> GetFusionApp(string appKey); | ||
Task<App?> GetFusionApp(string appKey); | ||
} |
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
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
42 changes: 10 additions & 32 deletions
42
...d/src/Equinor.ProjectExecutionPortal.Application/Queries/OnboardedApps/OnboardedAppDto.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 |
---|---|---|
@@ -1,44 +1,22 @@ | ||
using Equinor.ProjectExecutionPortal.Application.Infrastructure.Mappings; | ||
using Equinor.ProjectExecutionPortal.Application.Queries.ContextTypes; | ||
using Equinor.ProjectExecutionPortal.FusionPortalApi.Apps.Models; | ||
using Fusion.Integration.Apps.Abstractions.Models; | ||
|
||
namespace Equinor.ProjectExecutionPortal.Application.Queries.OnboardedApps; | ||
|
||
public enum FusionPortalAppInformationAmount | ||
{ | ||
Minimal, | ||
All | ||
} | ||
|
||
public class OnboardedAppDto : IMapFrom<Domain.Entities.OnboardedApp> | ||
{ | ||
public Guid Id { get; set; } | ||
public string AppKey { get; set; } | ||
public FusionPortalAppInformation? AppInformation { get; set; } | ||
public IList<ContextTypeDto> ContextTypes { get; set; } | ||
public string? AppKey { get; set; } | ||
public string? DisplayName { get; set; } | ||
public string? Description { get; set; } | ||
public App? AppInformation { get; set; } | ||
public IList<ContextTypeDto> ContextTypes { get; set; } = new List<ContextTypeDto>(); | ||
|
||
public void SupplyWithFusionData(FusionPortalAppInformation appInformation, FusionPortalAppInformationAmount amount) | ||
public void SupplyWithFusionData(App app) | ||
{ | ||
switch (amount) | ||
{ | ||
case FusionPortalAppInformationAmount.All: | ||
AppInformation = appInformation; | ||
break; | ||
|
||
case FusionPortalAppInformationAmount.Minimal: | ||
var appInfo = new FusionPortalAppInformation | ||
{ | ||
Key = appInformation.Key, | ||
Name = appInformation.Name, | ||
Description = appInformation.Description | ||
}; | ||
|
||
AppInformation = appInfo; | ||
|
||
break; | ||
|
||
default: | ||
throw new ArgumentOutOfRangeException(nameof(amount), amount, null); | ||
} | ||
DisplayName = app.DisplayName; | ||
Description = app.Description; | ||
AppInformation = app; | ||
} | ||
} |
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
65 changes: 65 additions & 0 deletions
65
.../Queries/Portals/GetPortalAppKeys/GetContextualAndGlobalAppKeysByPortalAndContextQuery.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,65 @@ | ||
using Equinor.ProjectExecutionPortal.Application.Services.ContextService; | ||
using Equinor.ProjectExecutionPortal.Domain.Common.Exceptions; | ||
using Equinor.ProjectExecutionPortal.Domain.Entities; | ||
using Equinor.ProjectExecutionPortal.Domain.Infrastructure; | ||
using Equinor.ProjectExecutionPortal.Infrastructure; | ||
using MediatR; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace Equinor.ProjectExecutionPortal.Application.Queries.Portals.GetPortalAppKeys; | ||
|
||
public class GetContextualAndGlobalAppKeysByPortalAndContextQuery : QueryBase<IList<string>> | ||
{ | ||
public GetContextualAndGlobalAppKeysByPortalAndContextQuery(Guid portalId, Guid contextId) | ||
{ | ||
PortalId = portalId; | ||
ContextId = contextId; | ||
} | ||
|
||
public Guid PortalId { get; } | ||
public Guid ContextId { get; } | ||
|
||
public class Handler : IRequestHandler<GetContextualAndGlobalAppKeysByPortalAndContextQuery, IList<string>> | ||
{ | ||
private readonly IReadWriteContext _readWriteContext; | ||
|
||
private readonly IContextService _contextService; | ||
|
||
public Handler(IReadWriteContext readWriteContext, IContextService contextService) | ||
{ | ||
_readWriteContext = readWriteContext; | ||
|
||
_contextService = contextService; | ||
} | ||
|
||
public async Task<IList<string>> Handle(GetContextualAndGlobalAppKeysByPortalAndContextQuery request, CancellationToken cancellationToken) | ||
{ | ||
var fusionContext = await _contextService.GetFusionContext(request.ContextId, cancellationToken); | ||
|
||
if (fusionContext == null) | ||
{ | ||
throw new NotFoundException($"Invalid context-id: {request.ContextId}"); | ||
} | ||
|
||
var portalWithContextualAndGlobalApps = await _readWriteContext.Set<Portal>() | ||
.AsNoTracking() | ||
.Include(portal => portal.Apps | ||
.Where(app => app.OnboardedContext == null || (app.OnboardedContext.ExternalId == fusionContext.ExternalId && app.OnboardedContext.Type == fusionContext.Type.Name))) | ||
.ThenInclude(app => app.OnboardedApp) | ||
.ThenInclude(app => app.ContextTypes) | ||
.FirstOrDefaultAsync(x => x.Id == request.PortalId, cancellationToken); | ||
|
||
if (portalWithContextualAndGlobalApps == null) | ||
{ | ||
throw new NotFoundException(nameof(Portal), request.PortalId); | ||
} | ||
|
||
var contextualAndGlobalPortalAppKeys = portalWithContextualAndGlobalApps.Apps | ||
.Where(apps => apps.OnboardedApp.ContextTypes.Count == 0 || apps.OnboardedApp.ContextTypes.Any(m => m.ContextTypeKey == fusionContext.Type.Name)) | ||
.Select(app => app.OnboardedApp.AppKey) | ||
.ToList(); | ||
|
||
return contextualAndGlobalPortalAppKeys; | ||
} | ||
} | ||
} |
Oops, something went wrong.