fs-gitlab 4.18.1

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.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +270 -0
  3. data/LICENSE.txt +24 -0
  4. data/README.md +260 -0
  5. data/exe/gitlab +11 -0
  6. data/lib/gitlab/api.rb +24 -0
  7. data/lib/gitlab/cli.rb +89 -0
  8. data/lib/gitlab/cli_helpers.rb +243 -0
  9. data/lib/gitlab/client/access_requests.rb +103 -0
  10. data/lib/gitlab/client/application_settings.rb +172 -0
  11. data/lib/gitlab/client/avatar.rb +21 -0
  12. data/lib/gitlab/client/award_emojis.rb +137 -0
  13. data/lib/gitlab/client/boards.rb +146 -0
  14. data/lib/gitlab/client/branches.rb +135 -0
  15. data/lib/gitlab/client/broadcast_messages.rb +75 -0
  16. data/lib/gitlab/client/build_variables.rb +135 -0
  17. data/lib/gitlab/client/builds.rb +108 -0
  18. data/lib/gitlab/client/commits.rb +216 -0
  19. data/lib/gitlab/client/container_registry.rb +85 -0
  20. data/lib/gitlab/client/deployments.rb +34 -0
  21. data/lib/gitlab/client/environments.rb +89 -0
  22. data/lib/gitlab/client/epic_issues.rb +23 -0
  23. data/lib/gitlab/client/epics.rb +73 -0
  24. data/lib/gitlab/client/events.rb +60 -0
  25. data/lib/gitlab/client/features.rb +48 -0
  26. data/lib/gitlab/client/group_badges.rb +88 -0
  27. data/lib/gitlab/client/group_boards.rb +141 -0
  28. data/lib/gitlab/client/group_labels.rb +88 -0
  29. data/lib/gitlab/client/group_milestones.rb +94 -0
  30. data/lib/gitlab/client/groups.rb +358 -0
  31. data/lib/gitlab/client/issue_links.rb +48 -0
  32. data/lib/gitlab/client/issues.rb +231 -0
  33. data/lib/gitlab/client/jobs.rb +250 -0
  34. data/lib/gitlab/client/keys.rb +29 -0
  35. data/lib/gitlab/client/labels.rb +88 -0
  36. data/lib/gitlab/client/lint.rb +19 -0
  37. data/lib/gitlab/client/markdown.rb +23 -0
  38. data/lib/gitlab/client/merge_request_approvals.rb +265 -0
  39. data/lib/gitlab/client/merge_requests.rb +386 -0
  40. data/lib/gitlab/client/milestones.rb +106 -0
  41. data/lib/gitlab/client/namespaces.rb +22 -0
  42. data/lib/gitlab/client/notes.rb +313 -0
  43. data/lib/gitlab/client/packages.rb +95 -0
  44. data/lib/gitlab/client/pipeline_schedules.rb +147 -0
  45. data/lib/gitlab/client/pipeline_triggers.rb +103 -0
  46. data/lib/gitlab/client/pipelines.rb +105 -0
  47. data/lib/gitlab/client/project_badges.rb +85 -0
  48. data/lib/gitlab/client/project_clusters.rb +83 -0
  49. data/lib/gitlab/client/project_release_links.rb +76 -0
  50. data/lib/gitlab/client/project_releases.rb +79 -0
  51. data/lib/gitlab/client/projects.rb +708 -0
  52. data/lib/gitlab/client/protected_tags.rb +59 -0
  53. data/lib/gitlab/client/remote_mirrors.rb +51 -0
  54. data/lib/gitlab/client/repositories.rb +113 -0
  55. data/lib/gitlab/client/repository_files.rb +131 -0
  56. data/lib/gitlab/client/repository_submodules.rb +27 -0
  57. data/lib/gitlab/client/resource_label_events.rb +82 -0
  58. data/lib/gitlab/client/resource_state_events.rb +57 -0
  59. data/lib/gitlab/client/runners.rb +211 -0
  60. data/lib/gitlab/client/search.rb +66 -0
  61. data/lib/gitlab/client/services.rb +53 -0
  62. data/lib/gitlab/client/sidekiq.rb +39 -0
  63. data/lib/gitlab/client/snippets.rb +95 -0
  64. data/lib/gitlab/client/system_hooks.rb +64 -0
  65. data/lib/gitlab/client/tags.rb +97 -0
  66. data/lib/gitlab/client/templates.rb +100 -0
  67. data/lib/gitlab/client/todos.rb +46 -0
  68. data/lib/gitlab/client/user_snippets.rb +114 -0
  69. data/lib/gitlab/client/users.rb +397 -0
  70. data/lib/gitlab/client/versions.rb +18 -0
  71. data/lib/gitlab/client/wikis.rb +79 -0
  72. data/lib/gitlab/client.rb +95 -0
  73. data/lib/gitlab/configuration.rb +57 -0
  74. data/lib/gitlab/error.rb +170 -0
  75. data/lib/gitlab/file_response.rb +48 -0
  76. data/lib/gitlab/help.rb +94 -0
  77. data/lib/gitlab/objectified_hash.rb +51 -0
  78. data/lib/gitlab/page_links.rb +35 -0
  79. data/lib/gitlab/paginated_response.rb +110 -0
  80. data/lib/gitlab/request.rb +109 -0
  81. data/lib/gitlab/shell.rb +83 -0
  82. data/lib/gitlab/shell_history.rb +57 -0
  83. data/lib/gitlab/version.rb +5 -0
  84. data/lib/gitlab.rb +56 -0
  85. metadata +204 -0
