netbox-client-ruby icon indicating copy to clipboard operation
netbox-client-ruby copied to clipboard

How do I get all the interfaces for the device

Open wilful opened this issue 11 months ago • 1 comments

Hi, tell me how, having only the hostname (name/display), to get all the interfaces of the device with addresses? In my case, I'm trying to use a device query and I get nil.

>> NetboxClientRuby.dcim.interfaces.find_by(device: 'brz-v-itmg-1')


I, [2024-03-12T23:14:48.133484 #73591]  INFO -- request: GET https://netbox.../api/dcim/interfaces.json?device=brz-v-itmg-1&limit=50
I, [2024-03-12T23:14:48.133513 #73591]  INFO -- request: Authorization: "Token ***"
User-Agent: "Faraday v1.10.3"
I, [2024-03-12T23:14:49.461606 #73591]  INFO -- response: Status 200
I, [2024-03-12T23:14:49.461814 #73591]  INFO -- response: content-type: "application/json"
vary: "HX-Request, Cookie, origin, Accept-Encoding"
allow: "GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, TRACE"
x-request-id: "1129bd3c-283c-49a0-9be5-14a6eefaf198"
x-content-type-options: "nosniff"
referrer-policy: "same-origin"
cross-origin-opener-policy: "same-origin"
x-frame-options: "SAMEORIGIN"
server: "envoy"
date: "Tue, 12 Mar 2024 20:14:49 GMT"
x-envoy-upstream-service-time: "862"
transfer-encoding: "chunked"
nil

But the same request in the console works and I get the necessary interfaces

curl -H "Authorization: Token ***" 'https://netbox.../api/dcim/interfaces.json?device=brz-v-itmg-1&limit=50' | jq
{
  "count": 7,
...

wilful avatar Mar 12 '24 17:03 wilful