using System;
using System.Threading;
using System.Threading.Tasks;
using StellaOps.Feedser.Core.Jobs;

namespace StellaOps.Feedser.Source.Vndr.Cisco;

internal static class CiscoJobKinds
{
    public const string Fetch = "source:vndr-cisco:fetch";
    public const string Parse = "source:vndr-cisco:parse";
    public const string Map = "source:vndr-cisco:map";
}

internal sealed class CiscoFetchJob : IJob
{
    private readonly CiscoConnector _connector;

    public CiscoFetchJob(CiscoConnector connector)
        => _connector = connector ?? throw new ArgumentNullException(nameof(connector));

    public Task ExecuteAsync(JobExecutionContext context, CancellationToken cancellationToken)
        => _connector.FetchAsync(context.Services, cancellationToken);
}

internal sealed class CiscoParseJob : IJob
{
    private readonly CiscoConnector _connector;

    public CiscoParseJob(CiscoConnector connector)
        => _connector = connector ?? throw new ArgumentNullException(nameof(connector));

    public Task ExecuteAsync(JobExecutionContext context, CancellationToken cancellationToken)
        => _connector.ParseAsync(context.Services, cancellationToken);
}

internal sealed class CiscoMapJob : IJob
{
    private readonly CiscoConnector _connector;

    public CiscoMapJob(CiscoConnector connector)
        => _connector = connector ?? throw new ArgumentNullException(nameof(connector));

    public Task ExecuteAsync(JobExecutionContext context, CancellationToken cancellationToken)
        => _connector.MapAsync(context.Services, cancellationToken);
}
