require 'sidekiq/web'
Oss::Application.routes.draw do
  match '*path', to: 'application#options_method_cros', via: :options
  apipie
  get "/become/:id", to: "application#become", as: :become_user
  get "/assume/:id", to: "application#assume", as: :assume_user
  get "/esim_response", to: "application#esim_response", as: :esim_response
  get "reports/report"
  delete "reports/remove_scheduled"
  get "reports/generate_pdf"
  post 'reports/create'
  post "reports/report"
  get 'reports/change_network/:id', to: 'reports#change_network'
  get '/reports/download_pdf/:id', to: 'reports#download_pdf'
  get '/reports/send_email/:id', to: 'reports#send_email'
  get '/activity_log/index', to: 'activity_log#index'
  get '/activity_log/list_activity', to: 'activity_log#list_activity'
  get '/activity_log/change_network/:id', to: 'activity_log#change_network'
  get '/payment_invoice/download_invoice/:id', to: 'payment_invoice#download_invoice'
  get "/sign_out_from_token_user", to: "application#sign_out_from_token_user", as: :sign_out_from_token_user
  # horst routes start
  mount Sidekiq::Web, at: '/sidekiq'
  resources :visitor_details do
    resources :visitor_timings
    collection do
      post :save_data
      get :save_data
      get :visitors_bar_chart
      get :dashboard
      post :dashboard
      get :store_hour_optimization
      post :store_hour_optimization
      get :visitors_unique_return
      get :avg_time_spend
    end
  end
  
  resources :init_templates

  resources :articles do
    resources :comments
  end
  # horst routes end
  
  resources :commands do
    member do 
      get :showing_status
    end
  end

  resources :upgrades
    resources :client_devices do
      collection do
        get 'client_details'
        post :save_client
      end
    end

  resources :v_lans

  resources :snmp_configs do 
    collection do 
      get :showing_tag
    end
  end
  get 'snmp_configs/change_network/:id', to: 'snmp_configs#change_network'


  resources :portforwarding_groups do
    collection do
      get :showing_tag
    end
  end

  resources :acl_groups do
    collection do
      get :showing_tag
      get :save_node_data
      get :clone_acl
    end
  end

  resources :integration_types do
    collection do
      get :get_zones
      get :get_domains
    end 
  end

  resources :static_routes do
    collection do
      get :showing_tag
      get :save_node_data
    end
  end

  resources :sqms do 
    collection do 
      get :showing_tag
    end
  end
  get 'sqms/change_network/:id', to: 'sqms#change_network'

  resources :non_provisioning, only: [:index]
  get 'static_routes/change_network/:id', to: 'static_routes#change_network'
  # get 'tags/:tag', to: 'inventory#form', as: :tag


  get 'apis/storehouroptimization'
  get 'apis/storefrontconversion'
  get 'apis/customer_recency'
  get 'apis/ap_status'

  get "radius_configurations/index"
  post "radius_configurations/create"
  get "radius_configurations/delete"
  post "radius_configurations/updat"
  get 'radius_configurations/change_network/:id', to: 'radius_configurations#change_network'
  

  devise_for :users, controllers: { registrations: "registrations" ,confirmations: "confirmations",sessions: "sessions"}
  # The priority is based upon order of creation: first created -> highest priority.
  # See how all your routes lay out with "rake routes".

  # You can have the root of your site routed with "root"

  #post 'inventory#change_network'
  resources :home do
    collection do 
      get 'configure'
      get 'verify_mac_id'
      get 'verify_network_name'
      get 'network_list'
      post 'bulk_update'
      get 'showing_tag'
  end


    resources :access_points do
      collection do 
        get :access_point
      end
    end

    resources :configuration do
      member do 
        get :change_ssid_state
      end
      collection do
        post :verify_ip
        put :bulk_update
      end
    end

    resources :wired_configs 
  end

  
  # match 'inventory/client_show/:nas_id/:mac_id', :controller => 'inventory', :action => 'client_show', :via => :get
  get 'configuration/ap_diagonstic' ,to: 'configuration#ap_diagonstic'
  get 'wired_configs/get_vlan_id' ,to: 'wired_configs#get_vlan_id'
  get 'configuration/get_ap_ssid' ,to: 'configuration#get_ap_ssid'
  get 'configuration/initiate_trace' ,to: 'configuration#initiate_trace'
  get 'download_trace/:uuid/:mac_id' ,to: 'configuration#download_trace'
  get 'configuration/change_network/:id', to: 'configuration#change_network'
  get 'integration_types/change_network/:id', to: 'integration_types#change_network'
  get 'inventory/change_network/:id', to: 'inventory#change_network'
  get "access_points/access_point"
  get '/access_points/change_network/:id', to: 'access_points#change_network'
  get '/visitor_details/change_network/:id', to: 'visitor_details#change_network'
  get 'inventory/live_connectivity', to: 'inventory#uptime_slots'
  get 'inventory/ap_details', to: 'inventory#ap_details'

  

  get "clients/clients_upload_download"
  # get "clients/client_show"

  get '/clients/client_show/:mac_id(/:nas_id)', to: 'clients#client_show'
  get '/clients/change_network/:id', to: 'clients#change_network'

  resources :inventory do 
    collection do 
      post 'bulk_update'
      get :show_enable_disable
      get :network_show
      get :showing_tag
      get :eathernet_traffic    
      get :get_states
      get :vpn_config
      get :enable_disable_vpn
      post :create_update_vpn
      get :device_details
      get :clone_vpn
    end
    member do
      get :past_report      
      get :get_ssids    
      post :save_lat_lng      
      post :reboot
    end
  end

  resources :assume_user_details do
    member do
      get :sessions_list
      delete :expire_token
    end
    collection do
      post :generate_token
      post :verify_token_details
      get :assume_user
    end
  end
  resources :radius_configurations
  
  #Monitoring dashboard routes
  get "monitoring/dashboard", to: 'monitoring#dashboard'
  get 'monitoring/change_network/:id', to: 'monitoring#change_network'
  get 'logging/change_network/:id', to: 'logging#change_network'
  get "monitoring/dashboard/refresh", to: 'monitoring#dashboard_refresh'
  get "monitoring/dashboard/fetch_history_data", to: 'monitoring#fetch_history_data'
  get "monitoring/AIOPS/:dashboard_name", to: 'monitoring#intelligence', as: :monitoring_aiops
  get "monitoring/dashboard/fetch_realtime_throughput_data", to: 'monitoring#fetch_realtime_throughput_data'

  resources :alerts do
    collection do
      get :notifications
      get :notification_list
      get :notification_group
      put :create_update_notification_group
      delete :delete_notification_group
      get :header_notification_list
      get :read_all_message
      get :test_webhook_event
    end
    member do
      get :read_message
    end
  end
  get 'alerts/change_network/:id', to: 'alerts#change_network'

  resources :ntp_servers
  get 'ntp_servers/change_network/:id', to: 'ntp_servers#change_network'
  
  resources :radio_profiles, :except => :show
   get 'radio_profiles/change_network/:id', to: 'radio_profiles#change_network'

  resources :air_quality_config

  namespace :admin do
      get 'assume_users'
      get 'approve_user'
      get 'all_inventories'

    resources :users do
      collection do
         get :email_exist
         get :user_setting
         post :update_user_setting
      end
      end
    get 'write_to_file/:input',to: 'users#write_to_file'

    resources :upgrade_datas do
      collection do
        get 'change_release_state'
      end
    end  

    resources :sim_managements    

    resources :master_inventory ,:only => [:index,:destroy]  do
      collection do 
	      post :bulk_update 
        get 'show_all' 
        get :default_wpa_password
        post :default_wpa_password
      end
      get :change_router_presence
      get 'show_all' 
    end
  end
  

  namespace :api, :defaults => {:format => :json} do
    namespace :v1 do
      namespace :admin do
        resources :machine_tokens 
      end
      resources :access_points do
        collection do
          put :apply_configuration
          post :provisioning
          get :list_inventory
        end
      end
      resources :network_ssids do
        collection do
          get :list_network_ssids
          put :update_network_ssid
        end
      end
      resources :location_networks do
        member do
          get 'devices', to: 'location_networks#get_network_devices'
        end
        collection do
          get :list_networks
          get :list_network_timezone
        end
      end
      resources :init_templates, :except => [:show] do
        collection do
          get :list_init_templates 
        end
      end
      resources :ap_metadata, :only => [:create]

      post 'master_inventory/add_devices', to: 'provisioning_aps#create_master_inventory'
      get 'devices/enable_telemetry', to: 'provisioning_aps#enable_telemetry'
    end

    namespace :v2 do
      get 'presence/storehouroptimization'
      get 'presence/customer_recency'
      get 'presence/storefrontconversion'
      get 'presence/ppl_bfr_afr_xmin'
      get 'presence/ppl_cnt_lyty_vsts'
    end
  end
  resources :firewall_config 
  get 'firewall_config/change_network/:id', to: 'firewall_config#change_network'

  resources :logging do 
    collection do
      get 'change_network'
      get 'updatus_enabled_status'
      get 'get_selected_associated_resources'
      get 'showing_tag'
      get 'filter_event_logging'
      get 'event_logging'
    end
  end
  root 'monitoring#dashboard'

  resources :sim_managements do
    collection do
      get 'get_sim_rate_plan_details'
      get 'change_auto_recharge_state'
      get 'download_csv'
    end
  end  

  post "purchase_orders/new"
  
  resources :purchase_orders do
    collection do
      get 'purchase_plan'
      get 'get_sim_rate_plan_details'
      post 'change_plan'
    end
  end 
  resources :payment_invoice do
    collection do
      get 'billings'
      get 'invoice'
      post 'make_payment'
      get 'make_payment'
      get 'activated_plans'
      post 'activated_plans'
      get 'download_invoice'
    end
  end 

  resources :sim_rate_plans do
    collection do
      get 'get_rate_plans'
      post 'get_rate_plans'
    end
  end 


  resources :organisation do
    collection do 
      get 'change_enable_state'
      get 'domain_exist'
      get 'live_domain_exist'
    end
  end 
  get 'settings' ,to: 'organisation#settings'
  get 'org_edit' ,to: 'organisation#org_edit'
  get "api/v1/organisations/search", to: "organisation#search"

  resources :switch_configurations do 
    collection do 
      get :get_switches_by_model
    end
  end

  resources :switch_port_configurations
  #API
  devise_scope :user do
    post "/api/v1/users/sign_in" => "sessions#create"
  end
  namespace :api, :defaults => {:format => :json} do
    namespace :v1 do
      post 'clone_network' => 'location_networks#create'
      put '/network_ssids' => 'network_ssids#update_network_ssid'
      post '/location_networks/:network_id/network_ssids' => 'network_ssids#create'
      post '/location_networks/:network_id/config_rollback' => 'location_networks#config_rollback'
#      get 'network_ssids' => 'network_ssids#list_network_ssids'
      get '/inventory/list' => 'access_points#list_inventory'
      
      post '/inventory/release_devices' => 'access_points#release_devices'
      post '/inventory/remove_devices' => 'access_points#remove_devices'
      post '/inventory/move_devices' => 'access_points#move_devices'
      get '/inventory/devices_from_serial' => 'access_points#get_devices_from_serial'

      get '/inventory/:mac_id/details' => 'access_points#list_inventory'
      get '/inventory/:mac_id/current_status' => 'access_points#current_status'
      post '/location_networks/:network_id/device_provision' => 'access_points#provisioning'
      get '/init_templates/list' => 'init_templates#list_init_templates'
      get '/init_templates/:init_template_id/details' => 'init_templates#list_init_templates'
    end
  end
  #JSON API routes
  scope(:path => '/api/v1/') do
    # the rest of your routes go here
    post 'client_devices/:client_action' => 'client_devices#client_actions', as: :client_device_actions, format: :json
    post 'inventory/' => 'inventory#create', format: :json
    put 'inventory/:id' => 'inventory#update', format: :json
    get 'inventory/:mac/connectivity_status' => 'inventory#uptime_slots', format: :json
    get 'query/:query_for/:query_type', to: 'monitoring#query', format: :json
    post 'query/:query_for/:query_type', to: 'monitoring#query', format: :json
    #get 'location_networks/:network_id/live_metrics' => 'monitoring#dashboard_refresh', format: :json
    #get "location_networks/:network_id/history_metrics", to: 'monitoring#fetch_history_data'
    get "inventory/:ap_mac/history_metrics", to: 'monitoring#fetch_history_data'
    get 'events/log' => 'logging#filter_event_logging'
    post 'inventory/:id/reboot' => 'inventory#reboot', format: :json
    resources :acl_groups, controller: :acl_groups, only: [:create, :update, :show, :index, :destroy], format: :json
    resources :upgrades, controller: :upgrades, only: [:create, :update, :show, :index, :destroy], format: :json
    get 'acl_groups/clone_acl/:id' => 'acl_groups#clone_acl'
    namespace :admin do
      get 'users/get_current_user' => 'users#get_current_user', format: :json
      resources :users, controller: :users, only: [:create, :update, :show, :index, :destroy], format: :json
    end
    put 'notification_groups/:notification_group_id' => 'alerts#create_update_notification_group', format: :json
    post 'notification_groups' => 'alerts#create_update_notification_group', format: :json
    delete 'notification_groups/:notification_group_id' => 'alerts#delete_notification_group', format: :json
    get 'notification_groups' => 'alerts#notification_group', format: :json
    get 'alerts/notification_group' => 'alerts#notification_group', format: :json
    get 'alerts/notifications' => 'alerts#notifications', format: :json
    get 'alerts/notification_list' => 'alerts#notification_list', format: :json
    put 'alerts/create_update_notification_group' => 'alerts#create_update_notification_group', format: :json
    delete 'alerts/delete_notification_group' => 'alerts#delete_notification_group', format: :json
    get 'alerts/:id/test_webhook' => 'alerts#test_webhook_event', format: :json
    scope(:path => 'switch_configuration/:switch_configuration_id/') do  
      resources :switch_port_configurations, controller: :switch_port_configurations, only: [:create, :update, :show, :index, :destroy], format: :json
    end 
    # API URL's Nested under location network
    scope(:path => 'location_networks/:network_id/') do
      get 'live_metrics' => 'monitoring#dashboard_refresh', format: :json
      get "history_metrics", to: 'monitoring#fetch_history_data'
      ############################
      #VLAN API
      resources :vlans, controller: :v_lans, only: [:create, :update, :show, :index, :destroy], param: :vlan_id, format: :json
      ############################
      #NTP Configuration API
      get 'ntp_configuration' => 'ntp_servers#index', format: :json
      post 'ntp_configuration' => 'ntp_servers#create', format: :json
      put 'ntp_configuration' => 'ntp_servers#update', format: :json
      delete 'ntp_configuration' => 'ntp_servers#destroy', format: :json
      #############################
      # Wired Configuration
      resources :wired_configurations, controller: :wired_configs, only: [:create, :update, :show, :index, :destroy], format: :json
      resources :logging, controller: :logging, only: [:create, :update, :show, :index, :destroy], format: :json
      resources :switch_configurations, controller: :switch_configurations, only: [:create, :update, :show, :index, :destroy], format: :json
      resources :radio_profiles, controller: :radio_profiles, only: [:create, :update, :show, :index, :destroy], format: :json
    end
  end
end
