AtlassianPS / ConfluencePS

Confluence REST API (including Cloud) via PowerShell
https://AtlassianPS.org/module/ConfluencePS
MIT License
152 stars 41 forks source link

Allow version comment to be included in Set-ConfluencePage #207

Open hkelley opened 1 year ago

hkelley commented 1 year ago

I saw the older issue #22 which seems to have been closed pending some API enhancements. From what I can see today, this method,

https://developer.atlassian.com/cloud/confluence/rest/v1/api-group-content/#api-wiki-rest-api-content-id-put

accepts a version object with a message property. Can this request be incorporated now?

JoseAPortilloJSC commented 2 months ago

The feature could be easily included just by adding 1 line of code:

(based on ConfluencePS 2.5.1 module, ConfluencePS.psm1) (valid for the "byObject" ParameterSetName, i.e. piping the page to the cmdlet, or passing the page as -InputObject)

Before

function Set-Page {
...
        switch ($PsCmdlet.ParameterSetName) {
            "byObject" {
                $iwParameters["Uri"] = $resourceApi -f $InputObject.ID
                $Content.version.number = ++$InputObject.Version.Number
                $Content.title = $InputObject.Title
                $Content.body.storage.value = $InputObject.Body

After

function Set-Page {
...
        switch ($PsCmdlet.ParameterSetName) {
            "byObject" {
                $iwParameters["Uri"] = $resourceApi -f $InputObject.ID
                $Content.version.number = ++$InputObject.Version.Number
                $Content.version.message = $InputObject.Version.Message       # THIS LINE
                $Content.title = $InputObject.Title
                $Content.body.storage.value = $InputObject.Body

Usage example:

$page = Get-ConfluencePage -PageID $pageId
$page.Body = ...
$page.Version.Message = "Updated by Octopus Deploy on $utcNow, deployed by $operatorName"
$page | Set-ConfluencePage

Locally patching the module (search for it on PSModulePath) leads to the desired result:

imagen

Could this be implemented? This is super useful for automated content updates. Thank you Jose.