Module: Octokit::EnterpriseAdminClient::Users

Included in:
Octokit::EnterpriseAdminClient
Defined in:
lib/octokit/enterprise_admin_client/users.rb

Overview

Methods for the Enterprise User Administration API

Instance Method Summary collapse

Instance Method Details

#create_impersonation_token(login, options = {}) ⇒ Object

Creates an impersonation OAuth token.

Examples:

@admin_client.create_impersonation_token('foobar', {:scopes => ['repo:write']})

Parameters:

  • login (String)

    The user to create a token for.

  • options (Array<String>) (defaults to: {})

    :scopes The scopes to apply.

See Also:



95
96
97
# File 'lib/octokit/enterprise_admin_client/users.rb', line 95

def create_impersonation_token(, options = {})
  post "admin/users/#{}/authorizations", options
end

#create_user(login, email, options = {}) ⇒ Object

Create a new user.

Examples:

@admin_client.create_user('foobar', '[email protected]')

Parameters:

  • login (String)

    The user’s username.

  • email (String)

    The user’s email address.

See Also:



16
17
18
19
20
# File 'lib/octokit/enterprise_admin_client/users.rb', line 16

def create_user(, email, options = {})
  options[:login] = 
  options[:email] = email
  post 'admin/users', options
end

#delete_impersonation_token(login, options = {}) ⇒ Object

Deletes an impersonation OAuth token.

Examples:

@admin_client.delete_impersonation_token('foobar')

Parameters:

  • login (String)

    The user whose token should be deleted.

See Also:



105
106
107
# File 'lib/octokit/enterprise_admin_client/users.rb', line 105

def delete_impersonation_token(, options = {})
  boolean_from_response :delete, "admin/users/#{}/authorizations", options
end

#delete_key(id, options = {}) ⇒ Object

Deletes a public SSH keys.

Examples:

@admin_client.delete_key(1)

Parameters:

  • id (Number)

    The ID of the key to delete.

See Also:



124
125
126
# File 'lib/octokit/enterprise_admin_client/users.rb', line 124

def delete_key(id, options = {})
  boolean_from_response :delete, "admin/keys/#{id}", options
end

#delete_user(username, options = {}) ⇒ Object

Deletes a user.

Examples:

@admin_client.delete_key(1)

Parameters:

  • username (String)

    The username to delete.

See Also:



62
63
64
# File 'lib/octokit/enterprise_admin_client/users.rb', line 62

def delete_user(username, options = {})
  boolean_from_response :delete,  "admin/users/#{username}", options
end

#demote(user, options = {}) ⇒ Boolean

Demote a site administrator to an ordinary user

Examples:

@admin_client.demote('holman')

Parameters:

  • user (String)

    Username of the user to demote.

Returns:

  • (Boolean)

    True if demote was successful, false otherwise.

See Also:



40
41
42
# File 'lib/octokit/enterprise_admin_client/users.rb', line 40

def demote(user, options = {})
  boolean_from_response :delete, "users/#{user}/site_admin", options
end

#list_all_keys(options = {}) ⇒ Object

Lists all the public SSH keys.



114
115
116
# File 'lib/octokit/enterprise_admin_client/users.rb', line 114

def list_all_keys(options = {})
  get 'admin/keys', options
end

#promote(user, options = {}) ⇒ Boolean

Promote an ordinary user to a site administrator

Examples:

@admin_client.promote('holman')

Parameters:

  • user (String)

    Username of the user to promote.

Returns:

  • (Boolean)

    True if promote was successful, false otherwise.

See Also:



29
30
31
# File 'lib/octokit/enterprise_admin_client/users.rb', line 29

def promote(user, options = {})
  boolean_from_response :put, "users/#{user}/site_admin", options
end

#rename_user(old_login, new_login, options = {}) ⇒ Object

Rename a user.

Examples:

@admin_client.rename_user('foobar', 'foofoobar')

Parameters:

  • old_login (String)

    The user’s old username.

  • new_login (String)

    The user’s new username.

See Also:



51
52
53
54
# File 'lib/octokit/enterprise_admin_client/users.rb', line 51

def rename_user(, , options = {})
  options[:login] = 
  patch "admin/users/#{}", options
end

#suspend(user, options = {}) ⇒ Boolean

Suspend a user.

Examples:

@admin_client.suspend('holman')

Parameters:

  • user (String)

    Username of the user to suspend.

Returns:

  • (Boolean)

    True if suspend was successful, false otherwise.

See Also:



73
74
75
# File 'lib/octokit/enterprise_admin_client/users.rb', line 73

def suspend(user, options = {})
  boolean_from_response :put, "users/#{user}/suspended", options
end

#unsuspend(user, options = {}) ⇒ Boolean

Unsuspend a user.

Examples:

@admin_client.unsuspend('holman')

Parameters:

  • user (String)

    Username of the user to unsuspend.

Returns:

  • (Boolean)

    True if unsuspend was successful, false otherwise.

See Also:



84
85
86
# File 'lib/octokit/enterprise_admin_client/users.rb', line 84

def unsuspend(user, options = {})
  boolean_from_response :delete, "users/#{user}/suspended", options
end