-
Notifications
You must be signed in to change notification settings - Fork 29
/
permission.go
109 lines (100 loc) · 3.17 KB
/
permission.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package jira
import (
"context"
"encoding/json"
"net/http"
)
type PermissionService struct {
client *Client
Scheme *PermissionSchemeService
}
type GlobalPermissionsScheme struct {
Permissions struct {
AddComments struct {
Key string `json:"key"`
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description"`
} `json:"ADD_COMMENTS"`
Administer struct {
Key string `json:"key"`
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description"`
} `json:"ADMINISTER"`
AdministerProjects struct {
Key string `json:"key"`
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description"`
} `json:"ADMINISTER_PROJECTS"`
AssignableUser struct {
Key string `json:"key"`
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description"`
} `json:"ASSIGNABLE_USER"`
AssignIssues struct {
Key string `json:"key"`
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description"`
} `json:"ASSIGN_ISSUES"`
BrowseProjects struct {
Key string `json:"key"`
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description"`
} `json:"BROWSE_PROJECTS"`
BulkChange struct {
Key string `json:"key"`
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description"`
} `json:"BULK_CHANGE"`
CloseIssues struct {
Key string `json:"key"`
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description"`
} `json:"CLOSE_ISSUES"`
CreateAttachments struct {
Key string `json:"key"`
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description"`
} `json:"CREATE_ATTACHMENTS"`
CreateIssues struct {
Key string `json:"key"`
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description"`
} `json:"CREATE_ISSUES"`
CreateProject struct {
Key string `json:"key"`
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description"`
} `json:"CREATE_PROJECT"`
} `json:"permissions"`
}
// Returns a list of permissions indicating which permissions the user has.
// Details of the user's permissions can be obtained in a global, project, or issue context.
// Docs: https://docs.go-atlassian.io/jira-software-cloud/permissions#get-my-permissions
func (p *PermissionService) Gets(ctx context.Context) (result *GlobalPermissionsScheme, response *Response, err error) {
var endpoint = "rest/api/3/permissions"
request, err := p.client.newRequest(ctx, http.MethodGet, endpoint, nil)
if err != nil {
return
}
request.Header.Set("Accept", "application/json")
response, err = p.client.Do(request)
if err != nil {
return
}
result = new(GlobalPermissionsScheme)
if err = json.Unmarshal(response.BodyAsBytes, &result); err != nil {
return
}
return
}