Types-implement #5
@@ -14,10 +14,10 @@ public class Domain {
|
|||||||
string description,
|
string description,
|
||||||
string sections
|
string sections
|
||||||
) {
|
) {
|
||||||
this.Id = id;
|
this.Id = id;
|
||||||
this.Name = name;
|
this.Name = name;
|
||||||
this.Description = description;
|
this.Description = description;
|
||||||
this.Sections = sections;
|
this.Sections = sections;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
|||||||
25
classlib/class/nameserver.cs
Normal file
25
classlib/class/nameserver.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
namespace PS.IPAM;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class Nameserver {
|
||||||
|
public int Id { get; }
|
||||||
|
public string Name { get; }
|
||||||
|
public string[] NameSevers { get; }
|
||||||
|
public string Permissions { get; }
|
||||||
|
public DateTime? EditDate { get; }
|
||||||
|
|
||||||
|
public Nameserver(
|
||||||
|
int id,
|
||||||
|
string name,
|
||||||
|
string nameServers,
|
||||||
|
string permissions,
|
||||||
|
DateTime? editDate
|
||||||
|
) {
|
||||||
|
this.Id = id;
|
||||||
|
this.Name = name;
|
||||||
|
this.NameSevers = nameServers.Split(';');
|
||||||
|
this.Permissions = permissions;
|
||||||
|
this.EditDate = editDate;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,20 +34,20 @@ public class Section {
|
|||||||
bool showSupernetOnly,
|
bool showSupernetOnly,
|
||||||
int dnsId
|
int dnsId
|
||||||
) {
|
) {
|
||||||
this.Id = id;
|
this.Id = id;
|
||||||
this.Name = name;
|
this.Name = name;
|
||||||
this.Description = description;
|
this.Description = description;
|
||||||
this.MasterSectionId = masterSectionId;
|
this.MasterSectionId = masterSectionId;
|
||||||
this.Permissions = permissions;
|
this.Permissions = permissions;
|
||||||
this.StrictMode = strictMode;
|
this.StrictMode = strictMode;
|
||||||
this.SubnetOrdering = subnetOrdering;
|
this.SubnetOrdering = subnetOrdering;
|
||||||
this.Order = order;
|
this.Order = order;
|
||||||
this.EditDate = editDate;
|
this.EditDate = editDate;
|
||||||
this.ShowSubnet = showSubnet;
|
this.ShowSubnet = showSubnet;
|
||||||
this.ShowVlan = showVlan;
|
this.ShowVlan = showVlan;
|
||||||
this.ShowVRF = showVRF;
|
this.ShowVRF = showVRF;
|
||||||
this.ShowSupernetOnly = showSupernetOnly;
|
this.ShowSupernetOnly = showSupernetOnly;
|
||||||
this.DNSId = dnsId;
|
this.DNSId = dnsId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ public class Session {
|
|||||||
DateTime? expires,
|
DateTime? expires,
|
||||||
Object? credentials
|
Object? credentials
|
||||||
) {
|
) {
|
||||||
AuthType = authType;
|
AuthType = authType;
|
||||||
Token = token;
|
Token = token;
|
||||||
AppID = appId;
|
AppID = appId;
|
||||||
URL = url;
|
URL = url;
|
||||||
Expires = expires;
|
Expires = expires;
|
||||||
Credentials = credentials;
|
Credentials = credentials;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,38 +69,38 @@ public class Subnetwork {
|
|||||||
Object calculation,
|
Object calculation,
|
||||||
Object? custom_fields
|
Object? custom_fields
|
||||||
) {
|
) {
|
||||||
this.Id = id;
|
this.Id = id;
|
||||||
this.Subnet = subnet;
|
this.Subnet = subnet;
|
||||||
this.Mask = mask;
|
this.Mask = mask;
|
||||||
this.SectionId = sectionId;
|
this.SectionId = sectionId;
|
||||||
this.Description = description;
|
this.Description = description;
|
||||||
this.LinkedSubnet = linkedSubnet;
|
this.LinkedSubnet = linkedSubnet;
|
||||||
this.FirewallAddressObject = firewallAddressObject;
|
this.FirewallAddressObject = firewallAddressObject;
|
||||||
this.VrfId = vrfId;
|
this.VrfId = vrfId;
|
||||||
this.MasterSubnetId = masterSubnetId;
|
this.MasterSubnetId = masterSubnetId;
|
||||||
this.AllowRequests = allowRequests;
|
this.AllowRequests = allowRequests;
|
||||||
this.VlanId = vlanId;
|
this.VlanId = vlanId;
|
||||||
this.ShowName = showName;
|
this.ShowName = showName;
|
||||||
this.DeviceId = deviceId;
|
this.DeviceId = deviceId;
|
||||||
this.Permissions = permissions;
|
this.Permissions = permissions;
|
||||||
this.PingSubnet = pingSubnet;
|
this.PingSubnet = pingSubnet;
|
||||||
this.DiscoverSubnet = discoverSubnet;
|
this.DiscoverSubnet = discoverSubnet;
|
||||||
this.ResolveDNS = resolveDNS;
|
this.ResolveDNS = resolveDNS;
|
||||||
this.DNSRecursive = dnsRecursive;
|
this.DNSRecursive = dnsRecursive;
|
||||||
this.DNSRecords = dnsRecords;
|
this.DNSRecords = dnsRecords;
|
||||||
this.NameserverId = nameserverId;
|
this.NameserverId = nameserverId;
|
||||||
this.ScanAgent = scanAgent;
|
this.ScanAgent = scanAgent;
|
||||||
this.IsFolder = isFolder;
|
this.IsFolder = isFolder;
|
||||||
this.IsFull = isFull;
|
this.IsFull = isFull;
|
||||||
this.IsPool = isPool;
|
this.IsPool = isPool;
|
||||||
this.TagId = tagId;
|
this.TagId = tagId;
|
||||||
this.Threshold = threshold;
|
this.Threshold = threshold;
|
||||||
this.LocationId = locationId;
|
this.LocationId = locationId;
|
||||||
this.EditDate = editDate;
|
this.EditDate = editDate;
|
||||||
this.LastScan = lastScan;
|
this.LastScan = lastScan;
|
||||||
this.LastDiscovery = lastDiscovery;
|
this.LastDiscovery = lastDiscovery;
|
||||||
this.Calculation = calculation;
|
this.Calculation = calculation;
|
||||||
this.ExtendedData = custom_fields;
|
this.ExtendedData = custom_fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetCIDR() {
|
public string GetCIDR() {
|
||||||
|
|||||||
@@ -22,13 +22,13 @@ public class Vlan : DynamicObject {
|
|||||||
int customer_id,
|
int customer_id,
|
||||||
Object? custom_fields
|
Object? custom_fields
|
||||||
) {
|
) {
|
||||||
this.Id = vlanId;
|
this.Id = vlanId;
|
||||||
this.DomainId = domainId;
|
this.DomainId = domainId;
|
||||||
this.Name = name;
|
this.Name = name;
|
||||||
this.Number = number;
|
this.Number = number;
|
||||||
this.Description = description;
|
this.Description = description;
|
||||||
this.EditDate = editDate;
|
this.EditDate = editDate;
|
||||||
this.CustomerId = customer_id;
|
this.CustomerId = customer_id;
|
||||||
this.ExtendedData = custom_fields;
|
this.ExtendedData = custom_fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,13 +20,13 @@ public class Vrf {
|
|||||||
DateTime? editDate,
|
DateTime? editDate,
|
||||||
Object? custom_fields
|
Object? custom_fields
|
||||||
) {
|
) {
|
||||||
this.Id = id;
|
this.Id = id;
|
||||||
this.Name = name;
|
this.Name = name;
|
||||||
this.RouteDistinguisher = rd;
|
this.RouteDistinguisher = rd;
|
||||||
this.Description = description;
|
this.Description = description;
|
||||||
this.Sections = sections;
|
this.Sections = sections;
|
||||||
this.EditDate = editDate;
|
this.EditDate = editDate;
|
||||||
this.ExtendedData = custom_fields;
|
this.ExtendedData = custom_fields;
|
||||||
}
|
}
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ public enum types {
|
|||||||
Domain,
|
Domain,
|
||||||
Section,
|
Section,
|
||||||
Subnetwork,
|
Subnetwork,
|
||||||
|
Nameserver,
|
||||||
Tag,
|
Tag,
|
||||||
Vlan,
|
Vlan,
|
||||||
Vrf
|
Vrf
|
||||||
|
|||||||
@@ -26,11 +26,9 @@ function Invoke-Request {
|
|||||||
if ($_tokenStatus -eq "NoToken") { throw "No session available!" }
|
if ($_tokenStatus -eq "NoToken") { throw "No session available!" }
|
||||||
if ($_tokenStatus -eq "Expired") { Update-Session }
|
if ($_tokenStatus -eq "Expired") { Update-Session }
|
||||||
|
|
||||||
$Controller = $Controller
|
|
||||||
|
|
||||||
$_uri = "$($script:psipamSession.URL)/api/$($script:psipamSession.AppID)/$Controller"
|
$_uri = "$($script:psipamSession.URL)/api/$($script:psipamSession.AppID)/$Controller"
|
||||||
if ($SubController) { $_uri += "/$SubController" }
|
if ($SubController -ne $null) { $SubController;$_uri += "/$SubController" }
|
||||||
if ($Identifiers) { $_uri += "/$($Identifiers -join '/')/" }
|
if ($Identifiers -ne $null) { $_uri += "/$($Identifiers -join '/')/" }
|
||||||
|
|
||||||
$_headers = @{
|
$_headers = @{
|
||||||
"Accept" = "application/json"
|
"Accept" = "application/json"
|
||||||
@@ -60,42 +58,48 @@ function Invoke-Request {
|
|||||||
|
|
||||||
Write-Verbose -Message "Invoking web request to $($_uri), with method $($_arguments.Method), headers: $($_arguments.Headers)"
|
Write-Verbose -Message "Invoking web request to $($_uri), with method $($_arguments.Method), headers: $($_arguments.Headers)"
|
||||||
|
|
||||||
$_response = Invoke-RestMethod @_arguments
|
try {
|
||||||
|
$_response = Invoke-RestMethod @_arguments
|
||||||
if ($_response.code -match "20\d") {
|
}
|
||||||
if ($Type -is [PS.IPAM.types]) {
|
catch [System.Net.WebException] {
|
||||||
switch ($Type) {
|
switch ($_.Exception.Message) {
|
||||||
"address" {
|
"The remote server returned an error: (404) Not Found." { Write-Verbose -Message "Not found." }
|
||||||
$_paramList = @("id","subnetId","ip","is_gateway","description","hostname","mac","owner","tag","deviceId","location","port","note","lastSeen","excludePing","PTRignore","PTR","firewallAddressObject","editDate","customer_id")
|
"The remote server returned an error: (400) Bad Request." { Write-Warning -Message "Bad Request." }
|
||||||
|
Default { Write-Verbose -Message "Error occured while requesting api" }
|
||||||
$_response.data | ForEach-Object {
|
|
||||||
New-Object -TypeName ([PS.IPAM.Address]) -ArgumentList (@(($_ | Select-Object $_paramList).psobject.properties.value) + ($_ | Select-Object -Property custom_* -ExcludeProperty 'custom_\*'))
|
|
||||||
}; break
|
|
||||||
}
|
|
||||||
"vlan" {
|
|
||||||
$_paramList = @("vlanId","domainId","name","number","description","editDate","customer_id","custom_fields")
|
|
||||||
|
|
||||||
$_response.data | ForEach-Object {
|
|
||||||
New-Object -TypeName ([PS.IPAM.Vlan]) -ArgumentList (@(($_ | Select-Object $_paramList).psobject.properties.value) + ($_ | Select-Object -Property custom_* -ExcludeProperty 'custom_\*'))
|
|
||||||
}; break
|
|
||||||
}
|
|
||||||
"subnetwork" {
|
|
||||||
$_response.data | ForEach-Object {
|
|
||||||
New-Object -TypeName ([PS.IPAM.Subnetwork]) -ArgumentList (@($_.psobject.properties.value[0..30]) + ($_ | Select-Object -Property custom_* -ExcludeProperty 'custom_\*'))
|
|
||||||
}; break
|
|
||||||
}
|
|
||||||
"vrf" {
|
|
||||||
$_response.data | ForEach-Object {
|
|
||||||
New-Object -TypeName ([PS.IPAM.Vrf]) -ArgumentList (@($_.psobject.properties.value[0..5]) + ($_ | Select-Object -Property custom_* -ExcludeProperty 'custom_\*'))
|
|
||||||
}; break
|
|
||||||
}
|
|
||||||
Default { $_response.data | ForEach-Object { New-Object -TypeName ("PS.IPAM.$Type") -ArgumentList $_.psobject.properties.value } }
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
return $_response.data
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (!$_response) { return $null }
|
||||||
|
|
||||||
|
if ($Type -is [PS.IPAM.types]) {
|
||||||
|
switch ($Type) {
|
||||||
|
"address" {
|
||||||
|
$_paramList = @("id","subnetId","ip","is_gateway","description","hostname","mac","owner","tag","deviceId","location","port","note","lastSeen","excludePing","PTRignore","PTR","firewallAddressObject","editDate","customer_id")
|
||||||
|
|
||||||
|
$_response.data | ForEach-Object {
|
||||||
|
New-Object -TypeName ([PS.IPAM.Address]) -ArgumentList (@(($_ | Select-Object $_paramList).psobject.properties.value) + ($_ | Select-Object -Property custom_* -ExcludeProperty 'custom_\*'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"vlan" {
|
||||||
|
$_paramList = @("vlanId","domainId","name","number","description","editDate","customer_id","custom_fields")
|
||||||
|
|
||||||
|
$_response.data | ForEach-Object {
|
||||||
|
New-Object -TypeName ([PS.IPAM.Vlan]) -ArgumentList (@(($_ | Select-Object $_paramList).psobject.properties.value) + ($_ | Select-Object -Property custom_* -ExcludeProperty 'custom_\*'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"subnetwork" {
|
||||||
|
$_response.data | ForEach-Object {
|
||||||
|
New-Object -TypeName ([PS.IPAM.Subnetwork]) -ArgumentList (@($_.psobject.properties.value[0..30]) + ($_ | Select-Object -Property custom_* -ExcludeProperty 'custom_\*'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"vrf" {
|
||||||
|
$_response.data | ForEach-Object {
|
||||||
|
New-Object -TypeName ([PS.IPAM.Vrf]) -ArgumentList (@($_.psobject.properties.value[0..5]) + ($_ | Select-Object -Property custom_* -ExcludeProperty 'custom_\*'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Default { $_response.data | ForEach-Object { New-Object -TypeName ("PS.IPAM.$Type") -ArgumentList $_.psobject.properties.value } }
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw ("Error - $($_response.code)")
|
$_response.data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,27 @@
|
|||||||
function Assign-Tag {
|
function Assign-Tag {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
|
||||||
|
Assign tag to address.
|
||||||
|
|
||||||
|
.PARAMETER Tag
|
||||||
|
Tag object to assign.
|
||||||
|
#>
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param (
|
param (
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0)]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[PS.IPAM.Address]
|
[PS.IPAM.Address]
|
||||||
$AddressObject,
|
$AddressObject,
|
||||||
[parameter(Mandatory=$true,Position=1)]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
Position=1
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[PS.IPAM.Tag]
|
[PS.IPAM.Tag]
|
||||||
$Tag
|
$Tag
|
||||||
|
|||||||
@@ -2,28 +2,80 @@ function Get-Address {
|
|||||||
[CmdletBinding(DefaultParameterSetName="ByID")]
|
[CmdletBinding(DefaultParameterSetName="ByID")]
|
||||||
[OutputType([PS.IPAM.address])]
|
[OutputType([PS.IPAM.address])]
|
||||||
param (
|
param (
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByID"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$Id,
|
$Id,
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByIP")]
|
[parameter(
|
||||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=1,ParameterSetName="BySubnetId")]
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByIP"
|
||||||
|
)]
|
||||||
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=1,
|
||||||
|
ParameterSetName="BySubnetId"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[ipaddress]
|
[ipaddress]
|
||||||
$IP,
|
$IP,
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByHostName")]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByHostName"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]
|
[string]
|
||||||
$HostName,
|
$HostName,
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByTag")]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByHostBase"
|
||||||
|
)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[string]
|
||||||
|
$HostBase,
|
||||||
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByTag"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$TagId,
|
$TagId,
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="BySubnetId")]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="BySubnetId"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$SubnetId,
|
$SubnetId,
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="BySubnetCIDR")]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="BySubnetCIDR"
|
||||||
|
)]
|
||||||
[ValidateScript({[ipaddress] $_.Split("/")[0] -and $_.Split("/")[1] -match "\d{1,2}"})]
|
[ValidateScript({[ipaddress] $_.Split("/")[0] -and $_.Split("/")[1] -match "\d{1,2}"})]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]
|
[string]
|
||||||
@@ -39,6 +91,7 @@ function Get-Address {
|
|||||||
"ByID" { $_identifiers = @($id); break }
|
"ByID" { $_identifiers = @($id); break }
|
||||||
"ByIP" { $_identifiers = ("search",$IP); break }
|
"ByIP" { $_identifiers = ("search",$IP); break }
|
||||||
"ByHostName" { $_identifiers = ("search_hostname",$HostName); break }
|
"ByHostName" { $_identifiers = ("search_hostname",$HostName); break }
|
||||||
|
"ByHostBase" { $_identifiers = ("search_hostbase",$HostBase); break }
|
||||||
"ByTag" { $_identifiers = ("tags",$TagId,[PS.IPAM.controllers]::addresses); break }
|
"ByTag" { $_identifiers = ("tags",$TagId,[PS.IPAM.controllers]::addresses); break }
|
||||||
"BySubnetId" {
|
"BySubnetId" {
|
||||||
if ($IP) {
|
if ($IP) {
|
||||||
|
|||||||
@@ -1,16 +1,34 @@
|
|||||||
function Get-FirstFreeIP {
|
function Get-FirstFreeIP {
|
||||||
[CmdletBinding(DefaultParameterSetName="ByID")]
|
[CmdletBinding(DefaultParameterSetName="ByID")]
|
||||||
param (
|
param (
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByCIDR")]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByCIDR"
|
||||||
|
)]
|
||||||
[ValidateScript({[ipaddress] $_.Split("/")[0] -and $_.Split("/")[1] -match "\d{1,2}"})]
|
[ValidateScript({[ipaddress] $_.Split("/")[0] -and $_.Split("/")[1] -match "\d{1,2}"})]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]
|
[string]
|
||||||
$CIDR,
|
$CIDR,
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByID"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$Id,
|
$Id,
|
||||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="BySubnetObject")]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="BySubnetObject"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[PS.IPAM.Subnetwork]
|
[PS.IPAM.Subnetwork]
|
||||||
$SubnetObject
|
$SubnetObject
|
||||||
|
|||||||
@@ -2,7 +2,13 @@ function Get-L2Domain {
|
|||||||
[CmdletBinding(DefaultParameterSetName="ByID")]
|
[CmdletBinding(DefaultParameterSetName="ByID")]
|
||||||
[OutputType([PS.IPAM.Domain])]
|
[OutputType([PS.IPAM.Domain])]
|
||||||
param (
|
param (
|
||||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByID"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$Id
|
$Id
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
function Get-Nameserver {
|
function Get-Nameserver {
|
||||||
[CmdletBinding(DefaultParameterSetName="ByID")]
|
[CmdletBinding(DefaultParameterSetName="ByID")]
|
||||||
param (
|
param (
|
||||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByID"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$Id
|
$Id
|
||||||
)
|
)
|
||||||
process {
|
process {
|
||||||
[string[]]$visiblePropertiesList = @('Id','Name','Address','Description')
|
|
||||||
$visibleProperties = [System.Management.Automation.PSPropertySet]::new('DefaultDisplayPropertySet',$visiblePropertiesList)
|
|
||||||
|
|
||||||
$_params = @{
|
$_params = @{
|
||||||
Controller = [PS.IPAM.controllers]::tools
|
Controller = [PS.IPAM.controllers]::tools
|
||||||
SubController = [PS.IPAM.subcontrollers]::nameservers
|
SubController = [PS.IPAM.subcontrollers]::nameservers
|
||||||
@@ -21,8 +24,7 @@ function Get-Nameserver {
|
|||||||
$_identifiers = @($_nameserverId)
|
$_identifiers = @($_nameserverId)
|
||||||
$_params.Add("Identifiers",$_identifiers)
|
$_params.Add("Identifiers",$_identifiers)
|
||||||
|
|
||||||
Invoke-Request @_params | Select-Object @{n="address";e={$_.namesrv1}},* | Select-Object -ExcludeProperty namesrv1 | `
|
Invoke-Request @_params
|
||||||
Add-Member -MemberType MemberSet -Name PSStandardMembers -Value $visibleProperties -PassThru
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Export-ModuleMember -Function Get-Nameserver
|
Export-ModuleMember -Function Get-Nameserver
|
||||||
@@ -2,11 +2,21 @@ function Get-Section {
|
|||||||
[CmdletBinding(DefaultParameterSetName="NoParams")]
|
[CmdletBinding(DefaultParameterSetName="NoParams")]
|
||||||
[OutputType([PS.IPAM.Section])]
|
[OutputType([PS.IPAM.Section])]
|
||||||
param (
|
param (
|
||||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,Position=0,ParameterSetName="ByID")]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByID"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$Id,
|
$Id,
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,Position=0,ParameterSetName="ByName")]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByName"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]
|
[string]
|
||||||
$Name
|
$Name
|
||||||
|
|||||||
@@ -1,4 +1,13 @@
|
|||||||
function Get-Tag {
|
function Get-Tag {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
|
||||||
|
Return address tag.
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
|
||||||
|
Return address tag by id, address object or subnetwork object. Or leave it empty at take all tags at once.
|
||||||
|
#>
|
||||||
[CmdletBinding(DefaultParameterSetName="NoParams")]
|
[CmdletBinding(DefaultParameterSetName="NoParams")]
|
||||||
[OutputType([PS.IPAM.Tag])]
|
[OutputType([PS.IPAM.Tag])]
|
||||||
param (
|
param (
|
||||||
|
|||||||
@@ -1,8 +1,20 @@
|
|||||||
function Get-Vlan {
|
function Get-Vlan {
|
||||||
[CmdletBinding(DefaultParameterSetName="ByID")]
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
|
||||||
|
Return vlan object.
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
|
||||||
|
Return vlan object by vlanId, vlan number, l2domainId (return all vlans in domain), subnet object or l2domain object
|
||||||
|
|
||||||
|
.PARAMETER Number
|
||||||
|
Vlan tag
|
||||||
|
#>
|
||||||
|
[CmdletBinding(DefaultParameterSetName="NoParams")]
|
||||||
[OutputType([PS.IPAM.Vlan])]
|
[OutputType([PS.IPAM.Vlan])]
|
||||||
param (
|
param (
|
||||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")]
|
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$Id,
|
$Id,
|
||||||
|
|||||||
@@ -1,20 +1,72 @@
|
|||||||
function New-Session {
|
function New-Session {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
|
||||||
|
Creates new session to phpIPAM instance.
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
|
||||||
|
Creates new session to phpIPAM instance by provided credentials or token.
|
||||||
|
|
||||||
|
.PARAMETER URL
|
||||||
|
Base URL of phpIPAM instance.
|
||||||
|
Example - http://ipam.example.com
|
||||||
|
|
||||||
|
.PARAMETER AppID
|
||||||
|
API id (specified in phpIPAM api settings)
|
||||||
|
|
||||||
|
.PARAMETER Token
|
||||||
|
User token foor authorization
|
||||||
|
|
||||||
|
.PARAMETER IgnoreSSL
|
||||||
|
Ignore SSL errors
|
||||||
|
|
||||||
|
.OUTPUTS
|
||||||
|
None. New-Session does not generate any output.
|
||||||
|
#>
|
||||||
[CmdletBinding(DefaultParameterSetName="Credentials")]
|
[CmdletBinding(DefaultParameterSetName="Credentials")]
|
||||||
param (
|
param (
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0)]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[validatescript({$_.startswith("http")})]
|
[validatescript({$_.startswith("http")})]
|
||||||
[string]$URL,
|
[string]$URL,
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=1)]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=1
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]$AppID,
|
[string]$AppID,
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=2,ParameterSetName="Credentials")]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=2,
|
||||||
|
ParameterSetName="Credentials"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[pscredential]$Credentials,
|
[pscredential]$Credentials,
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=2,ParameterSetName="Token")]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=2,
|
||||||
|
ParameterSetName="Token"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]$Token,
|
[string]$Token,
|
||||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=3)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=3
|
||||||
|
)]
|
||||||
[switch]$IgnoreSSL = $false
|
[switch]$IgnoreSSL = $false
|
||||||
)
|
)
|
||||||
switch ($PSCmdlet.ParameterSetName) {
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
|
|||||||
@@ -1,12 +1,7 @@
|
|||||||
function New-Subnet {
|
function New-Subnet {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param (
|
param (
|
||||||
[parameter(
|
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,HelpMessage="CIDR of subnet in dotted format (e.g 10.10.10.0/24)",Position=0)]
|
||||||
Mandatory=$true,
|
|
||||||
ValueFromPipeline=$true,
|
|
||||||
ValueFromPipelineByPropertyName=$true,
|
|
||||||
HelpMessage="CIDR of subnet in dotted format (e.g 10.10.10.0/24)",
|
|
||||||
Position=0)]
|
|
||||||
[ValidateScript({[ipaddress] $_.Split("/")[0] -and $_.Split("/")[1] -match "\d{1,2}"})]
|
[ValidateScript({[ipaddress] $_.Split("/")[0] -and $_.Split("/")[1] -match "\d{1,2}"})]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]
|
[string]
|
||||||
|
|||||||
BIN
ps.ipam.psd1
BIN
ps.ipam.psd1
Binary file not shown.
@@ -145,7 +145,7 @@
|
|||||||
</Members>
|
</Members>
|
||||||
</Type>
|
</Type>
|
||||||
<Type>
|
<Type>
|
||||||
<Name>ps.ipam.subnet</Name>
|
<Name>ps.ipam.subnetwork</Name>
|
||||||
<Members>
|
<Members>
|
||||||
<MemberSet>
|
<MemberSet>
|
||||||
<Name>PSStandardMembers</Name>
|
<Name>PSStandardMembers</Name>
|
||||||
@@ -154,9 +154,10 @@
|
|||||||
<Name>DefaultDisplayPropertySet</Name>
|
<Name>DefaultDisplayPropertySet</Name>
|
||||||
<ReferencedProperties>
|
<ReferencedProperties>
|
||||||
<Name>Id</Name>
|
<Name>Id</Name>
|
||||||
<Name>Name</Name>
|
<Name>Subnet</Name>
|
||||||
<Name>DomainId</Name>
|
<Name>Mask</Name>
|
||||||
<Name>Number</Name>
|
<Name>SectionId</Name>
|
||||||
|
<Name>Description</Name>
|
||||||
</ReferencedProperties>
|
</ReferencedProperties>
|
||||||
</PropertySet>
|
</PropertySet>
|
||||||
<PropertySet>
|
<PropertySet>
|
||||||
|
|||||||
Reference in New Issue
Block a user