@@ -0,0 +1,313 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to notes.
5
+ # @see https://docs.gitlab.com/ce/api/notes.html
6
+ module Notes
7
+ # Gets a list of projects notes.
8
+ #
9
+ # @example
10
+ # Gitlab.notes(5)
11
+ #
12
+ # @param [Integer] project The ID of a project.
13
+ # @option options [Integer] :page The page number.
14
+ # @option options [Integer] :per_page The number of results per page.
15
+ # @return [Array<Gitlab::ObjectifiedHash>]
16
+ def notes(project, options = {})
17
+ get("/projects/#{url_encode project}/notes", query: options)
18
+ end
19
+
20
+ # Gets a list of notes for a issue.
21
+ #
22
+ # @example
23
+ # Gitlab.issue_notes(5, 10)
24
+ #
25
+ # @param [Integer] project The ID of a project.
26
+ # @param [Integer] issue The ID of an issue.
27
+ # @option options [Integer] :page The page number.
28
+ # @option options [Integer] :per_page The number of results per page.
29
+ # @return [Array<Gitlab::ObjectifiedHash>]
30
+ def issue_notes(project, issue, options = {})
31
+ get("/projects/#{url_encode project}/issues/#{issue}/notes", query: options)
32
+ end
33
+
34
+ # Gets a list of notes for a snippet.
35
+ #
36
+ # @example
37
+ # Gitlab.snippet_notes(5, 1)
38
+ #
39
+ # @param [Integer] project The ID of a project.
40
+ # @param [Integer] snippet The ID of a snippet.
41
+ # @option options [Integer] :page The page number.
42
+ # @option options [Integer] :per_page The number of results per page.
43
+ # @return [Array<Gitlab::ObjectifiedHash>]
44
+ def snippet_notes(project, snippet, options = {})
45
+ get("/projects/#{url_encode project}/snippets/#{snippet}/notes", query: options)
46
+ end
47
+
48
+ # Gets a list of notes for a merge request.
49
+ #
50
+ # @example
51
+ # Gitlab.merge_request_notes(5, 1)
52
+ #
53
+ # @param [Integer] project The ID of a project.
54
+ # @param [Integer] merge_request The ID of a merge request.
55
+ # @option options [Integer] :page The page number.
56
+ # @option options [Integer] :per_page The number of results per page.
57
+ # @return [Array<Gitlab::ObjectifiedHash>]
58
+ def merge_request_notes(project, merge_request, options = {})
59
+ get("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes", query: options)
60
+ end
61
+ alias merge_request_comments merge_request_notes
62
+
63
+ # Gets a list of notes for an epic.
64
+ #
65
+ # @example
66
+ # Gitlab.epic_notes(5, 10)
67
+ #
68
+ # @param [Integer] project The ID of a group.
69
+ # @param [Integer] epic The ID of an epic.
70
+ # @option options [Integer] :page The page number.
71
+ # @option options [Integer] :per_page The number of results per page.
72
+ # @return [Array<Gitlab::ObjectifiedHash>]
73
+ def epic_notes(group, epic, options = {})
74
+ get("/groups/#{url_encode group}/epics/#{epic}/notes", query: options)
75
+ end
76
+
77
+ # Gets a single wall note.
78
+ #
79
+ # @example
80
+ # Gitlab.note(5, 15)
81
+ #
82
+ # @param [Integer] project The ID of a project.
83
+ # @param [Integer] id The ID of a note.
84
+ # @return [Gitlab::ObjectifiedHash]
85
+ def note(project, id)
86
+ get("/projects/#{url_encode project}/notes/#{id}")
87
+ end
88
+
89
+ # Gets a single issue note.
90
+ #
91
+ # @example
92
+ # Gitlab.issue_note(5, 10, 1)
93
+ #
94
+ # @param [Integer] project The ID of a project.
95
+ # @param [Integer] issue The ID of an issue.
96
+ # @param [Integer] id The ID of a note.
97
+ # @return [Gitlab::ObjectifiedHash]
98
+ def issue_note(project, issue, id)
99
+ get("/projects/#{url_encode project}/issues/#{issue}/notes/#{id}")
100
+ end
101
+
102
+ # Gets a single snippet note.
103
+ #
104
+ # @example
105
+ # Gitlab.snippet_note(5, 11, 3)
106
+ #
107
+ # @param [Integer] project The ID of a project.
108
+ # @param [Integer] snippet The ID of a snippet.
109
+ # @param [Integer] id The ID of a note.
110
+ # @return [Gitlab::ObjectifiedHash]
111
+ def snippet_note(project, snippet, id)
112
+ get("/projects/#{url_encode project}/snippets/#{snippet}/notes/#{id}")
113
+ end
114
+
115
+ # Gets a single merge_request note.
116
+ #
117
+ # @example
118
+ # Gitlab.merge_request_note(5, 11, 3)
119
+ #
120
+ # @param [Integer] project The ID of a project.
121
+ # @param [Integer] merge_request The ID of a merge_request.
122
+ # @param [Integer] id The ID of a note.
123
+ # @return [Gitlab::ObjectifiedHash]
124
+ def merge_request_note(project, merge_request, id)
125
+ get("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes/#{id}")
126
+ end
127
+
128
+ # Creates a new wall note.
129
+ #
130
+ # @example
131
+ # Gitlab.create_note(5, 'This is a wall note!')
132
+ #
133
+ # @param [Integer, String] project The ID or name of a project.
134
+ # @param [String] body The body of a note.
135
+ # @return [Gitlab::ObjectifiedHash] Information about created note.
136
+ def create_note(project, body)
137
+ post("/projects/#{url_encode project}/notes", body: { body: body })
138
+ end
139
+
140
+ # Creates a new issue note.
141
+ #
142
+ # @example
143
+ # Gitlab.create_issue_note(6, 1, 'Adding a note to my issue.')
144
+ #
145
+ # @param [Integer, String] project The ID or name of a project.
146
+ # @param [Integer] issue The ID of an issue.
147
+ # @param [String] body The body of a note.
148
+ # @return [Gitlab::ObjectifiedHash] Information about created note.
149
+ def create_issue_note(project, issue, body)
150
+ post("/projects/#{url_encode project}/issues/#{issue}/notes", body: { body: body })
151
+ end
152
+
153
+ # Creates a new snippet note.
154
+ #
155
+ # @example
156
+ # Gitlab.create_snippet_note(3, 2, 'Look at this awesome snippet!')
157
+ #
158
+ # @param [Integer, String] project The ID or name of a project.
159
+ # @param [Integer] snippet The ID of a snippet.
160
+ # @param [String] body The body of a note.
161
+ # @return [Gitlab::ObjectifiedHash] Information about created note.
162
+ def create_snippet_note(project, snippet, body)
163
+ post("/projects/#{url_encode project}/snippets/#{snippet}/notes", body: { body: body })
164
+ end
165
+
166
+ # Creates a new note for a single merge request.
167
+ #
168
+ # @example
169
+ # Gitlab.create_merge_request_note(5, 3, 'This MR is ready for review.')
170
+ #
171
+ # @param [Integer] project The ID of a project.
172
+ # @param [Integer] merge_request The ID of a merge request.
173
+ # @param [String] body The content of a note.
174
+ def create_merge_request_note(project, merge_request, body)
175
+ post("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes", body: { body: body })
176
+ end
177
+ alias create_merge_request_comment create_merge_request_note
178
+
179
+ # Creates a new epic note.
180
+ #
181
+ # @example
182
+ # Gitlab.create_epic_note(6, 1, 'Adding a note to my epic.')
183
+ #
184
+ # @param [Integer, String] group The ID or name of a group.
185
+ # @param [Integer] epic The ID of an epic.
186
+ # @param [String] body The body of a note.
187
+ # @return [Gitlab::ObjectifiedHash] Information about created note.
188
+ def create_epic_note(group, epic, body)
189
+ post("/groups/#{url_encode group}/epics/#{epic}/notes", body: { body: body })
190
+ end
191
+
192
+ # Deletes a wall note.
193
+ #
194
+ # @example
195
+ # Gitlab.delete_note(5, 15)
196
+ #
197
+ # @param [Integer] project The ID of a project.
198
+ # @param [Integer] id The ID of a note.
199
+ # @return [Gitlab::ObjectifiedHash]
200
+ def delete_note(project, id)
201
+ delete("/projects/#{url_encode project}/notes/#{id}")
202
+ end
203
+
204
+ # Deletes an issue note.
205
+ #
206
+ # @example
207
+ # Gitlab.delete_issue_note(5, 10, 1)
208
+ #
209
+ # @param [Integer] project The ID of a project.
210
+ # @param [Integer] issue The ID of an issue.
211
+ # @param [Integer] id The ID of a note.
212
+ # @return [Gitlab::ObjectifiedHash]
213
+ def delete_issue_note(project, issue, id)
214
+ delete("/projects/#{url_encode project}/issues/#{issue}/notes/#{id}")
215
+ end
216
+
217
+ # Deletes a snippet note.
218
+ #
219
+ # @example
220
+ # Gitlab.delete_snippet_note(5, 11, 3)
221
+ #
222
+ # @param [Integer] project The ID of a project.
223
+ # @param [Integer] snippet The ID of a snippet.
224
+ # @param [Integer] id The ID of a note.
225
+ # @return [Gitlab::ObjectifiedHash]
226
+ def delete_snippet_note(project, snippet, id)
227
+ delete("/projects/#{url_encode project}/snippets/#{snippet}/notes/#{id}")
228
+ end
229
+
230
+ # Deletes a merge_request note.
231
+ #
232
+ # @example
233
+ # Gitlab.delete_merge_request_note(5, 11, 3)
234
+ #
235
+ # @param [Integer] project The ID of a project.
236
+ # @param [Integer] merge_request The ID of a merge_request.
237
+ # @param [Integer] id The ID of a note.
238
+ # @return [Gitlab::ObjectifiedHash]
239
+ def delete_merge_request_note(project, merge_request, id)
240
+ delete("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes/#{id}")
241
+ end
242
+ alias delete_merge_request_comment delete_merge_request_note
243
+
244
+ # Modifies a wall note.
245
+ #
246
+ # @example
247
+ # Gitlab.edit_note(5, 15, 'This is an edited note')
248
+ #
249
+ # @param [Integer] project The ID of a project.
250
+ # @param [Integer] id The ID of a note.
251
+ # @param [String] body The content of a note.
252
+ # @return [Gitlab::ObjectifiedHash]
253
+ def edit_note(project, id, body)
254
+ put("/projects/#{url_encode project}/notes/#{id}", body: note_content(body))
255
+ end
256
+
257
+ # Modifies an issue note.
258
+ #
259
+ # @example
260
+ # Gitlab.edit_issue_note(5, 10, 1, 'This is an edited issue note')
261
+ #
262
+ # @param [Integer] project The ID of a project.
263
+ # @param [Integer] issue The ID of an issue.
264
+ # @param [Integer] id The ID of a note.
265
+ # @param [String] body The content of a note.
266
+ # @return [Gitlab::ObjectifiedHash]
267
+ def edit_issue_note(project, issue, id, body)
268
+ put("/projects/#{url_encode project}/issues/#{issue}/notes/#{id}", body: note_content(body))
269
+ end
270
+
271
+ # Modifies a snippet note.
272
+ #
273
+ # @example
274
+ # Gitlab.edit_snippet_note(5, 11, 3, 'This is an edited snippet note')
275
+ #
276
+ # @param [Integer] project The ID of a project.
277
+ # @param [Integer] snippet The ID of a snippet.
278
+ # @param [Integer] id The ID of a note.
279
+ # @param [String] body The content of a note.
280
+ # @return [Gitlab::ObjectifiedHash]
281
+ def edit_snippet_note(project, snippet, id, body)
282
+ put("/projects/#{url_encode project}/snippets/#{snippet}/notes/#{id}", body: note_content(body))
283
+ end
284
+
285
+ # Modifies a merge_request note.
286
+ #
287
+ # @example
288
+ # Gitlab.edit_merge_request_note(5, 11, 3, 'This is an edited merge request note')
289
+ #
290
+ # @param [Integer] project The ID of a project.
291
+ # @param [Integer] merge_request The ID of a merge_request.
292
+ # @param [Integer] id The ID of a note.
293
+ # @param [String] body The content of a note.
294
+ # @return [Gitlab::ObjectifiedHash]
295
+ def edit_merge_request_note(project, merge_request, id, body)
296
+ put("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes/#{id}", body: note_content(body))
297
+ end
298
+ alias edit_merge_request_comment edit_merge_request_note
299
+
300
+ private
301
+
302
+ # TODO: Remove this method after a couple deprecation cycles. Replace calls with the code
303
+ # in the 'else'.
304
+ def note_content(body)
305
+ if body.is_a?(Hash)
306
+ warn 'Passing the note body as a Hash is deprecated. You should just pass the String.'
307
+ body
308
+ else
309
+ { body: body }
310
+ end
311
+ end
312
+ end
313
+ end
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to GitLab Packages.
5
+ # @see https://docs.gitlab.com/ee/api/packages.html
6
+ module Packages
7
+ # Gets a list of project packages.
8
+ #
9
+ # @example
10
+ # Gitlab.project_packages(5)
11
+ # Gitlab.project_packages(5, { package_type: 'npm', sort: 'desc' })
12
+ #
13
+ # @param [Integer, String] :project the ID or name of a project.
14
+ # @param [Hash] options A customizable set of options.
15
+ # @options options [String] :order_by The field to use as order. One of created_at (default), name, version, or type.
16
+ # @options options [String] :sort The direction of the order, either asc (default) for ascending order or desc for descending order.
17
+ # @options options [String] :package_type Filter the returned packages by type. One of conan, maven, npm, pypi, composer, nuget, helm, terraform_module, or golang.
18
+ # @options options [String] :package_name Filter the project packages with a fuzzy search by name.
19
+ # @options options [String] :include_versionless When set to true, versionless packages are included in the response.
20
+ # @options options [String] :status Filter the returned packages by status. One of default (default), hidden, processing, error, or pending_destruction.
21
+ # @return [Array<Gitlab::ObjectifiedHash>]
22
+ def project_packages(project, options = {})
23
+ get("/projects/#{url_encode project}/packages", query: options)
24
+ end
25
+
26
+ # Gets a list of project packages.
27
+ #
28
+ # @example
29
+ # Gitlab.group_packages(5)
30
+ # Gitlab.group_packages(5, { package_type: 'npm', sort: 'desc' })
31
+ #
32
+ # @param [Integer, String] project the ID or name of a project.
33
+ # @param [Hash] options A customizable set of options.
34
+ # @options options [String] :exclude_subgroups If the parameter is included as true, packages from projects from subgroups are not listed. Default is false.
35
+ # @options options [String] :order_by The field to use as order. One of created_at (default), name, version, or type.
36
+ # @options options [String] :sort The direction of the order, either asc (default) for ascending order or desc for descending order.
37
+ # @options options [String] :package_type Filter the returned packages by type. One of conan, maven, npm, pypi, composer, nuget, helm, terraform_module, or golang.
38
+ # @options options [String] :package_name Filter the project packages with a fuzzy search by name.
39
+ # @options options [String] :include_versionless When set to true, versionless packages are included in the response.
40
+ # @options options [String] :status Filter the returned packages by status. One of default (default), hidden, processing, error, or pending_destruction.
41
+ # @return [Array<Gitlab::ObjectifiedHash>]
42
+ def group_packages(group, options = {})
43
+ get("/groups/#{url_encode group}/packages", query: options)
44
+ end
45
+
46
+ # Get a single project package.
47
+ #
48
+ # @example
49
+ # Gitlab.project_package(5, 3)
50
+ #
51
+ # @param [Integer, String] project The ID or name of a project.
52
+ # @param [Integer] id ID of a package.
53
+ # @return [Gitlab::ObjectifiedHash]
54
+ def project_package(project, id)
55
+ get("/projects/#{url_encode project}/packages/#{id}")
56
+ end
57
+
58
+ # Get a list of package files of a single package.
59
+ #
60
+ # @example
61
+ # Gitlab.project_package_files(5, 3)
62
+ #
63
+ # @param [Integer, String] project The ID or name of a project.
64
+ # @param [Integer] id ID of a package.
65
+ # @return [Array<Gitlab::ObjectifiedHash>]
66
+ def project_package_files(project, id)
67
+ get("/projects/#{url_encode project}/packages/#{id}/package_files")
68
+ end
69
+
70
+ # Deletes a project package.
71
+ #
72
+ # @example
73
+ # Gitlab.delete_project_package(5, 3)
74
+ #
75
+ # @param [Integer, String] project The ID or name of a project.
76
+ # @param [Integer] id ID of a package.
77
+ # @return [void] This API call returns an empty response body.
78
+ def delete_project_package(project, id)
79
+ delete("/projects/#{url_encode project}/packages/#{id}")
80
+ end
81
+
82
+ # Delete a package file.
83
+ #
84
+ # @example
85
+ # Gitlab.delete_project_file(5, 3, 1)
86
+ #
87
+ # @param [Integer, String] project The ID or name of a project.
88
+ # @param [Integer] package_id ID of a package.
89
+ # @param [Integer] file_id ID of a package file.
90
+ # @return [void] This API call returns an empty response body.
91
+ def delete_project_package_file(project, package_id, file_id)
92
+ delete("/projects/#{url_encode project}/packages/#{package_id}/package_files/#{file_id}")
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,147 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to pipeline schedules.
5
+ # @see https://docs.gitlab.com/ce/api/pipeline_schedules.html
6
+ module PipelineSchedules
7
+ # Gets a list of project pipeline schedules.
8
+ #
9
+ # @example
10
+ # Gitlab.pipeline_schedules(5)
11
+ # Gitlab.pipeline_schedules(5, { scope: 'active' })
12
+ #
13
+ # @param [Integer, String] project the ID or name of a project.
14
+ # @param [Hash] options A customizable set of options.
15
+ # @options options [String] :scope The scope of pipeline schedules, one of a 'active' or 'inactive'.
16
+ # @return [Array<Gitlab::ObjectifiedHash>]
17
+ def pipeline_schedules(project, options = {})
18
+ get("/projects/#{url_encode project}/pipeline_schedules", query: options)
19
+ end
20
+
21
+ # Gets a single pipeline schedule.
22
+ #
23
+ # @example
24
+ # Gitlab.pipeline_schedule(5, 3)
25
+ #
26
+ # @param [Integer, String] project The ID or name of a project.
27
+ # @param [Integer] id The ID of the pipeline schedule.
28
+ # @return [Gitlab::ObjectifiedHash]
29
+ def pipeline_schedule(project, id)
30
+ get("/projects/#{url_encode project}/pipeline_schedules/#{id}")
31
+ end
32
+
33
+ # Create a pipeline schedule.
34
+ #
35
+ # @example
36
+ # Gitlab.create_pipeline_schedule(5, { description: 'example' })
37
+ #
38
+ # @param [Integer, String] project The ID or name of a project.
39
+ # @param [Hash] options A customizable set of options.
40
+ # @option options [String] :description The description of pipeline scehdule.
41
+ # @option options [String] :ref The branch/tag name will be triggered.
42
+ # @option options [String] :cron The cron (e.g. 0 1 * * *).
43
+ # @option options [String] :cron_timezone The timezone supproted by ActiveSupport::TimeZone (e.g. Pacific Time (US & Canada)) (default: 'UTC').
44
+ # @option options [Boolean] :active The activation of pipeline schedule. If false is set, the pipeline schedule will deactivated initially (default: true).
45
+ # @return [Array<Gitlab::ObjectifiedHash>]
46
+ def create_pipeline_schedule(project, options = {})
47
+ post("/projects/#{url_encode project}/pipeline_schedules", body: options)
48
+ end
49
+
50
+ # Updates the pipeline schedule of a project.
51
+ #
52
+ # @example
53
+ # Gitlab.edit_pipeline_schedule(3, 2, { description: 'example2' })
54
+ #
55
+ # @param [Integer, String] project The ID or name of a project.
56
+ # @param [Integer] The pipeline schedule ID.
57
+ # @param [Hash] options A customizable set of options.
58
+ # @option options [String] :description The description of pipeline scehdule.
59
+ # @option options [String] :ref The branch/tag name will be triggered.
60
+ # @option options [String] :cron The cron (e.g. 0 1 * * *).
61
+ # @option options [String] :cron_timezone The timezone supproted by ActiveSupport::TimeZone (e.g. Pacific Time (US & Canada)) (default: 'UTC').
62
+ # @option options [Boolean] :active The activation of pipeline schedule. If false is set, the pipeline schedule will deactivated initially (default: true).
63
+ # @return [Array<Gitlab::ObjectifiedHash>] The updated pipeline schedule.
64
+ def edit_pipeline_schedule(project, pipeline_schedule_id, options = {})
65
+ put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}", body: options)
66
+ end
67
+
68
+ # Take ownership of a pipeline schedule.
69
+ #
70
+ # @example
71
+ # Gitlab.pipeline_schedule_take_ownership(5, 1)
72
+ #
73
+ # @param [Integer, String] project The ID or name of a project.
74
+ # @param [Integer] trigger_id The pipeline schedule ID.
75
+ # @return [Gitlab::ObjectifiedHash] The updated pipeline schedule.
76
+ def pipeline_schedule_take_ownership(project, pipeline_schedule_id)
77
+ post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/take_ownership")
78
+ end
79
+
80
+ # Run a scheduled pipeline immediately.
81
+ #
82
+ # @example
83
+ # Gitlab.run_pipeline_schedule(5, 1)
84
+ #
85
+ # @param [Integer, String] project The ID or name of a project.
86
+ # @param [Integer] trigger_id The pipeline schedule ID.
87
+ # @return [Gitlab::ObjectifiedHash] Pipeline created message.
88
+ def run_pipeline_schedule(project, pipeline_schedule_id)
89
+ post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/play")
90
+ end
91
+
92
+ # Delete a pipeline schedule.
93
+ #
94
+ # @example
95
+ # Gitlab.delete_pipeline_schedule(5, 1)
96
+ #
97
+ # @param [Integer, String] project The ID or name of a project.
98
+ # @param [Integer] trigger_id The pipeline schedule ID.
99
+ # @return [Gitlab::ObjectifiedHash] The deleted pipeline schedule.
100
+ def delete_pipeline_schedule(project, pipeline_schedule_id)
101
+ delete("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}")
102
+ end
103
+
104
+ # Create a pipeline schedule variable.
105
+ #
106
+ # @example
107
+ # Gitlab.create_pipeline_schedule_variable(5, 1, { key: 'foo', value: 'bar' })
108
+ #
109
+ # @param [Integer, String] project The ID or name of a project.
110
+ # @param [Integer] trigger_id The pipeline schedule ID.
111
+ # @param [Hash] options A customizable set of options.
112
+ # @option options [String] :key The key of a variable; must have no more than 255 characters; only A-Z, a-z, 0-9, and _ are allowed.
113
+ # @option options [String] :value The value of a variable
114
+ # @return [Array<Gitlab::ObjectifiedHash>] The created pipeline schedule variable.
115
+ def create_pipeline_schedule_variable(project, pipeline_schedule_id, options = {})
116
+ post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables", body: options)
117
+ end
118
+
119
+ # Updates the variable of a pipeline schedule.
120
+ #
121
+ # @example
122
+ # Gitlab.edit_pipeline_schedule_variable(3, 2, "foo" { value: 'bar' })
123
+ #
124
+ # @param [Integer, String] project The ID or name of a project.
125
+ # @param [Integer] The pipeline schedule ID.
126
+ # @param [String] The key of a variable.
127
+ # @param [Hash] options A customizable set of options.
128
+ # @option options [String] :value The value of a variable.
129
+ # @return [Array<Gitlab::ObjectifiedHash>] The updated pipeline schedule variable.
130
+ def edit_pipeline_schedule_variable(project, pipeline_schedule_id, key, options = {})
131
+ put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables/#{url_encode key}", body: options)
132
+ end
133
+
134
+ # Delete the variable of a pipeline schedule
135
+ #
136
+ # @example
137
+ # Gitlab.delete_pipeline_schedule_variable(3, 2, "foo")
138
+ #
139
+ # @param [Integer, String] project The ID or name of a project.
140
+ # @param [Integer] The pipeline schedule ID.
141
+ # @param [String] The key of a variable.
142
+ # @return [Array<Gitlab::ObjectifiedHash>] The deleted pipeline schedule variable.
143
+ def delete_pipeline_schedule_variable(project, pipeline_schedule_id, key, _options = {})
144
+ delete("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables/#{url_encode key}")
145
+ end
146
+ end
147
+ end
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to pipelines.
5
+ # @see https://docs.gitlab.com/ce/api/pipeline_triggers.html
6
+ # @see https://docs.gitlab.com/ce/ci/triggers/README.html
7
+ module PipelineTriggers
8
+ # Gets a list of the project's pipeline triggers
9
+ #
10
+ # @example
11
+ # Gitlab.triggers(5)
12
+ #
13
+ # @param [Integer, String] project The ID or name of a project.
14
+ # @return [Array<Gitlab::ObjectifiedHash>] The list of triggers.
15
+ def triggers(project)
16
+ get("/projects/#{url_encode project}/triggers")
17
+ end
18
+
19
+ # Gets details of project's pipeline trigger.
20
+ #
21
+ # @example
22
+ # Gitlab.trigger(5, 1)
23
+ #
24
+ # @param [Integer, String] project The ID or name of a project.
25
+ # @param [Integer] trigger_id The trigger ID.
26
+ # @return [Gitlab::ObjectifiedHash] The trigger.
27
+ def trigger(project, trigger_id)
28
+ get("/projects/#{url_encode project}/triggers/#{trigger_id}")
29
+ end
30
+
31
+ # Create a pipeline trigger for a project.
32
+ #
33
+ # @example
34
+ # Gitlab.create_trigger(5, description: "my description")
35
+ #
36
+ # @param [Integer, String] project The ID or name of a project.
37
+ # @param [String] description The trigger name
38
+ # @return [Gitlab::ObjectifiedHash] The created trigger.
39
+ def create_trigger(project, description)
40
+ post("/projects/#{url_encode project}/triggers", body: { description: description })
41
+ end
42
+
43
+ # Update a project trigger
44
+ #
45
+ # @example
46
+ # Gitlab.update_trigger(5, 1, description: "my description")
47
+ #
48
+ # @param [Integer, String] project The ID or name of a project.
49
+ # @param [Integer] trigger_id The trigger ID.
50
+ # @param [Hash] options A customizable set of options.
51
+ # @option options [String] :description The trigger name.
52
+ # @return [Gitlab::ObjectifiedHash] The updated trigger.
53
+ def update_trigger(project, trigger_id, options = {})
54
+ put("/projects/#{url_encode project}/triggers/#{trigger_id}", body: options)
55
+ end
56
+
57
+ # Take ownership of a project trigger
58
+ #
59
+ # @example
60
+ # Gitlab.trigger_take_ownership(5, 1)
61
+ #
62
+ # @param [Integer, String] project The ID or name of a project.
63
+ # @param [Integer] trigger_id The trigger ID.
64
+ # @return [Gitlab::ObjectifiedHash] The updated trigger.
65
+ def trigger_take_ownership(project, trigger_id)
66
+ post("/projects/#{url_encode project}/triggers/#{trigger_id}/take_ownership")
67
+ end
68
+
69
+ # Remove a project's pipeline trigger.
70
+ #
71
+ # @example
72
+ # Gitlab.remove_trigger(5, 1)
73
+ #
74
+ # @param [Integer, String] project The ID or name of a project.
75
+ # @param [Integer] trigger_id The trigger ID.
76
+ # @return [void] This API call returns an empty response body.
77
+ def remove_trigger(project, trigger_id)
78
+ delete("/projects/#{url_encode project}/triggers/#{trigger_id}")
79
+ end
80
+ alias delete_trigger remove_trigger
81
+
82
+ # Run the given project pipeline trigger.
83
+ #
84
+ # @example
85
+ # Gitlab.run_trigger(5, '7b9148c158980bbd9bcea92c17522d', 'master')
86
+ # Gitlab.run_trigger(5, '7b9148c158980bbd9bcea92c17522d', 'master', { variable1: "value", variable2: "value2" })
87
+ #
88
+ # @see https://docs.gitlab.com/ce/ci/triggers/README.html
89
+ #
90
+ # @param [Integer, String] project The ID or name of the project.
91
+ # @param [String] token The token of a trigger.
92
+ # @param [String] ref Branch or tag name to build.
93
+ # @param [Hash] variables A set of build variables to use for the build. (optional)
94
+ # @return [Gitlab::ObjectifiedHash] The trigger.
95
+ def run_trigger(project, token, ref, variables = {})
96
+ post("/projects/#{url_encode project}/trigger/pipeline", unauthenticated: true, body: {
97
+ token: token,
98
+ ref: ref,
99
+ variables: variables
100
+ })
101
+ end
102
+ end
103
+ end