Getting started with the python SDK part 4: working with request parameters
Hi Jason,
is it possible to include additional parameters if subcollections have been expanded?
I'd like to run a single query that returns all VLAN names and tags, as well as the interfaces assigned to each VLAN.
What I have so far.
- The following single line query for VLAN name and tag works as expected.
VLANS = lb01.tm.net.vlans.get_collection(requests_params={'params':'$select=name,tag'})
- The expand query works and I can loop through the results to get the data I want.
VLANS = chlb001.tm.net.vlans.get_collection(requests_params={'params': {'expandSubcollections':'true'}})
for vlan in VLANS:
... print(vlan.name)
... for interface in vlan.interfacesReference['items']:
... print(interface['name'])
...
VLAN_ First
1.3
VLAN_Second
VLAN_Third
1.2
VLAN_Fourth
1.3
What I would like is a way to combine the expandSubcollections parameter with the $Select to provide the interfaces numbers as well. Below is an example of one of the failed iterations I've tried. In bold are the specific parameters I'd like to retrieve.
VLANS = lb01.tm.net.vlans.get_collection(requests_params={'params': {'expandSubcollections':'true'}}& {'params': '$select=name,tag,interfaces_s'}})
Thanks for any thoughts and ideas!