gitlab 3.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/.travis.yml +6 -2
- data/CHANGELOG.md +244 -0
- data/CONTRIBUTING.md +195 -0
- data/LICENSE.txt +1 -1
- data/README.md +122 -10
- data/Rakefile +1 -1
- data/bin/console +10 -0
- data/bin/setup +6 -0
- data/exe/gitlab +7 -0
- data/gitlab.gemspec +9 -3
- data/lib/gitlab.rb +18 -2
- data/lib/gitlab/api.rb +6 -4
- data/lib/gitlab/cli.rb +89 -0
- data/lib/gitlab/cli_helpers.rb +241 -0
- data/lib/gitlab/client.rb +42 -6
- data/lib/gitlab/client/branches.rb +91 -0
- data/lib/gitlab/client/build_triggers.rb +51 -0
- data/lib/gitlab/client/build_variables.rb +66 -0
- data/lib/gitlab/client/builds.rb +106 -0
- data/lib/gitlab/client/commits.rb +146 -0
- data/lib/gitlab/client/groups.rb +66 -10
- data/lib/gitlab/client/issues.rb +61 -16
- data/lib/gitlab/client/labels.rb +57 -0
- data/lib/gitlab/client/merge_requests.rb +137 -26
- data/lib/gitlab/client/milestones.rb +44 -9
- data/lib/gitlab/client/namespaces.rb +20 -0
- data/lib/gitlab/client/notes.rb +71 -16
- data/lib/gitlab/client/pipelines.rb +68 -0
- data/lib/gitlab/client/projects.rb +236 -27
- data/lib/gitlab/client/repositories.rb +39 -45
- data/lib/gitlab/client/repository_files.rb +107 -0
- data/lib/gitlab/client/runners.rb +115 -0
- data/lib/gitlab/client/services.rb +50 -0
- data/lib/gitlab/client/snippets.rb +26 -21
- data/lib/gitlab/client/system_hooks.rb +59 -0
- data/lib/gitlab/client/tags.rb +96 -0
- data/lib/gitlab/client/users.rb +151 -7
- data/lib/gitlab/configuration.rb +20 -4
- data/lib/gitlab/error.rb +55 -12
- data/lib/gitlab/file_response.rb +46 -0
- data/lib/gitlab/help.rb +95 -0
- data/lib/gitlab/objectified_hash.rb +19 -3
- data/lib/gitlab/page_links.rb +33 -0
- data/lib/gitlab/paginated_response.rb +97 -0
- data/lib/gitlab/request.rb +65 -33
- data/lib/gitlab/shell.rb +84 -0
- data/lib/gitlab/shell_history.rb +59 -0
- data/lib/gitlab/version.rb +1 -1
- data/spec/fixtures/{project_branch.json → branch.json} +1 -1
- data/spec/fixtures/branch_delete.json +3 -0
- data/spec/fixtures/{project_branches.json → branches.json} +0 -0
- data/spec/fixtures/build.json +38 -0
- data/spec/fixtures/build_artifacts.json +0 -0
- data/spec/fixtures/build_cancel.json +24 -0
- data/spec/fixtures/build_erase.json +24 -0
- data/spec/fixtures/build_retry.json +24 -0
- data/spec/fixtures/builds.json +78 -0
- data/spec/fixtures/builds_commits.json +64 -0
- data/spec/fixtures/compare_merge_request_diff.json +31 -0
- data/spec/fixtures/error_project_not_found.json +1 -0
- data/spec/fixtures/get_repository_file.json +1 -0
- data/spec/fixtures/group_create_with_description.json +1 -0
- data/spec/fixtures/group_delete.json +1 -0
- data/spec/fixtures/group_member_edit.json +1 -0
- data/spec/fixtures/group_projects.json +44 -0
- data/spec/fixtures/group_search.json +2 -0
- data/spec/fixtures/label.json +1 -0
- data/spec/fixtures/labels.json +1 -0
- data/spec/fixtures/merge_request_changes.json +1 -0
- data/spec/fixtures/merge_request_closes_issues.json +1 -0
- data/spec/fixtures/{comment_merge_request.json → merge_request_comment.json} +0 -0
- data/spec/fixtures/merge_request_comments.json +1 -0
- data/spec/fixtures/merge_request_commits.json +1 -0
- data/spec/fixtures/milestone_issues.json +1 -0
- data/spec/fixtures/milestone_merge_requests.json +1 -0
- data/spec/fixtures/namespaces.json +1 -0
- data/spec/fixtures/pipeline.json +23 -0
- data/spec/fixtures/pipeline_cancel.json +23 -0
- data/spec/fixtures/pipeline_create.json +23 -0
- data/spec/fixtures/pipeline_retry.json +23 -0
- data/spec/fixtures/pipelines.json +48 -0
- data/spec/fixtures/project_commit.json +13 -0
- data/spec/fixtures/project_commit_comment.json +1 -0
- data/spec/fixtures/project_commit_comments.json +1 -0
- data/spec/fixtures/project_commit_create.json +22 -0
- data/spec/fixtures/project_commit_diff.json +10 -0
- data/spec/fixtures/project_commit_status.json +42 -0
- data/spec/fixtures/project_edit.json +21 -0
- data/spec/fixtures/project_events.json +1 -0
- data/spec/fixtures/project_fork.json +50 -0
- data/spec/fixtures/project_forked_for_user.json +50 -0
- data/spec/fixtures/project_runner_enable.json +7 -0
- data/spec/fixtures/project_runners.json +16 -0
- data/spec/fixtures/project_search.json +1 -0
- data/spec/fixtures/project_star.json +44 -0
- data/spec/fixtures/project_tag_annotated.json +1 -0
- data/spec/fixtures/project_tag_lightweight.json +1 -0
- data/spec/fixtures/project_unstar.json +44 -0
- data/spec/fixtures/project_update_commit_status.json +20 -0
- data/spec/fixtures/push_rule.json +1 -0
- data/spec/fixtures/raw_file.json +2 -0
- data/spec/fixtures/release_create.json +1 -0
- data/spec/fixtures/release_update.json +1 -0
- data/spec/fixtures/repository_file.json +1 -0
- data/spec/fixtures/runner.json +26 -0
- data/spec/fixtures/runner_delete.json +7 -0
- data/spec/fixtures/runner_edit.json +26 -0
- data/spec/fixtures/runners.json +16 -0
- data/spec/fixtures/runners_all.json +30 -0
- data/spec/fixtures/service.json +1 -0
- data/spec/fixtures/shell_history.json +2 -0
- data/spec/fixtures/snippet_content.json +3 -0
- data/spec/fixtures/system_hook.json +1 -0
- data/spec/fixtures/system_hooks.json +1 -0
- data/spec/fixtures/tag.json +1 -0
- data/spec/fixtures/tag_create.json +1 -0
- data/spec/fixtures/tag_create_with_description.json +1 -0
- data/spec/fixtures/tag_delete.json +1 -0
- data/spec/fixtures/tags.json +1 -0
- data/spec/fixtures/tree.json +1 -0
- data/spec/fixtures/trigger.json +7 -0
- data/spec/fixtures/triggers.json +16 -0
- data/spec/fixtures/user.json +1 -1
- data/spec/fixtures/user_block_unblock.json +1 -0
- data/spec/fixtures/user_email.json +1 -0
- data/spec/fixtures/user_emails.json +1 -0
- data/spec/fixtures/user_search.json +1 -0
- data/spec/fixtures/users.json +1 -1
- data/spec/fixtures/variable.json +4 -0
- data/spec/fixtures/variables.json +10 -0
- data/spec/gitlab/cli_helpers_spec.rb +57 -0
- data/spec/gitlab/cli_spec.rb +119 -0
- data/spec/gitlab/client/branches_spec.rb +99 -0
- data/spec/gitlab/client/build_triggers_spec.rb +67 -0
- data/spec/gitlab/client/build_variables_spec.rb +86 -0
- data/spec/gitlab/client/builds_spec.rb +148 -0
- data/spec/gitlab/client/client_spec.rb +11 -0
- data/spec/gitlab/client/commits_spec.rb +168 -0
- data/spec/gitlab/client/groups_spec.rb +116 -30
- data/spec/gitlab/client/issues_spec.rb +93 -29
- data/spec/gitlab/client/labels_spec.rb +68 -0
- data/spec/gitlab/client/merge_requests_spec.rb +171 -39
- data/spec/gitlab/client/milestones_spec.rb +45 -13
- data/spec/gitlab/client/namespaces_spec.rb +22 -0
- data/spec/gitlab/client/notes_spec.rb +82 -33
- data/spec/gitlab/client/pipelines_spec.rb +95 -0
- data/spec/gitlab/client/projects_spec.rb +371 -71
- data/spec/gitlab/client/repositories_spec.rb +51 -30
- data/spec/gitlab/client/repository_files_spec.rb +77 -0
- data/spec/gitlab/client/runners_spec.rb +185 -0
- data/spec/gitlab/client/services_spec.rb +55 -0
- data/spec/gitlab/client/snippets_spec.rb +35 -20
- data/spec/gitlab/client/system_hooks_spec.rb +69 -0
- data/spec/gitlab/client/tags_spec.rb +109 -0
- data/spec/gitlab/client/users_spec.rb +296 -34
- data/spec/gitlab/error_spec.rb +45 -0
- data/spec/gitlab/file_response_spec.rb +33 -0
- data/spec/gitlab/help_spec.rb +46 -0
- data/spec/gitlab/objectified_hash_spec.rb +48 -0
- data/spec/gitlab/page_links_spec.rb +16 -0
- data/spec/gitlab/paginated_response_spec.rb +60 -0
- data/spec/gitlab/request_spec.rb +73 -0
- data/spec/gitlab/shell_history_spec.rb +53 -0
- data/spec/gitlab/shell_spec.rb +80 -0
- data/spec/gitlab_spec.rb +48 -7
- data/spec/spec_helper.rb +24 -13
- metadata +287 -33
- data/spec/fixtures/create_merge_request.json +0 -1
- data/spec/fixtures/project_delete_key.json +0 -8
- data/spec/fixtures/update_merge_request.json +0 -1
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
class Gitlab::Client
|
|
2
2
|
# Defines methods related to milestones.
|
|
3
|
+
# @see https://docs.gitlab.com/ce/api/milestones.html
|
|
3
4
|
module Milestones
|
|
4
5
|
# Gets a list of project's milestones.
|
|
5
6
|
#
|
|
6
7
|
# @example
|
|
7
8
|
# Gitlab.milestones(5)
|
|
8
9
|
#
|
|
9
|
-
# @param [Integer] project The ID of a project.
|
|
10
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
10
11
|
# @param [Hash] options A customizable set of options.
|
|
11
12
|
# @option options [Integer] :page The page number.
|
|
12
13
|
# @option options [Integer] :per_page The number of results per page.
|
|
13
14
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
14
15
|
def milestones(project, options={})
|
|
15
|
-
get("/projects/#{project}/milestones", :
|
|
16
|
+
get("/projects/#{url_encode project}/milestones", query: options)
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
# Gets a single milestone.
|
|
@@ -20,29 +21,63 @@ class Gitlab::Client
|
|
|
20
21
|
# @example
|
|
21
22
|
# Gitlab.milestone(5, 36)
|
|
22
23
|
#
|
|
23
|
-
# @param [Integer, String] project The ID of a project.
|
|
24
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
24
25
|
# @param [Integer] id The ID of a milestone.
|
|
25
26
|
# @return [Gitlab::ObjectifiedHash]
|
|
26
27
|
def milestone(project, id)
|
|
27
|
-
get("/projects/#{project}/milestones/#{id}")
|
|
28
|
+
get("/projects/#{url_encode project}/milestones/#{id}")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Gets the issues of a given milestone.
|
|
32
|
+
#
|
|
33
|
+
# @example
|
|
34
|
+
# Gitlab.milestone_issues(5, 2)
|
|
35
|
+
#
|
|
36
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
37
|
+
# @param [Integer, String] milestone The ID of a milestone.
|
|
38
|
+
# @option options [Integer] :page The page number.
|
|
39
|
+
# @option options [Integer] :per_page The number of results per page.
|
|
40
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
41
|
+
def milestone_issues(project, milestone, options={})
|
|
42
|
+
get("/projects/#{url_encode project}/milestones/#{milestone}/issues", query: options)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Gets the merge_requests of a given milestone.
|
|
46
|
+
#
|
|
47
|
+
# @example
|
|
48
|
+
# Gitlab.milestone_merge_requests(5, 2)
|
|
49
|
+
#
|
|
50
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
51
|
+
# @param [Integer, String] milestone The ID of a milestone.
|
|
52
|
+
# @option options [Integer] :page The page number.
|
|
53
|
+
# @option options [Integer] :per_page The number of results per page.
|
|
54
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
55
|
+
def milestone_merge_requests(project, milestone, options={})
|
|
56
|
+
get("/projects/#{url_encode project}/milestones/#{milestone}/merge_requests", query: options)
|
|
28
57
|
end
|
|
29
58
|
|
|
30
59
|
# Creates a new milestone.
|
|
31
60
|
#
|
|
32
|
-
# @
|
|
61
|
+
# @example
|
|
62
|
+
# Gitlab.create_milestone(5, 'v1.0')
|
|
63
|
+
#
|
|
64
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
33
65
|
# @param [String] title The title of a milestone.
|
|
34
66
|
# @param [Hash] options A customizable set of options.
|
|
35
67
|
# @option options [String] :description The description of a milestone.
|
|
36
68
|
# @option options [String] :due_date The due date of a milestone.
|
|
37
69
|
# @return [Gitlab::ObjectifiedHash] Information about created milestone.
|
|
38
70
|
def create_milestone(project, title, options={})
|
|
39
|
-
body = {:title
|
|
40
|
-
post("/projects/#{project}/milestones", :
|
|
71
|
+
body = { title: title }.merge(options)
|
|
72
|
+
post("/projects/#{url_encode project}/milestones", body: body)
|
|
41
73
|
end
|
|
42
74
|
|
|
43
75
|
# Updates a milestone.
|
|
44
76
|
#
|
|
45
|
-
# @
|
|
77
|
+
# @example
|
|
78
|
+
# Gitlab.edit_milestone(5, 2, { state_event: 'activate' })
|
|
79
|
+
#
|
|
80
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
46
81
|
# @param [Integer] id The ID of a milestone.
|
|
47
82
|
# @param [Hash] options A customizable set of options.
|
|
48
83
|
# @option options [String] :title The title of a milestone.
|
|
@@ -51,7 +86,7 @@ class Gitlab::Client
|
|
|
51
86
|
# @option options [String] :state_event The state of a milestone ('close' or 'activate').
|
|
52
87
|
# @return [Gitlab::ObjectifiedHash] Information about updated milestone.
|
|
53
88
|
def edit_milestone(project, id, options={})
|
|
54
|
-
put("/projects/#{project}/milestones/#{id}", :
|
|
89
|
+
put("/projects/#{url_encode project}/milestones/#{id}", body: options)
|
|
55
90
|
end
|
|
56
91
|
end
|
|
57
92
|
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
class Gitlab::Client
|
|
2
|
+
# Defines methods related to namespaces
|
|
3
|
+
# @see https://docs.gitlab.com/ce/api/namespaces.html
|
|
4
|
+
module Namespaces
|
|
5
|
+
# Gets a list of namespaces.
|
|
6
|
+
# @see https://docs.gitlab.com/ce/api/namespaces.html#list-namespaces
|
|
7
|
+
#
|
|
8
|
+
# @example
|
|
9
|
+
# Gitlab.namespaces
|
|
10
|
+
#
|
|
11
|
+
# @param [Hash] options A customizable set of options.
|
|
12
|
+
# @options options [Integer] :page The page number.
|
|
13
|
+
# @options options [Integer] :per_page The number of results per page.
|
|
14
|
+
# @options opttion [String] :search The string to search for.
|
|
15
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
16
|
+
def namespaces(options={})
|
|
17
|
+
get("/namespaces", query: options)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
data/lib/gitlab/client/notes.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
class Gitlab::Client
|
|
2
2
|
# Defines methods related to notes.
|
|
3
|
+
# @see https://docs.gitlab.com/ce/api/notes.html
|
|
3
4
|
module Notes
|
|
4
5
|
# Gets a list of projects notes.
|
|
5
6
|
#
|
|
@@ -7,9 +8,11 @@ class Gitlab::Client
|
|
|
7
8
|
# Gitlab.notes(5)
|
|
8
9
|
#
|
|
9
10
|
# @param [Integer] project The ID of a project.
|
|
11
|
+
# @option options [Integer] :page The page number.
|
|
12
|
+
# @option options [Integer] :per_page The number of results per page.
|
|
10
13
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
11
|
-
def notes(project)
|
|
12
|
-
get("/projects/#{project}/notes")
|
|
14
|
+
def notes(project, options={})
|
|
15
|
+
get("/projects/#{url_encode project}/notes", query: options)
|
|
13
16
|
end
|
|
14
17
|
|
|
15
18
|
# Gets a list of notes for a issue.
|
|
@@ -19,9 +22,11 @@ class Gitlab::Client
|
|
|
19
22
|
#
|
|
20
23
|
# @param [Integer] project The ID of a project.
|
|
21
24
|
# @param [Integer] issue The ID of an issue.
|
|
25
|
+
# @option options [Integer] :page The page number.
|
|
26
|
+
# @option options [Integer] :per_page The number of results per page.
|
|
22
27
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
23
|
-
def issue_notes(project, issue)
|
|
24
|
-
get("/projects/#{project}/issues/#{issue}/notes")
|
|
28
|
+
def issue_notes(project, issue, options={})
|
|
29
|
+
get("/projects/#{url_encode project}/issues/#{issue}/notes", query: options)
|
|
25
30
|
end
|
|
26
31
|
|
|
27
32
|
# Gets a list of notes for a snippet.
|
|
@@ -31,9 +36,25 @@ class Gitlab::Client
|
|
|
31
36
|
#
|
|
32
37
|
# @param [Integer] project The ID of a project.
|
|
33
38
|
# @param [Integer] snippet The ID of a snippet.
|
|
39
|
+
# @option options [Integer] :page The page number.
|
|
40
|
+
# @option options [Integer] :per_page The number of results per page.
|
|
34
41
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
35
|
-
def snippet_notes(project, snippet)
|
|
36
|
-
get("/projects/#{project}/snippets/#{snippet}/notes")
|
|
42
|
+
def snippet_notes(project, snippet, options={})
|
|
43
|
+
get("/projects/#{url_encode project}/snippets/#{snippet}/notes", query: options)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Gets a list of notes for a merge request.
|
|
47
|
+
#
|
|
48
|
+
# @example
|
|
49
|
+
# Gitlab.merge_request_notes(5, 1)
|
|
50
|
+
#
|
|
51
|
+
# @param [Integer] project The ID of a project.
|
|
52
|
+
# @param [Integer] merge_request The ID of a merge request.
|
|
53
|
+
# @option options [Integer] :page The page number.
|
|
54
|
+
# @option options [Integer] :per_page The number of results per page.
|
|
55
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
56
|
+
def merge_request_notes(project, merge_request, options={})
|
|
57
|
+
get("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes", query: options)
|
|
37
58
|
end
|
|
38
59
|
|
|
39
60
|
# Gets a single wall note.
|
|
@@ -45,7 +66,7 @@ class Gitlab::Client
|
|
|
45
66
|
# @param [Integer] id The ID of a note.
|
|
46
67
|
# @return [Gitlab::ObjectifiedHash]
|
|
47
68
|
def note(project, id)
|
|
48
|
-
get("/projects/#{project}/notes/#{id}")
|
|
69
|
+
get("/projects/#{url_encode project}/notes/#{id}")
|
|
49
70
|
end
|
|
50
71
|
|
|
51
72
|
# Gets a single issue note.
|
|
@@ -58,7 +79,7 @@ class Gitlab::Client
|
|
|
58
79
|
# @param [Integer] id The ID of a note.
|
|
59
80
|
# @return [Gitlab::ObjectifiedHash]
|
|
60
81
|
def issue_note(project, issue, id)
|
|
61
|
-
get("/projects/#{project}/issues/#{issue}/notes/#{id}")
|
|
82
|
+
get("/projects/#{url_encode project}/issues/#{issue}/notes/#{id}")
|
|
62
83
|
end
|
|
63
84
|
|
|
64
85
|
# Gets a single snippet note.
|
|
@@ -68,39 +89,73 @@ class Gitlab::Client
|
|
|
68
89
|
#
|
|
69
90
|
# @param [Integer] project The ID of a project.
|
|
70
91
|
# @param [Integer] snippet The ID of a snippet.
|
|
71
|
-
# @param [Integer] id The ID of
|
|
92
|
+
# @param [Integer] id The ID of a note.
|
|
72
93
|
# @return [Gitlab::ObjectifiedHash]
|
|
73
94
|
def snippet_note(project, snippet, id)
|
|
74
|
-
get("/projects/#{project}/snippets/#{snippet}/notes/#{id}")
|
|
95
|
+
get("/projects/#{url_encode project}/snippets/#{snippet}/notes/#{id}")
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Gets a single merge_request note.
|
|
99
|
+
#
|
|
100
|
+
# @example
|
|
101
|
+
# Gitlab.merge_request_note(5, 11, 3)
|
|
102
|
+
#
|
|
103
|
+
# @param [Integer] project The ID of a project.
|
|
104
|
+
# @param [Integer] merge_request The ID of a merge_request.
|
|
105
|
+
# @param [Integer] id The ID of a note.
|
|
106
|
+
# @return [Gitlab::ObjectifiedHash]
|
|
107
|
+
def merge_request_note(project, merge_request, id)
|
|
108
|
+
get("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes/#{id}")
|
|
75
109
|
end
|
|
76
110
|
|
|
77
111
|
# Creates a new wall note.
|
|
78
112
|
#
|
|
79
|
-
# @
|
|
113
|
+
# @example
|
|
114
|
+
# Gitlab.create_note(5, 'This is a wall note!')
|
|
115
|
+
#
|
|
116
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
80
117
|
# @param [String] body The body of a note.
|
|
81
118
|
# @return [Gitlab::ObjectifiedHash] Information about created note.
|
|
82
119
|
def create_note(project, body)
|
|
83
|
-
post("/projects/#{project}/notes", :
|
|
120
|
+
post("/projects/#{url_encode project}/notes", body: { body: body })
|
|
84
121
|
end
|
|
85
122
|
|
|
86
123
|
# Creates a new issue note.
|
|
87
124
|
#
|
|
88
|
-
# @
|
|
125
|
+
# @example
|
|
126
|
+
# Gitlab.create_issue_note(6, 1, 'Adding a note to my issue.')
|
|
127
|
+
#
|
|
128
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
89
129
|
# @param [Integer] issue The ID of an issue.
|
|
90
130
|
# @param [String] body The body of a note.
|
|
91
131
|
# @return [Gitlab::ObjectifiedHash] Information about created note.
|
|
92
132
|
def create_issue_note(project, issue, body)
|
|
93
|
-
post("/projects/#{project}/issues/#{issue}/notes", :
|
|
133
|
+
post("/projects/#{url_encode project}/issues/#{issue}/notes", body: { body: body })
|
|
94
134
|
end
|
|
95
135
|
|
|
96
136
|
# Creates a new snippet note.
|
|
97
137
|
#
|
|
98
|
-
# @
|
|
138
|
+
# @example
|
|
139
|
+
# Gitlab.create_snippet_note(3, 2, 'Look at this awesome snippet!')
|
|
140
|
+
#
|
|
141
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
99
142
|
# @param [Integer] snippet The ID of a snippet.
|
|
100
143
|
# @param [String] body The body of a note.
|
|
101
144
|
# @return [Gitlab::ObjectifiedHash] Information about created note.
|
|
102
145
|
def create_snippet_note(project, snippet, body)
|
|
103
|
-
post("/projects/#{project}/snippets/#{snippet}/notes", :
|
|
146
|
+
post("/projects/#{url_encode project}/snippets/#{snippet}/notes", body: { body: body })
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# Creates a new note for a single merge request.
|
|
150
|
+
#
|
|
151
|
+
# @example
|
|
152
|
+
# Gitlab.create_merge_request_note(5, 3, 'This MR is ready for review.')
|
|
153
|
+
#
|
|
154
|
+
# @param [Integer] project The ID of a project.
|
|
155
|
+
# @param [Integer] merge_request The ID of a merge request.
|
|
156
|
+
# @param [String] body The content of a note.
|
|
157
|
+
def create_merge_request_note(project, merge_request, body)
|
|
158
|
+
post("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes", body: { body: body })
|
|
104
159
|
end
|
|
105
160
|
end
|
|
106
161
|
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
class Gitlab::Client
|
|
2
|
+
# Defines methods related to pipelines.
|
|
3
|
+
# @see https://docs.gitlab.com/ce/api/pipelines.html
|
|
4
|
+
module Pipelines
|
|
5
|
+
# Gets a list of project pipelines.
|
|
6
|
+
#
|
|
7
|
+
# @example
|
|
8
|
+
# Gitlab.pipelines(5)
|
|
9
|
+
# Gitlab.pipelines(5, { per_page: 10, page: 2 })
|
|
10
|
+
#
|
|
11
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
12
|
+
# @param [Hash] options A customizable set of options.
|
|
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 pipelines(project, options={})
|
|
17
|
+
get("/projects/#{url_encode project}/pipelines", query: options)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Gets a single pipeline.
|
|
21
|
+
#
|
|
22
|
+
# @example
|
|
23
|
+
# Gitlab.pipeline(5, 36)
|
|
24
|
+
#
|
|
25
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
26
|
+
# @param [Integer] id The ID of a pipeline.
|
|
27
|
+
# @return [Gitlab::ObjectifiedHash]
|
|
28
|
+
def pipeline(project, id)
|
|
29
|
+
get("/projects/#{url_encode project}/pipelines/#{id}")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Create a pipeline.
|
|
33
|
+
#
|
|
34
|
+
# @example
|
|
35
|
+
# Gitlab.create_pipeline(5, 'master')
|
|
36
|
+
#
|
|
37
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
38
|
+
# @param [String] ref Reference to commit.
|
|
39
|
+
# @return [Gitlab::ObjectifiedHash] The pipelines changes.
|
|
40
|
+
def create_pipeline(project, ref)
|
|
41
|
+
post("/projects/#{url_encode project}/pipeline?ref=#{ref}")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Cancels a pipeline.
|
|
45
|
+
#
|
|
46
|
+
# @example
|
|
47
|
+
# Gitlab.cancel_pipeline(5, 1)
|
|
48
|
+
#
|
|
49
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
50
|
+
# @param [Integer] id The ID of a pipeline.
|
|
51
|
+
# @return [Gitlab::ObjectifiedHash] The pipelines changes.
|
|
52
|
+
def cancel_pipeline(project, id)
|
|
53
|
+
post("/projects/#{url_encode project}/pipelines/#{id}/cancel")
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Retry a pipeline.
|
|
57
|
+
#
|
|
58
|
+
# @example
|
|
59
|
+
# Gitlab.retry_pipeline(5, 1)
|
|
60
|
+
#
|
|
61
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
62
|
+
# @param [Integer] id The ID of a pipeline.
|
|
63
|
+
# @return [Array<Gitlab::ObjectifiedHash>] The pipelines changes.
|
|
64
|
+
def retry_pipeline(project, id)
|
|
65
|
+
post("/projects/#{url_encode project}/pipelines/#{id}/retry")
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
class Gitlab::Client
|
|
2
2
|
# Defines methods related to projects.
|
|
3
|
+
# @see https://docs.gitlab.com/ce/api/projects.html
|
|
3
4
|
module Projects
|
|
4
5
|
# Gets a list of projects owned by the authenticated user.
|
|
5
6
|
#
|
|
@@ -9,11 +10,34 @@ class Gitlab::Client
|
|
|
9
10
|
# @param [Hash] options A customizable set of options.
|
|
10
11
|
# @option options [Integer] :page The page number.
|
|
11
12
|
# @option options [Integer] :per_page The number of results per page.
|
|
13
|
+
# @option options [String] :scope Scope of projects. 'owned' for list of projects owned by the authenticated user, 'all' to get all projects (admin only)
|
|
12
14
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
13
15
|
def projects(options={})
|
|
14
|
-
|
|
16
|
+
if options[:scope]
|
|
17
|
+
get("/projects/#{options[:scope]}", query: options)
|
|
18
|
+
else
|
|
19
|
+
get("/projects", query: options)
|
|
20
|
+
end
|
|
15
21
|
end
|
|
16
22
|
|
|
23
|
+
# Search for projects by name.
|
|
24
|
+
#
|
|
25
|
+
# @example
|
|
26
|
+
# Gitlab.project_search('gitlab')
|
|
27
|
+
# Gitlab.project_search('gitlab', { order_by: 'last_activity_at' })
|
|
28
|
+
# Gitlab.search_projects('gitlab', { order_by: 'name', sort: 'asc' })
|
|
29
|
+
#
|
|
30
|
+
# @param [Hash] options A customizable set of options.
|
|
31
|
+
# @option options [String] :per_page Number of projects to return per page
|
|
32
|
+
# @option options [String] :page The page to retrieve
|
|
33
|
+
# @option options [String] :order_by Return requests ordered by id, name, created_at or last_activity_at fields
|
|
34
|
+
# @option options [String] :sort Return requests sorted in asc or desc order
|
|
35
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
36
|
+
def project_search(query, options={})
|
|
37
|
+
get("/projects/search/#{query}", query: options)
|
|
38
|
+
end
|
|
39
|
+
alias_method :search_projects, :project_search
|
|
40
|
+
|
|
17
41
|
# Gets information about a project.
|
|
18
42
|
#
|
|
19
43
|
# @example
|
|
@@ -23,20 +47,36 @@ class Gitlab::Client
|
|
|
23
47
|
# @param [Integer, String] id The ID or name of a project.
|
|
24
48
|
# @return [Gitlab::ObjectifiedHash]
|
|
25
49
|
def project(id)
|
|
26
|
-
get("/projects/#{id}")
|
|
50
|
+
get("/projects/#{url_encode id}")
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Gets a list of project events.
|
|
54
|
+
#
|
|
55
|
+
# @example
|
|
56
|
+
# Gitlab.project_events(42)
|
|
57
|
+
# Gitlab.project_events('gitlab')
|
|
58
|
+
#
|
|
59
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
60
|
+
# @param [Hash] options A customizable set of options.
|
|
61
|
+
# @option options [Integer] :page The page number.
|
|
62
|
+
# @option options [Integer] :per_page The number of results per page.
|
|
63
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
64
|
+
def project_events(project, options={})
|
|
65
|
+
get("/projects/#{url_encode project}/events", query: options)
|
|
27
66
|
end
|
|
28
67
|
|
|
29
68
|
# Creates a new project.
|
|
30
69
|
#
|
|
31
70
|
# @example
|
|
32
71
|
# Gitlab.create_project('gitlab')
|
|
33
|
-
# Gitlab.create_project('viking', :
|
|
34
|
-
# Gitlab.create_project('Red', :
|
|
72
|
+
# Gitlab.create_project('viking', { description: 'Awesome project' })
|
|
73
|
+
# Gitlab.create_project('Red', { wall_enabled: false })
|
|
35
74
|
#
|
|
36
75
|
# @param [String] name The name of a project.
|
|
37
76
|
# @param [Hash] options A customizable set of options.
|
|
38
77
|
# @option options [String] :description The description of a project.
|
|
39
78
|
# @option options [String] :default_branch The default branch of a project.
|
|
79
|
+
# @option options [String] :namespace_id The namespace in which to create a project.
|
|
40
80
|
# @option options [Boolean] :wiki_enabled The wiki integration for a project (0 = false, 1 = true).
|
|
41
81
|
# @option options [Boolean] :wall_enabled The wall functionality for a project (0 = false, 1 = true).
|
|
42
82
|
# @option options [Boolean] :issues_enabled The issues integration for a project (0 = false, 1 = true).
|
|
@@ -47,7 +87,18 @@ class Gitlab::Client
|
|
|
47
87
|
# @return [Gitlab::ObjectifiedHash] Information about created project.
|
|
48
88
|
def create_project(name, options={})
|
|
49
89
|
url = options[:user_id] ? "/projects/user/#{options[:user_id]}" : "/projects"
|
|
50
|
-
post(url, :
|
|
90
|
+
post(url, body: { name: name }.merge(options))
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Deletes a project.
|
|
94
|
+
#
|
|
95
|
+
# @example
|
|
96
|
+
# Gitlab.delete_project(4)
|
|
97
|
+
#
|
|
98
|
+
# @param [Integer, String] id The ID or name of a project.
|
|
99
|
+
# @return [Gitlab::ObjectifiedHash] Information about deleted project.
|
|
100
|
+
def delete_project(id)
|
|
101
|
+
delete("/projects/#{id}")
|
|
51
102
|
end
|
|
52
103
|
|
|
53
104
|
# Gets a list of project team members.
|
|
@@ -63,7 +114,7 @@ class Gitlab::Client
|
|
|
63
114
|
# @option options [Integer] :per_page The number of results per page.
|
|
64
115
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
65
116
|
def team_members(project, options={})
|
|
66
|
-
get("/projects/#{project}/members", :
|
|
117
|
+
get("/projects/#{url_encode project}/members", query: options)
|
|
67
118
|
end
|
|
68
119
|
|
|
69
120
|
# Gets a project team member.
|
|
@@ -75,7 +126,7 @@ class Gitlab::Client
|
|
|
75
126
|
# @param [Integer] id The ID of a project team member.
|
|
76
127
|
# @return [Gitlab::ObjectifiedHash]
|
|
77
128
|
def team_member(project, id)
|
|
78
|
-
get("/projects/#{project}/members/#{id}")
|
|
129
|
+
get("/projects/#{url_encode project}/members/#{id}")
|
|
79
130
|
end
|
|
80
131
|
|
|
81
132
|
# Adds a user to project team.
|
|
@@ -89,7 +140,7 @@ class Gitlab::Client
|
|
|
89
140
|
# @param [Hash] options A customizable set of options.
|
|
90
141
|
# @return [Gitlab::ObjectifiedHash] Information about added team member.
|
|
91
142
|
def add_team_member(project, id, access_level)
|
|
92
|
-
post("/projects/#{project}/members", :
|
|
143
|
+
post("/projects/#{url_encode project}/members", body: { user_id: id, access_level: access_level })
|
|
93
144
|
end
|
|
94
145
|
|
|
95
146
|
# Updates a team member's project access level.
|
|
@@ -103,7 +154,7 @@ class Gitlab::Client
|
|
|
103
154
|
# @param [Hash] options A customizable set of options.
|
|
104
155
|
# @return [Array<Gitlab::ObjectifiedHash>] Information about updated team member.
|
|
105
156
|
def edit_team_member(project, id, access_level)
|
|
106
|
-
put("/projects/#{project}/members/#{id}", :
|
|
157
|
+
put("/projects/#{url_encode project}/members/#{id}", body: { access_level: access_level })
|
|
107
158
|
end
|
|
108
159
|
|
|
109
160
|
# Removes a user from project team.
|
|
@@ -116,7 +167,7 @@ class Gitlab::Client
|
|
|
116
167
|
# @param [Hash] options A customizable set of options.
|
|
117
168
|
# @return [Gitlab::ObjectifiedHash] Information about removed team member.
|
|
118
169
|
def remove_team_member(project, id)
|
|
119
|
-
delete("/projects/#{project}/members/#{id}")
|
|
170
|
+
delete("/projects/#{url_encode project}/members/#{id}")
|
|
120
171
|
end
|
|
121
172
|
|
|
122
173
|
# Gets a list of project hooks.
|
|
@@ -131,7 +182,7 @@ class Gitlab::Client
|
|
|
131
182
|
# @option options [Integer] :per_page The number of results per page.
|
|
132
183
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
133
184
|
def project_hooks(project, options={})
|
|
134
|
-
get("/projects/#{project}/hooks", :
|
|
185
|
+
get("/projects/#{url_encode project}/hooks", query: options)
|
|
135
186
|
end
|
|
136
187
|
|
|
137
188
|
# Gets a project hook.
|
|
@@ -144,7 +195,7 @@ class Gitlab::Client
|
|
|
144
195
|
# @param [Integer] id The ID of a hook.
|
|
145
196
|
# @return [Gitlab::ObjectifiedHash]
|
|
146
197
|
def project_hook(project, id)
|
|
147
|
-
get("/projects/#{project}/hooks/#{id}")
|
|
198
|
+
get("/projects/#{url_encode project}/hooks/#{id}")
|
|
148
199
|
end
|
|
149
200
|
|
|
150
201
|
# Adds a new hook to the project.
|
|
@@ -154,9 +205,15 @@ class Gitlab::Client
|
|
|
154
205
|
#
|
|
155
206
|
# @param [Integer, String] project The ID or name of a project.
|
|
156
207
|
# @param [String] url The hook URL.
|
|
208
|
+
# @param [Hash] options A customizable set of options.
|
|
209
|
+
# @param option [Boolean] :push_events Trigger hook on push events (0 = false, 1 = true)
|
|
210
|
+
# @param option [Boolean] :issues_events Trigger hook on issues events (0 = false, 1 = true)
|
|
211
|
+
# @param option [Boolean] :merge_requests_events Trigger hook on merge_requests events (0 = false, 1 = true)
|
|
212
|
+
# @param option [Boolean] :tag_push_events Trigger hook on push_tag events (0 = false, 1 = true)
|
|
157
213
|
# @return [Gitlab::ObjectifiedHash] Information about added hook.
|
|
158
|
-
def add_project_hook(project, url)
|
|
159
|
-
|
|
214
|
+
def add_project_hook(project, url, options={})
|
|
215
|
+
body = { url: url }.merge(options)
|
|
216
|
+
post("/projects/#{url_encode project}/hooks", body: body)
|
|
160
217
|
end
|
|
161
218
|
|
|
162
219
|
# Updates a project hook URL.
|
|
@@ -167,9 +224,15 @@ class Gitlab::Client
|
|
|
167
224
|
# @param [Integer, String] project The ID or name of a project.
|
|
168
225
|
# @param [Integer] id The ID of the hook.
|
|
169
226
|
# @param [String] url The hook URL.
|
|
227
|
+
# @param [Hash] options A customizable set of options.
|
|
228
|
+
# @param option [Boolean] :push_events Trigger hook on push events (0 = false, 1 = true)
|
|
229
|
+
# @param option [Boolean] :issues_events Trigger hook on issues events (0 = false, 1 = true)
|
|
230
|
+
# @param option [Boolean] :merge_requests_events Trigger hook on merge_requests events (0 = false, 1 = true)
|
|
231
|
+
# @param option [Boolean] :tag_push_events Trigger hook on push_tag events (0 = false, 1 = true)
|
|
170
232
|
# @return [Gitlab::ObjectifiedHash] Information about updated hook.
|
|
171
|
-
def edit_project_hook(project, id, url)
|
|
172
|
-
|
|
233
|
+
def edit_project_hook(project, id, url, options={})
|
|
234
|
+
body = { url: url }.merge(options)
|
|
235
|
+
put("/projects/#{url_encode project}/hooks/#{id}", body: body)
|
|
173
236
|
end
|
|
174
237
|
|
|
175
238
|
# Deletes a hook from project.
|
|
@@ -181,7 +244,61 @@ class Gitlab::Client
|
|
|
181
244
|
# @param [String] id The ID of the hook.
|
|
182
245
|
# @return [Gitlab::ObjectifiedHash] Information about deleted hook.
|
|
183
246
|
def delete_project_hook(project, id)
|
|
184
|
-
delete("/projects/#{project}/hooks/#{id}")
|
|
247
|
+
delete("/projects/#{url_encode project}/hooks/#{id}")
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
# Gets a project push rule.
|
|
251
|
+
# @see https://docs.gitlab.com/ee/api/projects.html#show-project-push-rules
|
|
252
|
+
#
|
|
253
|
+
# @example
|
|
254
|
+
# Gitlab.push_rule(42)
|
|
255
|
+
#
|
|
256
|
+
# @param [Integer] id The ID of a project.
|
|
257
|
+
# @return [Gitlab::ObjectifiedHash]
|
|
258
|
+
def push_rule(id)
|
|
259
|
+
get("/projects/#{id}/push_rule")
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
# Adds a project push rule.
|
|
263
|
+
# @see https://docs.gitlab.com/ee/api/projects.html#add-project-push-rule
|
|
264
|
+
#
|
|
265
|
+
# @example
|
|
266
|
+
# Gitlab.add_push_rule(42, { deny_delete_tag: false, commit_message_regex: '\\b[A-Z]{3}-[0-9]+\\b' })
|
|
267
|
+
#
|
|
268
|
+
# @param [Integer] id The ID of a project.
|
|
269
|
+
# @param [Hash] options A customizable set of options.
|
|
270
|
+
# @param option [Boolean] :deny_delete_tag Do not allow users to remove git tags with git push (0 = false, 1 = true)
|
|
271
|
+
# @param option [String] :commit_message_regex Commit message regex
|
|
272
|
+
# @return [Gitlab::ObjectifiedHash] Information about added push rule.
|
|
273
|
+
def add_push_rule(id, options={})
|
|
274
|
+
post("/projects/#{id}/push_rule", body: options)
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
# Updates a project push rule.
|
|
278
|
+
# @see https://docs.gitlab.com/ee/api/projects.html#edit-project-push-rule
|
|
279
|
+
#
|
|
280
|
+
# @example
|
|
281
|
+
# Gitlab.edit_push_rule(42, { deny_delete_tag: false, commit_message_regex: '\\b[A-Z]{3}-[0-9]+\\b' })
|
|
282
|
+
#
|
|
283
|
+
# @param [Integer] id The ID of a project.
|
|
284
|
+
# @param [Hash] options A customizable set of options.
|
|
285
|
+
# @param option [Boolean] :deny_delete_tag Do not allow users to remove git tags with git push (0 = false, 1 = true)
|
|
286
|
+
# @param option [String] :commit_message_regex Commit message regex
|
|
287
|
+
# @return [Gitlab::ObjectifiedHash] Information about updated push rule.
|
|
288
|
+
def edit_push_rule(id, options={})
|
|
289
|
+
put("/projects/#{id}/push_rule", body: options)
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
# Deletes a push rule from a project.
|
|
293
|
+
# @see https://docs.gitlab.com/ee/api/projects.html#delete-project-push-rule
|
|
294
|
+
#
|
|
295
|
+
# @example
|
|
296
|
+
# Gitlab.delete_push_rule(42)
|
|
297
|
+
#
|
|
298
|
+
# @param [Integer] id The ID of a project.
|
|
299
|
+
# @return [Gitlab::ObjectifiedHash] Information about deleted push rule.
|
|
300
|
+
def delete_push_rule(id, options={})
|
|
301
|
+
delete("/projects/#{id}/push_rule")
|
|
185
302
|
end
|
|
186
303
|
|
|
187
304
|
# Mark this project as forked from the other
|
|
@@ -193,7 +310,7 @@ class Gitlab::Client
|
|
|
193
310
|
# @param [Integer] id The ID of the project it is forked from.
|
|
194
311
|
# @return [Gitlab::ObjectifiedHash] Information about the forked project.
|
|
195
312
|
def make_forked_from(project, id)
|
|
196
|
-
post("/projects/#{project}/fork/#{id}")
|
|
313
|
+
post("/projects/#{url_encode project}/fork/#{id}")
|
|
197
314
|
end
|
|
198
315
|
|
|
199
316
|
# Remove a forked_from relationship for a project.
|
|
@@ -205,7 +322,7 @@ class Gitlab::Client
|
|
|
205
322
|
# @param [Integer] project The ID of the project it is forked from
|
|
206
323
|
# @return [Gitlab::ObjectifiedHash] Information about the forked project.
|
|
207
324
|
def remove_forked(project)
|
|
208
|
-
delete("/projects/#{project}/fork")
|
|
325
|
+
delete("/projects/#{url_encode project}/fork")
|
|
209
326
|
end
|
|
210
327
|
|
|
211
328
|
# Gets a project deploy keys.
|
|
@@ -213,13 +330,13 @@ class Gitlab::Client
|
|
|
213
330
|
# @example
|
|
214
331
|
# Gitlab.deploy_keys(42)
|
|
215
332
|
#
|
|
216
|
-
# @param [Integer] project The ID of a project.
|
|
333
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
217
334
|
# @param [Hash] options A customizable set of options.
|
|
218
335
|
# @option options [Integer] :page The page number.
|
|
219
336
|
# @option options [Integer] :per_page The number of results per page.
|
|
220
337
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
221
338
|
def deploy_keys(project, options={})
|
|
222
|
-
get("/projects/#{project}/
|
|
339
|
+
get("/projects/#{url_encode project}/deploy_keys", query: options)
|
|
223
340
|
end
|
|
224
341
|
|
|
225
342
|
# Gets a single project deploy key.
|
|
@@ -227,11 +344,11 @@ class Gitlab::Client
|
|
|
227
344
|
# @example
|
|
228
345
|
# Gitlab.deploy_key(42, 1)
|
|
229
346
|
#
|
|
230
|
-
# @param [Integer, String] project The ID of a project.
|
|
347
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
231
348
|
# @param [Integer] id The ID of a deploy key.
|
|
232
349
|
# @return [Gitlab::ObjectifiedHash]
|
|
233
350
|
def deploy_key(project, id)
|
|
234
|
-
get("/projects/#{project}/
|
|
351
|
+
get("/projects/#{url_encode project}/deploy_keys/#{id}")
|
|
235
352
|
end
|
|
236
353
|
|
|
237
354
|
# Creates a new deploy key.
|
|
@@ -239,12 +356,36 @@ class Gitlab::Client
|
|
|
239
356
|
# @example
|
|
240
357
|
# Gitlab.create_deploy_key(42, 'My Key', 'Key contents')
|
|
241
358
|
#
|
|
242
|
-
# @param [Integer] project The ID of a project.
|
|
359
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
243
360
|
# @param [String] title The title of a deploy key.
|
|
244
361
|
# @param [String] key The content of a deploy key.
|
|
245
362
|
# @return [Gitlab::ObjectifiedHash] Information about created deploy key.
|
|
246
363
|
def create_deploy_key(project, title, key)
|
|
247
|
-
post("/projects/#{project}/
|
|
364
|
+
post("/projects/#{url_encode project}/deploy_keys", body: { title: title, key: key })
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
# Enables a deploy key at the project.
|
|
368
|
+
#
|
|
369
|
+
# @example
|
|
370
|
+
# Gitlab.enable_deploy_key(42, 66)
|
|
371
|
+
#
|
|
372
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
373
|
+
# @param [Integer] key The ID of a deploy key.
|
|
374
|
+
# @return [Gitlab::ObjectifiedHash] Information about the enabled deploy key.
|
|
375
|
+
def enable_deploy_key(project, key)
|
|
376
|
+
post("/projects/#{url_encode project}/deploy_keys/#{key}/enable", body: { id: project, key_id: key })
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
# Disables a deploy key at the project.
|
|
380
|
+
#
|
|
381
|
+
# @example
|
|
382
|
+
# Gitlab.disable_deploy_key(42, 66)
|
|
383
|
+
#
|
|
384
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
385
|
+
# @param [Integer] key The ID of a deploy key.
|
|
386
|
+
# @return [Gitlab::ObjectifiedHash] Information about the disabled deploy key.
|
|
387
|
+
def disable_deploy_key(project, key)
|
|
388
|
+
post("/projects/#{url_encode project}/deploy_keys/#{key}/disable", body: { id: project, key_id: key })
|
|
248
389
|
end
|
|
249
390
|
|
|
250
391
|
# Deletes a deploy key from project.
|
|
@@ -252,11 +393,79 @@ class Gitlab::Client
|
|
|
252
393
|
# @example
|
|
253
394
|
# Gitlab.delete_deploy_key(42, 1)
|
|
254
395
|
#
|
|
255
|
-
# @param [Integer] project The ID of a project.
|
|
396
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
256
397
|
# @param [Integer] id The ID of a deploy key.
|
|
257
398
|
# @return [Gitlab::ObjectifiedHash] Information about deleted deploy key.
|
|
258
399
|
def delete_deploy_key(project, id)
|
|
259
|
-
delete("/projects/#{project}/
|
|
400
|
+
delete("/projects/#{url_encode project}/deploy_keys/#{id}")
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
# Forks a project into the user namespace.
|
|
404
|
+
#
|
|
405
|
+
# @example
|
|
406
|
+
# Gitlab.create_fork(42)
|
|
407
|
+
# Gitlab.create_fork(42, { sudo: 'another_username' })
|
|
408
|
+
#
|
|
409
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
410
|
+
# @param [Hash] options A customizable set of options.
|
|
411
|
+
# @option options [String] :sudo The username the project will be forked for
|
|
412
|
+
# @return [Gitlab::ObjectifiedHash] Information about the forked project.
|
|
413
|
+
def create_fork(id, options={})
|
|
414
|
+
post("/projects/#{id}/fork", body: options)
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
# Updates an existing project.
|
|
418
|
+
#
|
|
419
|
+
# @example
|
|
420
|
+
# Gitlab.edit_project(42)
|
|
421
|
+
# Gitlab.edit_project(42, { name: 'project_name' })
|
|
422
|
+
#
|
|
423
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
424
|
+
# @param [Hash] options A customizable set of options.
|
|
425
|
+
# @option options [String] :name The name of a project
|
|
426
|
+
# @option options [String] :path The name of a project
|
|
427
|
+
# @option options [String] :description The name of a project
|
|
428
|
+
# @return [Gitlab::ObjectifiedHash] Information about the edited project.
|
|
429
|
+
def edit_project(id, options={})
|
|
430
|
+
put("/projects/#{id}", query: options)
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
# Share project with group.
|
|
434
|
+
#
|
|
435
|
+
# @example
|
|
436
|
+
# Gitlab.share_project_with_group('gitlab', 2, 40)
|
|
437
|
+
#
|
|
438
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
439
|
+
# @param [Integer] id The ID of a group.
|
|
440
|
+
# @param [Integer] group_access The access level to project.
|
|
441
|
+
def share_project_with_group(project, id, group_access)
|
|
442
|
+
post("/projects/#{url_encode project}/share", body: { group_id: id, group_access: group_access })
|
|
443
|
+
end
|
|
444
|
+
|
|
445
|
+
# Stars a project.
|
|
446
|
+
# @see https://docs.gitlab.com/ce/api/projects.html#star-a-project
|
|
447
|
+
#
|
|
448
|
+
# @example
|
|
449
|
+
# Gitlab.star_project(42)
|
|
450
|
+
# Gitlab.star_project('gitlab-org/gitlab-ce')
|
|
451
|
+
#
|
|
452
|
+
# @param [Integer, String] id The ID or name of a project.
|
|
453
|
+
# @return [Gitlab::ObjectifiedHash] Information about starred project.
|
|
454
|
+
def star_project(id)
|
|
455
|
+
post("/projects/#{id}/star")
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
# Unstars a project.
|
|
459
|
+
# @see https://docs.gitlab.com/ce/api/projects.html#unstar-a-project
|
|
460
|
+
#
|
|
461
|
+
# @example
|
|
462
|
+
# Gitlab.unstar_project(42)
|
|
463
|
+
# Gitlab.unstar_project('gitlab-org/gitlab-ce')
|
|
464
|
+
#
|
|
465
|
+
# @param [Integer, String] id The ID or name of a project.
|
|
466
|
+
# @return [Gitlab::ObjectifiedHash] Information about unstarred project.
|
|
467
|
+
def unstar_project(id)
|
|
468
|
+
delete("/projects/#{id}/star")
|
|
260
469
|
end
|
|
261
470
|
end
|
|
262
471
|
end
|