-
Notifications
You must be signed in to change notification settings - Fork 2
/
jira-rest-api-libexec
executable file
·46 lines (35 loc) · 1.25 KB
/
jira-rest-api-libexec
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:-jira-rest-api}}
# Get all mates' unresolved issues.
f_get_mates_unresolved_issues() {
local mates=${1:-'error: mates missing'}
command -- "$API" get \
"/rest/api/2/search?maxResults=999&jql=assignee%20IN%20($mates)%20and%20resolution=Unresolved"
}
# Get all user's watching issues.
f_get_users_watched_issues() {
local user=${1:-'error: user missing'}
command -- "$API" get "/rest/api/2/search?maxResults=999&jql=watcher=$user"
}
# Watch all issues a user's team members have been assigned to.
f_watch_mates_issues() {
local \
user=${1:-'error: user missing'} \
mates=${2:-'error: mates missing'}
\f_get_mates_unresolved_issues "$mates" |
exec jq -r '"/rest/api/2/issue/\(.issues[].key)/watchers"' |
exec sort -u |
command -- xargs -n 1 -P 0 -I {} -- "$API" post "{}" "\"$user\""
}
# Remove user everywhere as watcher.
f_unwatch_issues() {
local user=${1:-'error: user missing'}
\f_get_users_watched_issues "$user" |
exec jq -r --arg user "$user" \
'"/rest/api/2/issue/\(.issues[].key)/watchers?username=\($user)"' |
command -- xargs -n 1 -P 0 -- "$API" delete
}
${1:+"f_$@"}
# vim: set ft=sh :