Roles

Module pglift.roles exposes the following API to manipulate PostgreSQL roles:

async pglift.roles.apply(instance: PostgreSQLInstance, role: Role) ApplyResult

Apply state described by specified interface model as a PostgreSQL role.

In case it’s not possible to inspect changed role, possibly due to the super-user password being modified, change_state attribute within the returned object is set to interface.ApplyResult.changed with a warning logged.

The instance should be running and not a standby.

Raises:

DependencyError – if the role cannot be dropped due some database dependency.

async pglift.roles.exists(instance: PostgreSQLInstance, name: str) bool

Return True if named role exists in ‘instance’.

The instance should be running.

async pglift.roles.get(instance: PostgreSQLInstance, name: str, *, password: bool = True) Role

Return the role object with specified name.

Raises:

RoleNotFound – if no role with specified ‘name’ exists.

async pglift.roles.drop(instance: PostgreSQLInstance, role: RoleDropped) None

Drop a role from instance.

Raises:
  • RoleNotFound – if no role with specified ‘role.name’ exists.

  • RoleNotFound – if no role with specified ‘role.reassign_owned’ exists.

  • DependencyError – if the role cannot be dropped due some database dependency.