gitlab-faraday 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 +7 -0
- data/lib/gitlab/api.rb +16 -0
- 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 +137 -0
- data/lib/gitlab/client/boards.rb +146 -0
- data/lib/gitlab/client/branches.rb +135 -0
- data/lib/gitlab/client/broadcast_messages.rb +75 -0
- data/lib/gitlab/client/build_variables.rb +135 -0
- data/lib/gitlab/client/builds.rb +108 -0
- data/lib/gitlab/client/commits.rb +216 -0
- data/lib/gitlab/client/container_registry.rb +90 -0
- data/lib/gitlab/client/deployments.rb +34 -0
- data/lib/gitlab/client/environments.rb +89 -0
- 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 +526 -0
- data/lib/gitlab/client/issue_links.rb +48 -0
- data/lib/gitlab/client/issues.rb +242 -0
- data/lib/gitlab/client/jobs.rb +250 -0
- data/lib/gitlab/client/keys.rb +29 -0
- data/lib/gitlab/client/labels.rb +88 -0
- 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 +415 -0
- data/lib/gitlab/client/merge_trains.rb +55 -0
- data/lib/gitlab/client/milestones.rb +106 -0
- data/lib/gitlab/client/namespaces.rb +22 -0
- data/lib/gitlab/client/notes.rb +313 -0
- data/lib/gitlab/client/packages.rb +95 -0
- data/lib/gitlab/client/pipeline_schedules.rb +159 -0
- data/lib/gitlab/client/pipeline_triggers.rb +103 -0
- data/lib/gitlab/client/pipelines.rb +130 -0
- 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 +792 -0
- data/lib/gitlab/client/protected_tags.rb +59 -0
- data/lib/gitlab/client/remote_mirrors.rb +90 -0
- data/lib/gitlab/client/repositories.rb +130 -0
- data/lib/gitlab/client/repository_files.rb +131 -0
- 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 +278 -0
- data/lib/gitlab/client/search.rb +66 -0
- data/lib/gitlab/client/services.rb +53 -0
- data/lib/gitlab/client/sidekiq.rb +39 -0
- data/lib/gitlab/client/snippets.rb +95 -0
- data/lib/gitlab/client/system_hooks.rb +64 -0
- data/lib/gitlab/client/tags.rb +97 -0
- data/lib/gitlab/client/templates.rb +100 -0
- data/lib/gitlab/client/todos.rb +46 -0
- data/lib/gitlab/client/user_snippets.rb +114 -0
- data/lib/gitlab/client/users.rb +521 -0
- data/lib/gitlab/client/versions.rb +18 -0
- data/lib/gitlab/client/wikis.rb +79 -0
- data/lib/gitlab/client.rb +96 -0
- data/lib/gitlab/configuration.rb +36 -0
- data/lib/gitlab/error.rb +114 -0
- data/lib/gitlab/file_response.rb +43 -0
- data/lib/gitlab/headers/page_links.rb +32 -0
- data/lib/gitlab/headers/total.rb +24 -0
- data/lib/gitlab/objectified_hash.rb +44 -0
- data/lib/gitlab/paginated_response.rb +114 -0
- data/lib/gitlab/request.rb +144 -0
- data/lib/gitlab/version.rb +5 -0
- data/lib/gitlab.rb +36 -0
- metadata +156 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Gitlab::Client
|
|
4
|
+
# Defines methods related to pipeline schedules.
|
|
5
|
+
# @see https://docs.gitlab.com/ce/api/pipeline_schedules.html
|
|
6
|
+
module PipelineSchedules
|
|
7
|
+
# Gets a list of project pipeline schedules.
|
|
8
|
+
#
|
|
9
|
+
# @example
|
|
10
|
+
# Gitlab.pipeline_schedules(5)
|
|
11
|
+
# Gitlab.pipeline_schedules(5, { scope: 'active' })
|
|
12
|
+
#
|
|
13
|
+
# @param [Integer, String] project the ID or name of a project.
|
|
14
|
+
# @param [Hash] options A customizable set of options.
|
|
15
|
+
# @options options [String] :scope The scope of pipeline schedules, one of a 'active' or 'inactive'.
|
|
16
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
17
|
+
def pipeline_schedules(project, options = {})
|
|
18
|
+
get("/projects/#{url_encode project}/pipeline_schedules", query: options)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Gets a single pipeline schedule.
|
|
22
|
+
#
|
|
23
|
+
# @example
|
|
24
|
+
# Gitlab.pipeline_schedule(5, 3)
|
|
25
|
+
#
|
|
26
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
27
|
+
# @param [Integer] id The ID of the pipeline schedule.
|
|
28
|
+
# @return [Gitlab::ObjectifiedHash]
|
|
29
|
+
def pipeline_schedule(project, id)
|
|
30
|
+
get("/projects/#{url_encode project}/pipeline_schedules/#{id}")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# 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
|
+
|
|
45
|
+
# Create a pipeline schedule.
|
|
46
|
+
#
|
|
47
|
+
# @example
|
|
48
|
+
# Gitlab.create_pipeline_schedule(5, { description: 'example' })
|
|
49
|
+
#
|
|
50
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
51
|
+
# @param [Hash] options A customizable set of options.
|
|
52
|
+
# @option options [String] :description The description of pipeline scehdule.
|
|
53
|
+
# @option options [String] :ref The branch/tag name will be triggered.
|
|
54
|
+
# @option options [String] :cron The cron (e.g. 0 1 * * *).
|
|
55
|
+
# @option options [String] :cron_timezone The timezone supproted by ActiveSupport::TimeZone (e.g. Pacific Time (US & Canada)) (default: 'UTC').
|
|
56
|
+
# @option options [Boolean] :active The activation of pipeline schedule. If false is set, the pipeline schedule will deactivated initially (default: true).
|
|
57
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
58
|
+
def create_pipeline_schedule(project, options = {})
|
|
59
|
+
post("/projects/#{url_encode project}/pipeline_schedules", body: options)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Updates the pipeline schedule of a project.
|
|
63
|
+
#
|
|
64
|
+
# @example
|
|
65
|
+
# Gitlab.edit_pipeline_schedule(3, 2, { description: 'example2' })
|
|
66
|
+
#
|
|
67
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
68
|
+
# @param [Integer] The pipeline schedule ID.
|
|
69
|
+
# @param [Hash] options A customizable set of options.
|
|
70
|
+
# @option options [String] :description The description of pipeline scehdule.
|
|
71
|
+
# @option options [String] :ref The branch/tag name will be triggered.
|
|
72
|
+
# @option options [String] :cron The cron (e.g. 0 1 * * *).
|
|
73
|
+
# @option options [String] :cron_timezone The timezone supproted by ActiveSupport::TimeZone (e.g. Pacific Time (US & Canada)) (default: 'UTC').
|
|
74
|
+
# @option options [Boolean] :active The activation of pipeline schedule. If false is set, the pipeline schedule will deactivated initially (default: true).
|
|
75
|
+
# @return [Array<Gitlab::ObjectifiedHash>] The updated pipeline schedule.
|
|
76
|
+
def edit_pipeline_schedule(project, pipeline_schedule_id, options = {})
|
|
77
|
+
put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}", body: options)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Take ownership of a pipeline schedule.
|
|
81
|
+
#
|
|
82
|
+
# @example
|
|
83
|
+
# Gitlab.pipeline_schedule_take_ownership(5, 1)
|
|
84
|
+
#
|
|
85
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
86
|
+
# @param [Integer] trigger_id The pipeline schedule ID.
|
|
87
|
+
# @return [Gitlab::ObjectifiedHash] The updated pipeline schedule.
|
|
88
|
+
def pipeline_schedule_take_ownership(project, pipeline_schedule_id)
|
|
89
|
+
post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/take_ownership")
|
|
90
|
+
end
|
|
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
|
+
|
|
104
|
+
# Delete a pipeline schedule.
|
|
105
|
+
#
|
|
106
|
+
# @example
|
|
107
|
+
# Gitlab.delete_pipeline_schedule(5, 1)
|
|
108
|
+
#
|
|
109
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
110
|
+
# @param [Integer] trigger_id The pipeline schedule ID.
|
|
111
|
+
# @return [Gitlab::ObjectifiedHash] The deleted pipeline schedule.
|
|
112
|
+
def delete_pipeline_schedule(project, pipeline_schedule_id)
|
|
113
|
+
delete("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}")
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Create a pipeline schedule variable.
|
|
117
|
+
#
|
|
118
|
+
# @example
|
|
119
|
+
# Gitlab.create_pipeline_schedule_variable(5, 1, { key: 'foo', value: 'bar' })
|
|
120
|
+
#
|
|
121
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
122
|
+
# @param [Integer] trigger_id The pipeline schedule ID.
|
|
123
|
+
# @param [Hash] options A customizable set of options.
|
|
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.
|
|
125
|
+
# @option options [String] :value The value of a variable
|
|
126
|
+
# @return [Array<Gitlab::ObjectifiedHash>] The created pipeline schedule variable.
|
|
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)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# Updates the variable of a pipeline schedule.
|
|
132
|
+
#
|
|
133
|
+
# @example
|
|
134
|
+
# Gitlab.edit_pipeline_schedule_variable(3, 2, "foo" { value: 'bar' })
|
|
135
|
+
#
|
|
136
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
137
|
+
# @param [Integer] The pipeline schedule ID.
|
|
138
|
+
# @param [String] The key of a variable.
|
|
139
|
+
# @param [Hash] options A customizable set of options.
|
|
140
|
+
# @option options [String] :value The value of a variable.
|
|
141
|
+
# @return [Array<Gitlab::ObjectifiedHash>] The updated pipeline schedule variable.
|
|
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)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Delete the variable of a pipeline schedule
|
|
147
|
+
#
|
|
148
|
+
# @example
|
|
149
|
+
# Gitlab.delete_pipeline_schedule_variable(3, 2, "foo")
|
|
150
|
+
#
|
|
151
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
152
|
+
# @param [Integer] The pipeline schedule ID.
|
|
153
|
+
# @param [String] The key of a variable.
|
|
154
|
+
# @return [Array<Gitlab::ObjectifiedHash>] The deleted pipeline schedule variable.
|
|
155
|
+
def delete_pipeline_schedule_variable(project, pipeline_schedule_id, key, _options = {})
|
|
156
|
+
delete("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables/#{url_encode key}")
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Gitlab::Client
|
|
4
|
+
# Defines methods related to pipelines.
|
|
5
|
+
# @see https://docs.gitlab.com/ce/api/pipeline_triggers.html
|
|
6
|
+
# @see https://docs.gitlab.com/ce/ci/triggers/README.html
|
|
7
|
+
module PipelineTriggers
|
|
8
|
+
# Gets a list of the project's pipeline triggers
|
|
9
|
+
#
|
|
10
|
+
# @example
|
|
11
|
+
# Gitlab.triggers(5)
|
|
12
|
+
#
|
|
13
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
14
|
+
# @return [Array<Gitlab::ObjectifiedHash>] The list of triggers.
|
|
15
|
+
def triggers(project)
|
|
16
|
+
get("/projects/#{url_encode project}/triggers")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Gets details of project's pipeline trigger.
|
|
20
|
+
#
|
|
21
|
+
# @example
|
|
22
|
+
# Gitlab.trigger(5, 1)
|
|
23
|
+
#
|
|
24
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
25
|
+
# @param [Integer] trigger_id The trigger ID.
|
|
26
|
+
# @return [Gitlab::ObjectifiedHash] The trigger.
|
|
27
|
+
def trigger(project, trigger_id)
|
|
28
|
+
get("/projects/#{url_encode project}/triggers/#{trigger_id}")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Create a pipeline trigger for a project.
|
|
32
|
+
#
|
|
33
|
+
# @example
|
|
34
|
+
# Gitlab.create_trigger(5, description: "my description")
|
|
35
|
+
#
|
|
36
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
37
|
+
# @param [String] description The trigger name
|
|
38
|
+
# @return [Gitlab::ObjectifiedHash] The created trigger.
|
|
39
|
+
def create_trigger(project, description)
|
|
40
|
+
post("/projects/#{url_encode project}/triggers", body: { description: description })
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Update a project trigger
|
|
44
|
+
#
|
|
45
|
+
# @example
|
|
46
|
+
# Gitlab.update_trigger(5, 1, description: "my description")
|
|
47
|
+
#
|
|
48
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
49
|
+
# @param [Integer] trigger_id The trigger ID.
|
|
50
|
+
# @param [Hash] options A customizable set of options.
|
|
51
|
+
# @option options [String] :description The trigger name.
|
|
52
|
+
# @return [Gitlab::ObjectifiedHash] The updated trigger.
|
|
53
|
+
def update_trigger(project, trigger_id, options = {})
|
|
54
|
+
put("/projects/#{url_encode project}/triggers/#{trigger_id}", body: options)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Take ownership of a project trigger
|
|
58
|
+
#
|
|
59
|
+
# @example
|
|
60
|
+
# Gitlab.trigger_take_ownership(5, 1)
|
|
61
|
+
#
|
|
62
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
63
|
+
# @param [Integer] trigger_id The trigger ID.
|
|
64
|
+
# @return [Gitlab::ObjectifiedHash] The updated trigger.
|
|
65
|
+
def trigger_take_ownership(project, trigger_id)
|
|
66
|
+
post("/projects/#{url_encode project}/triggers/#{trigger_id}/take_ownership")
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Remove a project's pipeline trigger.
|
|
70
|
+
#
|
|
71
|
+
# @example
|
|
72
|
+
# Gitlab.remove_trigger(5, 1)
|
|
73
|
+
#
|
|
74
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
75
|
+
# @param [Integer] trigger_id The trigger ID.
|
|
76
|
+
# @return [void] This API call returns an empty response body.
|
|
77
|
+
def remove_trigger(project, trigger_id)
|
|
78
|
+
delete("/projects/#{url_encode project}/triggers/#{trigger_id}")
|
|
79
|
+
end
|
|
80
|
+
alias delete_trigger remove_trigger
|
|
81
|
+
|
|
82
|
+
# Run the given project pipeline trigger.
|
|
83
|
+
#
|
|
84
|
+
# @example
|
|
85
|
+
# Gitlab.run_trigger(5, '7b9148c158980bbd9bcea92c17522d', 'master')
|
|
86
|
+
# Gitlab.run_trigger(5, '7b9148c158980bbd9bcea92c17522d', 'master', { variable1: "value", variable2: "value2" })
|
|
87
|
+
#
|
|
88
|
+
# @see https://docs.gitlab.com/ce/ci/triggers/README.html
|
|
89
|
+
#
|
|
90
|
+
# @param [Integer, String] project The ID or name of the project.
|
|
91
|
+
# @param [String] token The token of a trigger.
|
|
92
|
+
# @param [String] ref Branch or tag name to build.
|
|
93
|
+
# @param [Hash] variables A set of build variables to use for the build. (optional)
|
|
94
|
+
# @return [Gitlab::ObjectifiedHash] The trigger.
|
|
95
|
+
def run_trigger(project, token, ref, variables = {})
|
|
96
|
+
post("/projects/#{url_encode project}/trigger/pipeline", unauthenticated: true, body: {
|
|
97
|
+
token: token,
|
|
98
|
+
ref: ref,
|
|
99
|
+
variables: variables
|
|
100
|
+
})
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Gitlab::Client
|
|
4
|
+
# Defines methods related to pipelines.
|
|
5
|
+
# @see https://docs.gitlab.com/ce/api/pipelines.html
|
|
6
|
+
module Pipelines
|
|
7
|
+
# Gets a list of project pipelines.
|
|
8
|
+
#
|
|
9
|
+
# @example
|
|
10
|
+
# Gitlab.pipelines(5)
|
|
11
|
+
# Gitlab.pipelines(5, { per_page: 10, page: 2 })
|
|
12
|
+
#
|
|
13
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
14
|
+
# @param [Hash] options A customizable set of options.
|
|
15
|
+
# @option options [Integer] :page The page number.
|
|
16
|
+
# @option options [Integer] :per_page The number of results per page.
|
|
17
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
18
|
+
def pipelines(project, options = {})
|
|
19
|
+
get("/projects/#{url_encode project}/pipelines", query: options)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Gets a single pipeline.
|
|
23
|
+
#
|
|
24
|
+
# @example
|
|
25
|
+
# Gitlab.pipeline(5, 36)
|
|
26
|
+
#
|
|
27
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
28
|
+
# @param [Integer] id The ID of a pipeline.
|
|
29
|
+
# @return [Gitlab::ObjectifiedHash]
|
|
30
|
+
def pipeline(project, id)
|
|
31
|
+
get("/projects/#{url_encode project}/pipelines/#{id}")
|
|
32
|
+
end
|
|
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
|
+
|
|
58
|
+
# Create a pipeline.
|
|
59
|
+
#
|
|
60
|
+
# @example
|
|
61
|
+
# Gitlab.create_pipeline(5, 'master')
|
|
62
|
+
#
|
|
63
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
64
|
+
# @param [String] ref Reference to commit.
|
|
65
|
+
# @param [Hash] variables Variables passed to pipelines
|
|
66
|
+
# @return [Gitlab::ObjectifiedHash] The pipelines changes.
|
|
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
|
+
)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Cancels a pipeline.
|
|
82
|
+
#
|
|
83
|
+
# @example
|
|
84
|
+
# Gitlab.cancel_pipeline(5, 1)
|
|
85
|
+
#
|
|
86
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
87
|
+
# @param [Integer] id The ID of a pipeline.
|
|
88
|
+
# @return [Gitlab::ObjectifiedHash] The pipelines changes.
|
|
89
|
+
def cancel_pipeline(project, id)
|
|
90
|
+
post("/projects/#{url_encode project}/pipelines/#{id}/cancel")
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Retry a pipeline.
|
|
94
|
+
#
|
|
95
|
+
# @example
|
|
96
|
+
# Gitlab.retry_pipeline(5, 1)
|
|
97
|
+
#
|
|
98
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
99
|
+
# @param [Integer] id The ID of a pipeline.
|
|
100
|
+
# @return [Array<Gitlab::ObjectifiedHash>] The pipelines changes.
|
|
101
|
+
def retry_pipeline(project, id)
|
|
102
|
+
post("/projects/#{url_encode project}/pipelines/#{id}/retry")
|
|
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
|
|
129
|
+
end
|
|
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
|