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,114 +1,51 @@
|
||||
namespace PS.IPAM;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a subnet/network in phpIPAM.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class Subnetwork {
|
||||
public int Id { get; }
|
||||
public string Subnet { get; }
|
||||
public int Mask { get; }
|
||||
public int SectionId { get; }
|
||||
public string Description { get; }
|
||||
public string LinkedSubnet { get; }
|
||||
public string FirewallAddressObject { get; }
|
||||
public int VrfId { get; }
|
||||
public int MasterSubnetId { get; }
|
||||
public bool AllowRequests { get; }
|
||||
public int VlanId { get; }
|
||||
public bool ShowName { get; }
|
||||
public int DeviceId { get; }
|
||||
public string Permissions { get; }
|
||||
public bool PingSubnet { get; }
|
||||
public bool DiscoverSubnet { get; }
|
||||
public bool ResolveDNS { get; }
|
||||
public bool DNSRecursive { get; }
|
||||
public bool DNSRecords { get; }
|
||||
public int NameserverId { get; }
|
||||
public bool ScanAgent { get; }
|
||||
public bool IsFolder { get; }
|
||||
public bool IsFull { get; }
|
||||
public bool IsPool { get; }
|
||||
public int TagId { get; }
|
||||
public int Threshold { get; }
|
||||
public int LocationId { get; }
|
||||
public DateTime? EditDate { get; }
|
||||
public DateTime? LastScan { get; }
|
||||
public DateTime? LastDiscovery { get; }
|
||||
public Object Calculation { get; }
|
||||
public Object? ExtendedData { get; }
|
||||
public Subnetwork(
|
||||
int id,
|
||||
string subnet,
|
||||
int mask,
|
||||
int sectionId,
|
||||
string description,
|
||||
string linkedSubnet,
|
||||
string firewallAddressObject,
|
||||
int vrfId,
|
||||
int masterSubnetId,
|
||||
bool allowRequests,
|
||||
int vlanId,
|
||||
bool showName,
|
||||
int deviceId,
|
||||
string permissions,
|
||||
bool pingSubnet,
|
||||
bool discoverSubnet,
|
||||
bool resolveDNS,
|
||||
bool dnsRecursive,
|
||||
bool dnsRecords,
|
||||
int nameserverId,
|
||||
bool scanAgent,
|
||||
bool isFolder,
|
||||
bool isFull,
|
||||
bool isPool,
|
||||
int tagId,
|
||||
int threshold,
|
||||
int locationId,
|
||||
DateTime? editDate,
|
||||
DateTime? lastScan,
|
||||
DateTime? lastDiscovery,
|
||||
Object calculation,
|
||||
Object? custom_fields
|
||||
) {
|
||||
this.Id = id;
|
||||
this.Subnet = subnet;
|
||||
this.Mask = mask;
|
||||
this.SectionId = sectionId;
|
||||
this.Description = description;
|
||||
this.LinkedSubnet = linkedSubnet;
|
||||
this.FirewallAddressObject = firewallAddressObject;
|
||||
this.VrfId = vrfId;
|
||||
this.MasterSubnetId = masterSubnetId;
|
||||
this.AllowRequests = allowRequests;
|
||||
this.VlanId = vlanId;
|
||||
this.ShowName = showName;
|
||||
this.DeviceId = deviceId;
|
||||
this.Permissions = permissions;
|
||||
this.PingSubnet = pingSubnet;
|
||||
this.DiscoverSubnet = discoverSubnet;
|
||||
this.ResolveDNS = resolveDNS;
|
||||
this.DNSRecursive = dnsRecursive;
|
||||
this.DNSRecords = dnsRecords;
|
||||
this.NameserverId = nameserverId;
|
||||
this.ScanAgent = scanAgent;
|
||||
this.IsFolder = isFolder;
|
||||
this.IsFull = isFull;
|
||||
this.IsPool = isPool;
|
||||
this.TagId = tagId;
|
||||
this.Threshold = threshold;
|
||||
this.LocationId = locationId;
|
||||
this.EditDate = editDate;
|
||||
this.LastScan = lastScan;
|
||||
this.LastDiscovery = lastDiscovery;
|
||||
this.Calculation = calculation;
|
||||
this.ExtendedData = custom_fields;
|
||||
}
|
||||
public sealed record Subnetwork(
|
||||
int Id,
|
||||
string Subnet,
|
||||
int Mask,
|
||||
int SectionId,
|
||||
string Description,
|
||||
string LinkedSubnet,
|
||||
string FirewallAddressObject,
|
||||
int VrfId,
|
||||
int MasterSubnetId,
|
||||
bool AllowRequests,
|
||||
int VlanId,
|
||||
bool ShowName,
|
||||
int DeviceId,
|
||||
string Permissions,
|
||||
bool PingSubnet,
|
||||
bool DiscoverSubnet,
|
||||
bool ResolveDNS,
|
||||
bool DNSRecursive,
|
||||
bool DNSRecords,
|
||||
int NameserverId,
|
||||
bool ScanAgent,
|
||||
bool IsFolder,
|
||||
bool IsFull,
|
||||
bool IsPool,
|
||||
int TagId,
|
||||
int Threshold,
|
||||
int LocationId,
|
||||
DateTime? EditDate,
|
||||
DateTime? LastScan,
|
||||
DateTime? LastDiscovery,
|
||||
object Calculation,
|
||||
Dictionary<string, object>? ExtendedData = null
|
||||
)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the subnet in CIDR notation (e.g., "192.168.1.0/24").
|
||||
/// </summary>
|
||||
public string CIDR => $"{Subnet}/{Mask}";
|
||||
|
||||
public string GetCIDR() {
|
||||
return $"{this.Subnet}/{this.Mask}";
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.GetCIDR();
|
||||
}
|
||||
}
|
||||
public override string ToString() => CIDR;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user