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.last.is_a?(Hash) ? args.pop : {}
  params['data'] = args unless args.empty?
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  _validate_presence_of(issue_id)
  _normalize_params_keys(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={})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  _normalize_params_keys(params)
  _filter_params_keys(VALID_LABEL_INPUTS, params)
  _validate_inputs(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={})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  _validate_presence_of label_id
  _normalize_params_keys 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={})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  _validate_presence_of label_id
  _normalize_params_keys(params)
  get_request("/repos/#{user}/#{repo}/labels/#{label_id}", params)
end

def initialize(options = {})

Creates new Issues::Labels API
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={})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  _validate_presence_of(issue_id)
  _normalize_params_keys(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={})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  _normalize_params_keys(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={})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  _validate_presence_of milestone_id
  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={})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  _validate_presence_of issue_id
  _normalize_params_keys 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.last.is_a?(Hash) ? args.pop : {}
  params['data'] = args unless args.empty?
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  _validate_presence_of issue_id
  _normalize_params_keys(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={})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  _validate_presence_of label_id
  _normalize_params_keys(params)
  _filter_params_keys(VALID_LABEL_INPUTS, params)
  _validate_inputs(VALID_LABEL_INPUTS, params)
  patch_request("/repos/#{user}/#{repo}/labels/#{label_id}", params)
end