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:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user