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')


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')


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' })

Options Hash (options):

  • :new_name (String)

    The new name of a label.

  • :color (String)

    The color of a label.



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)


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

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