Skip to content

Instantly share code, notes, and snippets.

@skierkowski
Created April 29, 2015 22:22
Show Gist options
  • Save skierkowski/e063c801f43d8c155a1f to your computer and use it in GitHub Desktop.
Save skierkowski/e063c801f43d8c155a1f to your computer and use it in GitHub Desktop.
module Ephemeral
module Resources
class Build < Grape::API
def initialize
@builds = {}
end
desc 'Creates a new build'
params do
requires :image, type: String, desc: 'Docker Image ID'
requires :repo, type: String, desc: 'URL of target repository'
requires :build_type, type: String, desc: 'Middle ware'
end
post do
build_model = Ephemeral::Models::Build.new(params)
build_model.status = :queued
@builds[build_model.id] = build_model
data = Ephemeral::Entities::Build.represent(build_model)
Ephemeral::Worker.perform_async data
data
end
put do
id = params[:id]
build_model = @builds[id]
build_model.update(params) # this likely does not work
@builds[build_model.id] = build_model
data = Ephemeral::Entities::Build.represent(build_model)
data
end
get do
id = params[:id]
build_model = @builds[id]
data = Ephemeral::Entities::Build.represent(build_model)
data
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment