public/api-v1/content/Invoke-ConfluenceGetContentChildren.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
$ConfluenceChildExpand = @("attachment","comments","page")

#https://developer.atlassian.com/cloud/confluence/rest/#api-content-id-child-get
function Invoke-ConfluenceGetContentChildren {
    [CmdletBinding()]
    param (
        # The ID of the content to delete
        [Parameter(Mandatory,Position=0,ValueFromPipeline,ValueFromPipelineByPropertyName)]
        [Alias("Id")]
        [int32]
        $ContentId,

        # The current version of the content
        [Parameter(Position=1,ValueFromPipelineByPropertyName)]
        [Alias("ParentVersion")]
        [int32]
        $CurrentVersion,

        # Used to expand additional attributes
        [Parameter(Position=2,ValueFromPipelineByPropertyName)]
        [ValidateScript({ Compare-StringArraySubset $ConfluenceChildExpand $_ })]
        [string[]]
        $Expand,

        # The AtlassianContext object to use for the request (use New-AtlassianContext)
        [Parameter()]
        [object]
        $RequestContext
    )
    begin {
        $results = @()
    }
    process {
        $functionPath = "/wiki/rest/api/content/$ContentId/child"
        $verb = "GET"

        $query = New-PACRestMethodQueryParams @{}
        if($PSBoundParameters.ContainsKey("Expand")){$query.Add("expand",$Expand -join ",")}
        if($PSBoundParameters.ContainsKey("CurrentVersion")){$query.Add("parentVersion",$CurrentVersion)}

        $method = New-PACRestMethod $functionPath $verb $query
        $results += $method.Invoke($RequestContext)
    }
    end {
        $results
    }
}