1
0
mirror of https://github.com/interviewstreet/go-jira.git synced 2025-08-06 22:13:02 +02:00

Add some APIs on a JIRA group

This commit is contained in:
b4b4r07
2017-11-28 11:56:49 +09:00
parent 9f1498acb6
commit fbd056e79a
3 changed files with 106 additions and 0 deletions

24
user.go
View File

@ -27,6 +27,12 @@ type User struct {
ApplicationKeys []string `json:"applicationKeys,omitempty" structs:"applicationKeys,omitempty"`
}
// UserGroup represents the group list
type UserGroup struct {
Self string `json:"self,omitempty" structs:"self,omitempty"`
Name string `json:"name,omitempty" structs:"name,omitempty"`
}
// Get gets user info from JIRA
//
// JIRA API docs: https://docs.atlassian.com/jira/REST/cloud/#api/2/user-getUser
@ -72,3 +78,21 @@ func (s *UserService) Create(user *User) (*User, *Response, error) {
}
return responseUser, resp, nil
}
// GetGroups returns the groups which the user belongs to
//
// JIRA API docs: https://docs.atlassian.com/jira/REST/cloud/#api/2/user-getUserGroups
func (s *UserService) GetGroups(username string) (*[]UserGroup, *Response, error) {
apiEndpoint := fmt.Sprintf("/rest/api/2/user/groups?username=%s", username)
req, err := s.client.NewRequest("GET", apiEndpoint, nil)
if err != nil {
return nil, nil, err
}
userGroups := new([]UserGroup)
resp, err := s.client.Do(req, userGroups)
if err != nil {
return nil, resp, err
}
return userGroups, resp, nil
}