diff --git a/classlib/address.cs b/classlib/address.cs index 7f411fb..2546695 100644 --- a/classlib/address.cs +++ b/classlib/address.cs @@ -1,6 +1,7 @@ namespace PS.IPAM; using System; +[Serializable] public class Address { public int Id { get; } public int SubnetId { get; } @@ -13,11 +14,11 @@ public class Address { public int TagId { get; } public int DeviceId { get; } public string Location { get; } - public int Port { get; } + public string Port { get; } public string Note { get; } public DateTime? LastSeen { get; } public bool ExcludePing { get; } - public int PTRignore { get; } + public bool PTRignore { get; } public int PTR { get; } public string FirewallAddressObject { get; } public DateTime? EditDate { get; } @@ -35,11 +36,11 @@ public class Address { int tag, int deviceId, string location, - int port, + string port, string note, DateTime? lastSeen, bool excludePing, - int PTRignore, + bool PTRignore, int PTR, string firewallAddressObject, DateTime? editDate, diff --git a/classlib/classlib.csproj b/classlib/classlib.csproj index cfadb03..b3c1ee9 100644 --- a/classlib/classlib.csproj +++ b/classlib/classlib.csproj @@ -1,9 +1,10 @@ - net7.0 + netstandard2.1 enable enable + latest diff --git a/classlib/domain.cs b/classlib/domain.cs new file mode 100644 index 0000000..36b8530 --- /dev/null +++ b/classlib/domain.cs @@ -0,0 +1,27 @@ +namespace PS.IPAM; +using System; + +[Serializable] +public class Domain { + public int Id { get; } + public string Name { get; } + public string Description { get; } + public string Sections { get; } + + public Domain ( + int id, + string name, + string description, + string sections + ) { + this.Id = id; + this.Name = name; + this.Description = description; + this.Sections = sections; + } + + public override string ToString() + { + return this.Name; + } +} \ No newline at end of file diff --git a/classlib/enum.cs b/classlib/enum.cs deleted file mode 100644 index 23d694b..0000000 --- a/classlib/enum.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace PS.IPAM; -using System; - -enum Parameters { - IsGateway = "is_gateway"; -} \ No newline at end of file diff --git a/classlib/section.cs b/classlib/section.cs new file mode 100644 index 0000000..8f33f8b --- /dev/null +++ b/classlib/section.cs @@ -0,0 +1,54 @@ +namespace PS.IPAM; +using System; + +[Serializable] +public class Section { + public int Id { get; } + public string Name { get; } + public string Description { get; } + public int MasterSectionId { get; } + public string Permissions { get; } + public bool StrictMode { get; } + public string SubnetOrdering { get; } + public int Order { get; } + public DateTime? EditDate { get; } + public bool ShowVlan { get; } + public bool ShowVRF { get; } + public bool ShowSupernetOnly { get; } + public int DNSId { get; } + + public Section ( + int id, + string name, + string description, + int masterSectionId, + string permissions, + bool strictMode, + string subnetOrdering, + int order, + DateTime? editDate, + bool showVlan, + bool showVRF, + bool showSupernetOnly, + int dnsId + ) { + this.Id = id; + this.Name = name; + this.Description = description; + this.MasterSectionId = masterSectionId; + this.Permissions = permissions; + this.StrictMode = strictMode; + this.SubnetOrdering = subnetOrdering; + this.Order = order; + this.EditDate = editDate; + this.ShowVlan = showVlan; + this.ShowVRF = showVRF; + this.ShowSupernetOnly = showSupernetOnly; + this.DNSId = dnsId; + } + + public override string ToString() + { + return this.Name; + } +} \ No newline at end of file diff --git a/classlib/subnet.cs b/classlib/subnet.cs index e3aca08..bc8d07d 100644 --- a/classlib/subnet.cs +++ b/classlib/subnet.cs @@ -1,6 +1,7 @@ namespace PS.IPAM; using System; +[Serializable] public class Subnetwork { public int Id { get; } public string Subnet { get; } @@ -55,41 +56,12 @@ public class Subnetwork { this.ResolveDNS = resolveDNS; } - public override string ToString() - { + public string GetCIDR() { return $"{this.Subnet}/{this.Mask}"; } -} -id : 1 -subnet : fd13:6d20:29dc:cf27:: -mask : 64 -sectionId : 2 -description : Private subnet 1 -linked_subnet : -firewallAddressObject : -vrfId : 0 -masterSubnetId : 0 -allowRequests : 1 -vlanId : 1 -showName : 1 -device : 0 -permissions : {"3":"1","2":"2"} -pingSubnet : 0 -discoverSubnet : 0 -resolveDNS : 0 -DNSrecursive : 0 -DNSrecords : 0 -nameserverId : 0 -scanAgent : -customer_id : -isFolder : 0 -isFull : 0 -isPool : 0 -tag : 2 -threshold : 0 -location : -editDate : -lastScan : -lastDiscovery : -calculation : @{Type=IPv6; Host address=/; Host address (uncompressed)=/; Subnet prefix=fd13:6d20:29dc:cf27::/64; Prefix length=64; Subnet Reverse DNS=7.2.f.c.c.d.9.2.0.2.d.6.3.1.d.f.ip6.arpa; Min host IP=fd13:6d20:29dc:cf27::; Max host IP=fd13:6d20:29dc:cf27:ffff:ffff:ffff:ffff; Number of hosts=18446744073709551616; Address type=NET_IPV6} \ No newline at end of file + public override string ToString() + { + return this.GetCIDR(); + } +} \ No newline at end of file diff --git a/classlib/tag.cs b/classlib/tag.cs index 8b79ac0..9030726 100644 --- a/classlib/tag.cs +++ b/classlib/tag.cs @@ -1,5 +1,6 @@ namespace PS.IPAM; +[Serializable] public class Tag { public int Id { get; } public string Type { get; } diff --git a/classlib/vlan.cs b/classlib/vlan.cs new file mode 100644 index 0000000..2e7cff1 --- /dev/null +++ b/classlib/vlan.cs @@ -0,0 +1,32 @@ +namespace PS.IPAM; +using System; + +[Serializable] +public class Vlan { + public int Id { get; } + public int DomainId { get; } + public string Name { get; } + public int Number { get; } + public string Description { get; } + public DateTime? EditDate { get; } + public Vlan ( + int id, + int domainId, + string name, + int number, + string description, + DateTime? editDate + ) { + this.Id = id; + this.DomainId = domainId; + this.Name = name; + this.Number = number; + this.Description = description; + this.EditDate = editDate; + } + + public override string ToString() + { + return $"{this.Number}"; + } +} \ No newline at end of file diff --git a/classlib/vrf.cs b/classlib/vrf.cs new file mode 100644 index 0000000..39654c3 --- /dev/null +++ b/classlib/vrf.cs @@ -0,0 +1,32 @@ +namespace PS.IPAM; +using System; + +[Serializable] +public class Vrf { + public int Id { get; } + public string Name { get; } + public string RouteDistinguisher { get; } + public string Description { get; } + public string Sections { get; } + public DateTime? EditDate { get; } + + public Vrf( + int id, + string name, + string rd, + string description, + string sections, + DateTime? editDate + ) { + this.Id = id; + this.Name = name; + this.RouteDistinguisher = rd; + this.Description = description; + this.Sections = sections; + this.EditDate = editDate; + } + public override string ToString() + { + return this.Name; + } +} \ No newline at end of file diff --git a/functions/public/New-Session.ps1 b/functions/public/New-Session.ps1 index 560594e..1757310 100644 --- a/functions/public/New-Session.ps1 +++ b/functions/public/New-Session.ps1 @@ -3,6 +3,7 @@ function New-Session { param ( [parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0)] [ValidateNotNullOrEmpty()] + [validatescript({$_.startswith("http")})] [string]$URL, [parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=1)] [ValidateNotNullOrEmpty()] diff --git a/old/address.ps1 b/old/address.ps1 deleted file mode 100644 index 8c0f9c6..0000000 --- a/old/address.ps1 +++ /dev/null @@ -1,75 +0,0 @@ -Add-Type @' -using System; -namespace ps.ipam { - public class address { - public int Id { get; set; } - public int SubnetId { get; set; } - public string Ip { get; set; } - public bool IsGateway { get; set; } - public string Description { get; set; } - public string Hostname { get; set; } - public string MAC { get; set; } - public string Owner { get; set; } - public int TagId { get; set; } - public int DeviceId { get; set; } - public string Location { get; set; } - public int Port { get; set; } - public string Note { get; set; } - public DateTime? LastSeen { get; set; } - public bool ExcludePing { get; set; } - public int PTRignore { get; set; } - public int PTR { get; set; } - public string FirewallAddressObject { get; set; } - public DateTime? EditDate { get; set; } - public int CustomerId { get; set; } - - public address( - int id, - int subnetId, - string ip, - bool is_gateway, - string description, - string hostname, - string mac, - string owner, - int tag, - int deviceId, - string location, - int port, - string note, - DateTime? lastSeen, - bool excludePing, - int PTRignore, - int PTR, - string firewallAddressObject, - DateTime? editDate, - int customer_id - ) { - this.Id = id; - this.SubnetId = subnetId; - this.Ip = ip; - this.IsGateway = is_gateway; - this.Description = description; - this.Hostname = hostname; - this.MAC = mac; - this.Owner = owner; - this.TagId = tag; - this.DeviceId = deviceId; - this.Location = location; - this.Port = port; - this.Note = note; - this.EditDate = lastSeen; - this.ExcludePing = excludePing; - this.PTRignore = PTRignore; - this.PTR = PTR; - this.FirewallAddressObject = firewallAddressObject; - this.EditDate = editDate; - this.CustomerId = customer_id; - } - - public override string ToString() { - return this.Ip; - } - } -} -'@ \ No newline at end of file diff --git a/old/tag.ps1 b/old/tag.ps1 deleted file mode 100644 index 5d9d06e..0000000 --- a/old/tag.ps1 +++ /dev/null @@ -1,33 +0,0 @@ -class tag { - [int]$id - [string]$Type - [bool]$ShowTag - [System.Drawing.Color]$BGColor - [System.Drawing.Color]$FGColor - [bool]$Compress - [bool]$Locked - [bool]$UpdateTag - - tag ([int]$id,[string]$type,[bool]$showTag,[string]$BGColor,[string]$FGColor,[string]$compress,[string]$locked,[bool]$updateTag) { - $this.id = $id - $this.Type = $type - $this.ShowTag = $showTag - $this.BGColor = $BGColor - $this.FGColor = $FGColor - $this.Compress = $this.ToBool($compress) - $this.Locked = $this.ToBool($locked) - $this.UpdateTag = $updateTag - } - - [string] ToString() { - return $this.Type - } - - hidden [bool]ToBool([string]$str) { - if ($str -eq "Yes") { - return $true - } else { - return $false - } - } -} \ No newline at end of file diff --git a/ps.ipam.psd1 b/ps.ipam.psd1 index a267af2..a08729a 100644 Binary files a/ps.ipam.psd1 and b/ps.ipam.psd1 differ diff --git a/types/types.ps1xml b/types/types.ps1xml index d2f7654..a56619e 100644 --- a/types/types.ps1xml +++ b/types/types.ps1xml @@ -48,4 +48,125 @@ + + ps.ipam.domain + + + PSStandardMembers + + + DefaultDisplayPropertySet + + Id + Name + + + + DefaultKeyPropertySet + + Id + + + + + + + + ps.ipam.section + + + PSStandardMembers + + + DefaultDisplayPropertySet + + Id + Name + MasterSectionId + StrictMode + + + + DefaultKeyPropertySet + + Id + + + + + + + + ps.ipam.vlan + + + PSStandardMembers + + + DefaultDisplayPropertySet + + Id + Name + DomainId + Number + + + + DefaultKeyPropertySet + + Id + + + + + + + + ps.ipam.vrf + + + PSStandardMembers + + + DefaultDisplayPropertySet + + Id + Name + + + + DefaultKeyPropertySet + + Id + + + + + + + + ps.ipam.subnet + + + PSStandardMembers + + + DefaultDisplayPropertySet + + Id + Name + DomainId + Number + + + + DefaultKeyPropertySet + + Id + + + + + + \ No newline at end of file