101 lines
2.9 KiB
C#
101 lines
2.9 KiB
C#
// <copyright file="IPlanRuleStore.cs" company="Stella Operations">
|
|
// Copyright (c) Stella Operations. Licensed under BUSL-1.1.
|
|
// </copyright>
|
|
|
|
using System.Collections.Generic;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace StellaOps.Registry.TokenService.Admin;
|
|
|
|
/// <summary>
|
|
/// Abstraction for persistent plan rule storage.
|
|
/// </summary>
|
|
public interface IPlanRuleStore
|
|
{
|
|
/// <summary>
|
|
/// Gets all plan rules ordered by name.
|
|
/// </summary>
|
|
Task<IReadOnlyList<PlanRuleDto>> GetAllAsync(CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Gets a plan rule by ID.
|
|
/// </summary>
|
|
Task<PlanRuleDto?> GetByIdAsync(string id, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Gets a plan rule by name.
|
|
/// </summary>
|
|
Task<PlanRuleDto?> GetByNameAsync(string name, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Creates a new plan rule.
|
|
/// </summary>
|
|
Task<PlanRuleDto> CreateAsync(CreatePlanRequest request, string actor, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Updates an existing plan rule.
|
|
/// </summary>
|
|
Task<PlanRuleDto> UpdateAsync(string id, UpdatePlanRequest request, string actor, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Deletes a plan rule.
|
|
/// </summary>
|
|
Task<bool> DeleteAsync(string id, string actor, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Gets audit history for a plan.
|
|
/// </summary>
|
|
Task<IReadOnlyList<PlanAuditEntry>> GetAuditHistoryAsync(
|
|
string? planId = null,
|
|
int page = 1,
|
|
int pageSize = 50,
|
|
CancellationToken cancellationToken = default);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Exception thrown when a plan rule version conflict occurs.
|
|
/// </summary>
|
|
public sealed class PlanVersionConflictException : System.Exception
|
|
{
|
|
public PlanVersionConflictException(string planId, int expectedVersion, int actualVersion)
|
|
: base($"Plan '{planId}' version conflict: expected {expectedVersion}, actual {actualVersion}")
|
|
{
|
|
PlanId = planId;
|
|
ExpectedVersion = expectedVersion;
|
|
ActualVersion = actualVersion;
|
|
}
|
|
|
|
public string PlanId { get; }
|
|
public int ExpectedVersion { get; }
|
|
public int ActualVersion { get; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Exception thrown when a plan rule is not found.
|
|
/// </summary>
|
|
public sealed class PlanNotFoundException : System.Exception
|
|
{
|
|
public PlanNotFoundException(string planId)
|
|
: base($"Plan '{planId}' not found")
|
|
{
|
|
PlanId = planId;
|
|
}
|
|
|
|
public string PlanId { get; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Exception thrown when a plan name already exists.
|
|
/// </summary>
|
|
public sealed class PlanNameConflictException : System.Exception
|
|
{
|
|
public PlanNameConflictException(string name)
|
|
: base($"Plan with name '{name}' already exists")
|
|
{
|
|
Name = name;
|
|
}
|
|
|
|
public string Name { get; }
|
|
}
|