XML-RPC/Administration.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
#Requires -Version 3.0
<# Administration #>
function Export-ConfluenceSite {
    <#
    .SYNOPSIS
        Export the Confluence Instance to a File
 
    .DESCRIPTION
        Exports a Confluence instance and returns a String holding the URL for the download.
        The boolean argument indicates whether or not attachments ought to be included in the export.
        This method respects the property admin.ui.allow.manual.backup.download (as described on this page in confluence documentation); if the property is not set, or is set to false, this method will not return the download link, but instead return a string containing the actual path on the server where the export is located.
 
    .NOTES
        AUTHOR : Oliver Lipkau <oliver@lipkau.net>
        VERSION: 0.0.1 - OL - Initial Code
                 1.0.0 - OL - Replaced hashtables with Objects
 
    .INPUTS
        switch
 
    .OUTPUTS
        string
 
    .EXAMPLE
        Export-ConfluenceSite -apiURi "http://example.com" -token "000000"
        -----------
        Description
        Exports the Confluence Instance
 
 
    .EXAMPLE
        $param = @{apiURi = "http://example.com"; token = "000000"}
        Export-ConfluenceSite @param -includeAttachments
        -----------
        Description
        Exports the Cunfluence Instance and all it's attachments
 
    .LINK
        Atlassians's Docs:
            String exportSite(String token, boolean exportAttachments)
 
    #>

    [CmdletBinding(
    )]
    [OutputType(
        [string]
    )]
    param(
        # The URi of the API interface.
        [Parameter(
            Position=0,
            Mandatory=$true
        )]
        [string]$apiURi,

        # Confluence's Authentication Token.
        [Parameter(
            Position=1,
            Mandatory=$true
        )]
        [string]$Token,

        # Include Attachments in the export file.
        [switch]$includeAttachments
    )

    Begin
        { Write-Verbose "$($MyInvocation.MyCommand.Name):: Function started" }

    Process {
        Write-Verbose "$($MyInvocation.MyCommand.Name):: Exporting Confluence Instance $(if ($includeAttachments) {"including Attachments"})"
        ConvertFrom-Xml (Invoke-ConfluenceCall -Url $apiURi -MethodName "confluence2.exportSite" -Params ($token,$includeAttachments))
    }

    End
        { Write-Verbose "$($MyInvocation.MyCommand.Name):: Function ended" }
}
function Get-ConfluenceClusterInformation {
    <#
    .SYNOPSIS
        Returns information about the cluster this node is part of
 
    .DESCRIPTION
        Returns information about the cluster this node is part of
 
    .NOTES
        AUTHOR : Oliver Lipkau <oliver@lipkau.net>
        VERSION: 0.0.1 - OL - Initial Code
                 1.0.0 - OL - Replaced hashtables with Objects
 
    .INPUTS
 
 
    .OUTPUTS
        Confluence.ClusterInformation
 
    .EXAMPLE
        Get-ConfluenceClusterInformation -apiURi "http://example.com" -token "000000"
        -----------
        Description
        Fetch the Cluster Information of the Confluence Instance
 
    .LINK
        Atlassians's Docs:
            ClusterInformation getClusterInformation(String token)
 
    #>

    [CmdletBinding(
    )]
    [OutputType(
        [Confluence.ClusterInformation]
    )]
    param(
        # The URi of the API interface.
        [Parameter(
            Position=0,
            Mandatory=$true
        )]
        [string]$apiURi,

        # Confluence's Authentication Token.
        [Parameter(
            Position=1,
            Mandatory=$true
        )]
        [string]$Token
    )

    Begin
        { Write-Verbose "$($MyInvocation.MyCommand.Name):: Function started" }

    Process {
        Write-Verbose "$($MyInvocation.MyCommand.Name):: Getting Cluster Information"
        ConvertFrom-Xml (Invoke-ConfluenceCall -Url $apiURi -MethodName "confluence2.getClusterInformation" -Params ($token))
    }

    End
        { Write-Verbose "$($MyInvocation.MyCommand.Name):: Function ended" }
}
function Get-ConfluenceClusterNodeStatuses {
    <#
    .SYNOPSIS
        Returns a Vector of NodeStatus objects containing information about each node in the cluster
 
    .DESCRIPTION
        Returns a Vector of NodeStatus objects containing information about each node in the cluster
 
    .NOTES
        AUTHOR : Oliver Lipkau <oliver@lipkau.net>
        VERSION: 0.0.1 - OL - Initial Code
                 1.0.0 - OL - Replaced hashtables with Objects
 
    .INPUTS
         
 
    .OUTPUTS
         
 
    .EXAMPLE
        Get-ConfluenceClusterNodeStatuses -apiURi "http://example.com" -token "000000"
        -----------
        Description
        Returns a Vector of NodeStatus objects containing information about each node in the cluster
 
    .LINK
        Atlassians's Docs:
            Vector getClusterNodeStatuses(String token)
 
    #>

    [CmdletBinding(
    )]
    param(
        # The URi of the API interface.
        [Parameter(
            Position=0,
            Mandatory=$true
        )]
        [string]$apiURi,

        # Confluence's Authentication Token.
        [Parameter(
            Position=1,
            Mandatory=$true
        )]
        [string]$Token
    )

    Begin
        { Write-Verbose "$($MyInvocation.MyCommand.Name):: Function started" }

    Process {
        Write-Verbose "$($MyInvocation.MyCommand.Name):: Getting Cluster Node Status"
        ConvertFrom-Xml (Invoke-ConfluenceCall -Url $apiURi -MethodName "confluence2.getClusterNodeStatuses" -Params ($token))
    }

    End
        { Write-Verbose "$($MyInvocation.MyCommand.Name):: Function ended" }
}
function Test-ConfluencePluginEnabled {
    <#
    .SYNOPSIS
        Returns information about the cluster this node is part of
 
    .DESCRIPTION
        Returns information about the cluster this node is part of
 
    .NOTES
        AUTHOR : Oliver Lipkau <oliver@lipkau.net>
        VERSION: 0.0.1 - OL - Initial Code
                 1.0.0 - OL - Replaced hashtables with Objects
 
    .INPUTS
        string
 
    .OUTPUTS
        bool
 
    .EXAMPLE
        Test-ConfluencePluginEnabled -apiURi "http://example.com" -token "000000" -Plugin "pluginName"
        -----------
        Description
        Return if the Plugin "pluginName" is enabled
 
    .LINK
        Atlassians's Docs:
            boolean isPluginEnabled(String token, String pluginKey) - returns true if the plugin is installed and enabled, otherwise false.
 
    #>

    [CmdletBinding(
    )]
    [OutputType(
        [bool]
    )]
    param(
        # The URi of the API interface.
        [Parameter(
            Position=0,
            Mandatory=$true
        )]
        [string]$apiURi,

        # Confluence's Authentication Token.
        [Parameter(
            Position=1,
            Mandatory=$true
        )]
        [string]$Token,

        # Identifier of the Plugin to be tested.
        [Parameter(
            Position=2,
            Mandatory=$true,
            ValueFromPipeline=$true,
            ValueFromPipelineByPropertyName=$true
        )]
        [Alias("Name")]
        [string]$Plugin
    )

    Begin
        { Write-Verbose "$($MyInvocation.MyCommand.Name):: Function started" }

    Process {
        Write-Verbose "$($MyInvocation.MyCommand.Name):: Getting Status of Plugin $Plugin"
        ConvertFrom-Xml (Invoke-ConfluenceCall -Url $apiURi -MethodName "confluence2.isPluginEnabled" -Params ($token,$Plugin))
    }

    End
        { Write-Verbose "$($MyInvocation.MyCommand.Name):: Function ended" }
}
<#function Install-ConfluencePlugin {
    #boolean installPlugin(String token, String pluginFileName, byte[] pluginData) - installs a plugin in Confluence. Returns false if the file is not a JAR or XML file. Throws an exception if the installation fails for another reason.
}#>

<# /Administration #>