using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using StellaOps.Vexer.Core;

namespace StellaOps.Vexer.Storage.Mongo;

public interface IVexProviderStore
{
    ValueTask<VexProvider?> FindAsync(string id, CancellationToken cancellationToken);

    ValueTask<IReadOnlyCollection<VexProvider>> ListAsync(CancellationToken cancellationToken);

    ValueTask SaveAsync(VexProvider provider, CancellationToken cancellationToken);
}

public interface IVexConsensusStore
{
    ValueTask<VexConsensus?> FindAsync(string vulnerabilityId, string productKey, CancellationToken cancellationToken);

    ValueTask<IReadOnlyCollection<VexConsensus>> FindByVulnerabilityAsync(string vulnerabilityId, CancellationToken cancellationToken);

    ValueTask SaveAsync(VexConsensus consensus, CancellationToken cancellationToken);
}

public interface IVexCacheIndex
{
    ValueTask<VexCacheEntry?> FindAsync(VexQuerySignature signature, VexExportFormat format, CancellationToken cancellationToken);

    ValueTask SaveAsync(VexCacheEntry entry, CancellationToken cancellationToken);

    ValueTask RemoveAsync(VexQuerySignature signature, VexExportFormat format, CancellationToken cancellationToken);
}

public interface IVexCacheMaintenance
{
    ValueTask<int> RemoveExpiredAsync(DateTimeOffset asOf, CancellationToken cancellationToken);

    ValueTask<int> RemoveMissingManifestReferencesAsync(CancellationToken cancellationToken);
}
