gitlab 4.5.0 → 5.1.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/CHANGELOG.md +0 -267
- data/LICENSE.txt +1 -1
- data/README.md +40 -30
- data/exe/gitlab +5 -1
- data/lib/gitlab/api.rb +7 -3
- data/lib/gitlab/cli.rb +13 -9
- data/lib/gitlab/cli_helpers.rb +49 -45
- data/lib/gitlab/client/access_requests.rb +10 -1
- 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 +47 -8
- data/lib/gitlab/client/broadcast_messages.rb +75 -0
- data/lib/gitlab/client/build_variables.rb +19 -12
- data/lib/gitlab/client/builds.rb +13 -11
- data/lib/gitlab/client/commits.rb +73 -21
- data/lib/gitlab/client/container_registry.rb +85 -0
- data/lib/gitlab/client/deployments.rb +3 -1
- 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 +6 -4
- 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 +7 -6
- data/lib/gitlab/client/groups.rb +326 -12
- data/lib/gitlab/client/issue_links.rb +48 -0
- data/lib/gitlab/client/issues.rb +47 -13
- data/lib/gitlab/client/jobs.rb +96 -8
- data/lib/gitlab/client/keys.rb +13 -0
- data/lib/gitlab/client/labels.rb +6 -4
- data/lib/gitlab/client/lint.rb +19 -0
- data/lib/gitlab/client/markdown.rb +23 -0
- data/lib/gitlab/client/merge_request_approvals.rb +164 -9
- data/lib/gitlab/client/merge_requests.rb +148 -11
- data/lib/gitlab/client/merge_trains.rb +55 -0
- data/lib/gitlab/client/milestones.rb +19 -5
- data/lib/gitlab/client/namespaces.rb +4 -2
- data/lib/gitlab/client/notes.rb +38 -9
- data/lib/gitlab/client/packages.rb +95 -0
- data/lib/gitlab/client/pipeline_schedules.rb +36 -10
- data/lib/gitlab/client/pipeline_triggers.rb +10 -8
- data/lib/gitlab/client/pipelines.rb +65 -3
- data/lib/gitlab/client/project_badges.rb +85 -0
- data/lib/gitlab/client/project_clusters.rb +83 -0
- data/lib/gitlab/client/project_exports.rb +54 -0
- data/lib/gitlab/client/project_release_links.rb +76 -0
- data/lib/gitlab/client/project_releases.rb +90 -0
- data/lib/gitlab/client/projects.rb +307 -26
- data/lib/gitlab/client/protected_tags.rb +59 -0
- data/lib/gitlab/client/remote_mirrors.rb +51 -0
- data/lib/gitlab/client/repositories.rb +77 -6
- data/lib/gitlab/client/repository_files.rb +21 -3
- 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 +170 -18
- data/lib/gitlab/client/search.rb +66 -0
- data/lib/gitlab/client/services.rb +4 -1
- data/lib/gitlab/client/sidekiq.rb +2 -0
- data/lib/gitlab/client/snippets.rb +5 -3
- data/lib/gitlab/client/system_hooks.rb +9 -7
- data/lib/gitlab/client/tags.rb +10 -9
- 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 +302 -31
- data/lib/gitlab/client/versions.rb +18 -0
- data/lib/gitlab/client/wikis.rb +79 -0
- data/lib/gitlab/client.rb +48 -9
- data/lib/gitlab/configuration.rb +9 -6
- data/lib/gitlab/error.rb +73 -3
- data/lib/gitlab/file_response.rb +4 -2
- data/lib/gitlab/headers/page_links.rb +37 -0
- data/lib/gitlab/headers/total.rb +29 -0
- data/lib/gitlab/help.rb +16 -16
- data/lib/gitlab/objectified_hash.rb +27 -10
- data/lib/gitlab/paginated_response.rb +43 -25
- data/lib/gitlab/request.rb +51 -37
- data/lib/gitlab/shell.rb +6 -4
- data/lib/gitlab/shell_history.rb +11 -13
- data/lib/gitlab/version.rb +3 -1
- data/lib/gitlab.rb +23 -9
- metadata +59 -45
- data/.gitignore +0 -22
- data/CONTRIBUTING.md +0 -195
- data/Gemfile +0 -4
- data/Rakefile +0 -17
- data/bin/console +0 -10
- data/bin/setup +0 -6
- data/gitlab.gemspec +0 -33
- data/lib/gitlab/page_links.rb +0 -33
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Gitlab::Client
|
2
4
|
# Defines methods related to pipeline schedules.
|
3
5
|
# @see https://docs.gitlab.com/ce/api/pipeline_schedules.html
|
@@ -12,7 +14,7 @@ class Gitlab::Client
|
|
12
14
|
# @param [Hash] options A customizable set of options.
|
13
15
|
# @options options [String] :scope The scope of pipeline schedules, one of a 'active' or 'inactive'.
|
14
16
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
15
|
-
def pipeline_schedules(project, options={})
|
17
|
+
def pipeline_schedules(project, options = {})
|
16
18
|
get("/projects/#{url_encode project}/pipeline_schedules", query: options)
|
17
19
|
end
|
18
20
|
|
@@ -28,6 +30,18 @@ class Gitlab::Client
|
|
28
30
|
get("/projects/#{url_encode project}/pipeline_schedules/#{id}")
|
29
31
|
end
|
30
32
|
|
33
|
+
# Get all pipelines triggered by a pipeline schedule
|
34
|
+
#
|
35
|
+
# @example
|
36
|
+
# Gitlab.pipelines_by_pipeline_schedule(5, 3)
|
37
|
+
#
|
38
|
+
# @param [Integer, String] project The ID or name of a project.
|
39
|
+
# @param [Integer] id The ID of the pipeline schedule.
|
40
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
41
|
+
def pipelines_by_pipeline_schedule(project, id)
|
42
|
+
get("/projects/#{url_encode project}/pipeline_schedules/#{id}/pipelines")
|
43
|
+
end
|
44
|
+
|
31
45
|
# Create a pipeline schedule.
|
32
46
|
#
|
33
47
|
# @example
|
@@ -41,8 +55,8 @@ class Gitlab::Client
|
|
41
55
|
# @option options [String] :cron_timezone The timezone supproted by ActiveSupport::TimeZone (e.g. Pacific Time (US & Canada)) (default: 'UTC').
|
42
56
|
# @option options [Boolean] :active The activation of pipeline schedule. If false is set, the pipeline schedule will deactivated initially (default: true).
|
43
57
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
44
|
-
def create_pipeline_schedule(project, options={})
|
45
|
-
post("/projects/#{url_encode project}/pipeline_schedules",
|
58
|
+
def create_pipeline_schedule(project, options = {})
|
59
|
+
post("/projects/#{url_encode project}/pipeline_schedules", body: options)
|
46
60
|
end
|
47
61
|
|
48
62
|
# Updates the pipeline schedule of a project.
|
@@ -59,8 +73,8 @@ class Gitlab::Client
|
|
59
73
|
# @option options [String] :cron_timezone The timezone supproted by ActiveSupport::TimeZone (e.g. Pacific Time (US & Canada)) (default: 'UTC').
|
60
74
|
# @option options [Boolean] :active The activation of pipeline schedule. If false is set, the pipeline schedule will deactivated initially (default: true).
|
61
75
|
# @return [Array<Gitlab::ObjectifiedHash>] The updated pipeline schedule.
|
62
|
-
def edit_pipeline_schedule(project, pipeline_schedule_id, options={})
|
63
|
-
put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}",
|
76
|
+
def edit_pipeline_schedule(project, pipeline_schedule_id, options = {})
|
77
|
+
put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}", body: options)
|
64
78
|
end
|
65
79
|
|
66
80
|
# Take ownership of a pipeline schedule.
|
@@ -75,6 +89,18 @@ class Gitlab::Client
|
|
75
89
|
post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/take_ownership")
|
76
90
|
end
|
77
91
|
|
92
|
+
# Run a scheduled pipeline immediately.
|
93
|
+
#
|
94
|
+
# @example
|
95
|
+
# Gitlab.run_pipeline_schedule(5, 1)
|
96
|
+
#
|
97
|
+
# @param [Integer, String] project The ID or name of a project.
|
98
|
+
# @param [Integer] trigger_id The pipeline schedule ID.
|
99
|
+
# @return [Gitlab::ObjectifiedHash] Pipeline created message.
|
100
|
+
def run_pipeline_schedule(project, pipeline_schedule_id)
|
101
|
+
post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/play")
|
102
|
+
end
|
103
|
+
|
78
104
|
# Delete a pipeline schedule.
|
79
105
|
#
|
80
106
|
# @example
|
@@ -98,8 +124,8 @@ class Gitlab::Client
|
|
98
124
|
# @option options [String] :key The key of a variable; must have no more than 255 characters; only A-Z, a-z, 0-9, and _ are allowed.
|
99
125
|
# @option options [String] :value The value of a variable
|
100
126
|
# @return [Array<Gitlab::ObjectifiedHash>] The created pipeline schedule variable.
|
101
|
-
def create_pipeline_schedule_variable(project, pipeline_schedule_id, options={})
|
102
|
-
post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables",
|
127
|
+
def create_pipeline_schedule_variable(project, pipeline_schedule_id, options = {})
|
128
|
+
post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables", body: options)
|
103
129
|
end
|
104
130
|
|
105
131
|
# Updates the variable of a pipeline schedule.
|
@@ -113,8 +139,8 @@ class Gitlab::Client
|
|
113
139
|
# @param [Hash] options A customizable set of options.
|
114
140
|
# @option options [String] :value The value of a variable.
|
115
141
|
# @return [Array<Gitlab::ObjectifiedHash>] The updated pipeline schedule variable.
|
116
|
-
def edit_pipeline_schedule_variable(project, pipeline_schedule_id, key, options={})
|
117
|
-
put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables/#{url_encode key}",
|
142
|
+
def edit_pipeline_schedule_variable(project, pipeline_schedule_id, key, options = {})
|
143
|
+
put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables/#{url_encode key}", body: options)
|
118
144
|
end
|
119
145
|
|
120
146
|
# Delete the variable of a pipeline schedule
|
@@ -126,7 +152,7 @@ class Gitlab::Client
|
|
126
152
|
# @param [Integer] The pipeline schedule ID.
|
127
153
|
# @param [String] The key of a variable.
|
128
154
|
# @return [Array<Gitlab::ObjectifiedHash>] The deleted pipeline schedule variable.
|
129
|
-
def delete_pipeline_schedule_variable(project, pipeline_schedule_id, key,
|
155
|
+
def delete_pipeline_schedule_variable(project, pipeline_schedule_id, key, _options = {})
|
130
156
|
delete("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables/#{url_encode key}")
|
131
157
|
end
|
132
158
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Gitlab::Client
|
2
4
|
# Defines methods related to pipelines.
|
3
5
|
# @see https://docs.gitlab.com/ce/api/pipeline_triggers.html
|
@@ -35,7 +37,7 @@ class Gitlab::Client
|
|
35
37
|
# @param [String] description The trigger name
|
36
38
|
# @return [Gitlab::ObjectifiedHash] The created trigger.
|
37
39
|
def create_trigger(project, description)
|
38
|
-
post("/projects/#{url_encode project}/triggers", body: {description: description})
|
40
|
+
post("/projects/#{url_encode project}/triggers", body: { description: description })
|
39
41
|
end
|
40
42
|
|
41
43
|
# Update a project trigger
|
@@ -48,7 +50,7 @@ class Gitlab::Client
|
|
48
50
|
# @param [Hash] options A customizable set of options.
|
49
51
|
# @option options [String] :description The trigger name.
|
50
52
|
# @return [Gitlab::ObjectifiedHash] The updated trigger.
|
51
|
-
def update_trigger(project, trigger_id, options={})
|
53
|
+
def update_trigger(project, trigger_id, options = {})
|
52
54
|
put("/projects/#{url_encode project}/triggers/#{trigger_id}", body: options)
|
53
55
|
end
|
54
56
|
|
@@ -75,7 +77,7 @@ class Gitlab::Client
|
|
75
77
|
def remove_trigger(project, trigger_id)
|
76
78
|
delete("/projects/#{url_encode project}/triggers/#{trigger_id}")
|
77
79
|
end
|
78
|
-
|
80
|
+
alias delete_trigger remove_trigger
|
79
81
|
|
80
82
|
# Run the given project pipeline trigger.
|
81
83
|
#
|
@@ -90,12 +92,12 @@ class Gitlab::Client
|
|
90
92
|
# @param [String] ref Branch or tag name to build.
|
91
93
|
# @param [Hash] variables A set of build variables to use for the build. (optional)
|
92
94
|
# @return [Gitlab::ObjectifiedHash] The trigger.
|
93
|
-
def run_trigger(project, token, ref, variables={})
|
95
|
+
def run_trigger(project, token, ref, variables = {})
|
94
96
|
post("/projects/#{url_encode project}/trigger/pipeline", unauthenticated: true, body: {
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
97
|
+
token: token,
|
98
|
+
ref: ref,
|
99
|
+
variables: variables
|
100
|
+
})
|
99
101
|
end
|
100
102
|
end
|
101
103
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Gitlab::Client
|
2
4
|
# Defines methods related to pipelines.
|
3
5
|
# @see https://docs.gitlab.com/ce/api/pipelines.html
|
@@ -13,7 +15,7 @@ class Gitlab::Client
|
|
13
15
|
# @option options [Integer] :page The page number.
|
14
16
|
# @option options [Integer] :per_page The number of results per page.
|
15
17
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
16
|
-
def pipelines(project, options={})
|
18
|
+
def pipelines(project, options = {})
|
17
19
|
get("/projects/#{url_encode project}/pipelines", query: options)
|
18
20
|
end
|
19
21
|
|
@@ -29,6 +31,30 @@ class Gitlab::Client
|
|
29
31
|
get("/projects/#{url_encode project}/pipelines/#{id}")
|
30
32
|
end
|
31
33
|
|
34
|
+
# Gets a single pipeline's test report.
|
35
|
+
#
|
36
|
+
# @example
|
37
|
+
# Gitlab.pipeline_test_report(5, 36)
|
38
|
+
#
|
39
|
+
# @param [Integer, String] project The ID or name of a project.
|
40
|
+
# @param [Integer] id The ID of a pipeline.
|
41
|
+
# @return [Gitlab::ObjectifiedHash]
|
42
|
+
def pipeline_test_report(project, id)
|
43
|
+
get("/projects/#{url_encode project}/pipelines/#{id}/test_report")
|
44
|
+
end
|
45
|
+
|
46
|
+
# Gets a single pipeline's variables.
|
47
|
+
#
|
48
|
+
# @example
|
49
|
+
# Gitlab.pipeline_variables(5, 36)
|
50
|
+
#
|
51
|
+
# @param [Integer, String] project The ID or name of a project.
|
52
|
+
# @param [Integer] id The ID of a pipeline.
|
53
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
54
|
+
def pipeline_variables(project, id)
|
55
|
+
get("/projects/#{url_encode project}/pipelines/#{id}/variables")
|
56
|
+
end
|
57
|
+
|
32
58
|
# Create a pipeline.
|
33
59
|
#
|
34
60
|
# @example
|
@@ -36,9 +62,20 @@ class Gitlab::Client
|
|
36
62
|
#
|
37
63
|
# @param [Integer, String] project The ID or name of a project.
|
38
64
|
# @param [String] ref Reference to commit.
|
65
|
+
# @param [Hash] variables Variables passed to pipelines
|
39
66
|
# @return [Gitlab::ObjectifiedHash] The pipelines changes.
|
40
|
-
def create_pipeline(project, ref)
|
41
|
-
|
67
|
+
def create_pipeline(project, ref, variables = {})
|
68
|
+
body = {}
|
69
|
+
|
70
|
+
# This mapping is necessary, cause the API expects an array with objects (with `key` and `value` keys)
|
71
|
+
# See: https://docs.gitlab.com/ee/api/pipelines.html#create-a-new-pipeline
|
72
|
+
body[:variables] = variables.map { |(key, value)| { key: key, value: value } } if variables.any?
|
73
|
+
|
74
|
+
post(
|
75
|
+
"/projects/#{url_encode project}/pipeline",
|
76
|
+
query: { ref: ref },
|
77
|
+
body: body
|
78
|
+
)
|
42
79
|
end
|
43
80
|
|
44
81
|
# Cancels a pipeline.
|
@@ -64,5 +101,30 @@ class Gitlab::Client
|
|
64
101
|
def retry_pipeline(project, id)
|
65
102
|
post("/projects/#{url_encode project}/pipelines/#{id}/retry")
|
66
103
|
end
|
104
|
+
|
105
|
+
# Delete a pipeline
|
106
|
+
#
|
107
|
+
# @example
|
108
|
+
# Gitlab.delete_pipeline(5, 1)
|
109
|
+
#
|
110
|
+
# @param [Integer, String] project The ID or name of a project.
|
111
|
+
# @param [Integer] id The ID of a pipeline.
|
112
|
+
# @return [void] This API call returns an empty response body.
|
113
|
+
def delete_pipeline(project, id)
|
114
|
+
delete("/projects/#{url_encode project}/pipelines/#{id}")
|
115
|
+
end
|
116
|
+
|
117
|
+
# Update a pipeline metadata
|
118
|
+
#
|
119
|
+
# @example
|
120
|
+
# Gitlab.update_pipeline_metadata(5, 1, name: 'new name')
|
121
|
+
#
|
122
|
+
# @param [Integer, String] project The ID or name of a project.
|
123
|
+
# @param [Integer] id The ID of a pipeline.
|
124
|
+
# @option options [String] :name The new name of the pipeline.
|
125
|
+
# @return [Gitlab::ObjectifiedHash]
|
126
|
+
def update_pipeline_metadata(project, id, options = {})
|
127
|
+
put("/projects/#{url_encode project}/pipelines/#{id}/metadata", body: options)
|
128
|
+
end
|
67
129
|
end
|
68
130
|
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Gitlab::Client
|
4
|
+
# Defines methods related to project badges.
|
5
|
+
# @see https://docs.gitlab.com/ee/api/project_badges.html
|
6
|
+
module ProjectBadges
|
7
|
+
# Gets a list of a projects badges and its group badges.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# Gitlab.project_badges(5)
|
11
|
+
#
|
12
|
+
# @param [Integer, String] project The ID or name of a project.
|
13
|
+
# @return [Array<Gitlab::ObjectifiedHash>] List of all badges of a project
|
14
|
+
def project_badges(project)
|
15
|
+
get("/projects/#{url_encode project}/badges")
|
16
|
+
end
|
17
|
+
|
18
|
+
# Gets a badge of a project.
|
19
|
+
#
|
20
|
+
# @example
|
21
|
+
# Gitlab.project_badge(5, 42)
|
22
|
+
#
|
23
|
+
# @param [Integer, String] project The ID or name of a project.
|
24
|
+
# @param [Integer] badge_id The badge ID.
|
25
|
+
# @return [Gitlab::ObjectifiedHash] Information about the requested badge
|
26
|
+
def project_badge(project, badge_id)
|
27
|
+
get("/projects/#{url_encode project}/badges/#{badge_id}")
|
28
|
+
end
|
29
|
+
|
30
|
+
# Adds a badge to a project.
|
31
|
+
#
|
32
|
+
# @example
|
33
|
+
# Gitlab.add_project_badge(5, { link_url: 'https://abc.com/gitlab/gitlab-ce/commits/master', image_url: 'https://shields.io/my/badge1' })
|
34
|
+
#
|
35
|
+
# @param [Integer, String] project The ID or name of a project.
|
36
|
+
# @param [Hash] options A customizable set of options.
|
37
|
+
# @option options [String] :link_url(required) URL of the badge link
|
38
|
+
# @option options [String] :image_url(required) URL of the badge image
|
39
|
+
# @return [Gitlab::ObjectifiedHash] Information about the added project badge.
|
40
|
+
def add_project_badge(project, options = {})
|
41
|
+
post("/projects/#{url_encode project}/badges", body: options)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Updates a badge of a project..
|
45
|
+
#
|
46
|
+
# @example
|
47
|
+
# Gitlab.edit_project_badge(5, 1, { link_url: 'https://abc.com/gitlab/gitlab-ce/commits/master', image_url: 'https://shields.io/my/badge1' })
|
48
|
+
#
|
49
|
+
# @param [Integer, String] project The ID or name of a project.
|
50
|
+
# @param [Integer] badge_id The badge ID.
|
51
|
+
# @param [Hash] options A customizable set of options.
|
52
|
+
# @option options [String] :link_url(optional) URL of the badge link
|
53
|
+
# @option options [String] :image_url(optional) URL of the badge image
|
54
|
+
# @return [Gitlab::ObjectifiedHash] Information about the updated project badge.
|
55
|
+
def edit_project_badge(project, badge_id, options = {})
|
56
|
+
put("/projects/#{url_encode project}/badges/#{badge_id}", body: options)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Removes a badge from a project. Only projects badges will be removed by using this endpoint.
|
60
|
+
#
|
61
|
+
# @example
|
62
|
+
# Gitlab.remove_project_badge(5, 42)
|
63
|
+
#
|
64
|
+
# @param [Integer, String] project The ID or name of a project.
|
65
|
+
# @param [Integer] badge_id The badge ID.
|
66
|
+
# @return [nil] This API call returns an empty response body.
|
67
|
+
def remove_project_badge(project, badge_id)
|
68
|
+
delete("/projects/#{url_encode project}/badges/#{badge_id}")
|
69
|
+
end
|
70
|
+
|
71
|
+
# Preview a badge from a project.
|
72
|
+
#
|
73
|
+
# @example
|
74
|
+
# Gitlab.preview_project_badge(3, 'https://abc.com/gitlab/gitlab-ce/commits/master', 'https://shields.io/my/badge1')
|
75
|
+
#
|
76
|
+
# @param [Integer, String] project The ID or name of a project.
|
77
|
+
# @param [String] :link_url URL of the badge link
|
78
|
+
# @param [String] :image_url URL of the badge image
|
79
|
+
# @return [Gitlab::ObjectifiedHash] Returns how the link_url and image_url final URLs would be after resolving the placeholder interpolation.
|
80
|
+
def preview_project_badge(project, link_url, image_url)
|
81
|
+
query = { link_url: link_url, image_url: image_url }
|
82
|
+
get("/projects/#{url_encode project}/badges/render", query: query)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Gitlab::Client
|
4
|
+
# Defines methods related to project clusters.
|
5
|
+
# @see https://docs.gitlab.com/ce/api/project_clusters.html
|
6
|
+
module ProjectClusters
|
7
|
+
# Returns a list of project clusters.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# Gitlab.project_clusters(5)
|
11
|
+
#
|
12
|
+
# @param [Integer, String] project The ID or name of a project.
|
13
|
+
# @return [Array<Gitlab::ObjectifiedHash>] List of all clusters of a project
|
14
|
+
def project_clusters(project)
|
15
|
+
get("/projects/#{url_encode project}/clusters")
|
16
|
+
end
|
17
|
+
|
18
|
+
# Gets a single project cluster.
|
19
|
+
#
|
20
|
+
# @example
|
21
|
+
# Gitlab.project_cluster(5, 42)
|
22
|
+
#
|
23
|
+
# @param [Integer, String] project The ID or name of a project.
|
24
|
+
# @param [Integer] cluster_id The ID of the cluster.
|
25
|
+
# @return [Gitlab::ObjectifiedHash] Information about the requested cluster
|
26
|
+
def project_cluster(project, cluster_id)
|
27
|
+
get("/projects/#{url_encode project}/clusters/#{cluster_id}")
|
28
|
+
end
|
29
|
+
|
30
|
+
# Adds an existing Kubernetes cluster to the project.
|
31
|
+
#
|
32
|
+
# @example
|
33
|
+
# Gitlab.add_project_cluster(5, 'cluster-5', { enabled: false, platform_kubernetes_attributes: { api_url: 'https://35.111.51.20', token: '12345', ca_cert: "-----BEGIN CERTIFICATE-----\r\nhFiK1L61owwDQYJKoZIhvcNAQELBQAw\r\nLzEtMCsGA1UEAxMkZDA1YzQ1YjctNzdiMS00NDY0LThjNmEtMTQ0ZDJkZjM4ZDBj\r\nMB4XDTE4MTIyNzIwMDM1MVoXDTIzMTIyNjIxMDM1MVowLzEtMCsGA1UEAxMkZDA1\r\nYzQ1YjctNzdiMS00NDY0LThjNmEtMTQ0ZDJkZjM.......-----END CERTIFICATE-----", namespace: 'cluster-5-namespace', authorization_type: 'rbac' } })
|
34
|
+
# Gitlab.add_project_cluster(5, 'cluster-5', { platform_kubernetes_attributes: { api_url: 'https://35.111.51.20', token: '12345' } })
|
35
|
+
#
|
36
|
+
# @param [Integer, String] project The ID or name of a project.
|
37
|
+
# @param [String] name The name of the existing cluster.
|
38
|
+
# @param [Hash] options A customizable set of options.
|
39
|
+
# @option options [Boolean] :enabled(optional) Determines if cluster is active or not, defaults to true
|
40
|
+
# @option options [Hash] :platform_kubernetes_attributes A customizable set of Kubernetes platform attributes
|
41
|
+
# @suboption platform_kubernetes_attributes [String] :api_url(required) The URL to access the Kubernetes API
|
42
|
+
# @suboption platform_kubernetes_attributes [String] :token(required) The token to authenticate against Kubernetes
|
43
|
+
# @suboption platform_kubernetes_attributes [String] :ca_cert(optional) TLS certificate (needed if API is using a self-signed TLS certificate
|
44
|
+
# @suboption platform_kubernetes_attributes [String] :namespace(optional) The unique namespace related to the project
|
45
|
+
# @suboption platform_kubernetes_attributes [String] :authorization_type(optional) The cluster authorization type: rbac, abac or unknown_authorization. Defaults to rbac.
|
46
|
+
# @return [Gitlab::ObjectifiedHash] Information about the added project cluster.
|
47
|
+
def add_project_cluster(project, name, options = {})
|
48
|
+
body = { name: name }.merge(options)
|
49
|
+
post("/projects/#{url_encode project}/clusters/user", body: body)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Updates an existing project cluster.
|
53
|
+
#
|
54
|
+
# @example
|
55
|
+
# Gitlab.edit_project_cluster(5, 1, { name: 'cluster-6', platform_kubernetes_attributes: { api_url: 'https://35.111.51.20', token: '12345', ca_cert: "-----BEGIN CERTIFICATE-----\r\nhFiK1L61owwDQYJKoZIhvcNAQELBQAw\r\nLzEtMCsGA1UEAxMkZDA1YzQ1YjctNzdiMS00NDY0LThjNmEtMTQ0ZDJkZjM4ZDBj\r\nMB4XDTE4MTIyNzIwMDM1MVoXDTIzMTIyNjIxMDM1MVowLzEtMCsGA1UEAxMkZDA1\r\nYzQ1YjctNzdiMS00NDY0LThjNmEtMTQ0ZDJkZjM.......-----END CERTIFICATE-----", namespace: 'cluster-6-namespace' } })
|
56
|
+
#
|
57
|
+
# @param [Integer, String] project The ID or name of a project.
|
58
|
+
# @param [Integer] cluster_id The ID of the cluster.
|
59
|
+
# @param [Hash] options A customizable set of options.
|
60
|
+
# @option options [String] :name(optional) The name of the cluster
|
61
|
+
# @option options [Hash] :platform_kubernetes_attributes A customizable set of Kubernetes platform attributes
|
62
|
+
# @suboption platform_kubernetes_attributes [String] :api_url(required) The URL to access the Kubernetes API
|
63
|
+
# @suboption platform_kubernetes_attributes [String] :token(required) The token to authenticate against Kubernetes
|
64
|
+
# @suboption platform_kubernetes_attributes [String] :ca_cert(optional) TLS certificate (needed if API is using a self-signed TLS certificate
|
65
|
+
# @suboption platform_kubernetes_attributes [String] :namespace(optional) The unique namespace related to the project
|
66
|
+
# @return [Gitlab::ObjectifiedHash] Information about the updated project cluster.
|
67
|
+
def edit_project_cluster(project, cluster_id, options = {})
|
68
|
+
put("/projects/#{url_encode project}/clusters/#{cluster_id}", body: options)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Deletes an existing project cluster.
|
72
|
+
#
|
73
|
+
# @example
|
74
|
+
# Gitlab.delete_project_cluster(5, 42)
|
75
|
+
#
|
76
|
+
# @param [Integer, String] project The ID or name of a project.
|
77
|
+
# @param [Integer] cluster_id The ID of the cluster.
|
78
|
+
# @return [nil] This API call returns an empty response body.
|
79
|
+
def delete_project_cluster(project, cluster_id)
|
80
|
+
delete("/projects/#{url_encode project}/clusters/#{cluster_id}")
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Gitlab::Client
|
4
|
+
# Defines methods related to project exports.
|
5
|
+
# @see https://docs.gitlab.com/ce/api/project_import_export.html
|
6
|
+
module ProjectExports
|
7
|
+
# Start a new export
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# Gitlab.export_project(2)
|
11
|
+
#
|
12
|
+
# @param [Integer, String] id The ID or path of a project.
|
13
|
+
# @param [Hash] options A customizable set of options.
|
14
|
+
# @option options [String] description(optional) Overrides the project description
|
15
|
+
# @option options [hash] upload(optional) Hash that contains the information to upload the exported project to a web server
|
16
|
+
# @option options [String] upload[url] TThe URL to upload the project
|
17
|
+
# @option options [String] upload[http_method](optional) The HTTP method to upload the exported project. Only PUT and POST methods allowed. Default is PUT
|
18
|
+
# @return [Gitlab::ObjectifiedHash]
|
19
|
+
def export_project(id, options = {})
|
20
|
+
post("/projects/#{url_encode id}/export", body: options)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Get the status of export
|
24
|
+
#
|
25
|
+
# @example
|
26
|
+
# Gitlab.export_project_status(2)
|
27
|
+
#
|
28
|
+
# @param [Integer, String] id The ID or path of a project.
|
29
|
+
# @return [Gitlab::ObjectifiedHash]
|
30
|
+
def export_project_status(id)
|
31
|
+
get("/projects/#{url_encode id}/export")
|
32
|
+
end
|
33
|
+
|
34
|
+
# Download the finished export
|
35
|
+
#
|
36
|
+
# @example
|
37
|
+
# Gitlab.exported_project_download(2)
|
38
|
+
#
|
39
|
+
# @param [Integer, String] id The ID or path of a project.
|
40
|
+
# @return [Gitlab::FileResponse]
|
41
|
+
def exported_project_download(id)
|
42
|
+
get("/projects/#{url_encode id}/export/download",
|
43
|
+
format: nil,
|
44
|
+
headers: { Accept: 'application/octet-stream' },
|
45
|
+
parser: proc { |body, _|
|
46
|
+
if body.encoding == Encoding::ASCII_8BIT # binary response
|
47
|
+
::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
|
48
|
+
else # error with json response
|
49
|
+
::Gitlab::Request.parse(body)
|
50
|
+
end
|
51
|
+
})
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Gitlab::Client
|
4
|
+
# Defines methods related to project release links.
|
5
|
+
# @see https://docs.gitlab.com/ce/api/releases/links.html
|
6
|
+
module ProjectReleaseLinks
|
7
|
+
# Get assets as links from a Release.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# Gitlab.project_release_links(5, 'v0.3')
|
11
|
+
#
|
12
|
+
# @param [Integer, String] project The ID or name of a project.
|
13
|
+
# @param [String] tag_name The tag associated with the Release.
|
14
|
+
# @return [Array<Gitlab::ObjectifiedHash>] List of assets as links from a Release.
|
15
|
+
def project_release_links(project, tag_name)
|
16
|
+
get("/projects/#{url_encode project}/releases/#{tag_name}/assets/links")
|
17
|
+
end
|
18
|
+
|
19
|
+
# Get an asset as link from a Release.
|
20
|
+
#
|
21
|
+
# @example
|
22
|
+
# Gitlab.project_release_link(5, 'v0.3', 1)
|
23
|
+
#
|
24
|
+
# @param [Integer, String] project The ID or name of a project.
|
25
|
+
# @param [String] tag_name The tag associated with the Release.
|
26
|
+
# @param [Integer] link_id The id of the link.
|
27
|
+
# @return [Gitlab::ObjectifiedHash] Information about the release link
|
28
|
+
def project_release_link(project, tag_name, link_id)
|
29
|
+
get("/projects/#{url_encode project}/releases/#{tag_name}/assets/links/#{link_id}")
|
30
|
+
end
|
31
|
+
|
32
|
+
# Create an asset as a link from a Release.
|
33
|
+
#
|
34
|
+
# @example
|
35
|
+
# Gitlab.create_project_release_link(5, 'v0.1', { name: 'awesome-v0.2.dmg', url: 'http://192.168.10.15:3000' })
|
36
|
+
#
|
37
|
+
# @param [Integer, String] project The ID or name of a project.
|
38
|
+
# @param [String] tag_name The tag associated with the Release.
|
39
|
+
# @param [Hash] options A customizable set of options.
|
40
|
+
# @option options [String] :name(required) The name of the link.
|
41
|
+
# @option options [String] :url(required) The URL of the link.
|
42
|
+
# @return [Gitlab::ObjectifiedHash] Information about the created release link.
|
43
|
+
def create_project_release_link(project, tag_name, options = {})
|
44
|
+
post("/projects/#{url_encode project}/releases/#{tag_name}/assets/links", body: options)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Update an asset as a link from a Release. You have to specify at least one of name or url
|
48
|
+
#
|
49
|
+
# @example
|
50
|
+
# Gitlab.update_project_release_link(5, 'v0.3', 1, { name: 'awesome-v0.2.dmg', url: 'http://192.168.10.15:3000' })
|
51
|
+
#
|
52
|
+
# @param [Integer, String] project The ID or name of a project.
|
53
|
+
# @param [String] tag_name The tag where the release will be created from.
|
54
|
+
# @param [Integer] link_id The id of the link.
|
55
|
+
# @param [Hash] options A customizable set of options.
|
56
|
+
# @option options [String] :name(optional) The name of the link.
|
57
|
+
# @option options [String] :url(optional) The URL of the link.
|
58
|
+
# @return [Gitlab::ObjectifiedHash] Information about the updated release link.
|
59
|
+
def update_project_release_link(project, tag_name, link_id, options = {})
|
60
|
+
put("/projects/#{url_encode project}/releases/#{tag_name}/assets/links/#{link_id}", body: options)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Delete an asset as a link from a Release.
|
64
|
+
#
|
65
|
+
# @example
|
66
|
+
# Gitlab.delete_project_release_link(5, 'v0.3', 1)
|
67
|
+
#
|
68
|
+
# @param [Integer, String] project The ID or name of a project.
|
69
|
+
# @param [String] tag_name The tag where the release will be created from.
|
70
|
+
# @param [Integer] link_id The id of the link.
|
71
|
+
# @return [Gitlab::ObjectifiedHash] Information about the deleted release link.
|
72
|
+
def delete_project_release_link(project, tag_name, link_id)
|
73
|
+
delete("/projects/#{url_encode project}/releases/#{tag_name}/assets/links/#{link_id}")
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Gitlab::Client
|
4
|
+
# Defines methods related to project releases.
|
5
|
+
# @see https://docs.gitlab.com/ce/api/releases/
|
6
|
+
module ProjectReleases
|
7
|
+
# Returns Paginated list of a project's releases, sorted by created_at.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# Gitlab.project_releases(5)
|
11
|
+
#
|
12
|
+
# @param [Integer, String] project The ID or name of a project.
|
13
|
+
# @return [Array<Gitlab::ObjectifiedHash>] Paginated list of Releases, sorted by created_at.
|
14
|
+
def project_releases(project)
|
15
|
+
get("/projects/#{url_encode project}/releases")
|
16
|
+
end
|
17
|
+
|
18
|
+
# Gets a Release by a tag name
|
19
|
+
#
|
20
|
+
# @example
|
21
|
+
# Gitlab.project_release(5, 'v0.1')
|
22
|
+
#
|
23
|
+
# @param [Integer, String] project The ID or name of a project.
|
24
|
+
# @param [String] tag_name The tag where the release will be created from..
|
25
|
+
# @return [Gitlab::ObjectifiedHash] Information about the release
|
26
|
+
def project_release(project, tag_name)
|
27
|
+
get("/projects/#{url_encode project}/releases/#{tag_name}")
|
28
|
+
end
|
29
|
+
|
30
|
+
# Creates a Release. You need push access to the repository to create a Release.
|
31
|
+
#
|
32
|
+
# @example
|
33
|
+
# Gitlab.create_project_release(5, { name: 'New Release', tag_name: 'v0.3', description: 'Super nice release' })
|
34
|
+
# Gitlab.create_project_release(5, { name: 'New Release', tag_name: 'v0.3', description: 'Super nice release', assets: { links: [{ name: 'hoge', url: 'https://google.com' }] } })
|
35
|
+
#
|
36
|
+
# @param [Integer, String] project The ID or name of a project.
|
37
|
+
# @param [Hash] options A customizable set of options.
|
38
|
+
# @option options [String] :name(required) The release name.
|
39
|
+
# @option options [String] :tag_name(required) The tag where the release will be created from.
|
40
|
+
# @option options [String] :description(required) The description of the release. You can use markdown.
|
41
|
+
# @option options [String] :ref(optional) If tag_name does not exist, the release will be created from ref. It can be a commit SHA, another tag name, or a branch name.
|
42
|
+
# @option options [Hash] :assets(optional) A customizable set of options for release assets
|
43
|
+
# @asset assets [Array<link>] :links(optional) An array of assets links as hashes.
|
44
|
+
# @link links [Hash] link_elements A combination of a link name and a link url
|
45
|
+
# @link_element [String] :name The name of the link.
|
46
|
+
# @link_element [String] :url The url of the link.
|
47
|
+
# @return [Gitlab::ObjectifiedHash] Information about the created release.
|
48
|
+
def create_project_release(project, options = {})
|
49
|
+
post("/projects/#{url_encode project}/releases", body: options)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Updates a release.
|
53
|
+
#
|
54
|
+
# @example
|
55
|
+
# Gitlab.update_project_release(5, 'v0.3', { name: 'New Release', description: 'Super nice release' })
|
56
|
+
#
|
57
|
+
# @param [Integer, String] project The ID or name of a project.
|
58
|
+
# @param [String] tag_name The tag where the release will be created from.
|
59
|
+
# @param [Hash] options A customizable set of options.
|
60
|
+
# @option options [String] :name(optional) The release name.
|
61
|
+
# @option options [String] :description(optional) The description of the release. You can use markdown.
|
62
|
+
# @return [Gitlab::ObjectifiedHash] Information about the updated release.
|
63
|
+
def update_project_release(project, tag_name, options = {})
|
64
|
+
put("/projects/#{url_encode project}/releases/#{tag_name}", body: options)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Delete a Release. Deleting a Release will not delete the associated tag.
|
68
|
+
#
|
69
|
+
# @example
|
70
|
+
# Gitlab.delete_project_release(5, 'v0.3')
|
71
|
+
#
|
72
|
+
# @param [Integer, String] project The ID or name of a project.
|
73
|
+
# @param [String] tag_name The tag where the release will be created from.
|
74
|
+
# @return [Gitlab::ObjectifiedHash] Information about the deleted release.
|
75
|
+
def delete_project_release(project, tag_name)
|
76
|
+
delete("/projects/#{url_encode project}/releases/#{tag_name}")
|
77
|
+
end
|
78
|
+
|
79
|
+
# Gets Latest Release
|
80
|
+
#
|
81
|
+
# @example
|
82
|
+
# Gitlab.project_latest_release(5)
|
83
|
+
#
|
84
|
+
# @param [Integer, String] project The ID or name of a project
|
85
|
+
# @return [Gitlab::ObjectifiedHash] Information about the release
|
86
|
+
def project_latest_release(project)
|
87
|
+
get("/projects/#{url_encode project}/releases/permalink/latest")
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|