class Github::Issues::Labels
def add(user_name, repo_name, issue_id, *args)
github.issues.labels.add 'user-name', 'repo-name', 'issue-id', 'label1', 'label2', ...
github = Github.new
= Examples
Add labels to an issue
def add(user_name, repo_name, issue_id, *args) params = args.extract_options! params['data'] = args unless args.empty? set :user => user_name, :repo => repo_name assert_presence_of user, repo, issue_id normalize! params post_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params) end
def create(user_name, repo_name, params={})
github.issues.labels.create :name => 'API', :color => 'FFFFFF'
github = Github.new :user => 'user-name', :repo => 'repo-name'
= Examples
:color - Required string - 6 character hex code, without leading #
:name - Required string
= Inputs
Create a label
def create(user_name, repo_name, params={}) set :user => user_name, :repo => repo_name assert_presence_of user, repo normalize! params filter! VALID_LABEL_INPUTS, params assert_required_keys(VALID_LABEL_INPUTS, params) post_request("/repos/#{user}/#{repo}/labels", params) end
def delete(user_name, repo_name, label_id, params={})
github.issues.labels.delete 'user-name', 'repo-name', 'label-id'
github = Github.new
= Examples
Delete a label
def delete(user_name, repo_name, label_id, params={}) set :user => user_name, :repo => repo_name assert_presence_of user, repo assert_presence_of label_id normalize! params delete_request("/repos/#{user}/#{repo}/labels/#{label_id}", params) end
def get(user_name, repo_name, label_id, params={})
github.issues.labels.find 'user-name', 'repo-name', 'label-id'
github = Github.new
= Examples
Get a single label
def get(user_name, repo_name, label_id, params={}) set :user => user_name, :repo => repo_name assert_presence_of user, repo, label_id normalize! params get_request("/repos/#{user}/#{repo}/labels/#{label_id}", params) end
def initialize(options = {})
def initialize(options = {}) super(options) end
def issue(user_name, repo_name, issue_id, params={})
@github.issues.labels.issue 'user-name', 'repo-name', 'issue-id'
@github = Github.new
= Examples
List labels on an issue
def issue(user_name, repo_name, issue_id, params={}) set :user => user_name, :repo => repo_name assert_presence_of user, repo, issue_id normalize! params get_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params) end
def list(user_name, repo_name, params={})
github.issues.labels.list { |label| ... }
github.issues.labels.list
github = Github.new :user => 'user-name', :repo => 'repo-name'
= Examples
List all labels for a repository
def list(user_name, repo_name, params={}) set :user => user_name, :repo => repo_name assert_presence_of user, repo normalize! params response = get_request("/repos/#{user}/#{repo}/labels", params) return response unless block_given? response.each { |el| yield el } end
def milestone(user_name, repo_name, milestone_id, params={})
github.issues.labels. 'user-name', 'repo-name', 'milestone-id'
github = Github.new
= Examples
Get labels for every issue in a milestone
def milestone(user_name, repo_name, milestone_id, params={}) set :user => user_name, :repo => repo_name assert_presence_of user, repo, milestone_id normalize! params response = get_request("/repos/#{user}/#{repo}/milestones/#{milestone_id}/labels", params) return response unless block_given? response.each { |el| yield el } end
def remove(user_name, repo_name, issue_id, label_id=nil, params={})
github.issues.labels.remove 'user-name', 'repo-name', 'issue-id'
github = Github.new
= Examples
Remove all labels from an issue
github.issues.labels.remove 'user-name', 'repo-name', 'issue-id', 'label-id'
github = Github.new
= Examples
Remove a label from an issue
def remove(user_name, repo_name, issue_id, label_id=nil, params={}) set :user => user_name, :repo => repo_name assert_presence_of user, repo, issue_id normalize! params if label_id delete_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels/#{label_id}", params) else delete_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params) end end
def replace(user_name, repo_name, issue_id, *args)
github.issues.labels.replace 'user-name', 'repo-name', 'issue-id', 'label1', 'label2', ...
github = Github.new
= Examples
Sending an empty array ([]) will remove all Labels from the Issue.
Replace all labels for an issue
def replace(user_name, repo_name, issue_id, *args) params = args.extract_options! params['data'] = args unless args.empty? set :user => user_name, :repo => repo_name assert_presence_of user, repo, issue_id normalize! params put_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params) end
def update(user_name, repo_name, label_id, params={})
:name => 'API', :color => "FFFFFF"
@github.issues.labels.update 'user-name', 'repo-name', 'label-id',
@github = Github.new
= Examples
:color - Required string-6 character hex code, without leading #
:name - Required string
= Inputs
Update a label
def update(user_name, repo_name, label_id, params={}) set :user => user_name, :repo => repo_name assert_presence_of user, repo, label_id normalize! params filter! VALID_LABEL_INPUTS, params assert_required_keys(VALID_LABEL_INPUTS, params) patch_request("/repos/#{user}/#{repo}/labels/#{label_id}", params) end