class Github::Users::Keys

Constants

VALID_KEY_PARAM_NAMES

Public Instance Methods

all(*args)
Alias for: list
create(*args) click to toggle source

Create a public key for the authenticated user

Inputs

  • :title - Required string

  • :key - Required string. sha key

Examples

github = Github.new oauth_token: '...'
github.users.keys.create "title": "octocat@octomac", "key": "ssh-rsa AAA..."
# File lib/github_api/users/keys.rb, line 54
def create(*args)
  arguments(args) do
    sift VALID_KEY_PARAM_NAMES
  end
  post_request("/user/keys", arguments.params)
end
delete(*args) click to toggle source

Delete a public key for the authenticated user

Examples

github = Github.new oauth_token: '...'
github.users.keys.delete 'key-id'
# File lib/github_api/users/keys.rb, line 85
def delete(*args)
  arguments(args, :required => [:key_id])
  delete_request("/user/keys/#{key_id}", arguments.params)
end
find(*args)
Alias for: get
get(*args) click to toggle source

Get a single pulic key for the authenticated user

Examples

github = Github.new oauth_token: '...'
github.users.keys.get 'key-id'
# File lib/github_api/users/keys.rb, line 38
def get(*args)
  arguments(args, :required => [:key_id])
  get_request("/user/keys/#{key_id}", arguments.params)
end
Also aliased as: find
list(*args) { |el| ... } click to toggle source

List public keys for the authenticated user

Examples

github = Github.new oauth_token: '...'
github.users.keys.list
github.users.keys.list { |key| ... }

List public keys for the specified user

Examples

github.users.keys.list user: 'user-name'
github.users.keys.list user: 'user-name' { |key| ... }
# File lib/github_api/users/keys.rb, line 20
def list(*args)
  params = arguments(args).params
  response = if (user = params.delete('user'))
    get_request("/users/#{user}/keys", params)
  else
    get_request("/user/keys", params)
  end
  return response unless block_given?
  response.each { |el| yield el }
end
Also aliased as: all
update(*args) click to toggle source

Update a public key for the authenticated user

Inputs

  • :title - Required string

  • :key - Required string. sha key

Examples

github = Github.new oauth_token: '...'
github.users.keys.update 'key-id', "title": "octocat@octomac",
  "key": "ssh-rsa AAA..."
# File lib/github_api/users/keys.rb, line 72
def update(*args)
  arguments(args, :required => [:key_id]) do
    sift VALID_KEY_PARAM_NAMES
  end
  patch_request("/user/keys/#{key_id}", arguments.params)
end