| | | 1 | | using Elsa.Identity.Models; |
| | | 2 | | |
| | | 3 | | namespace Elsa.Identity.Endpoints.Roles.Delete; |
| | | 4 | | |
| | | 5 | | internal sealed class RemediateRoleDeletionRequest |
| | | 6 | | { |
| | | 7 | | public string? ExpectedDependencyVersion { get; set; } |
| | | 8 | | public bool ConfirmRemoveFromEditableJitPolicies { get; set; } |
| | | 9 | | public bool ConfirmEmptyDefaultRoles { get; set; } |
| | | 10 | | public bool ConfirmBestEffort { get; set; } |
| | | 11 | | } |
| | | 12 | | |
| | | 13 | | internal sealed record RoleDeletionErrorResponse(string Error, string Message, object? Details = null); |
| | | 14 | | |
| | | 15 | | internal sealed record RoleDeletionImpactResponse( |
| | | 16 | | string RoleId, |
| | | 17 | | string DependencyVersion, |
| | | 18 | | string ExecutionMode, |
| | | 19 | | bool CanDelete, |
| | | 20 | | bool CanRemediate, |
| | | 21 | | IReadOnlyCollection<RoleDeletionDependencyResponse> ConfigurationReferences, |
| | | 22 | | IReadOnlyCollection<RoleDeletionDependencyResponse> EditableReferences, |
| | | 23 | | IReadOnlyCollection<string> Warnings) |
| | | 24 | | { |
| | | 25 | | public static RoleDeletionImpactResponse From(RoleDeletionImpact impact) |
| | | 26 | | { |
| | | 27 | | var references = impact.Dependencies.Select(RoleDeletionDependencyResponse.From).ToArray(); |
| | | 28 | | return new RoleDeletionImpactResponse( |
| | | 29 | | impact.RoleId, |
| | | 30 | | impact.DependencyVersion, |
| | | 31 | | impact.ExecutionMode == RoleDeletionExecutionMode.Atomic ? "atomic" : "bestEffort", |
| | | 32 | | impact.CanDelete, |
| | | 33 | | impact.CanRemediate, |
| | | 34 | | references.Where(x => x.Ownership == "configuration").ToArray(), |
| | | 35 | | references.Where(x => x.Ownership == "database").ToArray(), |
| | | 36 | | impact.Dependencies.Any(x => x.RemovesLastDefaultRole) ? ["removes_last_default_role"] : []); |
| | | 37 | | } |
| | | 38 | | } |
| | | 39 | | |
| | 0 | 40 | | internal sealed record RoleDeletionDependencyResponse( |
| | 0 | 41 | | string Source, |
| | 0 | 42 | | string OwnerId, |
| | 0 | 43 | | string OwnerKey, |
| | 0 | 44 | | string PolicyBranch, |
| | 0 | 45 | | string Ownership, |
| | 0 | 46 | | string? ConfigurationPath, |
| | 0 | 47 | | long? Revision, |
| | 0 | 48 | | bool RemovesLastDefaultRole) |
| | | 49 | | { |
| | 0 | 50 | | public static RoleDeletionDependencyResponse From(RoleDeletionDependency dependency) => new( |
| | 0 | 51 | | dependency.Source, |
| | 0 | 52 | | dependency.OwnerId, |
| | 0 | 53 | | dependency.OwnerKey, |
| | 0 | 54 | | dependency.PolicyBranch, |
| | 0 | 55 | | dependency.Ownership == RoleDeletionDependencyOwnership.Configuration ? "configuration" : "database", |
| | 0 | 56 | | dependency.ConfigurationPath, |
| | 0 | 57 | | dependency.ExpectedRevision, |
| | 0 | 58 | | dependency.RemovesLastDefaultRole); |
| | | 59 | | } |