diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-10-29 16:39:46 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-10-29 16:39:46 +0200 |
commit | d636ad49bfba59499e45b445ca7e137e83613d8b (patch) | |
tree | 4f825ec920e898f2749c144992eff903887cc763 /lib | |
parent | d71914ca230ce83fe1d908d31fb11667a9539304 (diff) | |
download | gitlab-ce-d636ad49bfba59499e45b445ca7e137e83613d8b.tar.gz |
API: set gitlab-ci service for project
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/api.rb | 1 | ||||
-rw-r--r-- | lib/api/deploy_keys.rb | 10 | ||||
-rw-r--r-- | lib/api/services.rb | 40 |
3 files changed, 41 insertions, 10 deletions
diff --git a/lib/api/api.rb b/lib/api/api.rb index c4c9f166db1..4db81f42b4c 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -38,5 +38,6 @@ module API mount ProjectSnippets mount DeployKeys mount ProjectHooks + mount Services end end diff --git a/lib/api/deploy_keys.rb b/lib/api/deploy_keys.rb index 218b3d8eee2..b5997608997 100644 --- a/lib/api/deploy_keys.rb +++ b/lib/api/deploy_keys.rb @@ -5,16 +5,6 @@ module API before { authorize_admin_project } resource :projects do - helpers do - def handle_project_member_errors(errors) - if errors[:project_access].any? - error!(errors[:project_access], 422) - end - not_found! - end - end - - # Get a specific project's keys # # Example Request: diff --git a/lib/api/services.rb b/lib/api/services.rb new file mode 100644 index 00000000000..d562b9484c5 --- /dev/null +++ b/lib/api/services.rb @@ -0,0 +1,40 @@ +module API + # Projects API + class Services < Grape::API + before { authenticate! } + before { authorize_admin_project } + + resource :projects do + # Set GitLab CI service for project + # + # Parameters: + # token (required) - CI project token + # project_url (required) - CI project url + # + # Example Request: + # PUT /projects/:id/services/gitlab-ci + put ":id/services/gitlab-ci" do + required_attributes! [:token, :project_url] + attrs = attributes_for_keys [:token, :project_url] + user_project.build_missing_services + + if user_project.gitlab_ci_service.update_attributes(attrs.merge(active: true)) + true + else + not_found! + end + end + + # Delete GitLab CI service settings + # + # Example Request: + # DELETE /projects/:id/keys/:id + delete ":id/services/gitlab-ci" do + if user_project.gitlab_ci_service + user_project.gitlab_ci_service.destroy + end + end + end + end +end + |