### Home Classes Methods

### In Files

- lib/github_api/issues/labels.rb

### Parent

Github::API

### Methods

- #<<
- #add
- #all
- #create
- #delete
- #edit
- #find
- #get
- #list
- #remove
- #replace
- #update

### Class/Module Index

Quicksearch

- Github
- Github::API
- Github::Activity
- Github::Activity::Events
- Github::Activity::Notifications
- Github::Activity::Starring
- Github::Activity::Watching
- Github::ApiFactory
- Github::Arguments
- Github::Authorization
- Github::Authorizations
- Github::AutoloadHelper
- Github::Client
- Github::Configuration
- Github::Connection
- Github::Constants
- Github::CoreExt
- Github::CoreExt::OrderedHash
- Github::Descendants
- Github::Emojis
- Github::Error
- Github::Error::BadRequest
- Github::Error::ClientError
- Github::Error::Forbidden
- Github::Error::GithubError
- Github::Error::InternalServerError
- Github::Error::InvalidOptions
- Github::Error::NotAcceptable
- Github::Error::NotFound
- Github::Error::RequiredParams
- Github::Error::ServiceError
- Github::Error::ServiceUnavailable
- Github::Error::Unauthorized
- Github::Error::UnknownValue
- Github::Error::UnprocessableEntity
- Github::Error::Validations
- Github::Gists
- Github::Gists::Comments
- Github::GitData
- Github::GitData::Blobs
- Github::GitData::Commits
- Github::GitData::References
- Github::GitData::Tags
- Github::GitData::Trees
- Github::Gitignore
- Github::Issues
- Github::Issues::Assignees
- Github::Issues::Comments
- Github::Issues::Events
- Github::Issues::Labels
- Github::Issues::Milestones
- Github::Jsonable
- Github::Markdown
- Github::Meta
- Github::MimeType
- Github::Normalizer
- Github::Orgs
- Github::Orgs::Members
- Github::Orgs::Teams
- Github::PageIterator
- Github::PageLinks
- Github::PagedRequest
- Github::Pagination
- Github::ParameterFilter
- Github::ParamsHash
- Github::PullRequests
- Github::PullRequests::Comments
- Github::RateLimit
- Github::Repos
- Github::Repos::Collaborators
- Github::Repos::Comments
- Github::Repos::Commits
- Github::Repos::Contents
- Github::Repos::Downloads
- Github::Repos::Forks
- Github::Repos::Hooks
- Github::Repos::Keys
- Github::Repos::Merging
- Github::Repos::PubSubHubbub
- Github::Repos::Statistics
- Github::Repos::Statuses
- Github::Request
- Github::Request::BasicAuth
- Github::Request::Jsonize
- Github::Request::OAuth2
- Github::Resource
- Github::Response
- Github::Response::Header
- Github::Response::Jsonize
- Github::Response::Mashify
- Github::Response::RaiseError
- Github::Response::Xmlize
- Github::ResponseWrapper
- Github::S3Uploader
- Github::Say
- Github::Scopes
- Github::Search
- Github::Users
- Github::Users::Emails
- Github::Users::Followers
- Github::Users::Keys
- Github::Utils
- Github::Utils::Url
- Github::VERSION
- Github::Validations
- Github::Validations::Format
- Github::Validations::Presence
- Github::Validations::Required
- Github::Validations::Token
- Hash

No matching classes.

# Github::Issues::Labels

### Constants

VALID_LABEL_INPUTS

### Public Instance Methods

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

Add labels to an issue

# Examples

    github = Github.new
    github.issues.labels.add 'user-name', 'repo-name', 'issue-id', 'label1', 'label2', ...

    # File lib/github_api/issues/labels.rb, line 117
    def add(*args)
      arguments(args, :required => [:user, :repo, :issue_id])
      params = arguments.params
      params['data'] = arguments.remaining unless arguments.remaining.empty?

      post_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params)
    end

Also aliased as: <<
all(*args) click to toggle source
Alias for: list
create(*args) click to toggle source

Create a label

# Inputs

    <tt>:name</tt> - Required string
    <tt>:color</tt> - Required string - 6 character hex code, without leading #

