Class: JenkinsApi::Client::User
- Inherits:
- 
      Object
      
        - Object
- JenkinsApi::Client::User
 
- Includes:
- UriHelper
- Defined in:
- lib/jenkins_api_client/user.rb
Overview
This class is used to communicate with Jenkins and performing some user level operations - currently limited to fetching user info, but can be extended to support updating user fields
Instance Method Summary collapse
- 
  
    
      #get(user_id)  ⇒ Hash 
    
    
  
  
  
  
  
  
  
  
  
    Get a single user. 
- 
  
    
      #initialize(client)  ⇒ User 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    Initializes a new User object. 
- 
  
    
      #list  ⇒ Hash 
    
    
  
  
  
  
  
  
  
  
  
    Get a list of users Response will include same as is available from jenkins/user/#username userid, display name, and email-address. 
- 
  
    
      #to_s  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Returns a string representation of User class. 
Methods included from UriHelper
Constructor Details
#initialize(client) ⇒ User
Initializes a new User object.
| 43 44 45 46 47 | # File 'lib/jenkins_api_client/user.rb', line 43 def initialize(client) @client = client @logger = @client.logger @timeout = @client.timeout end | 
Instance Method Details
#get(user_id) ⇒ Hash
Get a single user
| 115 116 117 | # File 'lib/jenkins_api_client/user.rb', line 115 def get(user_id) response = @client.api_get_request("/user/#{path_encode user_id}") end | 
#list ⇒ Hash
Get a list of users Response will include same as is available from jenkins/user/#username userid, display name, and email-address
| 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | # File 'lib/jenkins_api_client/user.rb', line 64 def list @logger.info "Obtaining the list of users from jenkins" # First we need to get the list of users. # This is the same as "System.list_users", but since I didn't want to # depend on that class I reproduced the request here. userlist = @client.api_get_request("/asynchPeople") users = {} userlist['users'].each { |user| # Jenkins seems ok to fetch by full-name, as long as perfect match # since the name *came* from Jenkins this seems reasonably safe user = get(user['user']['fullName']) users[user['id']] = user if user } unless userlist.nil? return users end | 
#to_s ⇒ Object
Returns a string representation of User class.
| 51 52 53 | # File 'lib/jenkins_api_client/user.rb', line 51 def to_s "#<JenkinsApi::Client::User>" end |