public/api-v1/space/Invoke-ConfluenceCreateSpace.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
48
49
50
51
52
#https://developer.atlassian.com/cloud/confluence/rest/#api-api-space-post
function Invoke-ConfluenceCreateSpace {
    [CmdletBinding()]
    param (
        # The key of the new space
        [Parameter(Mandatory,Position=0,ValueFromPipelineByPropertyName)]
        [Alias("SpaceKey")]
        [string]
        $Key,

        # The name of the space
        [Parameter(Mandatory,Position=1,ValueFromPipelineByPropertyName)]
        [ValidateLength(1,200)]
        [string]
        $Name,

        # Description of the space
        [Parameter(Position=2,ValueFromPipelineByPropertyName)]
        [string]
        $Description,

        # # Permissions to associate with the space
        # [Parameter(Position=3,ValueFromPipelineByPropertyName)]
        # [pscustomobject[]]
        # $Permissions,

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

        $body = New-PACRestMethodJsonBody @{
            key = $Key
            name = $Name
        }
        if($PSBoundParameters.ContainsKey("Description")){$body.Add("description",@{plain=@{value=$Description;representation="plain"}})}
        #if($PSBoundParameters.ContainsKey("Permissions")){$body.Add("permissions",$Permissions)}

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