# Examples

    github = Github.new user: 'user-name', repo: 'repo-name'
    github.issues.labels.create name: 'API', color: 'FFFFFF'

    # File lib/github_api/issues/labels.rb, line 69
    def create(*args)
      arguments(args, :required => [:user, :repo]) do
        sift VALID_LABEL_INPUTS
        assert_required VALID_LABEL_INPUTS
      end

      post_request("/repos/#{user}/#{repo}/labels", arguments.params)
    end

delete(*args) click to toggle source

Delete a label

# Examples

    github = Github.new
    github.issues.labels.delete 'user-name', 'repo-name', 'label-name'

    # File lib/github_api/issues/labels.rb, line 105
    def delete(*args)
      arguments(args, :required => [:user, :repo, :label_name])

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

edit(*args) click to toggle source
Alias for: update
find(*args) click to toggle source
Alias for: get
get(*args) click to toggle source

Get a single label

# Examples

    github = Github.new
    github.issues.labels.find 'user-name', 'repo-name', 'label-name'

    github = Github.new user: 'user-name', repo: 'repo-name'
    github.issues.labels.get label_name: 'bug'

    # File lib/github_api/issues/labels.rb, line 51
    def get(*args)
      arguments(args, :required => [:user, :repo, :label_name])
      params = arguments.params

      get_request("/repos/#{user}/#{repo}/labels/#{label_name}", params)
    end

Also aliased as: find
list(*args) click to toggle source

List all labels for a repository

# Examples

    github = Github.new user: 'user-name', repo: 'repo-name'
    github.issues.labels.list
    github.issues.labels.list { |label| ... }

Get labels for every issue in a milestone

# Examples

    github = Github.new
    github.issues.labels.list 'user-name', 'repo-name', milestone_id: 'milestone-id'

List labels on an issue

# Examples

    github = Github.new
    github.issues.labels.list 'user-name', 'repo-name', issue_id: 'issue-id'

    # File lib/github_api/issues/labels.rb, line 26
    def list(*args)
      arguments(args, :required => [:user, :repo])
      params = arguments.params

      response = if (milestone_id = params.delete('milestone_id'))
        get_request("/repos/#{user}/#{repo}/milestones/#{milestone_id}/labels", params)
      elsif (issue_id = params.delete('issue_id'))
        get_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params)
      else
        get_request("/repos/#{user}/#{repo}/labels", params)
      end
      return response unless block_given?
      response.each { |el| yield el }
    end

Also aliased as: all
remove(*args) click to toggle source

Remove a label from an issue

# Examples

    github = Github.new
    github.issues.labels.remove 'user-name', 'repo-name', 'issue-id',
      lable_name: 'label-name'

Remove all labels from an issue

# Examples

    github = Github.new
    github.issues.labels.remove 'user-name', 'repo-name', 'issue-id'

    # File lib/github_api/issues/labels.rb, line 138
    def remove(*args)
      arguments(args, :required => [:user, :repo, :issue_id])
      params = arguments.params

      if (label_name = params.delete('label_name'))
        delete_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels/#{label_name}", params)
      else
        delete_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params)
      end
    end

replace(*args) click to toggle source

Replace all labels for an issue

Sending an empty array ([]) will remove all Labels from the Issue.

# Examples

    github = Github.new
    github.issues.labels.replace 'user-name', 'repo-name', 'issue-id', 'label1', 'label2', ...

    # File lib/github_api/issues/labels.rb, line 157
    def replace(*args)
      arguments(args, :required => [:user, :repo, :issue_id])
      params = arguments.params
      params['data'] = arguments.remaining unless arguments.remaining.empty?

      put_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params)
    end

update(*args) click to toggle source

Update a label

# Inputs

    <tt>:name</tt> - Required string
    <tt>:color</tt> - Required string-6 character hex code, without leading #

# Examples

    github = Github.new
    github.issues.labels.update 'user-name', 'repo-name', 'label-name',
      name: 'API', color: "FFFFFF"

    # File lib/github_api/issues/labels.rb, line 89
    def update(*args)
      arguments(args, :required => [:user, :repo, :label_name]) do
        sift VALID_LABEL_INPUTS
        assert_required VALID_LABEL_INPUTS
      end

      patch_request("/repos/#{user}/#{repo}/labels/#{label_name}", arguments.params)
    end

Also aliased as: edit

[Validate]

Generated with the Darkfish Rdoc Generator 2.