summaryrefslogtreecommitdiff
path: root/lib/api/v3/variables.rb
blob: 0f55a14fb28b2b816d0d99220f5341e1cf9d5604 (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
module API
  module V3
    class Variables < Grape::API
      include PaginationParams

      before { authenticate! }
      before { authorize! :admin_build, user_project }

      params do
        requires :id, type: String, desc: 'The ID of a project'
      end

      resource :projects do
        desc 'Delete an existing variable from a project' do
          success ::API::Entities::Variable
        end
        params do
          requires :key, type: String, desc: 'The key of the variable'
        end
        delete ':id/variables/:key' do
          variable = user_project.variables.find_by(key: params[:key])
          not_found!('Variable') unless variable

          present variable.destroy, with: ::API::Entities::Variable
        end
      end
    end
  end
end