class Github::Client::Repos::Collaborators

Public Instance Methods

<<(*args)
Alias for: add
add(*args) click to toggle source

Add collaborator

@example

github = Github.new
github.repos.collaborators.add 'user', 'repo', 'username'

@example

collaborators = Github::Repos::Collaborators.new
collaborators.add 'user', 'repo', 'username'

@api public

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

  put_request("/repos/#{arguments.user}/#{arguments.repo}/collaborators/#{arguments.username}", arguments.params)
end
Also aliased as: <<
all(*args)
Alias for: list
collaborator?(*args) click to toggle source

Checks if user is a collaborator for a given repository

@example

github = Github.new
github.repos.collaborators.collaborator?('user', 'repo', 'username')

@example

github = Github.new user: 'user-name', repo: 'repo-name'
github.collaborators.collaborator? username: 'collaborator'

@api public

# File lib/github_api/client/repos/collaborators.rb, line 62
def collaborator?(*args)
  arguments(args, required: [:user, :repo, :username])

  get_request("/repos/#{arguments.user}/#{arguments.repo}/collaborators/#{arguments.username}", arguments.params)
  true
rescue Github::Error::NotFound
  false
end
list(*args) { |el| ... } click to toggle source

List collaborators

When authenticating as an organization owner of an organization-owned repository, all organization owners are included in the list of collaborators. Otherwise, only users with access to the repository are returned in the collaborators list.

@example

github = Github.new
github.repos.collaborators.list 'user-name', 'repo-name'

@example

github.repos.collaborators.list 'user-name', 'repo-name' { |cbr| .. }

@return [Array]

@api public

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

  response = get_request("/repos/#{arguments.user}/#{arguments.repo}/collaborators", arguments.params)
  return response unless block_given?
  response.each { |el| yield el }
end
Also aliased as: all
remove(*args) click to toggle source

Removes collaborator

@example

github = Github.new
github.repos.collaborators.remove 'user', 'repo', 'username'

@api public

# File lib/github_api/client/repos/collaborators.rb, line 78
def remove(*args)
  arguments(args, required: [:user, :repo, :username])

  delete_request("/repos/#{arguments.user}/#{arguments.repo}/collaborators/#{arguments.username}", arguments.params)
end