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

#add_time_spent_on_issue(project, id, duration) ⇒ Object

Adds spent time for an issue

Examples:

Gitlab.estimate_time_of_issue(3, 42, '3h30m')

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of an issue.

  • duration (String)

    The time spent in human format. e.g: 3h30m



183
184
185
# File 'lib/gitlab/client/issues.rb', line 183

def add_time_spent_on_issue(project, id, duration)
  post("/projects/#{url_encode project}/issues/#{id}/add_spent_time", body: { duration: duration })
end

#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:



86
87
88
# File 'lib/gitlab/client/issues.rb', line 86

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:



54
55
56
57
# File 'lib/gitlab/client/issues.rb', line 54

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:



135
136
137
# File 'lib/gitlab/client/issues.rb', line 135

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:



74
75
76
# File 'lib/gitlab/client/issues.rb', line 74

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

#estimate_time_of_issue(project, id, duration) ⇒ Object

Sets an estimated time of work for an issue.

Examples:

Gitlab.estimate_time_of_issue(3, 42, '3h30m')

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of an issue.

  • duration (String)

    The duration in human format. e.g: 3h30m



160
161
162
# File 'lib/gitlab/client/issues.rb', line 160

def estimate_time_of_issue(project, id, duration)
  post("/projects/#{url_encode project}/issues/#{id}/time_estimate", body: { duration: url_encode(duration) })
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:



36
37
38
# File 'lib/gitlab/client/issues.rb', line 36

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:



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

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

#merge_requests_closing_issue_on_merge(project, id) ⇒ Object

List merge requests that will close issue on merge

Examples:

Gitlab.merge_requests_closing_issue_on_merge(3, 42)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of an issue.



227
228
229
# File 'lib/gitlab/client/issues.rb', line 227

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

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

Move an issue.

Examples:

Gitlab.move_issue(3, 42, { to_project_id: '4' })

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

  • :to_project_id (String)

    The ID of the new project.

Returns:



148
149
150
# File 'lib/gitlab/client/issues.rb', line 148

def move_issue(project, id, options = {})
  post("/projects/#{url_encode project}/issues/#{id}/move", body: options)
end

#participants_on_issue(project, id) ⇒ Object

Get participants on issue

Examples:

@gitlab.participants_on_issue(3, 42)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of an issue.



216
217
218
# File 'lib/gitlab/client/issues.rb', line 216

def participants_on_issue(project, id)
  get("/projects/#{url_encode project}/issues/#{id}/participants")
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:



98
99
100
# File 'lib/gitlab/client/issues.rb', line 98

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

#reset_time_estimate_of_issue(project, id) ⇒ Object

Resets the estimated time for an issue to 0 seconds.

Examples:

Gitlab.reset_time_estimate_of_issue(3, 42)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of an issue.



171
172
173
# File 'lib/gitlab/client/issues.rb', line 171

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

#reset_time_spent_on_issue(project, id) ⇒ Object

Resets the total spent time for this issue to 0 seconds.

Examples:

Gitlab.reset_time_spent_on_issue(3, 42)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of an issue.



194
195
196
# File 'lib/gitlab/client/issues.rb', line 194

def reset_time_spent_on_issue(project, id)
  post("/projects/#{url_encode project}/issues/#{id}/reset_spent_time")
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:



110
111
112
# File 'lib/gitlab/client/issues.rb', line 110

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

#time_stats_for_issue(project, id) ⇒ Object

Get time tracking stats for an issue

Examples:

@gitlab.time_stats_for_issue(3, 42)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of an issue.



205
206
207
# File 'lib/gitlab/client/issues.rb', line 205

def time_stats_for_issue(project, id)
  get("/projects/#{url_encode project}/issues/#{id}/time_stats")
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:



122
123
124
# File 'lib/gitlab/client/issues.rb', line 122

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