Getting started with the python SDK part 5: request parameters revisited

Last time out we looked at using request parameters. Stephan Manthey posted a comment on some of the advanced queries with the options parameter he uses and asked how they might be supported in the SDK. We’ll take the use cases one at a time, and show how to build that query.

Removing all management routes by using a globbing wildcard

method: DELETE
path:/mgmt/tm/sys/management-route
query: options=* or options=all

This isn't actually possible via the SDK until version 3.0.17, set to release today or Monday, but you can download the development branch to test it out if you like. I had to add a delete_collection method for this to work. The command to use this method in the SDK is:

 

x = b.tm.sys.management_route.delete_collection(requests_params={'params': 'options=*'}

 

Removing a set of unused pools by using more specific globbing

method: DELETE
path:/mgmt/tm/ltm/pool
query: options=pool_test_*

Via the SDK:

 

x = b.tm.ltm.pool.delete_collection(requests_params={'params': 'options=pool_test_*'}

 

Save a specific partition instead of saving all of them

method: POST
path:/mgmt/tm/sys/config
query: options=partitions { my_partition }

Via the SDK:

 

x = b.tm.sys.config.exec_cmd('save', requests_params={'params': 'options=partitions { my_partition }'}

 

Note you can save more than one partition if you like, separated by whitespace within the curly braces.

Retrieve detailed statistics

method: GET
path:/mgmt/tm/ltm/pool/~Common~mypool/stats
query: options=detail

Via the SDK:

 

x = b.tm.ltm.pool.get_collection(requests_params={'params': 'options=detail'}

 

Thanks again to Stephan for sharing the advanced query parameters he uses in his environment, hopefully these quick recipes with how to apply them in the SDK will help to expand your toolbox.

Updated Mar 10, 2023
Version 2.0

Was this article helpful?