import * as plugins from '../../plugins.js';
import { DcRouterDb } from '../classes.dcrouter-db.js';

const getDb = () => DcRouterDb.getInstance().getDb();

@plugins.smartdata.Collection(() => getDb())
export class VpnClientDoc extends plugins.smartdata.SmartDataDbDoc<VpnClientDoc, VpnClientDoc> {
  @plugins.smartdata.unI()
  @plugins.smartdata.svDb()
  public clientId!: string;

  @plugins.smartdata.svDb()
  public enabled!: boolean;

  @plugins.smartdata.svDb()
  public targetProfileIds?: string[];

  @plugins.smartdata.svDb()
  public description?: string;

  @plugins.smartdata.svDb()
  public assignedIp?: string;

  @plugins.smartdata.svDb()
  public noisePublicKey!: string;

  @plugins.smartdata.svDb()
  public wgPublicKey!: string;

  @plugins.smartdata.svDb()
  public wgPrivateKey?: string;

  @plugins.smartdata.svDb()
  public createdAt!: number;

  @plugins.smartdata.svDb()
  public updatedAt!: number;

  @plugins.smartdata.svDb()
  public expiresAt?: string;

  @plugins.smartdata.svDb()
  public destinationAllowList?: string[];

  @plugins.smartdata.svDb()
  public destinationBlockList?: string[];

  @plugins.smartdata.svDb()
  public useHostIp?: boolean;

  @plugins.smartdata.svDb()
  public useDhcp?: boolean;

  @plugins.smartdata.svDb()
  public staticIp?: string;

  @plugins.smartdata.svDb()
  public forceVlan?: boolean;

  @plugins.smartdata.svDb()
  public vlanId?: number;

  constructor() {
    super();
  }

  public static async findAll(): Promise<VpnClientDoc[]> {
    return await VpnClientDoc.getInstances({});
  }
}
