using System;
using System.Collections.Generic;
using StellaOps.Auth.Abstractions;

namespace StellaOps.Cli.Configuration;

public sealed class StellaOpsCliOptions
{
    public string ApiKey { get; set; } = string.Empty;

    public string BackendUrl { get; set; } = string.Empty;

    public string ScannerCacheDirectory { get; set; } = "scanners";

    public string ResultsDirectory { get; set; } = "results";

    public string DefaultRunner { get; set; } = "docker";

    public string ScannerSignaturePublicKeyPath { get; set; } = string.Empty;

    public int ScannerDownloadAttempts { get; set; } = 3;

    public int ScanUploadAttempts { get; set; } = 3;

    public StellaOpsCliAuthorityOptions Authority { get; set; } = new();
}

public sealed class StellaOpsCliAuthorityOptions
{
    public string Url { get; set; } = string.Empty;

    public string ClientId { get; set; } = string.Empty;

    public string? ClientSecret { get; set; }

    public string Username { get; set; } = string.Empty;

    public string? Password { get; set; }

    public string Scope { get; set; } = StellaOpsScopes.FeedserJobsTrigger;

    public string TokenCacheDirectory { get; set; } = string.Empty;

    public StellaOpsCliAuthorityResilienceOptions Resilience { get; set; } = new();
}

public sealed class StellaOpsCliAuthorityResilienceOptions
{
    public bool? EnableRetries { get; set; }

    public IList<TimeSpan> RetryDelays { get; set; } = new List<TimeSpan>();

    public bool? AllowOfflineCacheFallback { get; set; }

    public TimeSpan? OfflineCacheTolerance { get; set; }
}
