Base
This commit is contained in:
37
functions/public/Get-Tag.ps1
Normal file
37
functions/public/Get-Tag.ps1
Normal file
@@ -0,0 +1,37 @@
|
||||
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
|
||||
Reference in New Issue
Block a user