2015-03-09 04:31:05 -06:00
|
|
|
FarmBot::Application.routes.draw do
|
2019-04-11 15:03:14 -06:00
|
|
|
namespace :api, defaults: { format: :json }, constraints: { format: "json" } do
|
|
|
|
post "/rmq/user" => "rmq_utils#user_action", as: "rmq_user"
|
|
|
|
post "/rmq/vhost" => "rmq_utils#vhost_action", as: "rmq_vhost"
|
2019-03-07 10:52:01 -07:00
|
|
|
post "/rmq/resource" => "rmq_utils#resource_action", as: "rmq_resource"
|
2019-04-11 15:03:14 -06:00
|
|
|
post "/rmq/topic" => "rmq_utils#topic_action", as: "rmq_topic"
|
2018-06-20 11:42:52 -06:00
|
|
|
|
2018-02-17 11:19:00 -07:00
|
|
|
# Standard API Resources:
|
|
|
|
{
|
2019-04-19 11:56:45 -06:00
|
|
|
alerts: [:create, :destroy, :index],
|
2019-04-11 15:03:14 -06:00
|
|
|
farm_events: [:create, :destroy, :index, :show, :update],
|
|
|
|
farmware_envs: [:create, :destroy, :index, :show, :update],
|
2019-08-14 10:37:44 -06:00
|
|
|
first_party_farmwares: [:show, :index],
|
2019-04-19 00:08:15 -06:00
|
|
|
global_bulletins: [:show],
|
2019-04-11 15:03:14 -06:00
|
|
|
images: [:create, :destroy, :index, :show],
|
|
|
|
password_resets: [:create, :update],
|
|
|
|
peripherals: [:create, :destroy, :index, :show, :update],
|
|
|
|
pin_bindings: [:create, :destroy, :index, :show, :update],
|
|
|
|
plant_templates: [:create, :destroy, :index, :update],
|
2019-09-23 17:34:37 -06:00
|
|
|
point_groups: [:index, :show, :create, :update, :destroy],
|
2019-04-11 15:03:14 -06:00
|
|
|
regimens: [:create, :destroy, :index, :show, :update],
|
|
|
|
sensor_readings: [:create, :destroy, :index, :show],
|
|
|
|
sensors: [:create, :destroy, :index, :show, :update],
|
|
|
|
sequences: [:create, :destroy, :index, :show, :update],
|
|
|
|
tools: [:create, :destroy, :index, :show, :update],
|
|
|
|
webcam_feeds: [:create, :destroy, :index, :show, :update],
|
2019-12-03 10:30:22 -07:00
|
|
|
folders: [:create, :destroy, :index, :show, :update],
|
2018-02-27 12:15:02 -07:00
|
|
|
}.to_a.map { |(name, only)| resources name, only: only }
|
2018-02-17 11:19:00 -07:00
|
|
|
|
|
|
|
# Singular API Resources:
|
|
|
|
{
|
2019-06-18 11:57:55 -06:00
|
|
|
demo_account: [:create],
|
2019-04-11 15:03:14 -06:00
|
|
|
device_cert: [:create],
|
|
|
|
device: [:create, :destroy, :show, :update],
|
|
|
|
fbos_config: [:destroy, :show, :update],
|
|
|
|
firmware_config: [:destroy, :show, :update],
|
|
|
|
public_key: [:show],
|
|
|
|
tokens: [:create, :show],
|
|
|
|
web_app_config: [:destroy, :show, :update],
|
|
|
|
}.to_a.map { |(name, only)| resource name, only: only }
|
2018-05-04 09:42:51 -06:00
|
|
|
get "/corpus" => "corpuses#show", as: :api_corpus
|
2018-02-17 11:19:00 -07:00
|
|
|
|
2018-04-03 15:49:21 -06:00
|
|
|
resources(:points, except: []) { post :search, on: :collection }
|
2018-03-30 13:56:21 -06:00
|
|
|
|
2019-01-09 12:48:41 -07:00
|
|
|
resources :farmware_installations, except: [:update] do
|
|
|
|
post :refresh, on: :member
|
|
|
|
end
|
|
|
|
|
2018-03-30 13:56:21 -06:00
|
|
|
resources :logs, except: [:update, :show] do
|
2019-01-09 12:48:41 -07:00
|
|
|
# When farmware fetching fails and the user
|
2019-02-19 19:10:08 -07:00
|
|
|
# wants to try again.
|
2018-04-03 15:49:21 -06:00
|
|
|
get :search, on: :collection
|
2017-02-13 15:13:42 -07:00
|
|
|
end
|
2018-02-17 11:52:49 -07:00
|
|
|
|
2018-03-30 13:56:21 -06:00
|
|
|
resource :users, except: [:index] do
|
2017-08-31 13:29:11 -06:00
|
|
|
post :resend_verification, on: :member
|
2018-03-11 18:11:24 -06:00
|
|
|
post :control_certificate, on: :collection
|
2017-08-31 13:29:11 -06:00
|
|
|
end
|
2018-01-08 10:03:18 -07:00
|
|
|
|
2019-04-11 15:03:14 -06:00
|
|
|
resources :saved_gardens, except: [:show] do
|
|
|
|
post :snapshot, on: :collection
|
|
|
|
post :apply, on: :member
|
|
|
|
patch :apply, on: :member
|
2018-04-19 14:37:15 -06:00
|
|
|
end
|
|
|
|
|
2019-04-11 15:03:14 -06:00
|
|
|
get "/global_config" => "global_config#show", as: :global_config
|
|
|
|
get "/device/sync" => "devices#sync", as: :device_sync
|
|
|
|
post "/device/seed" => "devices#seed", as: :device_seed
|
2019-05-02 18:20:22 -06:00
|
|
|
post "/device/reset" => "devices#reset", as: :device_reset
|
2018-03-23 14:16:04 -06:00
|
|
|
|
2017-12-11 14:08:16 -07:00
|
|
|
# Make life easier on API users by not adding special rules for singular
|
2018-01-10 15:28:22 -07:00
|
|
|
# resources.
|
2018-02-17 11:19:00 -07:00
|
|
|
# Might be safe to remove now with the advent of TaggedResource.kind
|
2019-04-11 15:03:14 -06:00
|
|
|
get "/device/:id" => "devices#show", as: :get_device_redirect
|
2018-10-25 10:47:01 -06:00
|
|
|
patch "/device/:id" => "devices#update", as: :patch_device_redirect
|
2019-04-11 15:03:14 -06:00
|
|
|
put "/device/:id" => "devices#update", as: :put_device_redirect
|
2018-10-25 08:50:54 -06:00
|
|
|
|
2018-10-25 12:50:13 -06:00
|
|
|
delete "/fbos_config/:id" => "fbos_configs#destroy", as: "delete_fbos_config_redirect"
|
2019-04-11 15:03:14 -06:00
|
|
|
get "/fbos_config/:id" => "fbos_configs#show", as: "get_fbos_config_redirect"
|
|
|
|
put "/fbos_config/:id" => "fbos_configs#update", as: "put_fbos_config_redirect"
|
2018-10-25 08:50:54 -06:00
|
|
|
|
2018-10-25 12:50:13 -06:00
|
|
|
delete "/firmware_config/:id" => "firmware_configs#destroy", as: "delete_firmware_config_redirect"
|
2019-04-11 15:03:14 -06:00
|
|
|
get "/firmware_config/:id" => "firmware_configs#show", as: "get_firmware_config_redirect"
|
|
|
|
patch "/firmware_config/:id" => "firmware_configs#update", as: "patch_firmware_config_redirect"
|
|
|
|
put "/firmware_config/:id" => "firmware_configs#update", as: "put_firmware_config_redirect"
|
2018-10-25 08:50:54 -06:00
|
|
|
|
2019-04-11 15:03:14 -06:00
|
|
|
delete "/web_app_config/:id" => "web_app_configs#destroy", as: "delete_web_app_config_redirect"
|
|
|
|
get "/web_app_config/:id" => "web_app_configs#show", as: "get_web_app_config_redirect"
|
|
|
|
patch "/web_app_config/:id" => "web_app_configs#update", as: "patch_web_app_config_redirect"
|
|
|
|
put "/web_app_config/:id" => "web_app_configs#update", as: "put_web_app_config_redirect"
|
2018-10-25 08:50:54 -06:00
|
|
|
|
2018-10-25 10:47:01 -06:00
|
|
|
patch "/users/:id" => "users#update", as: :patch_users_redirect
|
2019-04-11 15:03:14 -06:00
|
|
|
put "/users/:id" => "users#update", as: :put_users_redirect
|
2018-10-25 08:50:54 -06:00
|
|
|
|
|
|
|
patch "/webcam_feed/:id" => "webcam_feeds#update", as: :patch_webcam_feed_redirect
|
2019-04-11 15:03:14 -06:00
|
|
|
put "/webcam_feed/:id" => "webcam_feeds#update", as: :put_webcam_feed_redirect
|
2018-10-25 08:50:54 -06:00
|
|
|
|
2019-04-11 15:03:14 -06:00
|
|
|
put "/password_resets" => "password_resets#update", as: :whatever
|
|
|
|
get "/storage_auth" => "images#storage_auth", as: :storage_auth
|
|
|
|
post "/export_data" => "devices#dump", as: :dump_device
|
2014-05-12 08:23:35 -06:00
|
|
|
end
|
|
|
|
|
2016-11-09 15:50:07 -07:00
|
|
|
devise_for :users
|
2016-11-17 07:55:28 -07:00
|
|
|
|
2017-08-10 07:01:36 -06:00
|
|
|
# =======================================================================
|
|
|
|
# NON-API (USER FACING) URLS:
|
|
|
|
# =======================================================================
|
2019-04-11 15:03:14 -06:00
|
|
|
get "/" => "dashboard#front_page", as: :front_page
|
2019-11-23 09:03:04 -07:00
|
|
|
get "/logout" => "dashboard#logout", as: :logout
|
2019-02-06 15:46:19 -07:00
|
|
|
|
2019-04-11 15:03:14 -06:00
|
|
|
get "/app" => "dashboard#main_app", as: :dashboard
|
|
|
|
get "/app/controls" => "dashboard#main_app", as: :app_landing_page
|
2019-06-24 10:36:08 -06:00
|
|
|
get "/app/messages" => "dashboard#main_app", as: :app_message_center
|
2018-02-17 11:19:00 -07:00
|
|
|
match "/app/*path", to: "dashboard#main_app", via: :all, constraints: { format: "html" }
|
2019-02-06 15:46:19 -07:00
|
|
|
|
2019-06-13 18:14:27 -06:00
|
|
|
get "/demo" => "dashboard#demo", as: :demo_main
|
2020-01-28 12:30:04 -07:00
|
|
|
get "/os" => "dashboard#os_download", as: :os_download
|
2019-04-11 15:03:14 -06:00
|
|
|
get "/password_reset/*token" => "dashboard#password_reset", as: :password_reset
|
2019-06-13 18:14:27 -06:00
|
|
|
get "/tos_update" => "dashboard#tos_update", as: :tos_update
|
2019-04-11 15:03:14 -06:00
|
|
|
get "/verify/:token" => "dashboard#confirmation_page", as: :confirmation_page
|
|
|
|
post "/csp_reports" => "dashboard#csp_reports", as: :csp_report
|
|
|
|
post "/direct_upload" => "dashboard#direct_upload", as: :direct_upload
|
2017-03-24 20:15:31 -06:00
|
|
|
end
|