summaryrefslogtreecommitdiff
path: root/lib/api/runners.rb
blob: ee7b343b7480524e6990f96ccc7139e01a43fc3e (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
module API
  # Issues API
  class Runners < Grape::API
    resource :runners do
      before { authenticate_runners!}

      # Register a build by runner
      #
      # Parameters:
      #   token (required) - The uniq token of runner
      #
      # Example Request:
      #   POST /builds/register
      post "register" do
        required_attributes! [:token, :public_key]

        runner = Runner.create(public_key: params[:public_key])

        if runner.id
          present runner, with: Entities::Runner
        else
          not_found!
        end
      end
    end
  end
end