Roles

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

pglift.roles.apply(instance, role, manager=<object object>)

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.

Parameters:
  • instance (PostgreSQLInstance)

  • role (Role)

  • manager (Annotated[AbstractInstanceManager, Dependency(var=<ContextVar name='InstanceManager' at 0x7bfc80b36110>)])

Return type:

ApplyResult

async pglift.roles.exists(instance, name)

Return True if named role exists in ‘instance’.

The instance should be running.

Parameters:
Return type:

bool

async pglift.roles.get(instance, name, *, password=True)

Return the role object with specified name.

Raises:

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

Parameters:
Return type:

Role

async pglift.roles.drop(instance, role)

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.

Parameters:
Return type:

None