@@ -8,6 +8,7 @@ type Workspace struct {
88 c * Client
99
1010 Repositories * Repositories
11+ Permissions * Permission
1112
1213 UUID string
1314 Type string
@@ -25,6 +26,22 @@ type WorkspaceList struct {
2526 Workspaces []Workspace
2627}
2728
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+
2845func (t * Workspace ) List () (* WorkspaceList , error ) {
2946 urlStr := t .c .requestUrl ("/workspaces" )
3047 response , err := t .c .execute ("GET" , urlStr , "" )
@@ -45,6 +62,23 @@ func (t *Workspace) Get(workspace string) (*Workspace, error) {
4562 return decodeWorkspace (response )
4663}
4764
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+
4882func decodeWorkspace (workspace interface {}) (* Workspace , error ) {
4983 var workspaceEntry Workspace
5084 workspaceResponseMap := workspace .(map [string ]interface {})
0 commit comments