From 527f42cca9be042990819a36a28be11ac3601702 Mon Sep 17 00:00:00 2001 From: Jake Spain Date: Tue, 7 Mar 2023 14:26:14 -0500 Subject: [PATCH] Remove api reroute in favor of using versioned api directly --- lib/vmpooler/api.rb | 3 +- lib/vmpooler/api/reroute.rb | 89 ------------------------------------- 2 files changed, 1 insertion(+), 91 deletions(-) delete mode 100644 lib/vmpooler/api/reroute.rb diff --git a/lib/vmpooler/api.rb b/lib/vmpooler/api.rb index 1d0dce8..3b0d9de 100644 --- a/lib/vmpooler/api.rb +++ b/lib/vmpooler/api.rb @@ -3,7 +3,7 @@ module Vmpooler class API < Sinatra::Base # Load API components - %w[helpers dashboard reroute v3 request_logger healthcheck].each do |lib| + %w[helpers dashboard v3 request_logger healthcheck].each do |lib| require "vmpooler/api/#{lib}" end # Load dashboard components @@ -52,7 +52,6 @@ module Vmpooler use Vmpooler::Dashboard use Vmpooler::API::Dashboard - use Vmpooler::API::Reroute use Vmpooler::API::V3 end diff --git a/lib/vmpooler/api/reroute.rb b/lib/vmpooler/api/reroute.rb deleted file mode 100644 index a8c66fa..0000000 --- a/lib/vmpooler/api/reroute.rb +++ /dev/null @@ -1,89 +0,0 @@ -# frozen_string_literal: true - -module Vmpooler - class API - class Reroute < Sinatra::Base - api_version = '1' - - get '/status/?' do - puts "DEPRECATION WARNING a client (#{request.user_agent}) called /status/? and got redirected to api_version=1, this behavior will change in the next major version, please modify the client to use v2 in advance" - call env.merge('PATH_INFO' => "/api/v#{api_version}/status") - end - - get '/summary/?' do - puts "DEPRECATION WARNING a client (#{request.user_agent}) called /summary/? and got redirected to api_version=1, this behavior will change in the next major version, please modify the client to use v2 in advance" - call env.merge('PATH_INFO' => "/api/v#{api_version}/summary") - end - - get '/summary/:route/?:key?/?' do - puts "DEPRECATION WARNING a client (#{request.user_agent}) called /summary/:route/?:key?/? and got redirected to api_version=1, this behavior will change in the next major version, please modify the client to use v2 in advance" - call env.merge('PATH_INFO' => "/api/v#{api_version}/summary/#{params[:route]}/#{params[:key]}") - end - - get '/token/?' do - puts "DEPRECATION WARNING a client (#{request.user_agent}) called /token/? and got redirected to api_version=1, this behavior will change in the next major version, please modify the client to use v2 in advance" - call env.merge('PATH_INFO' => "/api/v#{api_version}/token") - end - - post '/token/?' do - puts "DEPRECATION WARNING a client (#{request.user_agent}) called post /token/? and got redirected to api_version=1, this behavior will change in the next major version, please modify the client to use v2 in advance" - call env.merge('PATH_INFO' => "/api/v#{api_version}/token") - end - - get '/token/:token/?' do - puts "DEPRECATION WARNING a client (#{request.user_agent}) called /token/:token/? and got redirected to api_version=1, this behavior will change in the next major version, please modify the client to use v2 in advance" - call env.merge('PATH_INFO' => "/api/v#{api_version}/token/#{params[:token]}") - end - - delete '/token/:token/?' do - puts "DEPRECATION WARNING a client (#{request.user_agent}) called delete /token/:token/? and got redirected to api_version=1, this behavior will change in the next major version, please modify the client to use v2 in advance" - call env.merge('PATH_INFO' => "/api/v#{api_version}/token/#{params[:token]}") - end - - get '/vm/?' do - puts "DEPRECATION WARNING a client (#{request.user_agent}) called /vm? and got redirected to api_version=1, this behavior will change in the next major version, please modify the client to use v2 in advance" - call env.merge('PATH_INFO' => "/api/v#{api_version}/vm") - end - - post '/vm/?' do - puts "DEPRECATION WARNING a client (#{request.user_agent}) called post /vm? and got redirected to api_version=1, this behavior will change in the next major version, please modify the client to use v2 in advance" - call env.merge('PATH_INFO' => "/api/v#{api_version}/vm") - end - - post '/vm/:template/?' do - puts "DEPRECATION WARNING a client (#{request.user_agent}) called post /vm/:template/? and got redirected to api_version=1, this behavior will change in the next major version, please modify the client to use v2 in advance" - call env.merge('PATH_INFO' => "/api/v#{api_version}/vm/#{params[:template]}") - end - - get '/vm/:hostname/?' do - puts "DEPRECATION WARNING a client (#{request.user_agent}) called /vm/:hostname/? and got redirected to api_version=1, this behavior will change in the next major version, please modify the client to use v2 in advance" - call env.merge('PATH_INFO' => "/api/v#{api_version}/vm/#{params[:hostname]}") - end - - delete '/vm/:hostname/?' do - puts "DEPRECATION WARNING a client (#{request.user_agent}) called delete /vm/:hostname/? and got redirected to api_version=1, this behavior will change in the next major version, please modify the client to use v2 in advance" - call env.merge('PATH_INFO' => "/api/v#{api_version}/vm/#{params[:hostname]}") - end - - put '/vm/:hostname/?' do - puts "DEPRECATION WARNING a client (#{request.user_agent}) called put /vm/:hostname/? and got redirected to api_version=1, this behavior will change in the next major version, please modify the client to use v2 in advance" - call env.merge('PATH_INFO' => "/api/v#{api_version}/vm/#{params[:hostname]}") - end - - post '/vm/:hostname/snapshot/?' do - puts "DEPRECATION WARNING a client (#{request.user_agent}) called post /vm/:hostname/snapshot/? and got redirected to api_version=1, this behavior will change in the next major version, please modify the client to use v2 in advance" - call env.merge('PATH_INFO' => "/api/v#{api_version}/vm/#{params[:hostname]}/snapshot") - end - - post '/vm/:hostname/snapshot/:snapshot/?' do - puts "DEPRECATION WARNING a client (#{request.user_agent}) called post /vm/:hostname/snapshot/:snapshot/? and got redirected to api_version=1, this behavior will change in the next major version, please modify the client to use v2 in advance" - call env.merge('PATH_INFO' => "/api/v#{api_version}/vm/#{params[:hostname]}/snapshot/#{params[:snapshot]}") - end - - put '/vm/:hostname/disk/:size/?' do - puts "DEPRECATION WARNING a client (#{request.user_agent}) called put /vm/:hostname/disk/:size/? and got redirected to api_version=1, this behavior will change in the next major version, please modify the client to use v2 in advance" - call env.merge('PATH_INFO' => "/api/v#{api_version}/vm/#{params[:hostname]}/disk/#{params[:size]}") - end - end - end -end