Module: Gitlab::Client::Labels

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

Overview

Defines methods related to project labels.

Instance Method Summary collapse

Instance Method Details

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

Creates a new label.

Examples:

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

Options Hash (options):

  • :description (String)

    The description of the label.

  • :priority (String)

    The priority of the label. Must be greater or equal than zero or null to remove the priority.


30
31
32
# File 'lib/gitlab/client/labels.rb', line 30

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

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

Deletes a label.

Examples:

Gitlab.delete_label(2, 'Backlog')

60
61
62
# File 'lib/gitlab/client/labels.rb', line 60

def delete_label(project, name)
  delete("/projects/#{url_encode 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.

  • :description (String)

    The description of the label.

  • :priority (String)

    The priority of the label. Must be greater or equal than zero or null to remove the priority.


48
49
50
# File 'lib/gitlab/client/labels.rb', line 48

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

#labels(project, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Gets a list of project's labels.

Examples:

Gitlab.labels(5)

14
15
16
# File 'lib/gitlab/client/labels.rb', line 14

def labels(project, options = {})
  get("/projects/#{url_encode project}/labels", query: options)
end

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

Subscribes the user to a label to receive notifications

Examples:

Gitlab.subscribe_to_label(2, 'Backlog')

72
73
74
# File 'lib/gitlab/client/labels.rb', line 72

def subscribe_to_label(project, name)
  post("/projects/#{url_encode project}/labels/#{url_encode name}/subscribe")
end

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

Unsubscribes the user from a label to not receive notifications from it

Examples:

Gitlab.unsubscribe_from_label(2, 'Backlog')

84
85
86
# File 'lib/gitlab/client/labels.rb', line 84

def unsubscribe_from_label(project, name)
  post("/projects/#{url_encode project}/labels/#{url_encode name}/unsubscribe")
end