Module: Gitlab::Client::Projects
- Included in:
- Gitlab::Client
- Defined in:
- lib/gitlab/client/projects.rb
Overview
Defines methods related to projects.
Instance Method Summary collapse
-
#add_project_hook(project, url, options = {}) ⇒ Gitlab::ObjectifiedHash
Adds a new hook to the project.
-
#add_push_rule(id, options = {}) ⇒ Gitlab::ObjectifiedHash
Adds a project push rule.
-
#add_team_member(project, id, access_level, options = {}) ⇒ Gitlab::ObjectifiedHash
Adds a user to project team.
-
#create_deploy_key(project, title, key, options = {}) ⇒ Gitlab::ObjectifiedHash
Creates a new deploy key.
-
#create_fork(id, options = {}) ⇒ Gitlab::ObjectifiedHash
Forks a project into the user namespace.
-
#create_project(name, options = {}) ⇒ Gitlab::ObjectifiedHash
Creates a new project.
-
#delete_deploy_key(project, id) ⇒ Gitlab::ObjectifiedHash
Deletes a deploy key from project.
-
#delete_project(id) ⇒ Gitlab::ObjectifiedHash
Deletes a project.
-
#delete_project_hook(project, id) ⇒ Gitlab::ObjectifiedHash
Deletes a hook from project.
-
#delete_push_rule(id) ⇒ Gitlab::ObjectifiedHash
Deletes a push rule from a project.
-
#deploy_key(project, id) ⇒ Gitlab::ObjectifiedHash
Gets a single project deploy key.
-
#deploy_keys(project, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Gets a project deploy keys.
-
#disable_deploy_key(project, key) ⇒ Gitlab::ObjectifiedHash
Disables a deploy key at the project.
-
#edit_project(id, options = {}) ⇒ Gitlab::ObjectifiedHash
Updates an existing project.
-
#edit_project_hook(project, id, url, options = {}) ⇒ Gitlab::ObjectifiedHash
Updates a project hook URL.
-
#edit_push_rule(id, options = {}) ⇒ Gitlab::ObjectifiedHash
Updates a project push rule.
-
#edit_team_member(project, id, access_level, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Updates a team member’s project access level.
-
#enable_deploy_key(project, key) ⇒ Gitlab::ObjectifiedHash
Enables a deploy key at the project.
-
#make_forked_from(project, id) ⇒ Gitlab::ObjectifiedHash
Mark this project as forked from the other.
-
#project(id) ⇒ Gitlab::ObjectifiedHash
Gets information about a project.
-
#project_forks(id, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Get a list of all visible projects across GitLab for the authenticated user.
-
#project_hook(project, id) ⇒ Gitlab::ObjectifiedHash
Gets a project hook.
-
#project_hooks(project, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Gets a list of project hooks.
-
#project_search(query, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
(also: #search_projects)
Search for projects by name.
-
#projects(options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Gets a list of projects owned by the authenticated user.
-
#push_rule(id) ⇒ Gitlab::ObjectifiedHash
Gets a project push rule.
-
#remove_forked(project) ⇒ Gitlab::ObjectifiedHash
Remove a forked_from relationship for a project.
-
#remove_team_member(project, id) ⇒ Gitlab::ObjectifiedHash
Removes a user from project team.
-
#share_project_with_group(project, id, group_access) ⇒ Object
Share project with group.
-
#star_project(id) ⇒ Gitlab::ObjectifiedHash
Stars a project.
-
#team_member(project, id) ⇒ Gitlab::ObjectifiedHash
Gets a project team member.
-
#team_members(project, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Gets a list of project team members.
-
#unshare_project_with_group(project, id) ⇒ void
Unshare project with group.
-
#unstar_project(id) ⇒ Gitlab::ObjectifiedHash
Unstars a project.
-
#upload_file(id, file) ⇒ Gitlab::ObjectifiedHash
Uploads a file to the specified project to be used in an issue or merge request description, or a comment.
-
#user_projects(user_id, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Get a list of visible projects for the given user.
Instance Method Details
#add_project_hook(project, url, options = {}) ⇒ Gitlab::ObjectifiedHash
Adds a new hook to the project.
205 206 207 208 |
# File 'lib/gitlab/client/projects.rb', line 205 def add_project_hook(project, url, = {}) body = { url: url }.merge() post("/projects/#{url_encode project}/hooks", body: body) end |
#add_push_rule(id, options = {}) ⇒ Gitlab::ObjectifiedHash
Adds a project push rule.
264 265 266 |
# File 'lib/gitlab/client/projects.rb', line 264 def add_push_rule(id, = {}) post("/projects/#{url_encode id}/push_rule", body: ) end |
#add_team_member(project, id, access_level, options = {}) ⇒ Gitlab::ObjectifiedHash
Adds a user to project team.
129 130 131 132 |
# File 'lib/gitlab/client/projects.rb', line 129 def add_team_member(project, id, access_level, = {}) body = { user_id: id, access_level: access_level }.merge() post("/projects/#{url_encode project}/members", body: body) end |
#create_deploy_key(project, title, key, options = {}) ⇒ Gitlab::ObjectifiedHash
Creates a new deploy key.
355 356 357 |
# File 'lib/gitlab/client/projects.rb', line 355 def create_deploy_key(project, title, key, = {}) post("/projects/#{url_encode project}/deploy_keys", body: { title: title, key: key }.merge()) end |
#create_fork(id, options = {}) ⇒ Gitlab::ObjectifiedHash
Forks a project into the user namespace.
405 406 407 |
# File 'lib/gitlab/client/projects.rb', line 405 def create_fork(id, = {}) post("/projects/#{url_encode id}/fork", body: ) end |
#create_project(name, options = {}) ⇒ Gitlab::ObjectifiedHash
Creates a new project.
73 74 75 76 |
# File 'lib/gitlab/client/projects.rb', line 73 def create_project(name, = {}) url = [:user_id] ? "/projects/user/#{[:user_id]}" : '/projects' post(url, body: { name: name }.merge()) end |
#delete_deploy_key(project, id) ⇒ Gitlab::ObjectifiedHash
Deletes a deploy key from project.
391 392 393 |
# File 'lib/gitlab/client/projects.rb', line 391 def delete_deploy_key(project, id) delete("/projects/#{url_encode project}/deploy_keys/#{id}") end |
#delete_project(id) ⇒ Gitlab::ObjectifiedHash
Deletes a project.
85 86 87 |
# File 'lib/gitlab/client/projects.rb', line 85 def delete_project(id) delete("/projects/#{url_encode id}") end |
#delete_project_hook(project, id) ⇒ Gitlab::ObjectifiedHash
Deletes a hook from project.
237 238 239 |
# File 'lib/gitlab/client/projects.rb', line 237 def delete_project_hook(project, id) delete("/projects/#{url_encode project}/hooks/#{id}") end |
#delete_push_rule(id) ⇒ Gitlab::ObjectifiedHash
Deletes a push rule from a project.
291 292 293 |
# File 'lib/gitlab/client/projects.rb', line 291 def delete_push_rule(id) delete("/projects/#{url_encode id}/push_rule") end |
#deploy_key(project, id) ⇒ Gitlab::ObjectifiedHash
Gets a single project deploy key.
341 342 343 |
# File 'lib/gitlab/client/projects.rb', line 341 def deploy_key(project, id) get("/projects/#{url_encode project}/deploy_keys/#{id}") end |
#deploy_keys(project, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Gets a project deploy keys.
329 330 331 |
# File 'lib/gitlab/client/projects.rb', line 329 def deploy_keys(project, = {}) get("/projects/#{url_encode project}/deploy_keys", query: ) end |
#disable_deploy_key(project, key) ⇒ Gitlab::ObjectifiedHash
Disables a deploy key at the project.
379 380 381 |
# File 'lib/gitlab/client/projects.rb', line 379 def disable_deploy_key(project, key) post("/projects/#{url_encode project}/deploy_keys/#{key}/disable", body: { id: project, key_id: key }) end |
#edit_project(id, options = {}) ⇒ Gitlab::ObjectifiedHash
Updates an existing project.
(Any provided options will be passed to Gitlab. See Gitlab docs for all valid options)
442 443 444 |
# File 'lib/gitlab/client/projects.rb', line 442 def edit_project(id, = {}) put("/projects/#{url_encode id}", body: ) end |
#edit_project_hook(project, id, url, options = {}) ⇒ Gitlab::ObjectifiedHash
Updates a project hook URL.
224 225 226 227 |
# File 'lib/gitlab/client/projects.rb', line 224 def edit_project_hook(project, id, url, = {}) body = { url: url }.merge() put("/projects/#{url_encode project}/hooks/#{id}", body: body) end |
#edit_push_rule(id, options = {}) ⇒ Gitlab::ObjectifiedHash
Updates a project push rule.
279 280 281 |
# File 'lib/gitlab/client/projects.rb', line 279 def edit_push_rule(id, = {}) put("/projects/#{url_encode id}/push_rule", body: ) end |
#edit_team_member(project, id, access_level, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Updates a team member’s project access level.
146 147 148 149 |
# File 'lib/gitlab/client/projects.rb', line 146 def edit_team_member(project, id, access_level, = {}) body = { access_level: access_level }.merge() put("/projects/#{url_encode project}/members/#{id}", body: body) end |
#enable_deploy_key(project, key) ⇒ Gitlab::ObjectifiedHash
Enables a deploy key at the project.
367 368 369 |
# File 'lib/gitlab/client/projects.rb', line 367 def enable_deploy_key(project, key) post("/projects/#{url_encode project}/deploy_keys/#{key}/enable", body: { id: project, key_id: key }) end |
#make_forked_from(project, id) ⇒ Gitlab::ObjectifiedHash
Mark this project as forked from the other
303 304 305 |
# File 'lib/gitlab/client/projects.rb', line 303 def make_forked_from(project, id) post("/projects/#{url_encode project}/fork/#{id}") end |
#project(id) ⇒ Gitlab::ObjectifiedHash
Gets information about a project.
48 49 50 |
# File 'lib/gitlab/client/projects.rb', line 48 def project(id) get("/projects/#{url_encode id}") end |
#project_forks(id, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Get a list of all visible projects across GitLab for the authenticated user. When accessed without authentication, only public projects are returned.
Note: This feature was introduced in GitLab 10.1
423 424 425 |
# File 'lib/gitlab/client/projects.rb', line 423 def project_forks(id, = {}) get("/projects/#{url_encode id}/forks", query: ) end |
#project_hook(project, id) ⇒ Gitlab::ObjectifiedHash
Gets a project hook.
188 189 190 |
# File 'lib/gitlab/client/projects.rb', line 188 def project_hook(project, id) get("/projects/#{url_encode project}/hooks/#{id}") end |
#project_hooks(project, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Gets a list of project hooks.
175 176 177 |
# File 'lib/gitlab/client/projects.rb', line 175 def project_hooks(project, = {}) get("/projects/#{url_encode project}/hooks", query: ) end |
#project_search(query, options = {}) ⇒ Array<Gitlab::ObjectifiedHash> Also known as: search_projects
Search for projects by name.
35 36 37 |
# File 'lib/gitlab/client/projects.rb', line 35 def project_search(query, = {}) get('/projects', query: .merge(search: query)) end |
#projects(options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Gets a list of projects owned by the authenticated user.
(Any provided options will be passed to Gitlab. See Gitlab docs for all valid options)
18 19 20 |
# File 'lib/gitlab/client/projects.rb', line 18 def projects( = {}) get('/projects', query: ) end |
#push_rule(id) ⇒ Gitlab::ObjectifiedHash
Gets a project push rule.
249 250 251 |
# File 'lib/gitlab/client/projects.rb', line 249 def push_rule(id) get("/projects/#{url_encode id}/push_rule") end |
#remove_forked(project) ⇒ Gitlab::ObjectifiedHash
Remove a forked_from relationship for a project.
315 316 317 |
# File 'lib/gitlab/client/projects.rb', line 315 def remove_forked(project) delete("/projects/#{url_encode project}/fork") end |
#remove_team_member(project, id) ⇒ Gitlab::ObjectifiedHash
Removes a user from project team.
160 161 162 |
# File 'lib/gitlab/client/projects.rb', line 160 def remove_team_member(project, id) delete("/projects/#{url_encode project}/members/#{id}") end |
#share_project_with_group(project, id, group_access) ⇒ Object
Share project with group.
454 455 456 |
# File 'lib/gitlab/client/projects.rb', line 454 def share_project_with_group(project, id, group_access) post("/projects/#{url_encode project}/share", body: { group_id: id, group_access: group_access }) end |
#star_project(id) ⇒ Gitlab::ObjectifiedHash
Stars a project.
479 480 481 |
# File 'lib/gitlab/client/projects.rb', line 479 def star_project(id) post("/projects/#{url_encode id}/star") end |
#team_member(project, id) ⇒ Gitlab::ObjectifiedHash
Gets a project team member.
113 114 115 |
# File 'lib/gitlab/client/projects.rb', line 113 def team_member(project, id) get("/projects/#{url_encode project}/members/#{id}") end |
#team_members(project, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Gets a list of project team members.
101 102 103 |
# File 'lib/gitlab/client/projects.rb', line 101 def team_members(project, = {}) get("/projects/#{url_encode project}/members", query: ) end |
#unshare_project_with_group(project, id) ⇒ void
This method returns an undefined value.
Unshare project with group.
466 467 468 |
# File 'lib/gitlab/client/projects.rb', line 466 def unshare_project_with_group(project, id) delete("/projects/#{url_encode project}/share/#{id}") end |
#unstar_project(id) ⇒ Gitlab::ObjectifiedHash
Unstars a project.
492 493 494 |
# File 'lib/gitlab/client/projects.rb', line 492 def unstar_project(id) delete("/projects/#{url_encode id}/star") end |
#upload_file(id, file) ⇒ Gitlab::ObjectifiedHash
Uploads a file to the specified project to be used in an issue or merge request description, or a comment.
526 527 528 |
# File 'lib/gitlab/client/projects.rb', line 526 def upload_file(id, file) post("/projects/#{url_encode id}/uploads", body: { file: file }) end |
#user_projects(user_id, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Get a list of visible projects for the given user.
511 512 513 |
# File 'lib/gitlab/client/projects.rb', line 511 def user_projects(user_id, = {}) get("/users/#{url_encode user_id}/projects", query: ) end |