From 4fc6bac4b55bc2290ee45eaa8a966c589937a596 Mon Sep 17 00:00:00 2001 From: Arnike Date: Mon, 5 Dec 2022 16:51:33 +0300 Subject: [PATCH] subnet type --- classlib/class/subnet.cs | 50 ++++++++++++++++++++++++---- classlib/enum/subcontrollers.cs | 11 +++++- functions/private/Invoke-Request.ps1 | 11 +++--- ps.ipam.psm1 | 2 ++ 4 files changed, 61 insertions(+), 13 deletions(-) diff --git a/classlib/class/subnet.cs b/classlib/class/subnet.cs index bc8d07d..809d00f 100644 --- a/classlib/class/subnet.cs +++ b/classlib/class/subnet.cs @@ -9,15 +9,28 @@ public class Subnetwork { public int SectionId { get; } public string Description { get; } public string LinkedSubnet { get; } - public int FirewallAddressObject { 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 Device { get; } + public int DeviceId { get; } + public string Permissions { get; } public bool PingSubnet { get; } public bool DiscoverSubnet { 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 int TagId { get; } + public int Threshold { get; } + public int LocationId { get; } + public DateTime? EditDate { get; } + public DateTime? LastScan { get; } + public DateTime? LastDiscovery { get; } public bool ResolveDNS { get; } public Subnetwork( int id, @@ -26,16 +39,28 @@ public class Subnetwork { int sectionId, string description, string linkedSubnet, - int firewallAddressObject, + string firewallAddressObject, int vrfId, int masterSubnetId, - string permissions, bool allowRequests, int vlanId, bool showName, - int device, + int deviceId, + string permissions, bool pingSubnet, bool discoverSubnet, + bool dnsRecursive, + bool dnsRecords, + int nameserverId, + bool scanAgent, + bool isFolder, + bool isFull, + int tagId, + int threshold, + int locationId, + DateTime? editDate, + DateTime? lastScan, + DateTime? lastDiscovery, bool resolveDNS ) { this.Id = id; @@ -50,9 +75,22 @@ public class Subnetwork { this.AllowRequests = allowRequests; this.VlanId = vlanId; this.ShowName = showName; - this.Device = device; + this.DeviceId = deviceId; + this.Permissions = permissions; this.PingSubnet = pingSubnet; this.DiscoverSubnet = discoverSubnet; + this.DNSRecursive = dnsRecursive; + this.DNSRecords = dnsRecords; + this.NameserverId = nameserverId; + this.ScanAgent = scanAgent; + this.IsFolder = isFolder; + this.IsFull = isFull; + this.TagId = tagId; + this.Threshold = threshold; + this.LocationId = locationId; + this.EditDate = editDate; + this.LastScan = lastScan; + this.LastDiscovery = lastDiscovery; this.ResolveDNS = resolveDNS; } diff --git a/classlib/enum/subcontrollers.cs b/classlib/enum/subcontrollers.cs index 4565802..a674d67 100644 --- a/classlib/enum/subcontrollers.cs +++ b/classlib/enum/subcontrollers.cs @@ -3,5 +3,14 @@ using System; [Serializable] public enum subcontrollers { - nameservers + nameservers, + tags, + devices, + device_types, + vlans, + vrfs, + scanagents, + locations, + nat, + racks } \ No newline at end of file diff --git a/functions/private/Invoke-Request.ps1 b/functions/private/Invoke-Request.ps1 index 843242f..81640b2 100644 --- a/functions/private/Invoke-Request.ps1 +++ b/functions/private/Invoke-Request.ps1 @@ -2,8 +2,7 @@ function Invoke-Request { [CmdletBinding()] param ( [parameter(Mandatory=$true)] - [ValidateSet("POST","GET","PATCH","DELETE")] - [string] + [methods] $Method, [parameter(Mandatory=$true)] [ValidateSet("user","vlan","subnets","addresses","sections","vrf","l2domains","tools")] @@ -50,7 +49,7 @@ function Invoke-Request { Headers = $_headers } - if ($Method -match "POST|PATCH") { + if ($Method -eq [methods]::POST -or $Method -eq [methods]) { if ($Params -is [PSCustomObject]) { $_params = @{}; $Params | Get-Member -MemberType *Property | Where-Object { @@ -65,9 +64,9 @@ function Invoke-Request { if ($_response.code -match "20\d") { switch ($Type) { - "address" { $_response.data | ForEach-Object { New-Object -TypeName "PS.IPAM.Address" -ArgumentList $_.psobject.properties.value } } - "subnet" { $_response.data | ForEach-Object { New-Object -TypeName "PS.IPAM.Subnetwork" -ArgumentList $_.psobject.properties.value } } - "tag" { $_response.data | ForEach-Object { New-Object -TypeName "PS.IPAM.Tag" -ArgumentList $_.psobject.properties.value } } + "address" { $_response.data | ForEach-Object { New-Object -TypeName "Address" -ArgumentList $_.psobject.properties.value } } + "subnet" { $_response.data | ForEach-Object { New-Object -TypeName "Subnetwork" -ArgumentList $_.psobject.properties.value } } + "tag" { $_response.data | ForEach-Object { New-Object -TypeName "Tag" -ArgumentList $_.psobject.properties.value } } Default { $_response.data } } } else { diff --git a/ps.ipam.psm1 b/ps.ipam.psm1 index 89aad14..1b25c40 100644 --- a/ps.ipam.psm1 +++ b/ps.ipam.psm1 @@ -1,3 +1,5 @@ +using namespace ps.ipam + Get-ChildItem "$(Split-Path $script:MyInvocation.MyCommand.Path)\functions" -Filter "*.ps1" -Recurse | ForEach-Object { . $_.FullName }