forked from rcarmstrong/go-bamboo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
urls.go
95 lines (80 loc) · 2.97 KB
/
urls.go
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
package bamboo
import (
"fmt"
)
// -- Results --
const resultsBase = "result"
func numberedResultURL(key string) string {
return fmt.Sprintf(resultsBase+"/%s?expand=changes,metadata,plan,vcsRevisions,artifacts,comments,labels,stages", key)
}
// -- Permissions --
const permissionBase = "permissions/%s"
// Users
func userPermissionsListURL(resource, key string) string {
if resource == GlobalResource {
return fmt.Sprintf(permissionBase+"/users", GlobalResource)
}
return fmt.Sprintf(permissionBase+"/%s/users", resource, key)
}
func userPermissionsURL(resource, key, username string) string {
if resource == GlobalResource {
return fmt.Sprintf(permissionBase+"/users?name=%s", GlobalResource, username)
}
return fmt.Sprintf(permissionBase+"/%s/users?name=%s", resource, key, username)
}
func editUserPermissionsURL(resource, key, username string) string {
if resource == GlobalResource {
return fmt.Sprintf(permissionBase+"/users/%s", GlobalResource, username)
}
return fmt.Sprintf(permissionBase+"/%s/users/%s", resource, key, username)
}
func availableUsersURL(resource, key string) string {
if resource == GlobalResource {
return fmt.Sprintf(permissionBase+"/available-users", GlobalResource)
}
return fmt.Sprintf(permissionBase+"/%s/available-users", resource, key)
}
// Groups
func groupPermissionsListURL(resource, key string) string {
if resource == GlobalResource {
return fmt.Sprintf(permissionBase+"/groups", GlobalResource)
}
return fmt.Sprintf(permissionBase+"/%s/groups", resource, key)
}
func groupPermissionsURL(resource, key, groupname string) string {
if resource == GlobalResource {
return fmt.Sprintf(permissionBase+"/groups?name=%s", GlobalResource, groupname)
}
return fmt.Sprintf(permissionBase+"/%s/groups?name=%s", resource, key, groupname)
}
func editGroupPermissionsURL(resource, key, groupname string) string {
if resource == GlobalResource {
return fmt.Sprintf(permissionBase+"/groups/%s", GlobalResource, groupname)
}
return fmt.Sprintf(permissionBase+"/%s/groups/%s", resource, key, groupname)
}
func availableGroupsURL(resource, key string) string {
if resource == GlobalResource {
return fmt.Sprintf(permissionBase+"/available-groups", GlobalResource)
}
return fmt.Sprintf(permissionBase+"/%s/available-groups", resource, key)
}
// Roles
func rolePermissionsListURL(resource, key string) string {
if resource == GlobalResource {
return fmt.Sprintf(permissionBase+"/roles", GlobalResource)
}
return fmt.Sprintf(permissionBase+"/%s/roles", resource, key)
}
func loggedInRolePermissionsURL(resource, key string) string {
if resource == GlobalResource {
return fmt.Sprintf(permissionBase+"/roles/LOGGED_IN", GlobalResource)
}
return fmt.Sprintf(permissionBase+"/%s/roles/LOGGED_IN", resource, key)
}
func anonymousRolePermissionsURL(resource, key string) string {
if resource == GlobalResource {
return fmt.Sprintf(permissionBase+"/roles/ANONYMOUS", GlobalResource)
}
return fmt.Sprintf(permissionBase+"/%s/roles/ANONYMOUS", resource, key)
}