Skip to content

Instantly share code, notes, and snippets.

@JustLogic
Last active January 3, 2018 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JustLogic/fb66ff29390dc1abbf9f1439a0e20993 to your computer and use it in GitHub Desktop.
Save JustLogic/fb66ff29390dc1abbf9f1439a0e20993 to your computer and use it in GitHub Desktop.
JiraApiHelper is a wrapper around the .net jira api, with a function to get all users by iterating over the alphabet
public class JiraApiHelper
{
private readonly Jira inner_client;
public JiraApiHelper()
{
this.inner_client = Jira.CreateRestClient("JiraUrl", "UserName", "Password");
}
public List<User> GetAllUsers()
{
var users = new List<User>();
foreach (var item in "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z".Split(','))
{
var search_result = inner_client.RestClient.ExecuteRequest<List<User>>(Method.GET,
$"/rest/api/2/user/search?username={item}");
foreach (var user in search_result)
{
if (!users.Any(x => x.Key.Equals(user.Key, StringComparison.CurrentCultureIgnoreCase)))
users.Add(user);
}
}
return users;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment