Example of newt-like routes for rails

Just in case this might be helpful to someone, here's the entire newt
API implemented in non-resource style rails 3 routes (with a slight
modification for authentication). I probably made a few mistakes, but it
should be very close to the original API:

  devise_scope :user do
    # Newt authentication login
    match 'newt/login' => 'devise/sessions#create', :via => :post

    # Newt authentication status
    match 'newt/login' => 'devise/sessions#new', :via => :get

    # Newt authentication logout
    match 'newt/logout' => 'devise/sessions#destroy', :via => :get
  end

  # Newt status for all systems
  match 'newt/status' => 'machines#status_all', :via => :get

  # Newt MOTD
  match 'newt/status/motd' => 'machines#motd', :via => :get

  # Newt system status
  match 'newt/status/:machine' => 'machines#status', :via => :get

  # Newt files directory listing (download file if params[:view] is "read")
  match 'newt/file/:machine/:path' => 'machines#file_info', :via => :get

  # Newt file upload
  match 'newt/file/:machine/:path' => 'machines#upload_file', :via => :post

  # Newt submit a fork job
  match 'newt/job/:machine/fork' => 'machines#submit_fork', :via => :post

  # Newt submit a batch job
  match 'newt/job/:machine/batch' => 'machines#submit_batch', :via => :post

  # Newt query a job
  match 'newt/job/jobs/:job_id' => 'machines#query_job', :via => :get

  # Newt query all jobs
  match 'newt/job/jobs' => 'machines#all_jobs', :via => :get

  # Newt run a command
  match 'newt/command/:machine' => 'machines#run_command', :via => :post

  # Newt view queue
  match 'newt/queue/:machine' => 'machines#queue_job_all', :via => :get

  # Newt submit job to queue
  match 'newt/queue/:machine' => 'machines#queue_job_submit', :via => :post

  # Newt view job in queue
  match 'newt/queue/:machine/:job_id' => 'machines#queue_job_query',
:via => :get

  # Newt delete job from queue
  match 'newt/queue/:machine/:job_id' => 'machines#queue_job_delete',
:via => :delete

  # Newt liststore get available stores
  match 'newt/stores' => 'liststores#all', :via => :get

  # Newt liststore create store
  match 'newt/stores' => 'liststores#create', :via => :post

  # Newt liststore update store
  match 'newt/stores/:store_name' => 'liststores#update_store', :via => :put

  # Newt liststore get store contents
  match 'newt/stores/:store_name' => 'liststores#get', :via => :get

  # Newt liststore update document
  match 'newt/stores/:store_name/:document_name' =>
'liststores#update_document', :via => :put

  # Newt liststore get document contents
  match 'newt/stores/:store_name/:document_name' =>
'liststores#get_document', :via => :get

  # Newt account get general user account information
  match 'newt/account/:resource' => 'users#get_account_resource', :via
=> :get

-Jon

Received on Tuesday, 3 April 2012 15:40:58 UTC