diff --git a/lib/App/Netdisco/Web/API/Objects.pm b/lib/App/Netdisco/Web/API/Objects.pm index 83bb2d20..bf3a8711 100644 --- a/lib/App/Netdisco/Web/API/Objects.pm +++ b/lib/App/Netdisco/Web/API/Objects.pm @@ -46,6 +46,39 @@ foreach my $rel (qw/device_ips vlans ports modules port_vlans wireless_ports ssi }; } +swagger_path { + tags => ['Objects'], + path => setting('api_base')."/object/device/{ip}/neighbors", + description => 'Returns layer 2 neighbor relation data for a given device', + parameters => [ + ip => { + description => 'Canonical IP of the Device. Use Search methods to find this.', + required => 1, + in => 'path', + }, + scope => { + description => 'Scope of results, either "all", "cloud" (LLDP cloud), or "depth" (uses hops)', + default => 'depth', + in => 'query', + }, + hops => { + description => 'When specifying Scope "depth", this is the number of hops', + default => '1', + in => 'query', + }, + vlan => { + description => 'Limit results to devices carrying this numeric VLAN ID', + }, + ], + responses => { default => {} }, +}, get "/api/v1/object/device/:ip/neighbors" => require_role api => sub { + forward "/ajax/data/device/netmap", { + q => params->{'ip'}, + depth => params->{'hops'}, + mapshow => params->{'scope'}, + }; +}; + swagger_path { tags => ['Objects'], path => (setting('api_base') || '').'/object/device/{ip}/jobs', diff --git a/lib/App/Netdisco/Web/Plugin/Device/Neighbors.pm b/lib/App/Netdisco/Web/Plugin/Device/Neighbors.pm index 5b1fd196..9d13ef3f 100644 --- a/lib/App/Netdisco/Web/Plugin/Device/Neighbors.pm +++ b/lib/App/Netdisco/Web/Plugin/Device/Neighbors.pm @@ -138,7 +138,7 @@ sub make_link_infostring { $right_name, $_->[2], ($_->[3] || 'no description') } @zipped; } -ajax '/ajax/data/device/netmap' => require_login sub { +get '/ajax/data/device/netmap' => require_login sub { my $q = param('q'); my $qdev = schema(vars->{'tenant'})->resultset('Device') ->search_for_device($q) or send_error('Bad device', 400);