initial full swagger spec for nodeip search
This commit is contained in:
@@ -17,7 +17,7 @@ sub parse_search_params {
|
|||||||
foreach my $param (keys %{$params}) {
|
foreach my $param (keys %{$params}) {
|
||||||
if ($param ne 'return_url' and $param ne 'partial') {
|
if ($param ne 'return_url' and $param ne 'partial') {
|
||||||
if ($partial == 1) {
|
if ($partial == 1) {
|
||||||
$search->{"text(".$param.")"} = { like => '%'.$params->{$param}.'%'};
|
$search->{"text(".$param.")"} = { -ilike => '%'.$params->{$param}.'%'};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$search->{$param} = $params->{$param};
|
$search->{$param} = $params->{$param};
|
||||||
|
|||||||
@@ -1,19 +1,32 @@
|
|||||||
package App::Netdisco::Web::Plugin::API::NodeIP;
|
package App::Netdisco::Web::Plugin::API::NodeIP;
|
||||||
|
|
||||||
use Dancer ':syntax';
|
use Dancer ':syntax';
|
||||||
use Dancer::Plugin::Auth::Extensible;
|
|
||||||
|
|
||||||
use Dancer::Plugin::DBIC 'schema';
|
use Dancer::Plugin::DBIC 'schema';
|
||||||
|
use Dancer::Plugin::Auth::Extensible;
|
||||||
use Dancer::Exception qw(:all);
|
use Dancer::Exception qw(:all);
|
||||||
|
use Dancer::Plugin::Swagger;
|
||||||
|
|
||||||
|
use App::Netdisco::Web::Plugin;
|
||||||
|
use App::Netdisco::Util::API;
|
||||||
|
|
||||||
use NetAddr::IP::Lite;
|
use NetAddr::IP::Lite;
|
||||||
|
|
||||||
use App::Netdisco::Web::Plugin;
|
swagger_path {
|
||||||
|
description => 'Search for a Node to IP mapping (ARP entry)',
|
||||||
use App::Netdisco::Web::Plugin::API::Util;
|
parameters => [
|
||||||
|
mac => 'MAC address',
|
||||||
get '/api/nodeip/search' => sub {
|
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 $para = params;
|
||||||
my $search = parse_search_params($para);
|
my $search = parse_search_params($para);
|
||||||
my $ips;
|
my $ips;
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ api_token_lifetime: 3600
|
|||||||
path: '/'
|
path: '/'
|
||||||
web_plugins:
|
web_plugins:
|
||||||
- Inventory
|
- Inventory
|
||||||
- API::Node
|
# - API::Node
|
||||||
- API::NodeIP
|
- API::NodeIP
|
||||||
- API::Device
|
# - API::Device
|
||||||
- Report::PortVLANMismatch
|
- Report::PortVLANMismatch
|
||||||
- Report::PortAdminDown
|
- Report::PortAdminDown
|
||||||
- Report::PortBlocking
|
- Report::PortBlocking
|
||||||
|
|||||||
Reference in New Issue
Block a user