-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfluence-rest-api-libexec
More file actions
executable file
·46 lines (35 loc) · 1 KB
/
confluence-rest-api-libexec
File metadata and controls
executable file
·46 lines (35 loc) · 1 KB
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
#!/bin/sh
#
# Libexec: Confluence REST API.
export API=${API:-${api:-confluence-rest-api}}
f_get_space_keys() {
exec "$API" get space |
command -- jq -rc '.results[] | .key'
}
# (Un-)Watch all confluence spaces.
f_watch_spaces() {
local \
method=${1:-'error: method missing: delete|post'} \
username=${2:-'error: username missing'}
\f_get_space_keys |
exec grep -F -v -e "~$username" |
command -- xargs -n 1 -P 0 -I {} -- "$API" "$method" \
"/rest/api/user/watch/space/{}?username=$username"
}
# Add label(s) to entity.
f_label_entity() {
local \
id=${1:?id missing} \
data
data=$(exec jq -nR '[inputs | {prefix: "global", "name": .}]')
command -- "$API" post "/rest/api/content/$id/label" "$data"
}
# Delete label from entity.
f_unlabel_entity() {
local \
id=${1:?id missing} \
label=${2:?label missing}
command -- "$API" delete "/rest/api/content/$id/label/$label"
}
${1:+"f_$@"}
# vim: set ft=sh :