How do I access all 'Connection' info per device with a single API (GraphQL) call?

143 views
Skip to first unread message

Ryan

unread,
Nov 17, 2021, 6:47:25 PM11/17/21
to NetBox
Hello,

The newest Netbox update broke some of my API calls inside of a script, which is fine. I'd like to make the script more robust and easier to debug so I'm attempting to utilize GraphQL. My goal is to query a rack, and retrieve a set of specific information for every single item in the rac.

How do I access the electrical socket information outlined with the red box in such a way that it's associated with the device directly?
lenet.jpg
I'm able query for the cables, termination_b device name, _cable_peer_id, but for the life of me cannot access which socket that this cable ultimately plugs into. The Netbox front-end obviously "sees" the endpoint of this cable, or at least what slot it sits in the PDU.

Ideally I'd like to use the same method to grab the cable endpoints for interfaces as well without having to make a completely separate API call.

An example would be (examples in caps):
{
  rack(id: 24) {
    name
    devices {
      powerports {
        name
        _cable_peer_id
        type
        cable {
          status
           INSERT_CONNECTION_ENDPOINT_HERE
          _termination_b_device {
            name
             }
           }
         }
        }
      }
    }
  }
}

Thank you for your time :)
Reply all
Reply to author
Forward
0 new messages