Types-implement #4
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,5 +3,14 @@ using System;
|
||||
|
||||
[Serializable]
|
||||
public enum subcontrollers {
|
||||
nameservers
|
||||
nameservers,
|
||||
tags,
|
||||
devices,
|
||||
device_types,
|
||||
vlans,
|
||||
vrfs,
|
||||
scanagents,
|
||||
locations,
|
||||
nat,
|
||||
racks
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using namespace ps.ipam
|
||||
|
||||
Get-ChildItem "$(Split-Path $script:MyInvocation.MyCommand.Path)\functions" -Filter "*.ps1" -Recurse | ForEach-Object {
|
||||
. $_.FullName
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user