Sha256: 9ba7d0a6fe0d746448d7bad26cddbbe3cfb34959792b823de796e3f8da9feee5
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
module Logman class BucketAPI < ConsoleBase get '/api/buckets',:auth=>:user do json @user.buckets end get '/api/buckets/:id',:auth=>:user do json @user.buckets.find(params[:id]) end post '/api/buckets', :auth=> :admin do json = JSON.parse(request.body.read) bucket = Bucket.new(json) if bucket.save json bucket else status 422 bucket.errors.to_json end end put '/api/buckets/:id', :auth=> :admin do if params[:generateToken].blank? == false bucket = Bucket.find(params[:id]) bucket.new_token if bucket bucket.save return json bucket end json = JSON.parse(request.body.read) bucket = Bucket.find(params[:id]) if bucket.update_attributes(json) json bucket else status 422 bucket.errors.to_json end end delete '/api/buckets/:id', :auth=>:admin do bucket = Bucket.find(params[:id]) bucket.destroy if bucket status 200 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
logman-0.0.2 | lib/console/bucket_api.rb |