Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions PSPHPIPAM/Functions/Public/Vlans/Get-PhpIpamVlan.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<#
.SYNOPSIS
Get PhpIpam Vlan by vlan id
.DESCRIPTION
Get PhpIpam Vlan by vlan id
.EXAMPLE
PS C:\> New-PhpIpamVlan -Param @{"name"="vlan2"}

id : 8
name : vlan2
description :
masterVlan : 0
permissions :
strictMode : 1
subnetOrdering :
order :
editDate :
showVLAN : 0
showVRF : 0
showSupernetOnly : 0
DNS :

# get vlan by vlan id
PS C:\> get-PhpIpamVlan 8

# specify -id to using explicitly ById ParameterSet
PS C:\> get-PhpIpamVlan -id 8


.INPUTS
Inputs (if any)
.OUTPUTS
Output (if any)
.NOTES
General notes
#>
function Get-PhpIpamVlan {
[cmdletbinding()]
Param(

[parameter(
Mandatory = $true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
position = 0,
ParameterSetName = "ByID"
)]
[ValidateNotNullOrEmpty()]
[int]$ID
)

begin {

}
process {
if ($PSCmdlet.ParameterSetName -eq 'ByID') {
$r=Invoke-PhpIpamExecute -method get -controller vlan -identifiers @($ID)
}
Resolve-PhpIpamExecuteResult -result $r
}

end {

}
}

New-Alias -Name Get-PhpIpamVlanByVlanID -Value Get-PhpIpamVlan
new-alias -Name Get-PhpIpamVlanByID -Value Get-PhpIpamVlan
Export-ModuleMember -function Get-PhpIpamVlan -alias "Get-PhpIpamVlanByVlanID", "Get-PhpIpamVlanByID"
11 changes: 11 additions & 0 deletions PSPHPIPAM/Functions/Public/Vlans/Get-PhpIpamVlans.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function Get-PhpIpamVlans{
[cmdletbinding()]
param(

)
$r=Invoke-PhpIpamExecute -method get -controller vlans
Resolve-PhpIpamExecuteResult -result $r
}

New-Alias -Name Get-PhpIpamAllVlans -Value Get-PhpIpamVlans
Export-ModuleMember -Function Get-PhpIpamVlans -Alias Get-PhpIpamAllVlans
43 changes: 43 additions & 0 deletions PSPHPIPAM/Functions/Public/Vlans/New-PhpIpamVlan.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<#
.SYNOPSIS
Creates new vlan
.DESCRIPTION
Creates new vlan
.EXAMPLE
PS C:\> New-PhpIpamVlan -Params @{number=2323;name="test"}
Create an vlan 2323 with name test
.INPUTS
Hashtable contains vlan infos
.OUTPUTS
Output (if any)
.NOTES
General notes
#>
function New-PhpIpamVlan {

[cmdletBinding()]
Param(
[parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Position = 0)]
[validateScript( { $_ -is [system.collections.hashtable] })]
$Params = @{ }
)
begin {

}
process {
$r = Invoke-PhpIpamExecute -method post -controller vlans -params $Params

if ($r -and $r.success) {
if ($r.id) {
Get-PhpIpamVlanByID -id $r.id
}
} else {
Write-Error $r
}
}
end {

}
}

Export-ModuleMember -Function New-PhpIpamVlan
45 changes: 45 additions & 0 deletions PSPHPIPAM/Functions/Public/Vlans/Remove-PhpIpamVlan.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<#
.SYNOPSIS
Remove PhpIpam Vlan
.DESCRIPTION
Remove PhpIpam Vlan
.EXAMPLE
PS C:\> Remove-PhpIpamVlan -ID 20

.INPUTS
Inputs (if any)
.OUTPUTS
Output (if any)
.NOTES
General notes
#>
function Remove-PhpIpamVlan{
Param(
[parameter(
Mandatory=$true,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
Position=0,
ParameterSetName="ByID"
)]
[int]$ID
)
BEGIN{

}
PROCESS{
if($PSCmdlet.ParameterSetName -eq 'ByID'){
$r=Invoke-PhpIpamExecute -method delete -controller vlan -params @{'id'=$id}
if($r -and $r.success){
return $true
}else{
return $false
}
}
}
END{

}
}

Export-ModuleMember -Function Remove-PhpIpamVlan