Module: Gitlab::Client::Users

Included in:
Gitlab::Client
Defined in:
lib/gitlab/client/users.rb

Overview

Defines methods related to users.

Instance Method Summary collapse

Instance Method Details

#create_ssh_key(title, key) ⇒ Gitlab::ObjectifiedHash

Creates a new SSH key.

Examples:

Gitlab.create_ssh_key('key title', 'key body')

Parameters:

  • title (String)

    The title of an SSH key.

  • key (String)

    The SSH key body.

Returns:



74
75
76
# File 'lib/gitlab/client/users.rb', line 74

def create_ssh_key(title, key)
  post("/user/keys", :body => {:title => title, :key => key})
end

#delete_ssh_key(id) ⇒ Gitlab::ObjectifiedHash

Deletes an SSH key.

Examples:

Gitlab.delete_ssh_key(1)

Parameters:

  • id (Integer)

    The ID of a user’s SSH key.

Returns:



85
86
87
# File 'lib/gitlab/client/users.rb', line 85

def delete_ssh_key(id)
  delete("/user/keys/#{id}")
end

#session(email, password) ⇒ Gitlab::ObjectifiedHash

Creates a new user session.

Examples:

Gitlab.session('[email protected]', 'secret12345')

Parameters:

  • email (String)

    The email of a user.

  • password (String)

    The password of a user.

Returns:



38
39
40
# File 'lib/gitlab/client/users.rb', line 38

def session(email, password)
  post("/session", :body => {:email => email, :password => password})
end

#ssh_key(id) ⇒ Gitlab::ObjectifiedHash

Gets information about SSH key.

Examples:

Gitlab.ssh_key(1)

Parameters:

  • id (Integer)

    The ID of a user’s SSH key.

Returns:



62
63
64
# File 'lib/gitlab/client/users.rb', line 62

def ssh_key(id)
  get("/user/keys/#{id}")
end

#ssh_keys(options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Gets a list of user’s SSH keys.

Examples:

Gitlab.ssh_keys

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :page (Integer)

    The page number.

  • :per_page (Integer)

    The number of results per page.

Returns:



51
52
53
# File 'lib/gitlab/client/users.rb', line 51

def ssh_keys(options={})
  get("/user/keys", :query => options)
end

#user(id = nil) ⇒ Gitlab::ObjectifiedHash

Gets information about a user. Will return information about an authorized user if no ID passed.

Examples:

Gitlab.user
Gitlab.user(2)

Parameters:

  • id (Integer) (defaults to: nil)

    The ID of a user.

Returns:



26
27
28
# File 'lib/gitlab/client/users.rb', line 26

def user(id=nil)
  id.to_i.zero? ? get("/user") : get("/users/#{id}")
end

#users(options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Gets a list of users.

Examples:

Gitlab.users

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :page (Integer)

    The page number.

  • :per_page (Integer)

    The number of results per page.

Returns:



13
14
15
# File 'lib/gitlab/client/users.rb', line 13

def users(options={})
  get("/users", :query => options)
end