Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop a syntax to "ensure" a certain object exists on the server #12

Open
nvarscar opened this issue Feb 20, 2023 · 0 comments
Open
Labels
core Python-related, no Postgres knowledge needed enhancement New feature or request

Comments

@nvarscar
Copy link
Collaborator

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()
@nvarscar nvarscar added enhancement New feature or request core Python-related, no Postgres knowledge needed labels Feb 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Python-related, no Postgres knowledge needed enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant