Class: JenkinsApi::Client::User
- Inherits:
-
Object
- Object
- JenkinsApi::Client::User
- 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 System class.
Constructor Details
#initialize(client) ⇒ User
Initializes a new User object.
41 42 43 44 45 |
# File 'lib/jenkins_api_client/user.rb', line 41 def initialize(client) @client = client @logger = @client.logger @timeout = @client.timeout end |
Instance Method Details
#get(user_id) ⇒ Hash
Get a single user
113 114 115 |
# File 'lib/jenkins_api_client/user.rb', line 113 def get(user_id) response = @client.api_get_request("/user/#{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
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/jenkins_api_client/user.rb', line 62 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 System class.
49 50 51 |
# File 'lib/jenkins_api_client/user.rb', line 49 def to_s "#<JenkinsApi::Client::User>" end |