<?php

namespace App\Jobs;

use App\Models\Olt;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Cache;

class CommunitySyncJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public function __construct(public int $oltId) {}

    public function handle(): void
    {
        $olt = Olt::find($this->oltId);
        if (! $olt) {
            return;
        }

        // Placeholder: SNMP community creation will be implemented per-vendor in future.
        // For now we store the provided community and mark cached state.
        Cache::put('olt:community:'.$olt->id, ['community' => $olt->community], now()->addHours(6));
    }
}
