class Github::Client::Repos::Keys

Public Instance Methods

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

Create a key

@see developer.github.com/v3/repos/keys/#create

@param [String] :user @param [String] :repo @param [Hash] params @option params [String] :title

Required string.

@option params [String] :key

Required string.

@option params [String] :read_only

If true, the key will only be able to read repository contents.
Otherwise, the key will be able to read and write.

@example

github = Github.new
github.repos.keys.create 'user-name', 'repo-name',
  title: "octocat@octomac",
  key:  "ssh-rsa AAA..."

@api public

# File lib/github_api/client/repos/keys.rb, line 73
def create(*args)
  arguments(args, required: [:user, :repo])

  post_request("/repos/#{arguments.user}/#{arguments.repo}/keys",
               arguments.params)
end
Also aliased as: add
delete(*args) click to toggle source

Delete key

@see developer.github.com/v3/repos/keys/#delete

@param [String] :user @param [String] :repo @param [Integer] :id

@example

github = Github.new
github.repos.keys.delete 'user-name', 'repo-name', 'key-id'

@api public

# File lib/github_api/client/repos/keys.rb, line 94
def delete(*args)
  arguments(args, required: [:user, :repo, :id])

  delete_request("/repos/#{arguments.user}/#{arguments.repo}/keys/#{arguments.id}", arguments.params)
end
Also aliased as: remove
find(*args)
Alias for: get
get(*args) click to toggle source

Get a key

@see developer.github.com/v3/repos/keys/#get

@param [String] :user @param [String] :repo @param [Integer] :id

@example

github = Github.new
github.repos.keys.get 'user-name', 'repo-name', 'key-id'

@api public

# File lib/github_api/client/repos/keys.rb, line 44
def get(*args)
  arguments(args, required: [:user, :repo, :id])

  get_request("/repos/#{arguments.user}/#{arguments.repo}/keys/#{arguments.id}", arguments.params)
end
Also aliased as: find
list(*args) { |el| ... } click to toggle source

List deploy keys

@see developer.github.com/v3/repos/keys/#list

@param [String] :user @param [String :repo

@example

github = Github.new
github.repos.keys.list 'user-name', 'repo-name'
github.repos.keys.list 'user-name', 'repo-name' { |key| ... }

@example

keys = Github::Repos::Keys.new user: 'user-name', repo: 'repo-name'
keys.list

@api public

# File lib/github_api/client/repos/keys.rb, line 21
def list(*args)
  arguments(args, required: [:user, :repo])

  response = get_request("/repos/#{arguments.user}/#{arguments.repo}/keys",
                         arguments.params)
  return response unless block_given?
  response.each { |el| yield el }
end
Also aliased as: all
remove(*args)
Alias for: delete