fs-gitlab 4.18.1

Sign up to get free protection for your applications and to get access to all the features.
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,211 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to runners.
5
+ # @see https://docs.gitlab.com/ce/api/runners.html
6
+ module Runners
7
+ # Get a list of specific runners available to the user.
8
+ # @see https://docs.gitlab.com/ce/api/runners.html#list-owned-runners
9
+ #
10
+ # @example
11
+ # Gitlab.runners
12
+ # Gitlab.runners(type: 'instance_type', status: 'active')
13
+ # Gitlab.runners(tag_list: 'tag1,tag2')
14
+ #
15
+ # @param [Hash] options A customizable set of options.
16
+ # @option options [String] :type(optional) The type of runners to show, one of: instance_type, group_type, project_type
17
+ # @option options [String] :status(optional) The status of runners to show, one of: active, paused, online, offline
18
+ # @option options [String] :tag_list(optional) List of the runners tags (separated by comma)
19
+ # @return [Array<Gitlab::ObjectifiedHash>]
20
+ def runners(options = {})
21
+ get('/runners', query: options)
22
+ end
23
+
24
+ # Get a list of all runners in the GitLab instance (specific and shared). Access is restricted to users with admin privileges.
25
+ # @see https://docs.gitlab.com/ce/api/runners.html#list-all-runners
26
+ #
27
+ # @example
28
+ # Gitlab.all_runners
29
+ # Gitlab.all_runners(type: 'instance_type', status: 'active')
30
+ # Gitlab.all_runners(tag_list: 'tag1,tag2')
31
+ #
32
+ # @param [Hash] options A customizable set of options.
33
+ # @option options [String] :type(optional) The type of runners to show, one of: instance_type, group_type, project_type
34
+ # @option options [String] :status(optional) The status of runners to show, one of: active, paused, online, offline
35
+ # @option options [String] :tag_list(optional) List of the runners tags (separated by comma)
36
+ # @return [Array<Gitlab::ObjectifiedHash>]
37
+ def all_runners(options = {})
38
+ get('/runners/all', query: options)
39
+ end
40
+
41
+ # Get details of a runner..
42
+ # @see https://docs.gitlab.com/ce/api/runners.html#get-runners-details
43
+ #
44
+ # @example
45
+ # Gitlab.runner(42)
46
+ #
47
+ # @param [Integer, String] id The ID of a runner
48
+ # @return <Gitlab::ObjectifiedHash>
49
+ def runner(id)
50
+ get("/runners/#{id}")
51
+ end
52
+
53
+ # Update details of a runner.
54
+ # @see https://docs.gitlab.com/ce/api/runners.html#update-runners-details
55
+ #
56
+ # @example
57
+ # Gitlab.update_runner(42, { description: 'Awesome runner' })
58
+ # Gitlab.update_runner(42, { active: false })
59
+ #
60
+ # @param [Integer, String] id The ID of a runner
61
+ # @param [Hash] options A customizable set of options.
62
+ # @option options [String] :description(optional) The description of a runner
63
+ # @option options [Boolean] :active(optional) The state of a runner; can be set to true or false
64
+ # @option options [String] :tag_list(optional) The list of tags for a runner; put array of tags, that should be finally assigned to a runner(separated by comma)
65
+ # @option options [Boolean] :run_untagged(optional) Flag indicating the runner can execute untagged jobs
66
+ # @option options [Boolean] :locked(optional) Flag indicating the runner is locked
67
+ # @option options [String] :access_level(optional) The access_level of the runner; not_protected or ref_protected
68
+ # @option options [Integer] :maximum_timeout(optional) Maximum timeout set when this runner will handle the job
69
+ # @return <Gitlab::ObjectifiedHash>
70
+ def update_runner(id, options = {})
71
+ put("/runners/#{id}", body: options)
72
+ end
73
+
74
+ # Remove a runner.
75
+ # @see https://docs.gitlab.com/ce/api/runners.html#remove-a-runner
76
+ #
77
+ # @example
78
+ # Gitlab.delete_runner(42)
79
+ #
80
+ # @param [Integer, String] id The ID of a runner
81
+ # @return [nil] This API call returns an empty response body.
82
+ def delete_runner(id)
83
+ delete("/runners/#{id}")
84
+ end
85
+
86
+ # List jobs that are being processed or were processed by specified runner.
87
+ #
88
+ # @example
89
+ # Gitlab.runner_jobs(1)
90
+ # Gitlab.runner_jobs(1, status: 'success')
91
+ # Gitlab.runner_jobs(1, sort: 'desc')
92
+ #
93
+ # @param [Integer] id The ID of a runner.
94
+ # @param [Hash] options A customizable set of options.
95
+ # @option options [String] :status(optional) Status of the job; one of: running, success, failed, canceled
96
+ # @option options [String] :order_by(optional) Order jobs by id.
97
+ # @option options [String] :sort(optional) Sort jobs in asc or desc order (default: desc)
98
+ # @return [Array<Gitlab::ObjectifiedHash>]
99
+ def runner_jobs(runner_id, options = {})
100
+ get("/runners/#{url_encode runner_id}/jobs", query: options)
101
+ end
102
+
103
+ # List all runners (specific and shared) available in the project. Shared runners are listed if at least one shared runner is defined and shared runners usage is enabled in the project's settings.
104
+ # @see https://docs.gitlab.com/ce/api/runners.html#list-projects-runners
105
+ #
106
+ # @example
107
+ # Gitlab.project_runners(42)
108
+ # Gitlab.project_runners(42, type: 'instance_type', status: 'active')
109
+ # Gitlab.project_runners(42, tag_list: 'tag1,tag2')
110
+ #
111
+ # @param [Integer, String] id The ID or name of a project.
112
+ # @param [Hash] options A customizable set of options.
113
+ # @option options [String] :type(optional) The type of runners to show, one of: instance_type, group_type, project_type
114
+ # @option options [String] :status(optional) The status of runners to show, one of: active, paused, online, offline
115
+ # @option options [String] :tag_list(optional) List of the runners tags (separated by comma)
116
+ # @return [Array<Gitlab::ObjectifiedHash>]
117
+ def project_runners(project_id, options = {})
118
+ get("/projects/#{url_encode project_id}/runners", query: options)
119
+ end
120
+
121
+ # Enable an available specific runner in the project.
122
+ # @see https://docs.gitlab.com/ce/api/runners.html#enable-a-runner-in-project
123
+ #
124
+ # @example
125
+ # Gitlab.project_enable_runner(2, 42)
126
+ #
127
+ # @param [Integer, String] id The ID or name of a project.
128
+ # @param [Integer, String] id The ID of a runner.
129
+ # @return <Gitlab::ObjectifiedHash>
130
+ def project_enable_runner(project_id, id)
131
+ body = { runner_id: id }
132
+ post("/projects/#{url_encode project_id}/runners", body: body)
133
+ end
134
+
135
+ # Disable a specific runner from the project. It works only if the project isn't the only project associated with the specified runner.
136
+ # @see https://docs.gitlab.com/ce/api/runners.html#disable-a-runner-from-project
137
+ #
138
+ # @example
139
+ # Gitlab.project_disable_runner(2, 42)
140
+ #
141
+ # @param [Integer, String] id The ID or name of a project.
142
+ # @param [Integer, String] runner_id The ID of a runner.
143
+ # @return <Gitlab::ObjectifiedHash>
144
+ def project_disable_runner(id, runner_id)
145
+ delete("/projects/#{url_encode id}/runners/#{runner_id}")
146
+ end
147
+
148
+ # List all runners (specific and shared) available in the group as well its ancestor groups. Shared runners are listed if at least one shared runner is defined.
149
+ # @see https://docs.gitlab.com/ee/api/runners.html#list-groups-runners
150
+ #
151
+ # @example
152
+ # Gitlab.group_runners(9)
153
+ # Gitlab.group_runners(9, type: 'instance_type', status: 'active')
154
+ # Gitlab.group_runners(9, tag_list: 'tag1,tag2')
155
+ #
156
+ # @param [Integer, String] id The ID or name of a project.
157
+ # @param [Hash] options A customizable set of options.
158
+ # @option options [String] :type(optional) The type of runners to show, one of: instance_type, group_type, project_type
159
+ # @option options [String] :status(optional) The status of runners to show, one of: active, paused, online, offline
160
+ # @option options [String] :tag_list(optional) List of the runners tags (separated by comma)
161
+ # @return [Array<Gitlab::ObjectifiedHash>]
162
+ def group_runners(group, options = {})
163
+ get("/groups/#{url_encode group}/runners", query: options)
164
+ end
165
+
166
+ # Register a new Runner for the instance.
167
+ #
168
+ # @example
169
+ # Gitlab.register_runner('9142c16ea169eaaea3d752313a434a6e')
170
+ # Gitlab.register_runner('9142c16ea169eaaea3d752313a434a6e', description: 'Some Description', active: true, locked: false)
171
+ #
172
+ # @param [String] token(required) Registration token.
173
+ # @param [Hash] options A customizable set of options.
174
+ # @option options [String] :description(optional) Runner description.
175
+ # @option options [Hash] :info(optional) Runner metadata.
176
+ # @option options [Boolean] :active(optional) Whether the Runner is active.
177
+ # @option options [Boolean] :locked(optional) Whether the Runner should be locked for current project.
178
+ # @option options [Boolean] :run_untagged(optional) Whether the Runner should handle untagged jobs.
179
+ # @option options [Array<String>] :tag_list(optional) List of Runner tags.
180
+ # @option options [Integer] :maximum_timeout(optional) Maximum timeout set when this Runner will handle the job.
181
+ # @return <Gitlab::ObjectifiedHash> Response against runner registration
182
+ def register_runner(token, options = {})
183
+ body = { token: token }.merge(options)
184
+ post('/runners', body: body)
185
+ end
186
+
187
+ # Deletes a registed Runner.
188
+ #
189
+ # @example
190
+ # Gitlab.delete_registered_runner('9142c16ea169eaaea3d752313a434a6e')
191
+ #
192
+ # @param [String] token Runner authentication token.
193
+ # @return [nil] This API call returns an empty response body.
194
+ def delete_registered_runner(token)
195
+ body = { token: token }
196
+ delete('/runners', body: body)
197
+ end
198
+
199
+ # Validates authentication credentials for a registered Runner.
200
+ #
201
+ # @example
202
+ # Gitlab.verify_auth_registered_runner('9142c16ea169eaaea3d752313a434a6e')
203
+ #
204
+ # @param [String] token Runner authentication token.
205
+ # @return [nil] This API call returns an empty response body.
206
+ def verify_auth_registered_runner(token)
207
+ body = { token: token }
208
+ post('/runners/verify', body: body)
209
+ end
210
+ end
211
+ end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to global searches, searching in projects and searching in groups.
5
+ # @see https://docs.gitlab.com/ce/api/search.html
6
+ module Search
7
+ # Search globally across the GitLab instance.
8
+ #
9
+ # @example
10
+ # Gitlab.search_globally('projects', 'gitlab')
11
+ # Gitlab.search_globally('issues', 'gitlab')
12
+ # Gitlab.search_globally('merge_requests', 'gitlab')
13
+ # Gitlab.search_globally('milestones', 'gitlab')
14
+ # Gitlab.search_globally('snippet_titles', 'gitlab')
15
+ # Gitlab.search_globally('snippet_blobs', 'gitlab')
16
+ #
17
+ # @param [String] scope The scope to search in. Currently these scopes are supported: projects, issues, merge_requests, milestones, snippet_titles, snippet_blobs.
18
+ # @param [String] search The search query.
19
+ # @return [Array<Gitlab::ObjectifiedHash>] Returns a list of responses depending on the requested scope.
20
+ def search_globally(scope, search)
21
+ options = { scope: scope, search: search }
22
+ get('/search', query: options)
23
+ end
24
+
25
+ # Search within the specified group.
26
+ #
27
+ # @example
28
+ # Gitlab.search_in_group(1, 'projects', 'gitlab')
29
+ # Gitlab.search_in_group(1, 'issues', 'gitlab')
30
+ # Gitlab.search_in_group(1, 'merge_requests', 'gitlab')
31
+ # Gitlab.search_in_group(1, 'milestones', 'gitlab')
32
+ #
33
+ # @param [Integer, String] group The ID or name of a group.
34
+ # @param [String] scope The scope to search in. Currently these scopes are supported: projects, issues, merge_requests, milestones.
35
+ # @param [String] search The search query.
36
+ # @return [Array<Gitlab::ObjectifiedHash>] Returns a list of responses depending on the requested scope.
37
+ def search_in_group(group, scope, search)
38
+ options = { scope: scope, search: search }
39
+ get("/groups/#{url_encode group}/search", query: options)
40
+ end
41
+
42
+ # Search within the specified project.
43
+ #
44
+ # @example
45
+ # Gitlab.search_in_project(1, 'issues', 'gitlab')
46
+ # Gitlab.search_in_project(1, 'merge_requests', 'gitlab')
47
+ # Gitlab.search_in_project(1, 'milestones', 'gitlab')
48
+ # Gitlab.search_in_project(1, 'notes', 'gitlab')
49
+ # Gitlab.search_in_project(1, 'wiki_blobs', 'gitlab')
50
+ # Gitlab.search_in_project(1, 'commits', 'gitlab')
51
+ # Gitlab.search_in_project(1, 'blobs', 'gitlab')
52
+ #
53
+ # @param [Integer, String] project The ID or name of a project.
54
+ # @param [String] scope The scope to search in. Currently these scopes are supported: issues, merge_requests, milestones, notes, wiki_blobs, commits, blobs.
55
+ # @param [String] search The search query.
56
+ # @return [Array<Gitlab::ObjectifiedHash>] Returns a list of responses depending on the requested scope.
57
+ def search_in_project(project, scope, search, ref = nil)
58
+ options = { scope: scope, search: search }
59
+
60
+ # Add ref filter if provided - backward compatible with main project
61
+ options[:ref] = ref unless ref.nil?
62
+
63
+ get("/projects/#{url_encode project}/search", query: options)
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Third party services connected to a project.
5
+ # @see https://docs.gitlab.com/ce/api/services.html
6
+ module Services
7
+ # Create/Edit service
8
+ # Full service params documentation: https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/services.md
9
+ #
10
+ # @example
11
+ # Gitlab.change_service(42, :redmine, { new_issue_url: 'https://example.com/projects/test_project/issues/new',
12
+ # project_url: 'https://example.com/projects/test_project/issues',
13
+ # issues_url: 'https://example.com/issues/:id' })
14
+ #
15
+ # @param [Integer, String] project The ID or name of a project.
16
+ # @param [String] service A service code name.
17
+ # @param [Hash] params A service parameters.
18
+ # @return [Boolean]
19
+ def change_service(project, service, params)
20
+ put("/projects/#{url_encode project}/services/#{correct_service_name(service)}", body: params)
21
+ end
22
+
23
+ # Delete service
24
+ #
25
+ # @example
26
+ # Gitlab.delete_service(42, :redmine)
27
+ #
28
+ # @param [Integer, String] project The ID or name of a project.
29
+ # @param [String] service A service code name.
30
+ # @return [Boolean]
31
+ def delete_service(project, service)
32
+ delete("/projects/#{url_encode project}/services/#{correct_service_name(service)}")
33
+ end
34
+
35
+ # Get service
36
+ #
37
+ # @example
38
+ # Gitlab.service(42, :redmine)
39
+ #
40
+ # @param [Integer, String] project The ID or name of a project.
41
+ # @param [String] service A service code name.
42
+ # @return [Gitlab::ObjectifiedHash]
43
+ def service(project, service)
44
+ get("/projects/#{url_encode project}/services/#{correct_service_name(service)}")
45
+ end
46
+
47
+ private
48
+
49
+ def correct_service_name(service)
50
+ service.to_s.tr('_', '-')
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to sidekiq metrics.
5
+ # @see https://docs.gitlab.com/ce/api/sidekiq_metrics.html
6
+ module Sidekiq
7
+ # Get the current Queue Metrics
8
+ #
9
+ # @example
10
+ # Gitlab.sidekiq_queue_metrics
11
+ def sidekiq_queue_metrics
12
+ get('/sidekiq/queue_metrics')
13
+ end
14
+
15
+ # Get the current Process Metrics
16
+ #
17
+ # @example
18
+ # Gitlab.sidekiq_process_metrics
19
+ def sidekiq_process_metrics
20
+ get('/sidekiq/process_metrics')
21
+ end
22
+
23
+ # Get the current Job Statistics
24
+ #
25
+ # @example
26
+ # Gitlab.sidekiq_job_stats
27
+ def sidekiq_job_stats
28
+ get('/sidekiq/job_stats')
29
+ end
30
+
31
+ # Get a compound response of all the previously mentioned metrics
32
+ #
33
+ # @example
34
+ # Gitlab.sidekiq_compound_metrics
35
+ def sidekiq_compound_metrics
36
+ get('/sidekiq/compound_metrics')
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to snippets.
5
+ # @see https://docs.gitlab.com/ce/api/project_snippets.html
6
+ module Snippets
7
+ # Gets a list of project's snippets.
8
+ #
9
+ # @example
10
+ # Gitlab.snippets(42)
11
+ #
12
+ # @param [Integer, String] project The ID or name of a project.
13
+ # @param [Hash] options A customizable set of options.
14
+ # @option options [Integer] :page The page number.
15
+ # @option options [Integer] :per_page The number of results per page.
16
+ # @return [Gitlab::ObjectifiedHash]
17
+ def snippets(project, options = {})
18
+ get("/projects/#{url_encode project}/snippets", query: options)
19
+ end
20
+
21
+ # Gets information about a snippet.
22
+ #
23
+ # @example
24
+ # Gitlab.snippet(2, 14)
25
+ #
26
+ # @param [Integer, String] project The ID or name of a project.
27
+ # @param [Integer] id The ID of a snippet.
28
+ # @return [Gitlab::ObjectifiedHash]
29
+ def snippet(project, id)
30
+ get("/projects/#{url_encode project}/snippets/#{id}")
31
+ end
32
+
33
+ # Creates a new snippet.
34
+ #
35
+ # @example
36
+ # Gitlab.create_snippet(42, { title: 'REST', file_name: 'api.rb', code: 'some code', visibility: 'public'})
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] :title (required) The title of a snippet.
41
+ # @option options [String] :file_name (required) The name of a snippet file.
42
+ # @option options [String] :code (required) The content of a snippet.
43
+ # @option options [String] :lifetime (optional) The expiration date of a snippet.
44
+ # @option options [String] :visibility (required) The visibility of a snippet
45
+ # @return [Gitlab::ObjectifiedHash] Information about created snippet.
46
+ def create_snippet(project, options = {})
47
+ post("/projects/#{url_encode project}/snippets", body: options)
48
+ end
49
+
50
+ # Updates a snippet.
51
+ #
52
+ # @example
53
+ # Gitlab.edit_snippet(42, 34, { file_name: 'README.txt' })
54
+ #
55
+ # @param [Integer, String] project The ID or name of a project.
56
+ # @param [Integer] id The ID of a snippet.
57
+ # @param [Hash] options A customizable set of options.
58
+ # @option options [String] :title The title of a snippet.
59
+ # @option options [String] :file_name The name of a snippet file.
60
+ # @option options [String] :code The content of a snippet.
61
+ # @option options [String] :lifetime The expiration date of a snippet.
62
+ # @option options [String] :visibility (optional) The visibility of a snippet
63
+ # @return [Gitlab::ObjectifiedHash] Information about updated snippet.
64
+ def edit_snippet(project, id, options = {})
65
+ put("/projects/#{url_encode project}/snippets/#{id}", body: options)
66
+ end
67
+
68
+ # Deletes a snippet.
69
+ #
70
+ # @example
71
+ # Gitlab.delete_snippet(2, 14)
72
+ #
73
+ # @param [Integer, String] project The ID or name of a project.
74
+ # @param [Integer] id The ID of a snippet.
75
+ # @return [Gitlab::ObjectifiedHash] Information about deleted snippet.
76
+ def delete_snippet(project, id)
77
+ delete("/projects/#{url_encode project}/snippets/#{id}")
78
+ end
79
+
80
+ # Returns raw project snippet content as plain text.
81
+ #
82
+ # @example
83
+ # Gitlab.snippet_content(2, 14)
84
+ #
85
+ # @param [Integer, String] project The ID or name of a project.
86
+ # @param [Integer] id The ID of a snippet.
87
+ # @return [Gitlab::ObjectifiedHash] Information about deleted snippet.
88
+ def snippet_content(project, id)
89
+ get("/projects/#{url_encode project}/snippets/#{id}/raw",
90
+ format: nil,
91
+ headers: { Accept: 'text/plain' },
92
+ parser: ::Gitlab::Request::Parser)
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to system hooks.
5
+ # @see https://docs.gitlab.com/ce/api/system_hooks.html
6
+ module SystemHooks
7
+ # Gets a list of system hooks.
8
+ #
9
+ # @example
10
+ # Gitlab.hooks
11
+ # Gitlab.system_hooks
12
+ #
13
+ # @param [Hash] options A customizable set of options.
14
+ # @option options [Integer] :page The page number.
15
+ # @option options [Integer] :per_page The number of results per page.
16
+ # @return [Array<Gitlab::ObjectifiedHash>]
17
+ def hooks(options = {})
18
+ get('/hooks', query: options)
19
+ end
20
+ alias system_hooks hooks
21
+
22
+ # Adds a new system hook.
23
+ #
24
+ # @example
25
+ # Gitlab.add_hook('http://example.com/hook')
26
+ # Gitlab.add_system_hook('https://api.example.net/v1/hook')
27
+ #
28
+ # @param [String] url The hook URL.
29
+ # @param [Hash] options Additional options, as allowed by Gitlab API, including but not limited to:
30
+ # @option options [String] :token A secret token for Gitlab to send in the `X-Gitlab-Token` header for authentication.
31
+ # @option options [boolean] :enable_ssl_verification `false` will cause Gitlab to ignore invalid/unsigned certificate errors (default is `true`)
32
+ # @return [Gitlab::ObjectifiedHash]
33
+ def add_hook(url, options = {})
34
+ post('/hooks', body: options.merge(url: url))
35
+ end
36
+ alias add_system_hook add_hook
37
+
38
+ # Tests a system hook.
39
+ #
40
+ # @example
41
+ # Gitlab.hook(3)
42
+ # Gitlab.system_hook(12)
43
+ #
44
+ # @param [Integer] id The ID of a system hook.
45
+ # @return [Array<Gitlab::ObjectifiedHash>]
46
+ def hook(id)
47
+ get("/hooks/#{id}")
48
+ end
49
+ alias system_hook hook
50
+
51
+ # Deletes a new system hook.
52
+ #
53
+ # @example
54
+ # Gitlab.delete_hook(3)
55
+ # Gitlab.delete_system_hook(12)
56
+ #
57
+ # @param [Integer] id The ID of a system hook.
58
+ # @return [Gitlab::ObjectifiedHash]
59
+ def delete_hook(id)
60
+ delete("/hooks/#{id}")
61
+ end
62
+ alias delete_system_hook delete_hook
63
+ end
64
+ end
@@ -0,0 +1,97 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to tags.
5
+ # @see https://docs.gitlab.com/ce/api/tags.html
6
+ module Tags
7
+ # Gets a list of project repository tags.
8
+ #
9
+ # @example
10
+ # Gitlab.tags(42)
11
+ #
12
+ # @param [Integer, String] project The ID or name of a project.
13
+ # @param [Hash] options A customizable set of options.
14
+ # @option options [Integer] :page The page number.
15
+ # @option options [Integer] :per_page The number of results per page.
16
+ # @return [Array<Gitlab::ObjectifiedHash>]
17
+ def tags(project, options = {})
18
+ get("/projects/#{url_encode project}/repository/tags", query: options)
19
+ end
20
+ alias repo_tags tags
21
+
22
+ # Creates a new project repository tag.
23
+ #
24
+ # @example
25
+ # Gitlab.create_tag(42, 'new_tag', 'master')
26
+ # Gitlab.create_tag(42, 'v1.0', 'master', 'Release 1.0')
27
+ #
28
+ # @param [Integer, String] project The ID or name of a project.
29
+ # @param [String] tag_name The name of the new tag.
30
+ # @param [String] ref The ref (commit sha, branch name, or another tag) the tag will point to.
31
+ # @param [String] message Optional message for tag, creates annotated tag if specified.
32
+ # @param [String] description Optional release notes for tag.
33
+ # @return [Gitlab::ObjectifiedHash]
34
+ def create_tag(project, tag_name, ref, message = '', description = nil)
35
+ post("/projects/#{url_encode project}/repository/tags", body: { tag_name: tag_name, ref: ref, message: message, release_description: description })
36
+ end
37
+ alias repo_create_tag create_tag
38
+
39
+ # Gets information about a repository tag.
40
+ #
41
+ # @example
42
+ # Gitlab.tag(3, 'api')
43
+ # Gitlab.repo_tag(5, 'master')
44
+ #
45
+ # @param [Integer, String] project The ID or name of a project.
46
+ # @param [String] tag The name of the tag.
47
+ # @return [Gitlab::ObjectifiedHash]
48
+ def tag(project, tag)
49
+ get("/projects/#{url_encode project}/repository/tags/#{url_encode tag}")
50
+ end
51
+ alias repo_tag tag
52
+
53
+ # Deletes a repository tag. Requires Gitlab >= 6.8.x
54
+ #
55
+ # @example
56
+ # Gitlab.delete_tag(3, 'api')
57
+ # Gitlab.repo_delete_tag(5, 'master')
58
+ #
59
+ # @param [Integer, String] project The ID or name of a project.
60
+ # @param [String] tag The name of the tag to delete
61
+ # @return [Gitlab::ObjectifiedHash]
62
+ def delete_tag(project, tag)
63
+ delete("/projects/#{url_encode project}/repository/tags/#{url_encode tag}")
64
+ end
65
+ alias repo_delete_tag delete_tag
66
+
67
+ # Adds release notes to an existing repository tag. Requires Gitlab >= 8.2.0
68
+ #
69
+ # @example
70
+ # Gitlab.create_release(3, '1.0.0', 'This is ready for production')
71
+ # Gitlab.repo_create_release(5, '1.0.0', 'This is ready for production')
72
+ #
73
+ # @param [Integer, String] project The ID or name of a project.
74
+ # @param [String] tag The name of the new tag.
75
+ # @param [String] description Release notes with markdown support
76
+ # @return [Gitlab::ObjectifiedHash]
77
+ def create_release(project, tag, description)
78
+ post("/projects/#{url_encode project}/repository/tags/#{url_encode tag}/release", body: { description: description })
79
+ end
80
+ alias repo_create_release create_release
81
+
82
+ # Updates the release notes of a given release. Requires Gitlab >= 8.2.0
83
+ #
84
+ # @example
85
+ # Gitlab.update_release(3, '1.0.0', 'This is even more ready for production')
86
+ # Gitlab.repo_update_release(5, '1.0.0', 'This is even more ready for production')
87
+ #
88
+ # @param [Integer, String] project The ID or name of a project.
89
+ # @param [String] tag The name of the new tag.
90
+ # @param [String] description Release notes with markdown support
91
+ # @return [Gitlab::ObjectifiedHash]
92
+ def update_release(project, tag, description)
93
+ put("/projects/#{url_encode project}/repository/tags/#{url_encode tag}/release", body: { description: description })
94
+ end
95
+ alias repo_update_release update_release
96
+ end
97
+ end