diff --git a/lib/App/Netdisco/Util/API.pm b/lib/App/Netdisco/Util/API.pm index 3884dec0..0dc595cb 100644 --- a/lib/App/Netdisco/Util/API.pm +++ b/lib/App/Netdisco/Util/API.pm @@ -17,7 +17,7 @@ sub parse_search_params { foreach my $param (keys %{$params}) { if ($param ne 'return_url' and $param ne 'partial') { if ($partial == 1) { - $search->{"text(".$param.")"} = { like => '%'.$params->{$param}.'%'}; + $search->{"text(".$param.")"} = { -ilike => '%'.$params->{$param}.'%'}; } else { $search->{$param} = $params->{$param}; diff --git a/lib/App/Netdisco/Web/Plugin/API/NodeIP.pm b/lib/App/Netdisco/Web/Plugin/API/NodeIP.pm index 99c9b5c3..7c34f54a 100644 --- a/lib/App/Netdisco/Web/Plugin/API/NodeIP.pm +++ b/lib/App/Netdisco/Web/Plugin/API/NodeIP.pm @@ -1,19 +1,32 @@ package App::Netdisco::Web::Plugin::API::NodeIP; use Dancer ':syntax'; -use Dancer::Plugin::Auth::Extensible; - use Dancer::Plugin::DBIC 'schema'; - +use Dancer::Plugin::Auth::Extensible; use Dancer::Exception qw(:all); +use Dancer::Plugin::Swagger; + +use App::Netdisco::Web::Plugin; +use App::Netdisco::Util::API; use NetAddr::IP::Lite; -use App::Netdisco::Web::Plugin; - -use App::Netdisco::Web::Plugin::API::Util; - -get '/api/nodeip/search' => sub { +swagger_path { + description => 'Search for a Node to IP mapping (ARP entry)', + parameters => [ + mac => 'MAC address', + ip => 'IP address', + dns => 'FQDN of the node', + active => { type => 'boolean', description => 'Whether the entry is still fresh', }, + time_first => 'When first seen', + time_last => 'When last seen', + partial => { + type => 'boolean', + description => 'All parameters will be searched for case insensitively in their values', + }, + ], +}, +get '/api/nodeip/search' => require_role api => sub { my $para = params; my $search = parse_search_params($para); my $ips; diff --git a/share/config.yml b/share/config.yml index be91fc6f..fb3c2ab2 100644 --- a/share/config.yml +++ b/share/config.yml @@ -41,9 +41,9 @@ api_token_lifetime: 3600 path: '/' web_plugins: - Inventory - - API::Node +# - API::Node - API::NodeIP - - API::Device +# - API::Device - Report::PortVLANMismatch - Report::PortAdminDown - Report::PortBlocking