Refactor IPAM model classes to use records for Address, Subnetwork, Vlan, Vrf, Section, Tag, Domain, Nameserver, and Session; enhance documentation and implement value equality for records.

This commit is contained in:
2026-01-19 17:25:18 +03:00
parent 694822f0d6
commit f56784f2aa
44 changed files with 1601 additions and 1905 deletions

View File

@@ -1,41 +1,27 @@
namespace PS.IPAM;
using System;
using System.Dynamic;
using System.Collections.Generic;
/// <summary>
/// Represents a VLAN in phpIPAM.
/// </summary>
[Serializable]
public class Vlan : DynamicObject {
public int Id { get; }
public int VlanId { get; }
public int DomainId { get; }
public string Name { get; }
public int Number { get; }
public string Description { get; }
public DateTime? EditDate { get; }
public int CustomerId { get; }
public Object? ExtendedData { get; }
public Vlan (
int vlanId,
int domainId,
string name,
int number,
string description,
DateTime? editDate,
int customer_id,
Object? custom_fields
) {
this.Id = vlanId;
this.VlanId = vlanId;
this.DomainId = domainId;
this.Name = name;
this.Number = number;
this.Description = description;
this.EditDate = editDate;
this.CustomerId = customer_id;
this.ExtendedData = custom_fields;
}
public sealed record Vlan(
int Id,
int DomainId,
string Name,
int Number,
string Description,
DateTime? EditDate,
int CustomerId,
Dictionary<string, object>? ExtendedData = null
)
{
/// <summary>
/// Alias for Id to maintain API compatibility.
/// </summary>
public int VlanId => Id;
public override string ToString()
{
return $"{this.Number}";
}
}
public override string ToString() => Number.ToString();
}