You are viewing documentation about an older version (0.13.1). View latest version

snowflake.core.grant.Grants¶

class snowflake.core.grant.Grants(root: Root)¶

Bases: object

The entry point of the Snowflake Core Python APIs to manage Snowflake Grants.

Parameters:

root – A Root instance.

Methods

grant(grant: Grant) → None¶

Grant the specified privilege(s) on the named securable to the named grantee.

Parameters:

grant – an instance of Grant

Example

Apply a grant to test role >>> root.grants.grant(Grant( >>> grantee=Grantees.role(name=role_name), >>> securable=Securables.current_account, >>> privileges=[Privileges.create_database]))

revoke(grant: Grant, mode: DeleteMode = DeleteMode.restrict) → None¶

Revoke the specified privilege(s) on the named securable to the named grantee.

Parameters:

grant – an instance of Grant

Example

Revoke a Privilege from test role >>> root.grants.revoke(Grant( >>> grantee=Grantees.role(name=role_name), >>> securable=Securables.current_account, >>> privileges=[Privileges.create_database]))

revoke_grant_option(grant: Grant, mode: DeleteMode = DeleteMode.restrict) → None¶

Revoke the grant option on the specified privilege(s) on the named securable to the named grantee.

Parameters:

grant – an instance of Grant

Example

Revoke grant option for a Privilege from test role >>> root.grants.revoke(Grant( >>> grantee=Grantees.role(name=role_name), >>> securable=Securables.current_account, >>> privileges=[Privileges.create_database]))

to(grantee: Grantee, limit: int | None = None) → Iterable[GrantModel]¶

List the roles and privileges granted to the specified grantee.

Parameters:

grantee – an instance of Grantee

Example

>>>  root.grants.to(Grantee(
>>>  name="test-user",
>>>  grantee_type="user",
>>>  limit = 10))
Copy