Develop a syntax to "ensure" a certain object exists on the server #12
Open
Description
Example of how it should look like:
cluster.roles.ensure(name='foo', superuser=True)
The pseudocode of what it does behind the scenes:
try:
role = cluster.roles['foo']
except KeyError:
role = cluster.roles.new(name='foo') # potentially, kwargs could go here as well
for k,v in kwargs.items():
if not hasattr(role, k):
raise AttributeError
setattr(role, k, v) # not sure if setattr works with @property
role.create() if role._ephemeral else role.alter()