Closed synergiator closed 2 years ago
This project contains no business logic. The easy way to build some is to work around the listApis call.
for you specific issue,
def zone_exists(self, zone):
assert zone
zones = self.cs.listZones(name=zone, fetch_list=True)
return bool(zones)
NB the behaviour differs if you were to check by ID.
thanks for the shorter code - still I meant to say whether it is possible to dynamically map for API elements also sth like:
getId..
exists..
which is not explicitely there but maybe generic enough to be derivable as well
Probably. I guess nobody had such needs or managed to turn them into code.
@greut while you say, this project does not contain business logic, do you have knowledge of such a project, either would accept such code here?
That is, the boilerplate code for async calls could look like the following:
import sys
....
def call_async(self, method, **kwargs):
result = getattr(self.cs, method)(**kwargs)
asj = AsyncJob(self.cs,result['jobid'])
assert asj.isSuccessful() == True
jobresult = asj.getResult()
# concatenate output of async call at time of submission and
# after successful execution
return {**result, **jobresult}
The Go projects do have the logic since static typing makes things harder. Some of them, like cloudmonkey do read the listApis and then build their inner logic. Although, the listApis information aren't always useful.
I am not sure whether this project uses some generative/mapping technique to map to the CS API instead of implementing all calls?
If so, if possible, it would be really great to have some check functions, like:
Another example handling asynchronous calls: