gitlab-customer-support-operations_gitlab 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/support_ops_gitlab/gitlab/badges.rb +229 -0
- data/lib/support_ops_gitlab/gitlab/base.rb +552 -0
- data/lib/support_ops_gitlab/gitlab/client.rb +51 -0
- data/lib/support_ops_gitlab/gitlab/commits.rb +198 -0
- data/lib/support_ops_gitlab/gitlab/configuration.rb +86 -0
- data/lib/support_ops_gitlab/gitlab/epics.rb +325 -0
- data/lib/support_ops_gitlab/gitlab/events.rb +167 -0
- data/lib/support_ops_gitlab/gitlab/gpg_keys.rb +64 -0
- data/lib/support_ops_gitlab/gitlab/group_memberships.rb +33 -0
- data/lib/support_ops_gitlab/gitlab/groups.rb +431 -0
- data/lib/support_ops_gitlab/gitlab/invitations.rb +72 -0
- data/lib/support_ops_gitlab/gitlab/issues.rb +606 -0
- data/lib/support_ops_gitlab/gitlab/jobs.rb +61 -0
- data/lib/support_ops_gitlab/gitlab/markdown.rb +54 -0
- data/lib/support_ops_gitlab/gitlab/merge_requests.rb +411 -0
- data/lib/support_ops_gitlab/gitlab/milestones.rb +195 -0
- data/lib/support_ops_gitlab/gitlab/namespaces.rb +184 -0
- data/lib/support_ops_gitlab/gitlab/notes.rb +182 -0
- data/lib/support_ops_gitlab/gitlab/pipelines.rb +258 -0
- data/lib/support_ops_gitlab/gitlab/project_access_tokens.rb +245 -0
- data/lib/support_ops_gitlab/gitlab/project_memberships.rb +33 -0
- data/lib/support_ops_gitlab/gitlab/project_webhook_events.rb +33 -0
- data/lib/support_ops_gitlab/gitlab/project_webhooks.rb +218 -0
- data/lib/support_ops_gitlab/gitlab/projects.rb +741 -0
- data/lib/support_ops_gitlab/gitlab/repository_files.rb +102 -0
- data/lib/support_ops_gitlab/gitlab/repository_submodules.rb +78 -0
- data/lib/support_ops_gitlab/gitlab/ssh_keys.rb +67 -0
- data/lib/support_ops_gitlab/gitlab/user_emails.rb +147 -0
- data/lib/support_ops_gitlab/gitlab/user_memberships.rb +21 -0
- data/lib/support_ops_gitlab/gitlab/user_tokens.rb +344 -0
- data/lib/support_ops_gitlab/gitlab/users.rb +1059 -0
- data/lib/support_ops_gitlab/gitlab.rb +45 -0
- data/lib/support_ops_gitlab.rb +28 -0
- metadata +251 -0
@@ -0,0 +1,606 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines the module SupportOps.
|
4
|
+
module SupportOps
|
5
|
+
# Defines the module GitLab
|
6
|
+
module GitLab
|
7
|
+
##
|
8
|
+
# Defines the class Issues within the module {SupportOps::GitLab}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.0
|
12
|
+
# @attr [String] add_labels Comma-separated label names to add to an issue; if a label does not already exist, this creates a new project label and assigns it to the issue
|
13
|
+
# @attr [Array] assignee_ids The IDs of the users to assign the issue to
|
14
|
+
# @attr [Array] assignees An array of users assigned to the issue
|
15
|
+
# @attr [Hash] author The author of the issue
|
16
|
+
# @attr [String] closed_at The timestamp the issue was closed at
|
17
|
+
# @attr [Hash] closed_by The user who closed the issue
|
18
|
+
# @attr [Boolean] confidential If the issue is confidential or not
|
19
|
+
# @attr [String] created_at The timestamp of when the issue was created
|
20
|
+
# @attr [String] description The issue's description
|
21
|
+
# @attr [Boolean] discussion_locked If discussion on the issue is locked or not
|
22
|
+
# @attr [String] discussion_to_resolve The ID of a discussion to resolve; this fills out the issue with a default description and mark the discussion as resolved
|
23
|
+
# @attr [Integer] downvotes The number of downvotes the issue has
|
24
|
+
# @attr [String] due_date The due date
|
25
|
+
# @attr [Hash] epic the epic the issue is attached to
|
26
|
+
# @attr [Integer] epic_id The ID of the epic the issue is attached to
|
27
|
+
# @attr [Integer] epic_iid IID of the epic to add the issue to
|
28
|
+
# @attr [Boolean] has_tasks If the issue has attached tasks or not
|
29
|
+
# @attr [String] health_status The current health status of the issue
|
30
|
+
# @attr [Integer] id The global ID or URL-encoded path of the project
|
31
|
+
# @attr [Integer] iid The internal ID of a project’s issue
|
32
|
+
# @attr [Boolean] imported If the issue was imported or not
|
33
|
+
# @attr [String] imported_from
|
34
|
+
# @attr [String] issue_type The type of issue; either issue, incident, test_case, or task
|
35
|
+
# @attr [Hash] iteration The iteration the issue is in
|
36
|
+
# @attr [Array] labels Comma-separated list of label names
|
37
|
+
# @attr [Hash] _links Various links related to the issue
|
38
|
+
# @attr [Integer] merge_requests_count The number of merge requests attached to the issue4
|
39
|
+
# @attr [Integer] merge_request_to_resolve_discussions_of The IID of a merge request in which to resolve all issues
|
40
|
+
# @attr [Hash] milestone The milestone the issue is attached to
|
41
|
+
# @attr [Integer] milestone_id The ID ofthe milestone the issue is attached to
|
42
|
+
# @attr [Integer] moved_to_id The ID of the new issue the current issue was moved to
|
43
|
+
# @attr [Integer] project_id The ID of the project the issue is within
|
44
|
+
# @attr [String] remove_labels Comma-separated label names to remove from an issue
|
45
|
+
# @attr [Hash] references Reference tags for the issue
|
46
|
+
# @attr [String] severity
|
47
|
+
# @attr [String] state The current state of the issue
|
48
|
+
# @attr [String] state_event The state event of an issue; to close the issue, use close, and to reopen it, use reopen
|
49
|
+
# @attr [Hash] task_completion_status Informaiton on the task status of an issue
|
50
|
+
# @attr [String] task_status A string of the task status of an issue
|
51
|
+
# @attr [Hash] time_stats Information on the time spent on the issue
|
52
|
+
# @attr [String] title The issue title
|
53
|
+
# @attr [Integer] to_project_id The ID of the new project to move the issue to
|
54
|
+
# @attr [String] type The type of issue; either issue, incident, test_case, or task
|
55
|
+
# @attr [String] updated_at The timestamp of when the issue was last updated
|
56
|
+
# @attr [Integer] upvotes The number of upvotes on an issue
|
57
|
+
# @attr [Integer] user_notes_count The number of notes on the issue
|
58
|
+
# @attr [String] web_url The URL of the issue
|
59
|
+
# @attr [Integer] weight The weight of an issue
|
60
|
+
# @attr [Boolean] with_notes Clone the issue with notes
|
61
|
+
# @todo Promote an issue to an epic => https://docs.gitlab.com/api/issues/#promote-an-issue-to-an-epic
|
62
|
+
# @todo Clone an issue => https://docs.gitlab.com/api/issues/#clone-an-issue
|
63
|
+
# @todo Time tracking => https://docs.gitlab.com/api/issues/#time-tracking
|
64
|
+
# @todo List issue state events => https://docs.gitlab.com/api/issues/#list-issue-state-events
|
65
|
+
# @todo Incidents => https://docs.gitlab.com/api/issues/#incidents
|
66
|
+
# @todo Create a to-do item => https://docs.gitlab.com/api/issues/#create-a-to-do-item
|
67
|
+
# @todo List participants in an issue => https://docs.gitlab.com/api/issues/#list-participants-in-an-issue
|
68
|
+
class Issues < SupportOps::GitLab::Base
|
69
|
+
# @!parse
|
70
|
+
# # Creates/updates an issue
|
71
|
+
# #
|
72
|
+
# # @author Jason Colyer
|
73
|
+
# # @since 1.0.0
|
74
|
+
# # @return [Object] Instance of {SupportOps::GitLab::Issues}
|
75
|
+
# # @note This is inherited from {SupportOps::GitLab::Base#save!}
|
76
|
+
# # @see
|
77
|
+
# # https://docs.gitlab.com/api/issues/#new-issue
|
78
|
+
# # GitLab API > Issues > New issue
|
79
|
+
# # @see
|
80
|
+
# # https://docs.gitlab.com/api/issues/#edit-an-issue
|
81
|
+
# # GitLab API > Issues > Edit an issue
|
82
|
+
# # @example
|
83
|
+
# # require 'support_ops_gitlab'
|
84
|
+
# #
|
85
|
+
# # SupportOps::GitLab::Configuration.configure do |config|
|
86
|
+
# # config.token = ENV.fetch('GL_TOKEN')
|
87
|
+
# # config.url = 'https://gitlab.com/api/v4'
|
88
|
+
# # end
|
89
|
+
# #
|
90
|
+
# # new_issue = SupportOps::GitLab::Issues.new
|
91
|
+
# # new_issue.project_id = 123456
|
92
|
+
# # new_issue.title = 'the printer is on fire (again)'
|
93
|
+
# # new_issue.description = 'We need to put it out and stop this from happening again'
|
94
|
+
# #
|
95
|
+
# # new_issue.save!
|
96
|
+
# # pp new_issue.iid
|
97
|
+
# # #=> 13
|
98
|
+
# # pp new_issue.title
|
99
|
+
# # #=> "the printer is on fire (again)"
|
100
|
+
# # @example
|
101
|
+
# # require 'support_ops_gitlab'
|
102
|
+
# #
|
103
|
+
# # SupportOps::GitLab::Configuration.configure do |config|
|
104
|
+
# # config.token = ENV.fetch('GL_TOKEN')
|
105
|
+
# # config.url = 'https://gitlab.com/api/v4'
|
106
|
+
# # end
|
107
|
+
# #
|
108
|
+
# # existing_issue = SupportOps::GitLab::Issues.get!(iid: 13, project_id: 123456)
|
109
|
+
# # existing_issue.title = 'The printer has completely burned down'
|
110
|
+
# # existing_issue.description = 'Guess we need a new printer now'
|
111
|
+
# #
|
112
|
+
# # existing_issue.save!
|
113
|
+
# # pp existing_issue.iid
|
114
|
+
# # #=> 13
|
115
|
+
# # pp existing_issue.title
|
116
|
+
# # #=> "The printer has completely burned down"
|
117
|
+
# def save!; end
|
118
|
+
# @!parse
|
119
|
+
# # Deletes an issue
|
120
|
+
# #
|
121
|
+
# # @author Jason Colyer
|
122
|
+
# # @since 1.0.0
|
123
|
+
# # @return [Object] Instance of {SupportOps::GitLab::Issues}
|
124
|
+
# # @note This is inherited from {SupportOps::GitLab::Base#delete!}
|
125
|
+
# # @see
|
126
|
+
# # https://docs.gitlab.com/api/issues/#delete-an-issue
|
127
|
+
# # GitLab API > Issues > Delete an issue
|
128
|
+
# # @example
|
129
|
+
# # require 'support_ops_gitlab'
|
130
|
+
# #
|
131
|
+
# # SupportOps::GitLab::Configuration.configure do |config|
|
132
|
+
# # config.token = ENV.fetch('GL_TOKEN')
|
133
|
+
# # config.url = 'https://gitlab.com/api/v4'
|
134
|
+
# # end
|
135
|
+
# #
|
136
|
+
# # existing_issue = SupportOps::GitLab::Issues.get!(iid: 13, project_id: 123456)
|
137
|
+
# # existing_issue.delete!
|
138
|
+
# def delete!; end
|
139
|
+
# @!parse
|
140
|
+
# # Moves an issue
|
141
|
+
# #
|
142
|
+
# # @author Jason Colyer
|
143
|
+
# # @since 1.0.0
|
144
|
+
# # @return [Object] Instance of {SupportOps::GitLab::Issues}
|
145
|
+
# # @note This is inherited from {SupportOps::GitLab::Base#move!}
|
146
|
+
# # @see
|
147
|
+
# # https://docs.gitlab.com/api/issues/#move-an-issue
|
148
|
+
# # GitLab API > Issues > Move an issue
|
149
|
+
# # @example
|
150
|
+
# # require 'support_ops_gitlab'
|
151
|
+
# #
|
152
|
+
# # SupportOps::GitLab::Configuration.configure do |config|
|
153
|
+
# # config.token = ENV.fetch('GL_TOKEN')
|
154
|
+
# # config.url = 'https://gitlab.com/api/v4'
|
155
|
+
# # end
|
156
|
+
# #
|
157
|
+
# # existing_issue = SupportOps::GitLab::Issues.get!(iid: 13, project_id: 123456)
|
158
|
+
# # existing_issue.to_project_id = 789
|
159
|
+
# # existing_issue.move!
|
160
|
+
# # pp existing_issue.to_project_id
|
161
|
+
# # #=> 789
|
162
|
+
# def move!; end
|
163
|
+
# @!parse
|
164
|
+
# # Subscribe to an issue
|
165
|
+
# #
|
166
|
+
# # @author Jason Colyer
|
167
|
+
# # @since 1.0.0
|
168
|
+
# # @return [Object] Instance of {SupportOps::GitLab::Issues}
|
169
|
+
# # @note This is inherited from {SupportOps::GitLab::Base#subscribe!}
|
170
|
+
# # @see
|
171
|
+
# # https://docs.gitlab.com/api/issues/#subscribe-to-an-issue
|
172
|
+
# # GitLab API > Issues > Subscribe to an issue
|
173
|
+
# # @example
|
174
|
+
# # require 'support_ops_gitlab'
|
175
|
+
# #
|
176
|
+
# # SupportOps::GitLab::Configuration.configure do |config|
|
177
|
+
# # config.token = ENV.fetch('GL_TOKEN')
|
178
|
+
# # config.url = 'https://gitlab.com/api/v4'
|
179
|
+
# # end
|
180
|
+
# #
|
181
|
+
# # existing_issue = SupportOps::GitLab::Issues.get!(iid: 13, project_id: 789)
|
182
|
+
# # existing_issue.subscribe!
|
183
|
+
# def subscribe!; end
|
184
|
+
# @!parse
|
185
|
+
# # Unsubscribe to an issue
|
186
|
+
# #
|
187
|
+
# # @author Jason Colyer
|
188
|
+
# # @since 1.0.0
|
189
|
+
# # @return [Object] Instance of {SupportOps::GitLab::Issues}
|
190
|
+
# # @note This is inherited from {SupportOps::GitLab::Base#unsubscribe!}
|
191
|
+
# # @see
|
192
|
+
# # https://docs.gitlab.com/api/issues/#unsubscribe-to-an-issue
|
193
|
+
# # GitLab API > Issues > Unsubscribe to an issue
|
194
|
+
# # @example
|
195
|
+
# # require 'support_ops_gitlab'
|
196
|
+
# #
|
197
|
+
# # SupportOps::GitLab::Configuration.configure do |config|
|
198
|
+
# # config.token = ENV.fetch('GL_TOKEN')
|
199
|
+
# # config.url = 'https://gitlab.com/api/v4'
|
200
|
+
# # end
|
201
|
+
# #
|
202
|
+
# # existing_issue = SupportOps::GitLab::Issues.get!(iid: 13, project_id: 789)
|
203
|
+
# # existing_issue.unsubscribe!
|
204
|
+
# def unsubscribe!; end
|
205
|
+
# @!parse
|
206
|
+
# # List merge requests related to issue
|
207
|
+
# #
|
208
|
+
# # @author Jason Colyer
|
209
|
+
# # @since 1.0.0
|
210
|
+
# # @return [Boolean]
|
211
|
+
# # @note This is inherited from {SupportOps::GitLab::Base#merge_requests}
|
212
|
+
# # @see
|
213
|
+
# # https://docs.gitlab.com/api/issues/#list-merge-requests-related-to-issue
|
214
|
+
# # GitLab API Issues > List merge requests related to issue
|
215
|
+
# # @example
|
216
|
+
# # require 'support_ops_gitlab'
|
217
|
+
# #
|
218
|
+
# # SupportOps::GitLab::Configuration.configure do |config|
|
219
|
+
# # config.token = ENV.fetch('GL_TOKEN')
|
220
|
+
# # config.url = 'https://gitlab.com/api/v4'
|
221
|
+
# # end
|
222
|
+
# #
|
223
|
+
# # existing_issue = SupportOps::GitLab::Issues.get!(iid: 13, project_id: 789)
|
224
|
+
# # merge_requests = existing_issue.merge_requests
|
225
|
+
# # pp merge_requests.count
|
226
|
+
# # # => 4
|
227
|
+
# def merge_requests; end
|
228
|
+
# @!parse
|
229
|
+
# # List notes on an issue
|
230
|
+
# #
|
231
|
+
# # @author Jason Colyer
|
232
|
+
# # @since 1.0.0
|
233
|
+
# # @return [Boolean]
|
234
|
+
# # @note This is inherited from {SupportOps::GitLab::Base#notes}
|
235
|
+
# # @see
|
236
|
+
# # https://docs.gitlab.com/api/notes/#list-all-issue-notes
|
237
|
+
# # GitLab API > Notes (comments) > List all issue notes
|
238
|
+
# # @example
|
239
|
+
# # require 'support_ops_gitlab'
|
240
|
+
# #
|
241
|
+
# # SupportOps::GitLab::Configuration.configure do |config|
|
242
|
+
# # config.token = ENV.fetch('GL_TOKEN')
|
243
|
+
# # config.url = 'https://gitlab.com/api/v4'
|
244
|
+
# # end
|
245
|
+
# #
|
246
|
+
# # existing_issue = SupportOps::GitLab::Issues.get!(iid: 13, project_id: 789)
|
247
|
+
# # notes = existing_issue.notes
|
248
|
+
# # pp notes.count
|
249
|
+
# # # => 7
|
250
|
+
# def notes; end
|
251
|
+
define_attributes :add_labels, :assignee_ids, :assignees, :author,
|
252
|
+
:closed_at, :closed_by, :confidential, :created_at,
|
253
|
+
:description, :discussion_locked,
|
254
|
+
:discussion_to_aresolve, :downvotes, :due_date, :epic,
|
255
|
+
:epic_id, :epic_iid, :has_tasks, :health_status, :id,
|
256
|
+
:iid, :imported, :imported_from, :issue_type,
|
257
|
+
:iteration, :labels, :_links, :merge_requests_count,
|
258
|
+
:merge_request_to_resolve_discussions_of, :milestone,
|
259
|
+
:milestone_id, :moved_to_id, :project_id,
|
260
|
+
:remove_labels, :references, :severity, :state,
|
261
|
+
:state_event, :task_completion_status, :task_status,
|
262
|
+
:time_stats, :title, :to_project_id, :type, :updated_at,
|
263
|
+
:upvotes, :user_notes_count, :web_url, :weight,
|
264
|
+
:with_notes
|
265
|
+
readonly_attributes :author, :closed_at, :closed_by, :created_at,
|
266
|
+
:downvotes, :epic, :has_tasks, :id, :iid, :imported,
|
267
|
+
:imported_from, :iteration, :_links,
|
268
|
+
:merge_requests_count, :milestone, :moved_to_id,
|
269
|
+
:project_id, :references, :severity, :state,
|
270
|
+
:task_completion_status, :task_status, :time_stats,
|
271
|
+
:type, :updated_at, :upvotes, :user_notes_count,
|
272
|
+
:web_url
|
273
|
+
|
274
|
+
##
|
275
|
+
# Lists issues
|
276
|
+
#
|
277
|
+
# @author Jason Colyer
|
278
|
+
# @since 1.0.0
|
279
|
+
# @overload list(key: value)
|
280
|
+
# @param assignee_id [Integer optional] Return issues assigned to the given user id; 'None' returns unassigned issues; 'Any' returns issues with an assignee.
|
281
|
+
# @param assignee_username [String optional] Return issues assigned to the given username
|
282
|
+
# @param author_id [Integer optional] Return issues created by the given user id
|
283
|
+
# @param author_username [String optional] Return issues created by the given username
|
284
|
+
# @param confidential [Boolean optional] Filter confidential or public issues
|
285
|
+
# @param created_after [String optional] Return issues created on or after the given time; expected in ISO 8601 format (2019-03-15T08:00:00Z)
|
286
|
+
# @param created_before [String optional] Return issues created on or before the given time; expected in ISO 8601 format (2019-03-15T08:00:00Z)
|
287
|
+
# @param due_date [String optional] Return issues that have no due date, are overdue, or whose due date is this week, this month, or between two weeks ago and next month; accepts: 0 (no due date), any, today, tomorrow, overdue, week, month, next_month_and_previous_two_weeks
|
288
|
+
# @param epic_id [Integer optional] Return issues associated with the given epic ID; 'None' returns issues that are not associated with an epic; 'Any' returns issues that are associated with an epic
|
289
|
+
# @param health_status [String optional] Return issues with the specified health_status; 'None' returns issues with no health status assigned, and 'Any' returns issues with a health status assigned
|
290
|
+
# @param iids [Array optional] Return only the issues having the given iid
|
291
|
+
# @param issue_type [String optional] Filter to a given type of issue; one of issue, incident, test_case or task
|
292
|
+
# @param iteration_id [Integer optional] Return issues assigned to the given iteration ID; 'None' returns issues that do not belong to an iteration; 'Any' returns issues that belong to an iteration
|
293
|
+
# @param iteration_title [String optional] Return issues assigned to the iteration with the given title
|
294
|
+
# @param labels [String optional] Comma-separated list of label names, issues must have all labels to be returned; 'None' lists all issues with no labels; 'Any' lists all issues with at least one label
|
295
|
+
# @param milestone [String optional] The milestone title; 'None' lists all issues with no milestone; 'Any' lists all issues that have an assigned milestone
|
296
|
+
# @param milestone_id [String optional] Returns issues assigned to milestones with a given timebox value (None, Any, Upcoming, and Started); 'None' lists all issues with no milestone; 'Any' lists all issues that have an assigned milestone; 'Upcoming' lists all issues assigned to milestones due in the future; 'Started' lists all issues assigned to open, started milestones
|
297
|
+
# @param my_reaction_emoji [String optional] Return issues reacted by the authenticated user by the given emoji; 'None returns issues not given a reaction; 'Any' returns issues given at least one reaction
|
298
|
+
# @param non_archived [Boolean optional] Return issues only from non-archived projects
|
299
|
+
# @param order_by [String optional] Return issues ordered by created_at, due_date, label_priority, milestone_due, popularity, priority, relative_position, title, updated_at, or weight fields.
|
300
|
+
# @param project_id [Integer optional] The project to scope the list to (not providing it scopes it to the whole instance)
|
301
|
+
# @param scope [String optional] Return issues for the given scope: created_by_me, assigned_to_me or all
|
302
|
+
# @param search [String optional] Search issues against their title and description
|
303
|
+
# @param sort [String optional] Return issues sorted in asc or desc order
|
304
|
+
# @param state [String optional] Return all issues or just those that are opened or closed
|
305
|
+
# @param updated_after [String optional] Return issues updated on or after the given time; expected in ISO 8601 format (2019-03-15T08:00:00Z)
|
306
|
+
# @param updated_before [String optional] Return issues updated on or before the given time; expected in ISO 8601 format (2019-03-15T08:00:00Z)
|
307
|
+
# @param weight [Integer optional] Return issues with the specified weight; 'None' returns issues with no weight assigned; 'Any' returns issues with a weight assigned
|
308
|
+
# @param limit [Integer optional] The limit to the number of users
|
309
|
+
# returned. Default to 0 (i.e. no limit)
|
310
|
+
# @return [Array]
|
311
|
+
# @see
|
312
|
+
# https://docs.gitlab.com/api/issues/#list-issues
|
313
|
+
# GitLab API > Issues > List issues
|
314
|
+
# @see SupportOps::GitLab::Configuration Setting up a client
|
315
|
+
# @example
|
316
|
+
# require 'support_ops_gitlab'
|
317
|
+
#
|
318
|
+
# SupportOps::GitLab::Configuration.configure do |config|
|
319
|
+
# config.url = 'https://gitlab.example.com/api/v4'
|
320
|
+
# config.token = 'abc123'
|
321
|
+
# end
|
322
|
+
#
|
323
|
+
# issues = SupportOps::GitLab::Issues.list(project_id: 123456)
|
324
|
+
# pp issues.count
|
325
|
+
# # => 30
|
326
|
+
# pp issues.last.due_date
|
327
|
+
# # => "2018-07-31"
|
328
|
+
def self.list(**args)
|
329
|
+
args[:assignee_id] = nil unless args[:assignee_id]
|
330
|
+
args[:assignee_username] = nil unless args[:assignee_username]
|
331
|
+
args[:author_id] = nil unless args[:author_id]
|
332
|
+
args[:author_username] = nil unless args[:author_username]
|
333
|
+
args[:confidential] = nil unless args[:confidential]
|
334
|
+
args[:created_after] = nil unless args[:created_after]
|
335
|
+
args[:created_before] = nil unless args[:created_before]
|
336
|
+
args[:due_date] = nil unless args[:due_date]
|
337
|
+
args[:epic_id] = nil unless args[:epic_id]
|
338
|
+
args[:health_status] = nil unless args[:health_status]
|
339
|
+
args[:iids] = nil unless args[:iids]
|
340
|
+
args[:issue_type] = nil unless args[:issue_type]
|
341
|
+
args[:iteration_id] = nil unless args[:iteration_id]
|
342
|
+
args[:iteration_title] = nil unless args[:iteration_title]
|
343
|
+
args[:labels] = nil unless args[:labels]
|
344
|
+
args[:milestone] = nil unless args[:milestone]
|
345
|
+
args[:milestone_id] = nil unless args[:milestone_id]
|
346
|
+
args[:my_reaction_emoji] = nil unless args[:my_reaction_emoji]
|
347
|
+
args[:non_archived] = nil unless args[:non_archived]
|
348
|
+
args[:order_by] = nil unless args[:order_by]
|
349
|
+
args[:project_id] = nil unless args[:project_id]
|
350
|
+
args[:scope] = nil unless args[:scope]
|
351
|
+
args[:search] = nil unless args[:search]
|
352
|
+
args[:sort] = nil unless args[:sort]
|
353
|
+
args[:state] = nil unless args[:state]
|
354
|
+
args[:updated_after] = nil unless args[:updated_after]
|
355
|
+
args[:updated_before] = nil unless args[:updated_before]
|
356
|
+
args[:weight] = nil unless args[:weight]
|
357
|
+
args[:limit] = 0 unless args[:limit]
|
358
|
+
params = ''
|
359
|
+
params += "assignee_id=#{args[:assignee_id]}&" unless args[:assignee_id].nil?
|
360
|
+
params += "assignee_username=#{args[:assignee_username]}&" unless args[:assignee_username].nil?
|
361
|
+
params += "author_id=#{args[:author_id]}&" unless args[:author_id].nil?
|
362
|
+
params += "author_username=#{args[:author_username]}&" unless args[:author_username].nil?
|
363
|
+
params += "confidential=#{args[:confidential]}&" unless args[:confidential].nil?
|
364
|
+
params += "created_after=#{args[:created_after]}&" unless args[:created_after].nil?
|
365
|
+
params += "created_before=#{args[:created_before]}&" unless args[:created_before].nil?
|
366
|
+
params += "due_date=#{args[:due_date]}&" unless args[:due_date].nil?
|
367
|
+
params += "epic_id=#{args[:epic_id]}&" unless args[:epic_id].nil?
|
368
|
+
params += "health_status=#{args[:health_status]}&" unless args[:health_status].nil?
|
369
|
+
params += "iids=#{args[:iids]}&" unless args[:iids].nil?
|
370
|
+
params += "issue_type=#{args[:issue_type]}&" unless args[:issue_type].nil?
|
371
|
+
params += "iteration_id=#{args[:iteration_id]}&" unless args[:iteration_id].nil?
|
372
|
+
params += "iteration_title=#{args[:iteration_title]}&" unless args[:iteration_title].nil?
|
373
|
+
params += "labels=#{args[:labels]}&" unless args[:labels].nil?
|
374
|
+
params += "milestone=#{args[:milestone]}&" unless args[:milestone].nil?
|
375
|
+
params += "milestone_id=#{args[:milestone_id]}&" unless args[:milestone_id].nil?
|
376
|
+
params += "my_reaction_emoji=#{args[:my_reaction_emoji]}&" unless args[:my_reaction_emoji].nil?
|
377
|
+
params += "non_archived=#{args[:non_archived]}&" unless args[:non_archived].nil?
|
378
|
+
params += "order_by=#{args[:order_by]}&" unless args[:order_by].nil?
|
379
|
+
params += "scope=#{args[:scope]}&" unless args[:scope].nil?
|
380
|
+
params += "search=#{args[:search]}&" unless args[:search].nil?
|
381
|
+
params += "sort=#{args[:sort]}&" unless args[:sort].nil?
|
382
|
+
params += "state=#{args[:state]}&" unless args[:state].nil?
|
383
|
+
params += "updated_after=#{args[:updated_after]}&" unless args[:updated_after].nil?
|
384
|
+
params += "updated_before=#{args[:updated_before]}&" unless args[:updated_before].nil?
|
385
|
+
params += "weight=#{args[:weight]}&" unless args[:weight].nil?
|
386
|
+
array = []
|
387
|
+
page = 1
|
388
|
+
base_url = if args[:project_id].nil?
|
389
|
+
"issues"
|
390
|
+
else
|
391
|
+
"projects/#{args[:project_id]}/issues"
|
392
|
+
end
|
393
|
+
loop do
|
394
|
+
response = client.connection.get("#{base_url}?#{params}&page=#{page}&per_page=100")
|
395
|
+
body = Oj.load(response.body)
|
396
|
+
array += body.map { |i| Issues.new(i) }
|
397
|
+
break if args[:limit].to_i.positive? && array.count >= args[:limit].to_i
|
398
|
+
break if body.count < 100
|
399
|
+
|
400
|
+
page += 1
|
401
|
+
end
|
402
|
+
return array if args[:limit].to_i.zero?
|
403
|
+
|
404
|
+
array.first(args[:limit].to_i)
|
405
|
+
end
|
406
|
+
|
407
|
+
##
|
408
|
+
# Locates a specific issue in the GitLab system
|
409
|
+
#
|
410
|
+
# @author Jason Colyer
|
411
|
+
# @since 1.0.0
|
412
|
+
# @see
|
413
|
+
# https://docs.gitlab.com/api/issues/#single-issue
|
414
|
+
# GitLab API > Issues > Single issue
|
415
|
+
# @see SupportOps::GitLab::Configuration Setting up a client
|
416
|
+
# @example
|
417
|
+
# require 'support_ops_gitlab'
|
418
|
+
#
|
419
|
+
# SupportOps::GitLab::Configuration.configure do |config|
|
420
|
+
# config.url = 'https://gitlab.com/api/v4'
|
421
|
+
# config.token = 'abc123'
|
422
|
+
# end
|
423
|
+
#
|
424
|
+
# issue = SupportOps::GitLab::Issues.get(987654)
|
425
|
+
# pp issue.title
|
426
|
+
# # => "Awesome issue"
|
427
|
+
# pp issue.id
|
428
|
+
# # => 28
|
429
|
+
# pp issue.project_id
|
430
|
+
# # => 123456
|
431
|
+
# @example
|
432
|
+
# require 'support_ops_gitlab'
|
433
|
+
#
|
434
|
+
# SupportOps::GitLab::Configuration.configure do |config|
|
435
|
+
# config.url = 'https://gitlab.com/api/v4'
|
436
|
+
# config.token = 'abc123'
|
437
|
+
# end
|
438
|
+
#
|
439
|
+
# issue = SupportOps::GitLab::Issues.get(iid: 28, project_id: 123456)
|
440
|
+
# pp issue.title
|
441
|
+
# # => "Awesome issue"
|
442
|
+
# pp issue.id
|
443
|
+
# # => 987654
|
444
|
+
def self.get(object)
|
445
|
+
if object.is_a? Issues
|
446
|
+
Issues.new(id: id).find
|
447
|
+
elsif object.is_a? Hash
|
448
|
+
Issues.new({ id: object[:id], iid: object[:iid], project_id: object[:project_id] }).find
|
449
|
+
else
|
450
|
+
Issues.new(id: object).find
|
451
|
+
end
|
452
|
+
end
|
453
|
+
|
454
|
+
##
|
455
|
+
# Locates a specific issue in the GitLab system
|
456
|
+
#
|
457
|
+
# @author Jason Colyer
|
458
|
+
# @since 1.0.0
|
459
|
+
# @see
|
460
|
+
# https://docs.gitlab.com/api/issues/#single-issue
|
461
|
+
# GitLab API > Issues > Single issue
|
462
|
+
# @see SupportOps::GitLab::Configuration Setting up a client
|
463
|
+
# @example
|
464
|
+
# require 'support_ops_gitlab'
|
465
|
+
#
|
466
|
+
# SupportOps::GitLab::Configuration.configure do |config|
|
467
|
+
# config.url = 'https://gitlab.com/api/v4'
|
468
|
+
# config.token = 'abc123'
|
469
|
+
# end
|
470
|
+
#
|
471
|
+
# issue = SupportOps::GitLab::Issues.get!(987654)
|
472
|
+
# pp issue.title
|
473
|
+
# # => "Awesome issue"
|
474
|
+
# pp issue.id
|
475
|
+
# # => 28
|
476
|
+
# pp issue.project_id
|
477
|
+
# # => 123456
|
478
|
+
# @example
|
479
|
+
# require 'support_ops_gitlab'
|
480
|
+
#
|
481
|
+
# SupportOps::GitLab::Configuration.configure do |config|
|
482
|
+
# config.url = 'https://gitlab.com/api/v4'
|
483
|
+
# config.token = 'abc123'
|
484
|
+
# end
|
485
|
+
#
|
486
|
+
# issue = SupportOps::GitLab::Issues.get!(iid: 28, project_id: 123456)
|
487
|
+
# pp issue.title
|
488
|
+
# # => "Awesome issue"
|
489
|
+
# pp issue.id
|
490
|
+
# # => 987654
|
491
|
+
def self.get!(object)
|
492
|
+
if object.is_a? Issues
|
493
|
+
Issues.new(id: id).find!
|
494
|
+
elsif object.is_a? Hash
|
495
|
+
Issues.new({ id: object[:id], iid: object[:iid], project_id: object[:project_id] }).find!
|
496
|
+
else
|
497
|
+
Issues.new(id: object).find!
|
498
|
+
end
|
499
|
+
end
|
500
|
+
|
501
|
+
private
|
502
|
+
|
503
|
+
##
|
504
|
+
# @private
|
505
|
+
def get_record
|
506
|
+
raise "Cannot locate issue based off provided info" if self.id.nil? && (self.iid.nil? || self.project_id.nil?)
|
507
|
+
base_url = if self.id.nil?
|
508
|
+
"projects/#{self.project_id}/issues/#{self.iid}"
|
509
|
+
else
|
510
|
+
"issues/#{self.id}"
|
511
|
+
end
|
512
|
+
response = self.client.connection.get(base_url)
|
513
|
+
return nil if response.status != 200
|
514
|
+
|
515
|
+
Oj.load(response.body)
|
516
|
+
end
|
517
|
+
|
518
|
+
##
|
519
|
+
# @private
|
520
|
+
def create_record
|
521
|
+
raise 'Cannot create a issue without a project_id attribute' if self.project_id.nil?
|
522
|
+
data = attributes_for_save
|
523
|
+
data[:confidential] = false if data[:confidential].nil?
|
524
|
+
data.delete(:epic_id) if data[:epic_id].nil?
|
525
|
+
data.delete(:epic_iid) if data[:epic_iid].nil?
|
526
|
+
response = self.client.connection.post("projects/#{self.project_id}/issues", data.to_json)
|
527
|
+
body = Oj.load(response.body)
|
528
|
+
raise "Failed to create issue => #{body}" if response.status != 201
|
529
|
+
body
|
530
|
+
end
|
531
|
+
|
532
|
+
##
|
533
|
+
# @private
|
534
|
+
def update_record
|
535
|
+
raise 'Cannot update a issue without a project_id attribute' if self.project_id.nil?
|
536
|
+
raise "Failed to update issue => You didn't change anything in the object" if attributes_for_save.keys == [:id]
|
537
|
+
response = self.client.connection.put("projects/#{self.project_id}/issues/#{self.iid}", attributes_for_save.to_json)
|
538
|
+
body = Oj.load(response.body)
|
539
|
+
raise "Failed to update issue #{self.id} => #{body}" if response.status != 200
|
540
|
+
body
|
541
|
+
end
|
542
|
+
|
543
|
+
##
|
544
|
+
# @private
|
545
|
+
def delete_record
|
546
|
+
raise 'Cannot delete a issue without a project_id attribute' if self.project_id.nil?
|
547
|
+
response = self.client.connection.delete("projects/#{self.project_id}/issues/#{self.iid}")
|
548
|
+
body = Oj.load(response.body)
|
549
|
+
raise "Failed to delete issue #{self.id} => #{body}" unless response.status == 204
|
550
|
+
true
|
551
|
+
end
|
552
|
+
|
553
|
+
##
|
554
|
+
# @private
|
555
|
+
def move_record
|
556
|
+
raise 'You have to provide a to_project_id' if self.to_project_id.nil?
|
557
|
+
data = { to_project_id: self.to_project_id }.to_json
|
558
|
+
response = self.client.connection.post("projects/#{self.project_id}/issues/#{self.iid}/move", data)
|
559
|
+
body = Oj.load(response.body)
|
560
|
+
raise "Failed to move issue #{self.id} to #{self.to_project_id}=> #{body}" unless response.status == 201
|
561
|
+
body.each do |key, value|
|
562
|
+
self.instance_variable_set("@#{key}", value) if self.respond_to?("#{key}=")
|
563
|
+
end
|
564
|
+
body
|
565
|
+
end
|
566
|
+
|
567
|
+
##
|
568
|
+
# @private
|
569
|
+
def subscribe_record
|
570
|
+
response = self.client.connection.post("projects/#{self.project_id}/issues/#{self.iid}/subscribe")
|
571
|
+
raise "Unable to subscribe to issue #{self.id} => #{body}" unless [201, 304].include? response.status
|
572
|
+
true
|
573
|
+
end
|
574
|
+
|
575
|
+
##
|
576
|
+
# @private
|
577
|
+
def unsubscribe_record
|
578
|
+
response = self.client.connection.post("projects/#{self.project_id}/issues/#{self.iid}/unsubscribe")
|
579
|
+
raise "Unable to unsubscribe to issue #{self.id} => #{body}" unless [201, 304].include? response.status
|
580
|
+
true
|
581
|
+
end
|
582
|
+
|
583
|
+
##
|
584
|
+
# @private
|
585
|
+
def merge_requests_record
|
586
|
+
array = []
|
587
|
+
page = 1
|
588
|
+
loop do
|
589
|
+
response = self.client.connection.get("projects/#{self.project_id}/issues/#{self.iid}/related_merge_requests?per_page=100&page=#{page}")
|
590
|
+
body = Oj.load(response.body)
|
591
|
+
array += body.map { |m| MergeRequests.new(m) }
|
592
|
+
break if body.count < 100
|
593
|
+
|
594
|
+
page += 1
|
595
|
+
end
|
596
|
+
array
|
597
|
+
end
|
598
|
+
|
599
|
+
##
|
600
|
+
# @private
|
601
|
+
def notes_record
|
602
|
+
Notes.list(type: 'Issue', type_id: self.iid, project_id: self.project_id)
|
603
|
+
end
|
604
|
+
end
|
605
|
+
end
|
606
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines the module SupportOps.
|
4
|
+
module SupportOps
|
5
|
+
# Defines the module GitLab
|
6
|
+
module GitLab
|
7
|
+
##
|
8
|
+
# Defines the class Jobs within the module {SupportOps::GitLab}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.0
|
12
|
+
# @attr [Boolean] allow_failure
|
13
|
+
# @attr [Boolean] archived
|
14
|
+
# @attr [Array] artifacts
|
15
|
+
# @attr [String] artifacts_expire_at
|
16
|
+
# @attr [Hash] artifacts_file
|
17
|
+
# @attr [Hash] commit
|
18
|
+
# @attr [String] coverage
|
19
|
+
# @attr [String] created_at
|
20
|
+
# @attr [String] duration
|
21
|
+
# @attr [String] erased_at
|
22
|
+
# @attr [String] failure_reason
|
23
|
+
# @attr [String] finished_at
|
24
|
+
# @attr [Integer] id
|
25
|
+
# @attr [String] name
|
26
|
+
# @attr [Hash] pipeline
|
27
|
+
# @attr [Hash] project
|
28
|
+
# @attr [String] queued_duration
|
29
|
+
# @attr [String] ref
|
30
|
+
# @attr [Hash] runner
|
31
|
+
# @attr [Hash] runner_manager
|
32
|
+
# @attr [String] source
|
33
|
+
# @attr [String] stage
|
34
|
+
# @attr [String] started_at
|
35
|
+
# @attr [String] status
|
36
|
+
# @attr [String] tag
|
37
|
+
# @attr [Array] tag_list
|
38
|
+
# @attr [Hash] user
|
39
|
+
# @attr [String] web_url
|
40
|
+
# @todo Document meaning of attributes
|
41
|
+
# @todo All items listed at https://docs.gitlab.com/api/jobs/#list-project-jobs
|
42
|
+
class Jobs < SupportOps::GitLab::Base
|
43
|
+
define_attributes :allow_failure, :archived, :artifacts,
|
44
|
+
:artifacts_expire_at, :artifacts_file, :commit,
|
45
|
+
:coverage, :created_at, :duration, :erased_at,
|
46
|
+
:failure_reason, :finished_at, :id, :name, :pipeline,
|
47
|
+
:project, :queued_duration, :ref, :runner,
|
48
|
+
:runner_manager, :source, :stage, :started_at, :status,
|
49
|
+
:tag, :tag_list, :user, :web_url
|
50
|
+
readonly_attributes :allow_failure, :archived, :artifacts,
|
51
|
+
:artifacts_expire_at, :artifacts_file, :commit,
|
52
|
+
:coverage, :created_at, :duration, :erased_at,
|
53
|
+
:failure_reason, :finished_at, :id, :name, :pipeline,
|
54
|
+
:project, :queued_duration, :ref, :runner,
|
55
|
+
:runner_manager, :source, :stage, :started_at,
|
56
|
+
:status, :tag, :tag_list, :user, :web_url
|
57
|
+
|
58
|
+
private
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|