Tinkering with the BIGREST Python SDK - Part 1
Let me add a few things, that explain the design options and challenges...
Token
This is how you would normally use the SDK with token:
device = BIGIP(ip, username, password, request_token=True)
The SDK uses the username and password to request a token, and uses that token while is valid and automatic requests a new one when it expires.
There are 2 token functions that can be used to get tokens.
token() and refresh_token()
Both BIG-IP and BIG-IQ can use token, but only BIG-IQ uses refresh token.
BIG-IQ refresh token is valid for many hours, and is used to request a token.
Those functions can be used for any scenario where you don't have the username or password, and you only got a token or refresh token to use.
Very unusual use case, but they are there as options, as the REST API supports it.
SSL and Proxy
Yes, the SDK is hardcoded to skip SSL certificate check.
No proxy support at the moment, maybe in the future.
Properties
The first versions of the SDK I had with obj.name.
The problem is when you use the show command, because the properties have names like "clientside.maxConns", and you can't have an attribute with a dot in the name.
As far as remember, f5-common-python did not implement /stats part of the REST API, so is not a problem there.
Single or Multiple Objects
For the load command, I want to be sure it returns always the same type of object, to avoid errors with returning different type of objects.
So, this is why it returns a list even when the device has a single virtual server for example.
I thought about using 2 methods, load and list_load, but it would be confusing and duplication of code.
REST API Extra Properties
Initially I thought I had to remove extra properties when updating the object, but it turns out the REST API just ignore them.
So, you can load a object with the extra properties from the REST API, and send everything back to the API, and it will not give any error (just ignore it).
The only thing I had to do is convert to enabled=True or disabled=True, for cases where it has enabled=False or disabled=False.