@@ -731,6 +731,64 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
731
731
} ) ;
732
732
} ;
733
733
734
+ // ## Search user on Jira ##
735
+ // ### Takes ###
736
+ //
737
+ // username: A query string used to search username, name or e-mail address
738
+ // startAt: The index of the first user to return (0-based)
739
+ // maxResults: The maximum number of users to return (defaults to 50).
740
+ // includeActive: If true, then active users are included in the results (default true)
741
+ // includeInactive: If true, then inactive users are included in the results (default false)
742
+ // * callback: for when it's done
743
+ //
744
+ // ### Returns ###
745
+ //
746
+ // * error: string if there's an error
747
+ // * users: array of users for the user
748
+ //
749
+ // [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#d2e3756)
750
+ //
751
+ this . searchUsers = function ( username , startAt , maxResults , includeActive , includeInactive , callback ) {
752
+ startAt = ( startAt !== undefined ) ? startAt : 0 ;
753
+ maxResults = ( maxResults !== undefined ) ? maxResults : 50 ;
754
+ includeActive = ( includeActive !== undefined ) ? includeActive : true ;
755
+ includeInactive = ( includeInactive !== undefined ) ? includeInactive : false ;
756
+
757
+ var options = {
758
+ rejectUnauthorized : this . strictSSL ,
759
+ uri : this . makeUri (
760
+ '/user/search?username=' + username +
761
+ '&startAt=' + startAt +
762
+ '&maxResults=' + maxResults +
763
+ '&includeActive=' + includeActive +
764
+ '&includeInactive=' + includeInactive ) ,
765
+ method : 'GET' ,
766
+ json : true ,
767
+ followAllRedirects : true
768
+ } ;
769
+
770
+ this . request ( options , function ( error , response , body ) {
771
+
772
+ if ( error ) {
773
+ callback ( error , null ) ;
774
+ return ;
775
+ }
776
+
777
+ if ( response . statusCode === 400 ) {
778
+ callback ( 'Unable to search' ) ;
779
+ return ;
780
+ }
781
+
782
+ if ( response . statusCode !== 200 ) {
783
+ callback ( response . statusCode + ': Unable to connect to JIRA during search.' ) ;
784
+ return ;
785
+ }
786
+
787
+ callback ( null , body ) ;
788
+
789
+ } ) ;
790
+ } ;
791
+
734
792
// ## Get issues related to a user ##
735
793
// ### Takes ###
736
794
//
0 commit comments