@@ -8,6 +8,7 @@ type Workspace struct {
8
8
c * Client
9
9
10
10
Repositories * Repositories
11
+ Permissions * Permission
11
12
12
13
UUID string
13
14
Type string
@@ -25,6 +26,22 @@ type WorkspaceList struct {
25
26
Workspaces []Workspace
26
27
}
27
28
29
+ type Permission struct {
30
+ c * Client
31
+
32
+ Type string
33
+ }
34
+
35
+ func (t * Permission ) GetUserPermissions (organization , member string ) (* Permission , error ) {
36
+ urlStr := t .c .requestUrl ("/workspaces/%s/permissions?q=user.nickname=\" %s\" " , organization , member )
37
+ response , err := t .c .execute ("GET" , urlStr , "" )
38
+ if err != nil {
39
+ return nil , err
40
+ }
41
+
42
+ return decodePermission (response ), err
43
+ }
44
+
28
45
func (t * Workspace ) List () (* WorkspaceList , error ) {
29
46
urlStr := t .c .requestUrl ("/workspaces" )
30
47
response , err := t .c .execute ("GET" , urlStr , "" )
@@ -45,6 +62,23 @@ func (t *Workspace) Get(workspace string) (*Workspace, error) {
45
62
return decodeWorkspace (response )
46
63
}
47
64
65
+ func decodePermission (permission interface {}) * Permission {
66
+ permissionResponseMap := permission .(map [string ]interface {})
67
+ if permissionResponseMap ["size" ].(float64 ) == 0 {
68
+ return nil
69
+ }
70
+
71
+ permissionValues := permissionResponseMap ["values" ].([]interface {})
72
+ if len (permissionValues ) == 0 {
73
+ return nil
74
+ }
75
+
76
+ permissionValue := permissionValues [0 ].(map [string ]interface {})
77
+ return & Permission {
78
+ Type : permissionValue ["permission" ].(string ),
79
+ }
80
+ }
81
+
48
82
func decodeWorkspace (workspace interface {}) (* Workspace , error ) {
49
83
var workspaceEntry Workspace
50
84
workspaceResponseMap := workspace .(map [string ]interface {})
0 commit comments