Module: Gitlab::Client::Labels

Included in:
Gitlab::Client
Defined in:
lib/gitlab/client/labels.rb

Overview

Defines methods related to labels.

Instance Method Summary collapse

Instance Method Details

#create_label(project, name, color) ⇒ Gitlab::ObjectifiedHash

Creates a new label.

Examples:

Gitlab.create_label(42, "Backlog", '#DD10AA')

Parameters:

  • project (Integer)

    The ID of a project.

  • [String] (Hash)

    a customizable set of options

Returns:



25
26
27
# File 'lib/gitlab/client/labels.rb', line 25

def create_label(project, name, color)
  post("/projects/#{project}/labels", :body => { :name => name, :color => color})
end

#delete_label(project, name) ⇒ Gitlab::ObjectifiedHash

Deletes a label.

Examples:

Gitlab.delete_label(2, 'Backlog')

Parameters:

  • project (Integer)

    The ID of a project.

  • name (String)

    The name of a label.

Returns:



53
54
55
# File 'lib/gitlab/client/labels.rb', line 53

def delete_label(project, name)
  delete("/projects/#{project}/labels", :body => {:name => name} )
end

#edit_label(project, name, options = {}) ⇒ Gitlab::ObjectifiedHash

Updates a label.

Examples:

Gitlab.edit_label(42, "Backlog", :new_name => 'TODO')
Gitlab.edit_label(42, "Backlog", :new_name => 'TODO', :color => '#DD10AA')

Parameters:

  • project (Integer)

    The ID of a project.

  • name (String)

    The name of a label.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :new_name (String)

    The new name of a label.

  • :color (String)

    The color of a label.

Returns:



41
42
43
# File 'lib/gitlab/client/labels.rb', line 41

def edit_label(project, name, options={})
  put("/projects/#{project}/labels", :body => options.merge({:name => name}))
end

#labels(project) ⇒ Array<Gitlab::ObjectifiedHash>

Gets a list of project’s labels.

Examples:

Gitlab.labels(5)

Parameters:

  • project (Integer)

    The ID of a project.

Returns:



12
13
14
# File 'lib/gitlab/client/labels.rb', line 12

def labels(project)
  get("/projects/#{project}/labels")
end