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_custom_attribute(key, value, project_id) ⇒ Gitlab::ObjectifiedHash
Creates a new custom_attribute.
-
#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.
-
#all_members(project, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Gets a list of all project team members including inherited members.
-
#archive_project(id) ⇒ Gitlab::ObjectifiedHash
Archives a project.
-
#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.
-
#create_project_access_token(project, name, scopes, expires_at, options = {}) ⇒ Gitlab::ObjectifiedHash
Creates a new project access token.
-
#delete_deploy_key(project, id) ⇒ Gitlab::ObjectifiedHash
Deletes a deploy key from project.
-
#delete_project(id) ⇒ Gitlab::ObjectifiedHash
Deletes a project.
-
#delete_project_custom_attribute(key, project_id = nil) ⇒ Boolean
Delete custom_attribute Will delete a custom_attribute.
-
#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_deploy_key(project, id, title, options = {}) ⇒ Gitlab::ObjectifiedHash
Updates an existing deploy key.
-
#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, options = {}) ⇒ Gitlab::ObjectifiedHash
Gets information about a project.
-
#project_access_token(project, token_id) ⇒ Gitlab::ObjectifiedHash
Get a specific project access token.
-
#project_access_tokens(project, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
List all project access tokens.
-
#project_custom_attribute(key, project_id) ⇒ Gitlab::ObjectifiedHash
Gets single project custom_attribute.
-
#project_custom_attributes(project_id) ⇒ Gitlab::ObjectifiedHash
Gets project custom_attributes.
-
#project_deploy_tokens(project, options = {}) ⇒ Object
List project deploy tokens.
-
#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_languages(project) ⇒ Gitlab::ObjectifiedHash
Get languages used with percentage value.
-
#project_search(query, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
(also: #search_projects)
Search for projects by name.
-
#project_template(project, type, key, options = {}) ⇒ Gitlab::ObjectifiedHash
Get one project template of a particular type.
-
#project_templates(project, type) ⇒ Array<Gitlab::ObjectifiedHash>
Get all project templates of a particular type.
-
#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.
-
#revoke_project_access_token(project, token_id) ⇒ Gitlab::ObjectifiedHash
Revoke a project access token.
-
#rotate_project_access_token(project, token_id, options = {}) ⇒ Gitlab::ObjectifiedHash
Rotate a project access token.
-
#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.
-
#transfer_project(project, namespace) ⇒ Gitlab::ObjectifiedHash
Transfer a project to a new namespace.
-
#unarchive_project(id) ⇒ Gitlab::ObjectifiedHash
Unarchives a project.
-
#unshare_project_with_group(project, id) ⇒ void
Unshare project with group.
-
#unstar_project(id) ⇒ Gitlab::ObjectifiedHash
Unstars a project.
-
#upload_file(id, file_fullpath) ⇒ 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.
-
#user_starred_projects(user_id, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Get a list of visible projects that the given user has starred.
Instance Method Details
#add_project_custom_attribute(key, value, project_id) ⇒ Gitlab::ObjectifiedHash
Creates a new custom_attribute
683 684 685 686 |
# File 'lib/gitlab/client/projects.rb', line 683 def add_project_custom_attribute(key, value, project_id) url = "/projects/#{project_id}/custom_attributes/#{key}" put(url, body: { value: value }) end |
#add_project_hook(project, url, options = {}) ⇒ Gitlab::ObjectifiedHash
Adds a new hook to the project.
228 229 230 231 |
# File 'lib/gitlab/client/projects.rb', line 228 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.
287 288 289 |
# File 'lib/gitlab/client/projects.rb', line 287 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.
150 151 152 153 |
# File 'lib/gitlab/client/projects.rb', line 150 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 |
#all_members(project, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Gets a list of all project team members including inherited members.
120 121 122 |
# File 'lib/gitlab/client/projects.rb', line 120 def all_members(project, = {}) get("/projects/#{url_encode project}/members/all", query: ) end |
#archive_project(id) ⇒ Gitlab::ObjectifiedHash
Archives a project.
636 637 638 |
# File 'lib/gitlab/client/projects.rb', line 636 def archive_project(id) post("/projects/#{url_encode id}/archive") end |
#create_deploy_key(project, title, key, options = {}) ⇒ Gitlab::ObjectifiedHash
Creates a new deploy key.
378 379 380 |
# File 'lib/gitlab/client/projects.rb', line 378 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.
442 443 444 |
# File 'lib/gitlab/client/projects.rb', line 442 def create_fork(id, = {}) post("/projects/#{url_encode id}/fork", body: ) end |
#create_project(name, options = {}) ⇒ Gitlab::ObjectifiedHash
Creates a new project.
76 77 78 79 |
# File 'lib/gitlab/client/projects.rb', line 76 def create_project(name, = {}) url = [:user_id] ? "/projects/user/#{[:user_id]}" : '/projects' post(url, body: { name: name }.merge()) end |
#create_project_access_token(project, name, scopes, expires_at, options = {}) ⇒ Gitlab::ObjectifiedHash
Creates a new project access token.
761 762 763 |
# File 'lib/gitlab/client/projects.rb', line 761 def create_project_access_token(project, name, scopes, expires_at, = {}) post("/projects/#{url_encode project}/access_tokens", body: { name: name, scopes: scopes, expires_at: expires_at }.merge()) end |
#delete_deploy_key(project, id) ⇒ Gitlab::ObjectifiedHash
Deletes a deploy key from project.
428 429 430 |
# File 'lib/gitlab/client/projects.rb', line 428 def delete_deploy_key(project, id) delete("/projects/#{url_encode project}/deploy_keys/#{id}") end |
#delete_project(id) ⇒ Gitlab::ObjectifiedHash
Deletes a project.
88 89 90 |
# File 'lib/gitlab/client/projects.rb', line 88 def delete_project(id) delete("/projects/#{url_encode id}") end |
#delete_project_custom_attribute(key, project_id = nil) ⇒ Boolean
Delete custom_attribute Will delete a custom_attribute
697 698 699 |
# File 'lib/gitlab/client/projects.rb', line 697 def delete_project_custom_attribute(key, project_id = nil) delete("/projects/#{project_id}/custom_attributes/#{key}") end |
#delete_project_hook(project, id) ⇒ Gitlab::ObjectifiedHash
Deletes a hook from project.
260 261 262 |
# File 'lib/gitlab/client/projects.rb', line 260 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.
314 315 316 |
# File 'lib/gitlab/client/projects.rb', line 314 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.
364 365 366 |
# File 'lib/gitlab/client/projects.rb', line 364 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.
352 353 354 |
# File 'lib/gitlab/client/projects.rb', line 352 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.
402 403 404 |
# File 'lib/gitlab/client/projects.rb', line 402 def disable_deploy_key(project, key) post("/projects/#{url_encode project}/deploy_keys/#{key}/disable", body: { id: project, key_id: key }) end |
#edit_deploy_key(project, id, title, options = {}) ⇒ Gitlab::ObjectifiedHash
Updates an existing deploy key.
416 417 418 |
# File 'lib/gitlab/client/projects.rb', line 416 def edit_deploy_key(project, id, title, = {}) put("/projects/#{url_encode project}/deploy_keys/#{id}", body: { title: title }.merge()) 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)
479 480 481 |
# File 'lib/gitlab/client/projects.rb', line 479 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.
247 248 249 250 |
# File 'lib/gitlab/client/projects.rb', line 247 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.
302 303 304 |
# File 'lib/gitlab/client/projects.rb', line 302 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.
169 170 171 172 |
# File 'lib/gitlab/client/projects.rb', line 169 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.
390 391 392 |
# File 'lib/gitlab/client/projects.rb', line 390 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
326 327 328 |
# File 'lib/gitlab/client/projects.rb', line 326 def make_forked_from(project, id) post("/projects/#{url_encode project}/fork/#{id}") end |
#project(id, options = {}) ⇒ Gitlab::ObjectifiedHash
Gets information about a project.
51 52 53 |
# File 'lib/gitlab/client/projects.rb', line 51 def project(id, = {}) get("/projects/#{url_encode id}", query: ) end |
#project_access_token(project, token_id) ⇒ Gitlab::ObjectifiedHash
Get a specific project access token.
745 746 747 |
# File 'lib/gitlab/client/projects.rb', line 745 def project_access_token(project, token_id) get("/projects/#{url_encode project}/access_tokens/#{token_id}") end |
#project_access_tokens(project, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
List all project access tokens.
732 733 734 |
# File 'lib/gitlab/client/projects.rb', line 732 def project_access_tokens(project, = {}) get("/projects/#{url_encode project}/access_tokens", query: ) end |
#project_custom_attribute(key, project_id) ⇒ Gitlab::ObjectifiedHash
Gets single project custom_attribute.
670 671 672 |
# File 'lib/gitlab/client/projects.rb', line 670 def project_custom_attribute(key, project_id) get("/projects/#{project_id}/custom_attributes/#{key}") end |
#project_custom_attributes(project_id) ⇒ Gitlab::ObjectifiedHash
Gets project custom_attributes.
658 659 660 |
# File 'lib/gitlab/client/projects.rb', line 658 def project_custom_attributes(project_id) get("/projects/#{project_id}/custom_attributes") end |
#project_deploy_tokens(project, options = {}) ⇒ Object
List project deploy tokens
708 709 710 |
# File 'lib/gitlab/client/projects.rb', line 708 def project_deploy_tokens(project, = {}) get("/projects/#{url_encode project}/deploy_tokens", query: ) 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
460 461 462 |
# File 'lib/gitlab/client/projects.rb', line 460 def project_forks(id, = {}) get("/projects/#{url_encode id}/forks", query: ) end |
#project_hook(project, id) ⇒ Gitlab::ObjectifiedHash
Gets a project hook.
211 212 213 |
# File 'lib/gitlab/client/projects.rb', line 211 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.
198 199 200 |
# File 'lib/gitlab/client/projects.rb', line 198 def project_hooks(project, = {}) get("/projects/#{url_encode project}/hooks", query: ) end |
#project_languages(project) ⇒ Gitlab::ObjectifiedHash
Get languages used with percentage value
719 720 721 |
# File 'lib/gitlab/client/projects.rb', line 719 def project_languages(project) get("/projects/#{url_encode project}/languages") 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 |
#project_template(project, type, key, options = {}) ⇒ Gitlab::ObjectifiedHash
Get one project template of a particular type
625 626 627 |
# File 'lib/gitlab/client/projects.rb', line 625 def project_template(project, type, key, = {}) get("/projects/#{url_encode project}/templates/#{type}/#{key}", query: ) end |
#project_templates(project, type) ⇒ Array<Gitlab::ObjectifiedHash>
Get all project templates of a particular type
607 608 609 |
# File 'lib/gitlab/client/projects.rb', line 607 def project_templates(project, type) get("/projects/#{url_encode project}/templates/#{type}") 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.
272 273 274 |
# File 'lib/gitlab/client/projects.rb', line 272 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.
338 339 340 |
# File 'lib/gitlab/client/projects.rb', line 338 def remove_forked(project) delete("/projects/#{url_encode project}/fork") end |
#remove_team_member(project, id) ⇒ Gitlab::ObjectifiedHash
Removes a user from project team.
183 184 185 |
# File 'lib/gitlab/client/projects.rb', line 183 def remove_team_member(project, id) delete("/projects/#{url_encode project}/members/#{id}") end |
#revoke_project_access_token(project, token_id) ⇒ Gitlab::ObjectifiedHash
Revoke a project access token.
788 789 790 |
# File 'lib/gitlab/client/projects.rb', line 788 def revoke_project_access_token(project, token_id) delete("/projects/#{url_encode project}/access_tokens/#{token_id}") end |
#rotate_project_access_token(project, token_id, options = {}) ⇒ Gitlab::ObjectifiedHash
Rotate a project access token.
775 776 777 |
# File 'lib/gitlab/client/projects.rb', line 775 def rotate_project_access_token(project, token_id, = {}) post("/projects/#{url_encode project}/access_tokens/#{token_id}/rotate", query: ) end |
#share_project_with_group(project, id, group_access) ⇒ Object
Share project with group.
491 492 493 |
# File 'lib/gitlab/client/projects.rb', line 491 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.
528 529 530 |
# File 'lib/gitlab/client/projects.rb', line 528 def star_project(id) post("/projects/#{url_encode id}/star") end |
#team_member(project, id) ⇒ Gitlab::ObjectifiedHash
Gets a project team member.
132 133 134 |
# File 'lib/gitlab/client/projects.rb', line 132 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.
104 105 106 |
# File 'lib/gitlab/client/projects.rb', line 104 def team_members(project, = {}) get("/projects/#{url_encode project}/members", query: ) end |
#transfer_project(project, namespace) ⇒ Gitlab::ObjectifiedHash
Transfer a project to a new namespace.
515 516 517 |
# File 'lib/gitlab/client/projects.rb', line 515 def transfer_project(project, namespace) put("/projects/#{url_encode project}/transfer", body: { namespace: namespace }) end |
#unarchive_project(id) ⇒ Gitlab::ObjectifiedHash
Unarchives a project.
647 648 649 |
# File 'lib/gitlab/client/projects.rb', line 647 def unarchive_project(id) post("/projects/#{url_encode id}/unarchive") end |
#unshare_project_with_group(project, id) ⇒ void
This method returns an undefined value.
Unshare project with group.
503 504 505 |
# File 'lib/gitlab/client/projects.rb', line 503 def unshare_project_with_group(project, id) delete("/projects/#{url_encode project}/share/#{id}") end |
#unstar_project(id) ⇒ Gitlab::ObjectifiedHash
Unstars a project.
541 542 543 |
# File 'lib/gitlab/client/projects.rb', line 541 def unstar_project(id) delete("/projects/#{url_encode id}/star") end |
#upload_file(id, file_fullpath) ⇒ Gitlab::ObjectifiedHash
Uploads a file to the specified project to be used in an issue or merge request description, or a comment.
593 594 595 |
# File 'lib/gitlab/client/projects.rb', line 593 def upload_file(id, file_fullpath) post("/projects/#{url_encode id}/uploads", body: { file: File.open(file_fullpath, 'r') }) end |
#user_projects(user_id, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Get a list of visible projects for the given user.
579 580 581 |
# File 'lib/gitlab/client/projects.rb', line 579 def user_projects(user_id, = {}) get("/users/#{url_encode user_id}/projects", query: ) end |
#user_starred_projects(user_id, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Get a list of visible projects that the given user has starred.
560 561 562 |
# File 'lib/gitlab/client/projects.rb', line 560 def user_starred_projects(user_id, = {}) get("/users/#{url_encode user_id}/starred_projects", query: ) end |