summaryrefslogtreecommitdiff
path: root/lib/api/services.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-10-29 16:39:46 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-10-29 16:39:46 +0200
commitd636ad49bfba59499e45b445ca7e137e83613d8b (patch)
tree4f825ec920e898f2749c144992eff903887cc763 /lib/api/services.rb
parentd71914ca230ce83fe1d908d31fb11667a9539304 (diff)
downloadgitlab-ce-d636ad49bfba59499e45b445ca7e137e83613d8b.tar.gz
API: set gitlab-ci service for project
Diffstat (limited to 'lib/api/services.rb')
-rw-r--r--lib/api/services.rb40
1 files changed, 40 insertions, 0 deletions
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
+