37 lines
1.2 KiB
PowerShell
37 lines
1.2 KiB
PowerShell
function Get-Tag {
|
|
[CmdletBinding(DefaultParameterSetName="NoParams")]
|
|
[OutputType('tag')]
|
|
param (
|
|
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")]
|
|
[ValidateScript({ $_ -match "^\d+$" })]
|
|
[ValidateNotNullOrEmpty()]
|
|
[string]
|
|
$Id,
|
|
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByAddressObject")]
|
|
[ValidateNotNullOrEmpty()]
|
|
[ps.ipam.address]
|
|
$InputObject
|
|
)
|
|
process {
|
|
$_params = @{
|
|
Controller = "addresses"
|
|
Method = "GET"
|
|
Type = "tag"
|
|
}
|
|
$_identifiers = @("tags")
|
|
switch ($PSCmdlet.ParameterSetName) {
|
|
"ByID" { $_identifiers += $Id }
|
|
"ByAddressObject" {
|
|
if ($InputObject.TagId) {
|
|
$_identifiers += $InputObject.TagId
|
|
} else {
|
|
return $null
|
|
}
|
|
}
|
|
}
|
|
$_params.Add("Identifiers",$_identifiers)
|
|
|
|
Invoke-Request @_params
|
|
}
|
|
}
|
|
Export-ModuleMember -Function Get-Tag |