gitlab 4.2.0 → 4.18.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 +5 -5
- data/CHANGELOG.md +4 -2
- data/LICENSE.txt +1 -1
- data/README.md +96 -25
- data/exe/gitlab +5 -1
- data/lib/gitlab/api.rb +8 -3
- data/lib/gitlab/cli.rb +15 -15
- data/lib/gitlab/cli_helpers.rb +63 -61
- data/lib/gitlab/client/access_requests.rb +103 -0
- data/lib/gitlab/client/application_settings.rb +172 -0
- data/lib/gitlab/client/avatar.rb +21 -0
- data/lib/gitlab/client/award_emojis.rb +5 -3
- data/lib/gitlab/client/boards.rb +62 -4
- data/lib/gitlab/client/branches.rb +53 -14
- data/lib/gitlab/client/broadcast_messages.rb +75 -0
- data/lib/gitlab/client/build_variables.rb +78 -9
- data/lib/gitlab/client/builds.rb +13 -11
- data/lib/gitlab/client/commits.rb +89 -19
- data/lib/gitlab/client/container_registry.rb +85 -0
- data/lib/gitlab/client/deployments.rb +34 -0
- data/lib/gitlab/client/environments.rb +5 -3
- data/lib/gitlab/client/epic_issues.rb +23 -0
- data/lib/gitlab/client/epics.rb +73 -0
- data/lib/gitlab/client/events.rb +60 -0
- data/lib/gitlab/client/features.rb +48 -0
- data/lib/gitlab/client/group_badges.rb +88 -0
- data/lib/gitlab/client/group_boards.rb +141 -0
- data/lib/gitlab/client/group_labels.rb +88 -0
- data/lib/gitlab/client/group_milestones.rb +94 -0
- data/lib/gitlab/client/groups.rb +197 -17
- data/lib/gitlab/client/issue_links.rb +48 -0
- data/lib/gitlab/client/issues.rb +98 -4
- data/lib/gitlab/client/jobs.rb +96 -8
- data/lib/gitlab/client/keys.rb +13 -0
- data/lib/gitlab/client/labels.rb +7 -5
- data/lib/gitlab/client/lint.rb +19 -0
- data/lib/gitlab/client/markdown.rb +23 -0
- data/lib/gitlab/client/merge_request_approvals.rb +265 -0
- data/lib/gitlab/client/merge_requests.rb +237 -9
- data/lib/gitlab/client/milestones.rb +19 -5
- data/lib/gitlab/client/namespaces.rb +4 -2
- data/lib/gitlab/client/notes.rb +58 -12
- data/lib/gitlab/client/pipeline_schedules.rb +147 -0
- data/lib/gitlab/client/pipeline_triggers.rb +12 -10
- data/lib/gitlab/client/pipelines.rb +40 -3
- data/lib/gitlab/client/project_badges.rb +85 -0
- data/lib/gitlab/client/project_clusters.rb +83 -0
- data/lib/gitlab/client/project_release_links.rb +76 -0
- data/lib/gitlab/client/project_releases.rb +79 -0
- data/lib/gitlab/client/projects.rb +280 -47
- data/lib/gitlab/client/protected_tags.rb +59 -0
- data/lib/gitlab/client/remote_mirrors.rb +51 -0
- data/lib/gitlab/client/repositories.rb +60 -6
- data/lib/gitlab/client/repository_files.rb +23 -5
- data/lib/gitlab/client/repository_submodules.rb +27 -0
- data/lib/gitlab/client/resource_label_events.rb +82 -0
- data/lib/gitlab/client/resource_state_events.rb +57 -0
- data/lib/gitlab/client/runners.rb +111 -15
- data/lib/gitlab/client/search.rb +66 -0
- data/lib/gitlab/client/services.rb +4 -1
- data/lib/gitlab/client/sidekiq.rb +39 -0
- data/lib/gitlab/client/snippets.rb +8 -4
- data/lib/gitlab/client/system_hooks.rb +9 -7
- data/lib/gitlab/client/tags.rb +15 -14
- data/lib/gitlab/client/templates.rb +100 -0
- data/lib/gitlab/client/todos.rb +7 -5
- data/lib/gitlab/client/user_snippets.rb +114 -0
- data/lib/gitlab/client/users.rb +166 -30
- data/lib/gitlab/client/versions.rb +18 -0
- data/lib/gitlab/client/wikis.rb +79 -0
- data/lib/gitlab/client.rb +49 -12
- data/lib/gitlab/configuration.rb +8 -6
- data/lib/gitlab/error.rb +74 -5
- data/lib/gitlab/file_response.rb +5 -3
- data/lib/gitlab/help.rb +19 -20
- data/lib/gitlab/objectified_hash.rb +27 -10
- data/lib/gitlab/page_links.rb +11 -9
- data/lib/gitlab/paginated_response.rb +37 -24
- data/lib/gitlab/request.rb +42 -53
- data/lib/gitlab/shell.rb +11 -12
- data/lib/gitlab/shell_history.rb +11 -13
- data/lib/gitlab/version.rb +3 -1
- data/lib/gitlab.rb +19 -8
- metadata +50 -395
- data/.gitignore +0 -22
- data/.travis.yml +0 -8
- data/CONTRIBUTING.md +0 -195
- data/Gemfile +0 -4
- data/Rakefile +0 -9
- data/bin/console +0 -10
- data/bin/setup +0 -6
- data/gitlab.gemspec +0 -31
- data/spec/fixtures/board_list.json +0 -1
- data/spec/fixtures/board_lists.json +0 -1
- data/spec/fixtures/boards.json +0 -1
- data/spec/fixtures/branch.json +0 -1
- data/spec/fixtures/branch_delete.json +0 -3
- data/spec/fixtures/branches.json +0 -1
- data/spec/fixtures/build.json +0 -38
- data/spec/fixtures/build_artifacts.json +0 -0
- data/spec/fixtures/build_cancel.json +0 -24
- data/spec/fixtures/build_erase.json +0 -24
- data/spec/fixtures/build_retry.json +0 -24
- data/spec/fixtures/builds.json +0 -78
- data/spec/fixtures/builds_commits.json +0 -64
- data/spec/fixtures/compare_merge_request_diff.json +0 -31
- data/spec/fixtures/empty.json +0 -0
- data/spec/fixtures/environment.json +0 -6
- data/spec/fixtures/environments.json +0 -14
- data/spec/fixtures/error_already_exists.json +0 -1
- data/spec/fixtures/error_project_not_found.json +0 -1
- data/spec/fixtures/get_repository_file.json +0 -1
- data/spec/fixtures/group.json +0 -60
- data/spec/fixtures/group_create.json +0 -1
- data/spec/fixtures/group_create_with_description.json +0 -1
- data/spec/fixtures/group_delete.json +0 -1
- data/spec/fixtures/group_member.json +0 -1
- data/spec/fixtures/group_member_delete.json +0 -1
- data/spec/fixtures/group_member_edit.json +0 -1
- data/spec/fixtures/group_members.json +0 -1
- data/spec/fixtures/group_projects.json +0 -44
- data/spec/fixtures/group_search.json +0 -2
- data/spec/fixtures/groups.json +0 -2
- data/spec/fixtures/issue.json +0 -1
- data/spec/fixtures/issue_award_emoji.json +0 -16
- data/spec/fixtures/issue_award_emojis.json +0 -34
- data/spec/fixtures/issues.json +0 -1
- data/spec/fixtures/job.json +0 -43
- data/spec/fixtures/job_trace.json +0 -1
- data/spec/fixtures/jobs.json +0 -91
- data/spec/fixtures/key.json +0 -1
- data/spec/fixtures/keys.json +0 -1
- data/spec/fixtures/label.json +0 -1
- data/spec/fixtures/label_unsubscribe.json +0 -1
- data/spec/fixtures/labels.json +0 -1
- data/spec/fixtures/merge_request.json +0 -1
- data/spec/fixtures/merge_request_award_emoji.json +0 -16
- data/spec/fixtures/merge_request_award_emojis.json +0 -34
- data/spec/fixtures/merge_request_changes.json +0 -1
- data/spec/fixtures/merge_request_closes_issues.json +0 -1
- data/spec/fixtures/merge_request_comment.json +0 -1
- data/spec/fixtures/merge_request_comments.json +0 -1
- data/spec/fixtures/merge_request_commits.json +0 -1
- data/spec/fixtures/merge_requests.json +0 -1
- data/spec/fixtures/milestone.json +0 -1
- data/spec/fixtures/milestone_issues.json +0 -1
- data/spec/fixtures/milestone_merge_requests.json +0 -1
- data/spec/fixtures/milestones.json +0 -1
- data/spec/fixtures/namespaces.json +0 -1
- data/spec/fixtures/note.json +0 -1
- data/spec/fixtures/note_award_emoji.json +0 -16
- data/spec/fixtures/note_award_emojis.json +0 -18
- data/spec/fixtures/notes.json +0 -1
- data/spec/fixtures/pipeline.json +0 -23
- data/spec/fixtures/pipeline_cancel.json +0 -23
- data/spec/fixtures/pipeline_create.json +0 -23
- data/spec/fixtures/pipeline_jobs.json +0 -91
- data/spec/fixtures/pipeline_retry.json +0 -23
- data/spec/fixtures/pipelines.json +0 -48
- data/spec/fixtures/project.json +0 -1
- data/spec/fixtures/project_commit.json +0 -13
- data/spec/fixtures/project_commit_comment.json +0 -1
- data/spec/fixtures/project_commit_comments.json +0 -1
- data/spec/fixtures/project_commit_create.json +0 -22
- data/spec/fixtures/project_commit_diff.json +0 -10
- data/spec/fixtures/project_commit_status.json +0 -42
- data/spec/fixtures/project_commits.json +0 -1
- data/spec/fixtures/project_edit.json +0 -21
- data/spec/fixtures/project_events.json +0 -1
- data/spec/fixtures/project_for_user.json +0 -1
- data/spec/fixtures/project_fork.json +0 -50
- data/spec/fixtures/project_fork_link.json +0 -1
- data/spec/fixtures/project_forked_for_user.json +0 -50
- data/spec/fixtures/project_hook.json +0 -1
- data/spec/fixtures/project_hooks.json +0 -1
- data/spec/fixtures/project_issues.json +0 -1
- data/spec/fixtures/project_key.json +0 -6
- data/spec/fixtures/project_keys.json +0 -6
- data/spec/fixtures/project_runner_enable.json +0 -7
- data/spec/fixtures/project_runners.json +0 -16
- data/spec/fixtures/project_search.json +0 -1
- data/spec/fixtures/project_star.json +0 -44
- data/spec/fixtures/project_tag_annotated.json +0 -1
- data/spec/fixtures/project_tag_lightweight.json +0 -1
- data/spec/fixtures/project_tags.json +0 -1
- data/spec/fixtures/project_unstar.json +0 -44
- data/spec/fixtures/project_update_commit_status.json +0 -20
- data/spec/fixtures/projects.json +0 -1
- data/spec/fixtures/push_rule.json +0 -1
- data/spec/fixtures/raw_file.json +0 -2
- data/spec/fixtures/release_create.json +0 -1
- data/spec/fixtures/release_update.json +0 -1
- data/spec/fixtures/repository_file.json +0 -1
- data/spec/fixtures/run_trigger.json +0 -1
- data/spec/fixtures/runner.json +0 -26
- data/spec/fixtures/runner_delete.json +0 -7
- data/spec/fixtures/runner_edit.json +0 -26
- data/spec/fixtures/runners.json +0 -16
- data/spec/fixtures/runners_all.json +0 -30
- data/spec/fixtures/service.json +0 -1
- data/spec/fixtures/session.json +0 -1
- data/spec/fixtures/shell_history.json +0 -2
- data/spec/fixtures/snippet.json +0 -1
- data/spec/fixtures/snippet_award_emoji.json +0 -16
- data/spec/fixtures/snippet_award_emojis.json +0 -34
- data/spec/fixtures/snippet_content.json +0 -3
- data/spec/fixtures/snippets.json +0 -1
- data/spec/fixtures/system_hook.json +0 -1
- data/spec/fixtures/system_hooks.json +0 -1
- data/spec/fixtures/tag.json +0 -1
- data/spec/fixtures/tag_create.json +0 -1
- data/spec/fixtures/tag_create_with_description.json +0 -1
- data/spec/fixtures/tag_delete.json +0 -1
- data/spec/fixtures/tags.json +0 -1
- data/spec/fixtures/team_member.json +0 -1
- data/spec/fixtures/team_members.json +0 -1
- data/spec/fixtures/todo.json +0 -73
- data/spec/fixtures/todos.json +0 -148
- data/spec/fixtures/tree.json +0 -1
- data/spec/fixtures/trigger.json +0 -10
- data/spec/fixtures/triggers.json +0 -12
- data/spec/fixtures/user.json +0 -1
- data/spec/fixtures/user_block_unblock.json +0 -1
- data/spec/fixtures/user_email.json +0 -1
- data/spec/fixtures/user_emails.json +0 -1
- data/spec/fixtures/user_search.json +0 -1
- data/spec/fixtures/users.json +0 -1
- data/spec/fixtures/variable.json +0 -4
- data/spec/fixtures/variables.json +0 -10
- data/spec/gitlab/cli_helpers_spec.rb +0 -57
- data/spec/gitlab/cli_spec.rb +0 -119
- data/spec/gitlab/client/award_emojis_spec.rb +0 -391
- data/spec/gitlab/client/boards_spec.rb +0 -94
- data/spec/gitlab/client/branches_spec.rb +0 -116
- data/spec/gitlab/client/build_variables_spec.rb +0 -86
- data/spec/gitlab/client/builds_spec.rb +0 -148
- data/spec/gitlab/client/client_spec.rb +0 -11
- data/spec/gitlab/client/commits_spec.rb +0 -168
- data/spec/gitlab/client/environments_spec.rb +0 -132
- data/spec/gitlab/client/groups_spec.rb +0 -195
- data/spec/gitlab/client/issues_spec.rb +0 -186
- data/spec/gitlab/client/jobs_spec.rb +0 -135
- data/spec/gitlab/client/keys_spec.rb +0 -19
- data/spec/gitlab/client/labels_spec.rb +0 -100
- data/spec/gitlab/client/merge_requests_spec.rb +0 -224
- data/spec/gitlab/client/milestones_spec.rb +0 -98
- data/spec/gitlab/client/namespaces_spec.rb +0 -22
- data/spec/gitlab/client/notes_spec.rb +0 -333
- data/spec/gitlab/client/pipeline_triggers_spec.rb +0 -157
- data/spec/gitlab/client/pipelines_spec.rb +0 -95
- data/spec/gitlab/client/projects_spec.rb +0 -613
- data/spec/gitlab/client/repositories_spec.rb +0 -94
- data/spec/gitlab/client/repository_files_spec.rb +0 -95
- data/spec/gitlab/client/runners_spec.rb +0 -185
- data/spec/gitlab/client/services_spec.rb +0 -55
- data/spec/gitlab/client/snippets_spec.rb +0 -100
- data/spec/gitlab/client/system_hooks_spec.rb +0 -69
- data/spec/gitlab/client/tags_spec.rb +0 -109
- data/spec/gitlab/client/todos_spec.rb +0 -45
- data/spec/gitlab/client/users_spec.rb +0 -418
- data/spec/gitlab/error_spec.rb +0 -45
- data/spec/gitlab/file_response_spec.rb +0 -33
- data/spec/gitlab/help_spec.rb +0 -46
- data/spec/gitlab/objectified_hash_spec.rb +0 -48
- data/spec/gitlab/page_links_spec.rb +0 -16
- data/spec/gitlab/paginated_response_spec.rb +0 -60
- data/spec/gitlab/request_spec.rb +0 -73
- data/spec/gitlab/shell_history_spec.rb +0 -53
- data/spec/gitlab/shell_spec.rb +0 -80
- data/spec/gitlab_spec.rb +0 -97
- data/spec/spec_helper.rb +0 -74
data/lib/gitlab/client/groups.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class Gitlab::Client
|
|
2
4
|
# Defines methods related to groups.
|
|
3
5
|
# @see https://docs.gitlab.com/ce/api/groups.html
|
|
@@ -12,8 +14,8 @@ class Gitlab::Client
|
|
|
12
14
|
# @option options [Integer] :page The page number.
|
|
13
15
|
# @option options [Integer] :per_page The number of results per page.
|
|
14
16
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
15
|
-
def groups(options={})
|
|
16
|
-
get(
|
|
17
|
+
def groups(options = {})
|
|
18
|
+
get('/groups', query: options)
|
|
17
19
|
end
|
|
18
20
|
|
|
19
21
|
# Gets a single group.
|
|
@@ -22,9 +24,12 @@ class Gitlab::Client
|
|
|
22
24
|
# Gitlab.group(42)
|
|
23
25
|
#
|
|
24
26
|
# @param [Integer] id The ID of a group.
|
|
27
|
+
# @param [Hash] options A customizable set of options.
|
|
28
|
+
# @option options [Boolean] :with_custom_attributes Include custom attributes in response (admins only)
|
|
29
|
+
# @option options [Boolean] :with_projects Include details about group projects (default: true)
|
|
25
30
|
# @return [Gitlab::ObjectifiedHash]
|
|
26
|
-
def group(id)
|
|
27
|
-
get("/groups/#{id}")
|
|
31
|
+
def group(id, options = {})
|
|
32
|
+
get("/groups/#{url_encode id}", query: options)
|
|
28
33
|
end
|
|
29
34
|
|
|
30
35
|
# Creates a new group.
|
|
@@ -36,9 +41,9 @@ class Gitlab::Client
|
|
|
36
41
|
# @param [String] name The name of a group.
|
|
37
42
|
# @param [String] path The path of a group.
|
|
38
43
|
# @return [Gitlab::ObjectifiedHash] Information about created group.
|
|
39
|
-
def create_group(name, path, options={})
|
|
44
|
+
def create_group(name, path, options = {})
|
|
40
45
|
body = { name: name, path: path }.merge(options)
|
|
41
|
-
post(
|
|
46
|
+
post('/groups', body: body)
|
|
42
47
|
end
|
|
43
48
|
|
|
44
49
|
# Delete's a group.
|
|
@@ -48,7 +53,7 @@ class Gitlab::Client
|
|
|
48
53
|
# @param [Integer] id The ID of a group
|
|
49
54
|
# @return [Gitlab::ObjectifiedHash] Information about the deleted group.
|
|
50
55
|
def delete_group(id)
|
|
51
|
-
delete("/groups/#{id}")
|
|
56
|
+
delete("/groups/#{url_encode id}")
|
|
52
57
|
end
|
|
53
58
|
|
|
54
59
|
# Get a list of group members.
|
|
@@ -62,8 +67,47 @@ class Gitlab::Client
|
|
|
62
67
|
# @option options [Integer] :page The page number.
|
|
63
68
|
# @option options [Integer] :per_page The number of results per page.
|
|
64
69
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
65
|
-
def group_members(id, options={})
|
|
66
|
-
get("/groups/#{id}/members", query: options)
|
|
70
|
+
def group_members(id, options = {})
|
|
71
|
+
get("/groups/#{url_encode id}/members", query: options)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Get a list of group members that are billable.
|
|
75
|
+
#
|
|
76
|
+
# @example
|
|
77
|
+
# Gitlab.group_billable_members(1)
|
|
78
|
+
# Gitlab.group_billable_members(1, { per_page: 40 })
|
|
79
|
+
#
|
|
80
|
+
# @param [Integer] id The ID of a group.
|
|
81
|
+
# @param [Hash] options A customizable set of options.
|
|
82
|
+
# @option options [Integer] :page The page number.
|
|
83
|
+
# @option options [Integer] :per_page The number of results per page.
|
|
84
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
85
|
+
def group_billable_members(id, options = {})
|
|
86
|
+
get("/groups/#{url_encode id}/billable_members", query: options)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Get details of a single group member.
|
|
90
|
+
#
|
|
91
|
+
# @example
|
|
92
|
+
# Gitlab.group_member(1, 10)
|
|
93
|
+
#
|
|
94
|
+
# @param [Integer] team_id The ID of the group to find a member in.
|
|
95
|
+
# @param [Integer] user_id The user id of the member to find.
|
|
96
|
+
# @return [Gitlab::ObjectifiedHash] (id, username, name, email, state, access_level ...)
|
|
97
|
+
def group_member(team_id, user_id)
|
|
98
|
+
get("/groups/#{url_encode team_id}/members/#{user_id}")
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Gets a list of merge requests of a group.
|
|
102
|
+
#
|
|
103
|
+
# @example
|
|
104
|
+
# Gitlab.group_merge_requests(5)
|
|
105
|
+
#
|
|
106
|
+
# @param [Integer, String] group_id The ID or name of a group.
|
|
107
|
+
# @param [Hash] options A customizable set of options.
|
|
108
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
109
|
+
def group_merge_requests(group, options = {})
|
|
110
|
+
get("/groups/#{group}/merge_requests", query: options)
|
|
67
111
|
end
|
|
68
112
|
|
|
69
113
|
# Adds a user to group.
|
|
@@ -76,7 +120,7 @@ class Gitlab::Client
|
|
|
76
120
|
# @param [Integer] access_level Project access level.
|
|
77
121
|
# @return [Gitlab::ObjectifiedHash] Information about added team member.
|
|
78
122
|
def add_group_member(team_id, user_id, access_level)
|
|
79
|
-
post("/groups/#{team_id}/members", body: { user_id: user_id, access_level: access_level })
|
|
123
|
+
post("/groups/#{url_encode team_id}/members", body: { user_id: user_id, access_level: access_level })
|
|
80
124
|
end
|
|
81
125
|
|
|
82
126
|
# Edit a user of a group.
|
|
@@ -89,7 +133,7 @@ class Gitlab::Client
|
|
|
89
133
|
# @param [Integer] access_level Project access level.
|
|
90
134
|
# @return [Gitlab::ObjectifiedHash] Information about edited team member.
|
|
91
135
|
def edit_group_member(team_id, user_id, access_level)
|
|
92
|
-
put("/groups/#{team_id}/members/#{user_id}", body: { access_level: access_level })
|
|
136
|
+
put("/groups/#{url_encode team_id}/members/#{user_id}", body: { access_level: access_level })
|
|
93
137
|
end
|
|
94
138
|
|
|
95
139
|
# Removes user from user group.
|
|
@@ -101,7 +145,7 @@ class Gitlab::Client
|
|
|
101
145
|
# @param [Integer] user_id The ID of a user.
|
|
102
146
|
# @return [Gitlab::ObjectifiedHash] Information about removed team member.
|
|
103
147
|
def remove_group_member(team_id, user_id)
|
|
104
|
-
delete("/groups/#{team_id}/members/#{user_id}")
|
|
148
|
+
delete("/groups/#{url_encode team_id}/members/#{user_id}")
|
|
105
149
|
end
|
|
106
150
|
|
|
107
151
|
# Transfers a project to a group
|
|
@@ -113,7 +157,7 @@ class Gitlab::Client
|
|
|
113
157
|
# @param [Integer] project_id The ID of a project.
|
|
114
158
|
def transfer_project_to_group(id, project_id)
|
|
115
159
|
body = { id: id, project_id: project_id }
|
|
116
|
-
post("/groups/#{id}/projects/#{project_id}", body: body)
|
|
160
|
+
post("/groups/#{url_encode id}/projects/#{project_id}", body: body)
|
|
117
161
|
end
|
|
118
162
|
|
|
119
163
|
# Search for groups by name
|
|
@@ -126,9 +170,9 @@ class Gitlab::Client
|
|
|
126
170
|
# @option options [String] :per_page Number of projects to return per page
|
|
127
171
|
# @option options [String] :page The page to retrieve
|
|
128
172
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
129
|
-
def group_search(search, options={})
|
|
173
|
+
def group_search(search, options = {})
|
|
130
174
|
options[:search] = search
|
|
131
|
-
get(
|
|
175
|
+
get('/groups', query: options)
|
|
132
176
|
end
|
|
133
177
|
|
|
134
178
|
# Get a list of projects under a group
|
|
@@ -137,8 +181,144 @@ class Gitlab::Client
|
|
|
137
181
|
#
|
|
138
182
|
# @param [Integer] id The ID of a group
|
|
139
183
|
# @return [Array<Gitlab::ObjectifiedHash>] List of projects under a group
|
|
140
|
-
def group_projects(id, options={})
|
|
141
|
-
get("/groups/#{id}/projects", query: options)
|
|
184
|
+
def group_projects(id, options = {})
|
|
185
|
+
get("/groups/#{url_encode id}/projects", query: options)
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
# Get a list of subgroups under a group
|
|
189
|
+
# @example
|
|
190
|
+
# Gitlab.group_subgroups(1)
|
|
191
|
+
#
|
|
192
|
+
# @param [Integer] id the ID of a group
|
|
193
|
+
# @param [Hash] options A customizable set of options.
|
|
194
|
+
# @option options [String] :skip_groups Skip the group IDs passed.
|
|
195
|
+
# @option options [String] :all_available Show all the groups you have access to (defaults to false for authenticated users).
|
|
196
|
+
# @option options [String] :search Return the list of authorized groups matching the search criteria.
|
|
197
|
+
# @option options [String] :order_by Order groups by name or path. Default is name.
|
|
198
|
+
# @option options [String] :sort Order groups in asc or desc order. Default is asc.
|
|
199
|
+
# @option options [String] :statistics Include group statistics (admins only).
|
|
200
|
+
# @option options [String] :owned Limit to groups owned by the current user.
|
|
201
|
+
# @return [Array<Gitlab::ObjectifiedHash>] List of subgroups under a group
|
|
202
|
+
def group_subgroups(id, options = {})
|
|
203
|
+
get("/groups/#{url_encode id}/subgroups", query: options)
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# Updates an existing group.
|
|
207
|
+
#
|
|
208
|
+
# @example
|
|
209
|
+
# Gitlab.edit_group(42)
|
|
210
|
+
# Gitlab.edit_group(42, { name: 'Group Name' })
|
|
211
|
+
#
|
|
212
|
+
# @param [Integer] group The ID.
|
|
213
|
+
# @param [Hash] options A customizable set of options
|
|
214
|
+
# @option options [String] :name The name of the group.
|
|
215
|
+
# @option options [String] :path The path of the group.
|
|
216
|
+
# @option options [String] :description The description of the group.
|
|
217
|
+
# @option options [String] :visibility The visibility level of the group. Can be private, internal, or public
|
|
218
|
+
# @option options [String] :lfs_enabled Enable/disable Large File Storage (LFS) for the projects in this groupr.
|
|
219
|
+
# @option options [String] :request_access_enabled Allow users to request member access.
|
|
220
|
+
# @return [Gitlab::ObjectifiedHash] Information about the edited group.
|
|
221
|
+
def edit_group(id, options = {})
|
|
222
|
+
put("/groups/#{url_encode id}", body: options)
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# Gets a list of issues of a group.
|
|
226
|
+
#
|
|
227
|
+
# @example
|
|
228
|
+
# Gitlab.group_issues(5)
|
|
229
|
+
#
|
|
230
|
+
# @param [Integer, String] group_id The ID or name of a group.
|
|
231
|
+
# @param [Hash] options A customizable set of options.
|
|
232
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
233
|
+
def group_issues(group, options = {})
|
|
234
|
+
get("/groups/#{group}/issues", query: options)
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# Sync group with LDAP
|
|
238
|
+
#
|
|
239
|
+
# @example
|
|
240
|
+
# Gitlab.sync_ldap_group(1)
|
|
241
|
+
#
|
|
242
|
+
# @param [Integer] id The ID or name of a group.
|
|
243
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
244
|
+
def sync_ldap_group(id)
|
|
245
|
+
post("/groups/#{url_encode id}/ldap_sync")
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
# Add LDAP group link
|
|
249
|
+
#
|
|
250
|
+
# @example
|
|
251
|
+
# Gitlab.add_ldap_group_links(1, 'all', 50, 'ldap')
|
|
252
|
+
#
|
|
253
|
+
# @param [Integer] id The ID of a group
|
|
254
|
+
# @param [String] cn The CN of a LDAP group
|
|
255
|
+
# @param [Integer] group_access Minimum access level for members of the LDAP group.
|
|
256
|
+
# @param [String] provider LDAP provider for the LDAP group
|
|
257
|
+
# @return [Gitlab::ObjectifiedHash] Information about added ldap group link
|
|
258
|
+
def add_ldap_group_links(id, commonname, group_access, provider)
|
|
259
|
+
post("/groups/#{url_encode id}/ldap_group_links", body: { cn: commonname, group_access: group_access, provider: provider })
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
# Delete LDAP group link
|
|
263
|
+
#
|
|
264
|
+
# @example
|
|
265
|
+
# Gitlab.delete_ldap_group_links(1, 'all')
|
|
266
|
+
#
|
|
267
|
+
# @param [Integer] id The ID of a group
|
|
268
|
+
# @param [String] cn The CN of a LDAP group
|
|
269
|
+
# @return [Gitlab::ObjectifiedHash] Empty hash
|
|
270
|
+
def delete_ldap_group_links(id, commonname, provider)
|
|
271
|
+
delete("/groups/#{url_encode id}/ldap_group_links/#{url_encode provider}/#{url_encode commonname}")
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
# Gets group custom_attributes.
|
|
275
|
+
#
|
|
276
|
+
# @example
|
|
277
|
+
# Gitlab.group_custom_attributes(2)
|
|
278
|
+
#
|
|
279
|
+
# @param [Integer] group_id The ID of a group.
|
|
280
|
+
# @return [Gitlab::ObjectifiedHash]
|
|
281
|
+
def group_custom_attributes(group_id)
|
|
282
|
+
get("/groups/#{group_id}/custom_attributes")
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
# Gets single group custom_attribute.
|
|
286
|
+
#
|
|
287
|
+
# @example
|
|
288
|
+
# Gitlab.group_custom_attribute('key', 2)
|
|
289
|
+
#
|
|
290
|
+
# @param [String] key The custom_attributes key
|
|
291
|
+
# @param [Integer] group_id The ID of a group.
|
|
292
|
+
# @return [Gitlab::ObjectifiedHash]
|
|
293
|
+
def group_custom_attribute(key, group_id)
|
|
294
|
+
get("/groups/#{group_id}/custom_attributes/#{key}")
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
# Creates a new custom_attribute
|
|
298
|
+
#
|
|
299
|
+
# @example
|
|
300
|
+
# Gitlab.add_custom_attribute('some_new_key', 'some_new_value', 2)
|
|
301
|
+
#
|
|
302
|
+
# @param [String] key The custom_attributes key
|
|
303
|
+
# @param [String] value The custom_attributes value
|
|
304
|
+
# @param [Integer] group_id The ID of a group.
|
|
305
|
+
# @return [Gitlab::ObjectifiedHash]
|
|
306
|
+
def add_group_custom_attribute(key, value, group_id)
|
|
307
|
+
url = "/groups/#{group_id}/custom_attributes/#{key}"
|
|
308
|
+
put(url, body: { value: value })
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
# Delete custom_attribute
|
|
312
|
+
# Will delete a custom_attribute
|
|
313
|
+
#
|
|
314
|
+
# @example
|
|
315
|
+
# Gitlab.delete_group_custom_attribute('somekey', 2)
|
|
316
|
+
#
|
|
317
|
+
# @param [String] key The custom_attribute key to delete
|
|
318
|
+
# @param [Integer] group_id The ID of a group.
|
|
319
|
+
# @return [Boolean]
|
|
320
|
+
def delete_group_custom_attribute(key, group_id = nil)
|
|
321
|
+
delete("/groups/#{group_id}/custom_attributes/#{key}")
|
|
142
322
|
end
|
|
143
323
|
end
|
|
144
324
|
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Gitlab::Client
|
|
4
|
+
# Defines methods related to issue links.
|
|
5
|
+
# @see https://docs.gitlab.com/ee/api/issue_links.html
|
|
6
|
+
module IssueLinks
|
|
7
|
+
# Gets a list of links for a issue.
|
|
8
|
+
#
|
|
9
|
+
# @example
|
|
10
|
+
# Gitlab.issue_links(5, 10)
|
|
11
|
+
#
|
|
12
|
+
# @param [Integer] project The ID of a project.
|
|
13
|
+
# @param [Integer] issue The ID of an issue.
|
|
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 issue_links(project, issue, options = {})
|
|
18
|
+
get("/projects/#{url_encode project}/issues/#{issue}/links", query: options)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Creates a new issue link.
|
|
22
|
+
#
|
|
23
|
+
# @example
|
|
24
|
+
# Gitlab.create_issue_link(6, 1, 6, 2)
|
|
25
|
+
#
|
|
26
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
27
|
+
# @param [Integer] issue The ID of an issue.
|
|
28
|
+
# @param [Integer] target_project_id Project ID the target issue is located in.
|
|
29
|
+
# @param [Integer] target_issue_iid The ID of the target issue.
|
|
30
|
+
# @return [Gitlab::ObjectifiedHash] Information about created link.
|
|
31
|
+
def create_issue_link(project, issue, target_project_id, target_issue_iid)
|
|
32
|
+
post("/projects/#{url_encode project}/issues/#{issue}/links", body: { target_project_id: target_project_id, target_issue_iid: target_issue_iid })
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Deletes an issue link.
|
|
36
|
+
#
|
|
37
|
+
# @example
|
|
38
|
+
# Gitlab.delete_issue_link(5, 10, 123)
|
|
39
|
+
#
|
|
40
|
+
# @param [Integer] project The ID of a project.
|
|
41
|
+
# @param [Integer] issue The ID of an issue.
|
|
42
|
+
# @param [Integer] id The ID of a link.
|
|
43
|
+
# @return [Gitlab::ObjectifiedHash]
|
|
44
|
+
def delete_issue_link(project, issue, id)
|
|
45
|
+
delete("/projects/#{url_encode project}/issues/#{issue}/links/#{id}")
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
data/lib/gitlab/client/issues.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class Gitlab::Client
|
|
2
4
|
# Defines methods related to issues.
|
|
3
5
|
# @see https://docs.gitlab.com/ce/api/issues.html
|
|
@@ -15,9 +17,9 @@ class Gitlab::Client
|
|
|
15
17
|
# @option options [Integer] :page The page number.
|
|
16
18
|
# @option options [Integer] :per_page The number of results per page.
|
|
17
19
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
18
|
-
def issues(project=nil, options={})
|
|
20
|
+
def issues(project = nil, options = {})
|
|
19
21
|
if project.to_s.empty? && project.to_i.zero?
|
|
20
|
-
get(
|
|
22
|
+
get('/issues', query: options)
|
|
21
23
|
else
|
|
22
24
|
get("/projects/#{url_encode project}/issues", query: options)
|
|
23
25
|
end
|
|
@@ -49,7 +51,7 @@ class Gitlab::Client
|
|
|
49
51
|
# @option options [Integer] :milestone_id The ID of a milestone to assign issue.
|
|
50
52
|
# @option options [String] :labels Comma-separated label names for an issue.
|
|
51
53
|
# @return [Gitlab::ObjectifiedHash] Information about created issue.
|
|
52
|
-
def create_issue(project, title, options={})
|
|
54
|
+
def create_issue(project, title, options = {})
|
|
53
55
|
body = { title: title }.merge(options)
|
|
54
56
|
post("/projects/#{url_encode project}/issues", body: body)
|
|
55
57
|
end
|
|
@@ -69,7 +71,7 @@ class Gitlab::Client
|
|
|
69
71
|
# @option options [String] :labels Comma-separated label names for an issue.
|
|
70
72
|
# @option options [String] :state_event The state event of an issue ('close' or 'reopen').
|
|
71
73
|
# @return [Gitlab::ObjectifiedHash] Information about updated issue.
|
|
72
|
-
def edit_issue(project, id, options={})
|
|
74
|
+
def edit_issue(project, id, options = {})
|
|
73
75
|
put("/projects/#{url_encode project}/issues/#{id}", body: options)
|
|
74
76
|
end
|
|
75
77
|
|
|
@@ -133,5 +135,97 @@ class Gitlab::Client
|
|
|
133
135
|
def delete_issue(project, id)
|
|
134
136
|
delete("/projects/#{url_encode project}/issues/#{id}")
|
|
135
137
|
end
|
|
138
|
+
|
|
139
|
+
# Move an issue.
|
|
140
|
+
#
|
|
141
|
+
# @example
|
|
142
|
+
# Gitlab.move_issue(3, 42, { to_project_id: '4' })
|
|
143
|
+
#
|
|
144
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
145
|
+
# @param [Integer] id The ID of an issue.
|
|
146
|
+
# @option options [String] :to_project_id The ID of the new project.
|
|
147
|
+
# @return [Gitlab::ObjectifiedHash] Information about moved issue.
|
|
148
|
+
def move_issue(project, id, options = {})
|
|
149
|
+
post("/projects/#{url_encode project}/issues/#{id}/move", body: options)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# Sets an estimated time of work for an issue.
|
|
153
|
+
#
|
|
154
|
+
# @example
|
|
155
|
+
# Gitlab.estimate_time_of_issue(3, 42, '3h30m')
|
|
156
|
+
#
|
|
157
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
158
|
+
# @param [Integer] id The ID of an issue.
|
|
159
|
+
# @param [String] duration The duration in human format. e.g: 3h30m
|
|
160
|
+
def estimate_time_of_issue(project, id, duration)
|
|
161
|
+
post("/projects/#{url_encode project}/issues/#{id}/time_estimate", body: { duration: url_encode(duration) })
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# Resets the estimated time for an issue to 0 seconds.
|
|
165
|
+
#
|
|
166
|
+
# @example
|
|
167
|
+
# Gitlab.reset_time_estimate_of_issue(3, 42)
|
|
168
|
+
#
|
|
169
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
170
|
+
# @param [Integer] id The ID of an issue.
|
|
171
|
+
def reset_time_estimate_of_issue(project, id)
|
|
172
|
+
post("/projects/#{url_encode project}/issues/#{id}/reset_time_estimate")
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
# Adds spent time for an issue
|
|
176
|
+
#
|
|
177
|
+
# @example
|
|
178
|
+
# Gitlab.estimate_time_of_issue(3, 42, '3h30m')
|
|
179
|
+
#
|
|
180
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
181
|
+
# @param [Integer] id The ID of an issue.
|
|
182
|
+
# @param [String] duration The time spent in human format. e.g: 3h30m
|
|
183
|
+
def add_time_spent_on_issue(project, id, duration)
|
|
184
|
+
post("/projects/#{url_encode project}/issues/#{id}/add_spent_time", body: { duration: duration })
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# Resets the total spent time for this issue to 0 seconds.
|
|
188
|
+
#
|
|
189
|
+
# @example
|
|
190
|
+
# Gitlab.reset_time_spent_on_issue(3, 42)
|
|
191
|
+
#
|
|
192
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
193
|
+
# @param [Integer] id The ID of an issue.
|
|
194
|
+
def reset_time_spent_on_issue(project, id)
|
|
195
|
+
post("/projects/#{url_encode project}/issues/#{id}/reset_spent_time")
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# Get time tracking stats for an issue
|
|
199
|
+
#
|
|
200
|
+
# @example
|
|
201
|
+
# @gitlab.time_stats_for_issue(3, 42)
|
|
202
|
+
#
|
|
203
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
204
|
+
# @param [Integer] id The ID of an issue.
|
|
205
|
+
def time_stats_for_issue(project, id)
|
|
206
|
+
get("/projects/#{url_encode project}/issues/#{id}/time_stats")
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# Get participants on issue
|
|
210
|
+
#
|
|
211
|
+
# @example
|
|
212
|
+
# @gitlab.participants_on_issue(3, 42)
|
|
213
|
+
#
|
|
214
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
215
|
+
# @param [Integer] id The ID of an issue.
|
|
216
|
+
def participants_on_issue(project, id)
|
|
217
|
+
get("/projects/#{url_encode project}/issues/#{id}/participants")
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# List merge requests that will close issue on merge
|
|
221
|
+
#
|
|
222
|
+
# @example
|
|
223
|
+
# Gitlab.merge_requests_closing_issue_on_merge(3, 42)
|
|
224
|
+
#
|
|
225
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
226
|
+
# @param [Integer] id The ID of an issue.
|
|
227
|
+
def merge_requests_closing_issue_on_merge(project, id)
|
|
228
|
+
get("/projects/#{url_encode project}/issues/#{id}/closed_by")
|
|
229
|
+
end
|
|
136
230
|
end
|
|
137
231
|
end
|
data/lib/gitlab/client/jobs.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class Gitlab::Client
|
|
2
4
|
# Defines methods related to projects.
|
|
3
5
|
# @see https://docs.gitlab.com/ee/api/jobs.html
|
|
@@ -7,10 +9,13 @@ class Gitlab::Client
|
|
|
7
9
|
# @example
|
|
8
10
|
# Gitlab.jobs(1)
|
|
9
11
|
# Gitlab.jobs("project")
|
|
12
|
+
# Gitlab.jobs("project", {scope: ["manual", "success"], per_page: 100 })
|
|
10
13
|
#
|
|
11
14
|
# @param [Integer, String] id The ID or name of a project.
|
|
12
15
|
# @param [Hash] options A customizable set of options.
|
|
13
16
|
# @option options [Array] :scope The scope of jobs to show, one or array of: created, pending, running, failed, success, canceled, skipped, manual; showing all jobs if none provided.
|
|
17
|
+
# @option options [Integer] :page The page number.
|
|
18
|
+
# @option options [Integer] :per_page The number of results per page.
|
|
14
19
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
15
20
|
def jobs(project_id, options = {})
|
|
16
21
|
get("/projects/#{url_encode project_id}/jobs", query: options)
|
|
@@ -31,6 +36,21 @@ class Gitlab::Client
|
|
|
31
36
|
get("/projects/#{url_encode project_id}/pipelines/#{pipeline_id}/jobs", query: options)
|
|
32
37
|
end
|
|
33
38
|
|
|
39
|
+
# Gets a list of Bridge Jobs from a pipeline
|
|
40
|
+
#
|
|
41
|
+
# @example
|
|
42
|
+
# Gitlab.pipeline_bridges(1, 2)
|
|
43
|
+
# Gitlab.pipeline_bridges("project", 2)
|
|
44
|
+
#
|
|
45
|
+
# @param [Integer, String] The ID or name of a project.
|
|
46
|
+
# @param [Integer] the id of the pipeline
|
|
47
|
+
# @param [Hash] options A customizable set of options.
|
|
48
|
+
# @option options [Array] :scope The scope of bridge jobs to show, one or array of: created, pending, running, failed, success, canceled, skipped, manual; showing all bridge jobs if none provided.
|
|
49
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
50
|
+
def pipeline_bridges(project_id, pipeline_id, options = {})
|
|
51
|
+
get("/projects/#{url_encode project_id}/pipelines/#{pipeline_id}/bridges", query: options)
|
|
52
|
+
end
|
|
53
|
+
|
|
34
54
|
# Gets a single job
|
|
35
55
|
#
|
|
36
56
|
# @example
|
|
@@ -65,16 +85,70 @@ class Gitlab::Client
|
|
|
65
85
|
# Gitlab.job_artifacts_download(1, "master", "release")
|
|
66
86
|
# Gitlab.job_artifacts_download("project", "master", "release")
|
|
67
87
|
#
|
|
68
|
-
# @param [Integer, String]
|
|
69
|
-
# @param [String] ref
|
|
70
|
-
# @param [String] job
|
|
71
|
-
# @return [
|
|
88
|
+
# @param [Integer, String] project_id The ID or name of a project.
|
|
89
|
+
# @param [String] ref Ref Name
|
|
90
|
+
# @param [String] job jobname
|
|
91
|
+
# @return [Gitlab::FileResponse]
|
|
72
92
|
def job_artifacts_download(project_id, ref_name, job_name)
|
|
73
|
-
get("/projects/#{url_encode project_id}/jobs/artifacts/#{ref_name}/download",
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
93
|
+
get("/projects/#{url_encode project_id}/jobs/artifacts/#{ref_name}/download",
|
|
94
|
+
query: { job: job_name },
|
|
95
|
+
format: nil,
|
|
96
|
+
headers: { Accept: 'application/octet-stream' },
|
|
97
|
+
parser: proc { |body, _|
|
|
98
|
+
if body.encoding == Encoding::ASCII_8BIT # binary response
|
|
99
|
+
::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
|
|
100
|
+
else # error with json response
|
|
101
|
+
::Gitlab::Request.parse(body)
|
|
102
|
+
end
|
|
103
|
+
})
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Download a single artifact file by job ID
|
|
107
|
+
#
|
|
108
|
+
# @example
|
|
109
|
+
# Gitlab.download_job_artifact_file(1, 5, "some/release/file.pdf")
|
|
110
|
+
#
|
|
111
|
+
# @param [Integer, String] project_id(required) The ID or name of a project.
|
|
112
|
+
# @param [String] job_id(required) The unique job identifier.
|
|
113
|
+
# @param [String] artifact_path(required) Path to a file inside the artifacts archive.
|
|
114
|
+
# @return [Gitlab::FileResponse]
|
|
115
|
+
def download_job_artifact_file(project_id, job_id, artifact_path)
|
|
116
|
+
get("/projects/#{url_encode project_id}/jobs/#{job_id}/artifacts/#{artifact_path}",
|
|
117
|
+
format: nil,
|
|
118
|
+
headers: { Accept: 'application/octet-stream' },
|
|
119
|
+
parser: proc { |body, _|
|
|
120
|
+
if body.encoding == Encoding::ASCII_8BIT # binary response
|
|
121
|
+
::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
|
|
122
|
+
else # error with json response
|
|
123
|
+
::Gitlab::Request.parse(body)
|
|
124
|
+
end
|
|
125
|
+
})
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Download a single artifact file from specific tag or branch
|
|
129
|
+
#
|
|
130
|
+
# @example
|
|
131
|
+
# Gitlab.download_branch_artifact_file(1, "master", "some/release/file.pdf", 'pdf')
|
|
132
|
+
#
|
|
133
|
+
# @param [Integer, String] project_id(required) The ID or name of a project.
|
|
134
|
+
# @param [String] ref_name(required) Branch or tag name in repository. HEAD or SHA references are not supported.
|
|
135
|
+
# @param [String] artifact_path(required) Path to a file inside the artifacts archive.
|
|
136
|
+
# @param [String] job(required) The name of the job.
|
|
137
|
+
# @return [Gitlab::FileResponse]
|
|
138
|
+
def download_branch_artifact_file(project_id, ref_name, artifact_path, job)
|
|
139
|
+
get("/projects/#{url_encode project_id}/jobs/artifacts/#{ref_name}/raw/#{artifact_path}",
|
|
140
|
+
query: { job: job },
|
|
141
|
+
format: nil,
|
|
142
|
+
headers: { Accept: 'application/octet-stream' },
|
|
143
|
+
parser: proc { |body, _|
|
|
144
|
+
if body.encoding == Encoding::ASCII_8BIT # binary response
|
|
145
|
+
::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
|
|
146
|
+
else # error with json response
|
|
147
|
+
::Gitlab::Request.parse(body)
|
|
148
|
+
end
|
|
149
|
+
})
|
|
77
150
|
end
|
|
151
|
+
alias download_tag_artifact_file download_branch_artifact_file
|
|
78
152
|
|
|
79
153
|
# Get Job Trace
|
|
80
154
|
#
|
|
@@ -158,5 +232,19 @@ class Gitlab::Client
|
|
|
158
232
|
def job_artifacts_keep(project_id, job_id)
|
|
159
233
|
post("/projects/#{url_encode project_id}/jobs/#{job_id}/artifacts/keep")
|
|
160
234
|
end
|
|
235
|
+
|
|
236
|
+
# Delete Artifacts
|
|
237
|
+
# Deletes the artifacts associated with a job.
|
|
238
|
+
#
|
|
239
|
+
# @example
|
|
240
|
+
# Gitlab.job_artifacts_delete(1,1)
|
|
241
|
+
# Gitlab.job_artifacts_delete("project", 1)
|
|
242
|
+
#
|
|
243
|
+
# @param [Integer, String] The ID or name of a project.
|
|
244
|
+
# @param [Integer] the id of the job
|
|
245
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
246
|
+
def job_artifacts_delete(project_id, job_id)
|
|
247
|
+
delete("/projects/#{url_encode project_id}/jobs/#{job_id}/artifacts")
|
|
248
|
+
end
|
|
161
249
|
end
|
|
162
250
|
end
|
data/lib/gitlab/client/keys.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class Gitlab::Client
|
|
2
4
|
# Defines methods related to keys.
|
|
3
5
|
# @see https://docs.gitlab.com/ce/api/keys.html
|
|
@@ -12,5 +14,16 @@ class Gitlab::Client
|
|
|
12
14
|
def key(id)
|
|
13
15
|
get("/keys/#{id}")
|
|
14
16
|
end
|
|
17
|
+
|
|
18
|
+
# Gets information about a key by key fingerprint.
|
|
19
|
+
#
|
|
20
|
+
# @example
|
|
21
|
+
# Gitlab.key_by_fingerprint("9f:70:33:b3:50:4d:9a:a3:ef:ea:13:9b:87:0f:7f:7e")
|
|
22
|
+
#
|
|
23
|
+
# @param [String] fingerprint The Fingerprint of a key.
|
|
24
|
+
# @return [Gitlab::ObjectifiedHash]
|
|
25
|
+
def key_by_fingerprint(fingerprint)
|
|
26
|
+
get('/keys', query: { fingerprint: fingerprint })
|
|
27
|
+
end
|
|
15
28
|
end
|
|
16
29
|
end
|
data/lib/gitlab/client/labels.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class Gitlab::Client
|
|
2
|
-
# Defines methods related to labels.
|
|
4
|
+
# Defines methods related to project labels.
|
|
3
5
|
# @see https://docs.gitlab.com/ce/api/labels.html
|
|
4
6
|
module Labels
|
|
5
7
|
# Gets a list of project's labels.
|
|
@@ -9,8 +11,8 @@ class Gitlab::Client
|
|
|
9
11
|
#
|
|
10
12
|
# @param [Integer, String] project The ID or name of a project.
|
|
11
13
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
12
|
-
def labels(project)
|
|
13
|
-
get("/projects/#{url_encode project}/labels")
|
|
14
|
+
def labels(project, options = {})
|
|
15
|
+
get("/projects/#{url_encode project}/labels", query: options)
|
|
14
16
|
end
|
|
15
17
|
|
|
16
18
|
# Creates a new label.
|
|
@@ -43,7 +45,7 @@ class Gitlab::Client
|
|
|
43
45
|
# @option options [String] :description The description of the label.
|
|
44
46
|
# @option options [String] :priority The priority of the label. Must be greater or equal than zero or null to remove the priority.
|
|
45
47
|
# @return [Gitlab::ObjectifiedHash] Information about updated label.
|
|
46
|
-
def edit_label(project, name, options={})
|
|
48
|
+
def edit_label(project, name, options = {})
|
|
47
49
|
put("/projects/#{url_encode project}/labels", body: options.merge(name: name))
|
|
48
50
|
end
|
|
49
51
|
|
|
@@ -56,7 +58,7 @@ class Gitlab::Client
|
|
|
56
58
|
# @param [String] name The name of a label.
|
|
57
59
|
# @return [Gitlab::ObjectifiedHash] Information about deleted label.
|
|
58
60
|
def delete_label(project, name)
|
|
59
|
-
delete("/projects/#{url_encode project}/labels
|
|
61
|
+
delete("/projects/#{url_encode project}/labels/#{name}")
|
|
60
62
|
end
|
|
61
63
|
|
|
62
64
|
# Subscribes the user to a label to receive notifications
|