Getting started with the python SDK part 4: working with request parameters
In the previous article in this series, we looked at how to work with statistics. In this article, we’ll mirror some of the naked query parameters covered in the Demystifying iControl REST part 3 art...
Updated Jun 06, 2023
Version 2.0JRahm
Admin
Joined January 20, 2005
JRahm
Dec 29, 2020Admin
Hi , sorry for the delayed response, this one fell through the cracks. You can definitely get payload back for a combined selection and expansion, but not exactly as you desire. Because you are doing a selection on the top level object, you need to select name, tag, and then the entire interfacesReference. This is still beneficial to reduce how much useless data you pull back, but also still requires a little post-processing. In postman, the query looks like this:
https://{{host}}/mgmt/tm/net/vlan?expandSubcollections=true&$select=name,tag,interfacesReference
From the sdk, you need to format it as a single request params object:
VLANS = b.tm.net.vlans.get_collection(requests_params={'params': {'expandSubcollections':'true', '$select': 'name,tag,interfacesReference'}})
And the data returned looks like this:
{'name': 'v.10', 'tag': 10, 'interfacesReference': {'link': 'https://localhost/mgmt/tm/net/vlan/~Common~v.10/interfaces?ver=15.1.0.5', 'isSubcollection': True, 'items': [{'kind': 'tm:net:vlan:interfaces:interfacesstate', 'name': '1.3', 'fullPath': '1.3', 'generation': 1, 'selfLink': 'https://localhost/mgmt/tm/net/vlan/~Common~v.10/interfaces/1.3?ver=15.1.0.5', 'tagMode': 'none', 'untagged': True, 'nameReference': {'link': 'https://localhost/mgmt/tm/net/interface/1.3?ver=15.1.0.5'}}]}}
Or in picture format with pretty printing: