Fixes, added session class

This commit is contained in:
2022-12-12 13:08:04 +03:00
parent 7d0d1b53ae
commit 5a34f03779
22 changed files with 193 additions and 225 deletions

View File

@@ -1,10 +1,10 @@
function Get-Section {
[CmdletBinding(DefaultParameterSetName="ByID")]
[CmdletBinding(DefaultParameterSetName="NoParams")]
[OutputType([PS.IPAM.Section])]
param (
[parameter(Mandatory=$false,ValueFromPipeline=$true,Position=0,ParameterSetName="ByID")]
[ValidateScript({ $_ -match "^\d+$" })]
[ValidateNotNullOrEmpty()]
[string]
[int]
$Id,
[parameter(Mandatory=$true,ValueFromPipeline=$true,Position=0,ParameterSetName="ByName")]
[ValidateNotNullOrEmpty()]
@@ -12,12 +12,10 @@ function Get-Section {
$Name
)
process {
[string[]]$visiblePropertiesList = @('Id','Name','Description')
$visibleProperties = [System.Management.Automation.PSPropertySet]::new('DefaultDisplayPropertySet',$visiblePropertiesList)
$_params = @{
Controller = "sections"
Controller = [PS.IPAM.controllers]::sections
Method = "GET"
Type = [PS.IPAM.types]::Section
}
switch ($PSCmdlet.ParameterSetName) {
"ByID" { $_identifiers = @($Id) }
@@ -25,8 +23,7 @@ function Get-Section {
}
$_params.Add("Identifiers",$_identifiers)
Invoke-Request @_params | `
Add-Member -MemberType MemberSet -Name PSStandardMembers -Value $visibleProperties -PassThru
Invoke-Request @_params
}
}
Export-ModuleMember Get-Section