using ZB.MOM.WW.OtOpcUa.Configuration.Enums; namespace ZB.MOM.WW.OtOpcUa.AdminUI.Acls; /// /// Backs the ACL authoring surface (#520 stage 7): the scope picker's two trees, and the /// authoring-time checks that stop a grant being saved against a principal or a scope that names /// nothing. /// /// /// /// A service rather than logic in the Razor pages, because this repo has no bUnit — anything /// only a page can reach is untestable, and the whole point of the stage is that authoring stops /// producing grants that silently authorize nobody. The same rationale /// IApiKeyAdminService carries. /// /// /// The picker chooses the kind and the id together. Before this, ScopeKind was a /// dropdown and ScopeId a free-text box, so the two could disagree — a /// row pointing at a TagId is well-formed, saves, deploys, /// and resolves to nothing. Selecting a tree node produces both, so that pairing cannot be made by /// hand. is what catches the rows that already exist, or that were /// typed in before the picker was reached. /// /// public interface IAclScopeService { /// /// Loads the raw and UNS scope trees for one cluster. Both are rooted at that cluster, so a scope in /// another cluster is unreachable through the picker rather than merely discouraged — the structural /// equivalent of the deploy gate's NodeAclScopeCrossCluster rule. /// /// The cluster the grant belongs to. /// The cancellation token. /// The two trees; either may be empty when the cluster has nothing of that kind yet. Task LoadRootsAsync(string clusterId, CancellationToken ct = default); /// /// Loads one lazy level beneath a raw-tree node. UNS nodes are loaded whole by /// and never reach here. /// /// The node being expanded. /// The cancellation token. /// The child rows, or empty for a leaf. Task> LoadChildrenAsync(AclScopeNode parent, CancellationToken ct = default); /// /// Resolves an authored scope against the current configuration, mirroring the deploy gate's /// NodeAclScope* rules so the page rejects what the deployment would reject. /// /// The cluster the grant belongs to. /// The authored scope kind. /// The authored scope id; null or blank for a cluster-wide grant. /// The cancellation token. /// What the scope resolves to, or why it does not. Task CheckScopeAsync( string clusterId, NodeAclScopeKind kind, string? scopeId, CancellationToken ct = default); /// /// Lists the principal names worth suggesting: every principal an API key authenticates as, every /// principal an existing grant already names, and the reserved anonymous principal. /// /// The cancellation token. /// Distinct principal names, ordered. Task> LoadKnownPrincipalsAsync(CancellationToken ct = default); /// Reports how many API keys currently authenticate as a principal. /// The principal name as authored. /// The cancellation token. /// The usage counts. Task CheckPrincipalAsync(string principal, CancellationToken ct = default); }