@@ -6,11 +6,16 @@ function Add-Label {
66 [OutputType ([ConfluencePS.ContentLabelSet ])]
77 param (
88 [Parameter ( Mandatory = $true )]
9- [URi ] $apiURi ,
9+ [uri ] $ApiUri ,
1010
11- [Parameter ( Mandatory = $true )]
11+ [Parameter ( Mandatory = $false )]
1212 [PSCredential ]$Credential ,
1313
14+ [Parameter ( Mandatory = $false )]
15+ [ValidateNotNull ()]
16+ [System.Security.Cryptography.X509Certificates.X509Certificate ]
17+ $Certificate ,
18+
1419 [Parameter (
1520 Position = 0 ,
1621 ValueFromPipeline = $true ,
@@ -32,7 +37,7 @@ function Add-Label {
3237 BEGIN {
3338 Write-Verbose " [$ ( $MyInvocation.MyCommand.Name ) ] Function started"
3439
35- $resourceApi = " $apiURi /content/{0}/label"
40+ $resourceApi = " $ApiUri /content/{0}/label"
3641 }
3742
3843 PROCESS {
@@ -71,13 +76,9 @@ function Add-Label {
7176 Throw $exception
7277 }
7378
74- $iwParameters = @ {
75- Uri = " "
76- Method = ' Post'
77- Body = " "
78- OutputType = [ConfluencePS.Label ]
79- Credential = $Credential
80- }
79+ $iwParameters = Copy-CommonParameter - InputObject $PSBoundParameters
80+ $iwParameters [' Method' ] = ' Post'
81+ $iwParameters [' OutputType' ] = [ConfluencePS.Label ]
8182
8283 # Extract name if an Object is provided
8384 if (($Label -is [ConfluencePS.Label ]) -or $Label -is [ConfluencePS.Label []]) {
@@ -92,14 +93,15 @@ function Add-Label {
9293 $InputObject = $_.Page
9394 }
9495 else {
95- $InputObject = Get-Page - PageID $_page - ApiURi $apiURi - Credential $Credential
96+ $authAndApiUri = Copy-CommonParameter - InputObject $PSBoundParameters - AdditionalParameter " ApiUri"
97+ $InputObject = Get-Page - PageID $_page @authAndApiUri
9698 }
9799
98100 $iwParameters [" Uri" ] = $resourceApi -f $_page
99101 $iwParameters [" Body" ] = ($Label | Foreach-Object {@ {prefix = ' global' ; name = $_ }}) | ConvertTo-Json
100102
101103 Write-Debug " [$ ( $MyInvocation.MyCommand.Name ) ] Content to be sent: $ ( $iwParameters [" Body" ] | Out-String ) "
102- If ($PSCmdlet.ShouldProcess (" Label $Label , PageID $_page " )) {
104+ if ($PSCmdlet.ShouldProcess (" Label $Label , PageID $_page " )) {
103105 $output = [ConfluencePS.ContentLabelSet ]@ { Page = $InputObject }
104106 $output.Labels += (Invoke-Method @iwParameters )
105107 $output
0 commit comments