Welcome to mirror list, hosted at ThFree Co, Russian Federation.

services.rb « api « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3ad59cf3adf6ab95629b8fed1aa175f26efafeca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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/services/gitlab-ci
      delete ":id/services/gitlab-ci" do
        if user_project.gitlab_ci_service
          user_project.gitlab_ci_service.update_attributes(
            active: false,
            token: nil,
            project_url: nil
          )
        end
      end

      # Set Hipchat service for project
      #
      # Parameters:
      #   token (required) - Hipchat token
      #   room (required) - Hipchat room name
      #
      # Example Request:
      #   PUT /projects/:id/services/hipchat
      put ':id/services/hipchat' do
        required_attributes! [:token, :room]
        attrs = attributes_for_keys [:token, :room]
        user_project.build_missing_services

        if user_project.hipchat_service.update_attributes(
            attrs.merge(active: true))
          true
        else
          not_found!
        end
      end

      # Delete Hipchat service settings
      #
      # Example Request:
      #   DELETE /projects/:id/services/hipchat
      delete ':id/services/hipchat' do
        if user_project.hipchat_service
          user_project.hipchat_service.update_attributes(
            active: false,
            token: nil,
            room: nil
          )
        end
      end
    end
  end
end