Module: Gitlab::Client::Issues

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

Overview

Defines methods related to issues.

Instance Method Summary collapse

Instance Method Details

#close_issue(project, id) ⇒ Gitlab::ObjectifiedHash

Closes an issue.

Examples:

Gitlab.close_issue(3, 42)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of an issue.

Returns:



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

def close_issue(project, id)
  put("/projects/#{url_encode project}/issues/#{id}", body: { state_event: 'close' })
end

#create_issue(project, title, options = {}) ⇒ Gitlab::ObjectifiedHash

Creates a new issue.

Examples:

Gitlab.create_issue(5, 'New issue')
Gitlab.create_issue(5, 'New issue', { description: 'This is a new issue', assignee_id: 42 })

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • title (String)

    The title of an issue.

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

    A customizable set of options.

Options Hash (options):

  • :description (String)

    The description of an issue.

  • :assignee_id (Integer)

    The ID of a user to assign issue.

  • :milestone_id (Integer)

    The ID of a milestone to assign issue.

  • :labels (String)

    Comma-separated label names for an issue.

Returns:



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

def create_issue(project, title, options={})
  body = { title: title }.merge(options)
  post("/projects/#{url_encode project}/issues", body: body)
end

#delete_issue(project, id) ⇒ Gitlab::ObjectifiedHash

Deletes an issue. Only for admins and project owners

Examples:

Gitlab.delete_issue(3, 42)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of an issue.

Returns:



133
134
135
# File 'lib/gitlab/client/issues.rb', line 133

def delete_issue(project, id)
  delete("/projects/#{url_encode project}/issues/#{id}")
end

#edit_issue(project, id, options = {}) ⇒ Gitlab::ObjectifiedHash

Updates an issue.

Examples:

Gitlab.edit_issue(6, 1, { title: 'Updated title' })

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of an issue.

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

    A customizable set of options.

Options Hash (options):

  • :title (String)

    The title of an issue.

  • :description (String)

    The description of an issue.

  • :assignee_id (Integer)

    The ID of a user to assign issue.

  • :milestone_id (Integer)

    The ID of a milestone to assign issue.

  • :labels (String)

    Comma-separated label names for an issue.

  • :state_event (String)

    The state event of an issue ('close' or 'reopen').

Returns:



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

def edit_issue(project, id, options={})
  put("/projects/#{url_encode project}/issues/#{id}", body: options)
end

#issue(project, id) ⇒ Gitlab::ObjectifiedHash

Gets a single issue.

Examples:

Gitlab.issue(5, 42)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of an issue.

Returns:



34
35
36
# File 'lib/gitlab/client/issues.rb', line 34

def issue(project, id)
  get("/projects/#{url_encode project}/issues/#{id}")
end

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

Gets a list of user's issues. Will return a list of project's issues if project ID passed.

Examples:

Gitlab.issues
Gitlab.issues(5)
Gitlab.issues({ per_page: 40 })

Parameters:

  • project (Integer, String) (defaults to: nil)

    The ID or name of a project.

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

    A customizable set of options.

Options Hash (options):

  • :page (Integer)

    The page number.

  • :per_page (Integer)

    The number of results per page.

Returns:



18
19
20
21
22
23
24
# File 'lib/gitlab/client/issues.rb', line 18

def issues(project=nil, options={})
  if project.to_s.empty? && project.to_i.zero?
    get("/issues", query: options)
  else
    get("/projects/#{url_encode project}/issues", query: options)
  end
end

#reopen_issue(project, id) ⇒ Gitlab::ObjectifiedHash

Reopens an issue.

Examples:

Gitlab.reopen_issue(3, 42)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of an issue.

Returns:



96
97
98
# File 'lib/gitlab/client/issues.rb', line 96

def reopen_issue(project, id)
  put("/projects/#{url_encode project}/issues/#{id}", body: { state_event: 'reopen' })
end

#subscribe_to_issue(project, id) ⇒ Gitlab::ObjectifiedHash

Subscribe to an issue.

Examples:

Gitlab.subscribe_to_issue(3, 42)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of an issue.

Returns:



108
109
110
# File 'lib/gitlab/client/issues.rb', line 108

def subscribe_to_issue(project, id)
  post("/projects/#{url_encode project}/issues/#{id}/subscribe")
end

#unsubscribe_from_issue(project, id) ⇒ Gitlab::ObjectifiedHash

Unsubscribe from an issue.

Examples:

Gitlab.unsubscribe_from_issue(3, 42)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of an issue.

Returns:



120
121
122
# File 'lib/gitlab/client/issues.rb', line 120

def unsubscribe_from_issue(project, id)
  post("/projects/#{url_encode project}/issues/#{id}/unsubscribe")
end