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.
Methods
- grant(grant: Grant) None ¶
Grant the specified privilege(s) on the named securable to the named grantee.
- Parameters:
grant (Grant) – The
Grant
object, together with theGrant
’s properties: grantee, securable, privilege; grant_option is optional.
Examples
Applying a grant to a 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 (Grant) – The
Grant
object, together with theGrant
’s properties: grantee, securable, privilege; grant_option is optional.
Examples
Revoking 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 (Grant) – The
Grant
object, together with theGrant
’s properties: grantee, securable, privilege; grant_option is optional.
Examples
Revoking 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 (Grantee) – The
Grantee
to list the roles and privileges of.
Examples
Listing the roles and privileges granted to the grantee:
>>> root.grants.to( ... Grantee( ... name="test-user", ... grantee_type="user", ... limit = 10, ... ) ... )