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, options = {}) ⇒ Gitlab::ObjectifiedHash

Creates a new label.

Examples:

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

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • name (String)

    The name of a label.

  • color (String)

    The color of a label.

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

    A customizable set of options.

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.

Returns:



28
29
30
# File 'lib/gitlab/client/labels.rb', line 28

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

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • name (String)

    The name of a label.

Returns:



58
59
60
# File 'lib/gitlab/client/labels.rb', line 58

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

Parameters:

  • project (Integer, String)

    The ID or name 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.

  • :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.

Returns:



46
47
48
# File 'lib/gitlab/client/labels.rb', line 46

def edit_label(project, name, options={})
  put("/projects/#{url_encode 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, String)

    The ID or name of a project.

Returns:



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

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

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

Subscribes the user to a label to receive notifications

Examples:

Gitlab.subscribe_to_label(2, 'Backlog')

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • name (String)

    The name of a label.

Returns:



70
71
72
# File 'lib/gitlab/client/labels.rb', line 70

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

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • name (String)

    The name of a label.

Returns:



82
83
84
# File 'lib/gitlab/client/labels.rb', line 82

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