diff --git a/lib/jira.js b/lib/jira.js index e919d9da..9cb11589 100644 --- a/lib/jira.js +++ b/lib/jira.js @@ -1916,5 +1916,69 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor callback(response.statusCode + ': Error while retrieving backlog'); }); }; +// ## Get de users of a group ## + // ### Takes ### + // * group: group name + // * callback: for when it's done + // + // ### Returns ### + // * error string + // * users object + /* + Users item is in the format: + { + "name": "jira-developers", + "self": "https://localhost:8443/rest/api/2/group?groupname=jira-developers", + "users": { + "size": 1, + "items": [ + { + "self": "https://localhost:8443/rest/api/2/user?username=someone", + "name": "someone", + "emailAddress": "someone@localhost.com", + "avatarUrls": { + "48x48": "https://localhost:8443/secure/useravatar?ownerId=someone&avatarId=10302", + "24x24": "https://localhost:8443/secure/useravatar?size=small&ownerId=someone&avatarId=10302", + "16x16": "https://localhost:8443/secure/useravatar?size=xsmall&ownerId=someone&avatarId=10302", + "32x32": "https://localhost:8443/secure/useravatar?size=medium&ownerId=someone&avatarId=10302" + }, + "displayName": "Someone People", + "active": true + } + ], + "max-results": 50, + "start-index": 0, + "end-index": 0 + }, + "expand": "users" + } + */ + this.getGroupMembers = function(group,maxResults,startIndex,endIndex, callback) { + startIndex = (startIndex !== undefined) ? startIndex : 0; + endIndex = (endIndex !== undefined) ? endIndex : 50 + maxResults = (maxResults !== undefined) ? maxResults : 50; + var options = { + rejectUnauthorized: this.strictSSL, + uri: this.makeUri('/group?groupname='+group + +'&expand=users['+startIndex+':'+endIndex+']' + +'&maxResults='+maxResults), + method: 'GET', + json: true + }; + console.log(options); + this.doRequest(options, function(error, response) { + if (error) { + callback(error, null); + return; + } + + if (response.statusCode === 200) { + callback(null, response.body); + return; + } + + callback(response.statusCode + ': Error while retrieving users'); + }); + }; }).call(JiraApi.prototype);