snowflake.core.role.RoleCollection¶
- class snowflake.core.role.RoleCollection(root: Root)¶
- Bases: - AccountObjectCollectionParent[- RoleResource]- Represents the collection operations on the Snowflake Role resource. - With this collection, you can create, iterate through, and search for roles that you have access to in the current context. - Examples - Creating a role instance: - >>> role_collection = root.roles >>> role_collection.create(Role(name="test-role", comment="samplecomment")) - Attributes - root¶
- The Root object this collection belongs to. 
 - Methods - create(role: RoleModel, *, mode: CreateMode = CreateMode.error_if_exists) RoleResource¶
- Create a role in Snowflake. - Parameters:
- role (Role) – The - Roleobject, together with the- Role’s properties: name ; comment is optional
- mode (CreateMode, optional) – - One of the following enum values. - CreateMode.error_if_exists: Throw an- snowflake.core.exceptions.ConflictErrorif the role already exists in Snowflake. Equivalent to SQL- create role <name> ....- CreateMode.or_replace: Replace if the role already exists in Snowflake. Equivalent to SQL- create or replace role <name> ....- CreateMode.if_not_exists: Do nothing if the role already exists in Snowflake. Equivalent to SQL- create role <name> if not exists...- Default is - CreateMode.error_if_exists.
 
 - Examples - Creating a role, replacing any existing role with the same name: - >>> role = Role(name="test-role", comment="samplecomment") >>> role_ref = root.roles.create(role, mode=CreateMode.or_replace) 
 - create_async(role: RoleModel, *, mode: CreateMode = CreateMode.error_if_exists) PollingOperation[RoleResource]¶
- An asynchronous version of - create().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - items() ItemsView[str, T]¶
 - iter(*, like: str | None = None, limit: int | None = None, starts_with: str | None = None, from_name: str | None = None) Iterator[RoleModel]¶
- Iterate through - Roleobjects from Snowflake, filtering on any optional ‘like’ pattern.- Parameters:
- like (str, optional) – A case-insensitive string functioning as a filter, with support for SQL wildcard characters (% and _). 
- starts_with (str, optional) – String used to filter the command output based on the string of characters that appear at the beginning of the object name. Uses case-sensitive pattern matching. 
- show_limit (int, optional) – Limit of the maximum number of rows returned by iter(). The default is - None, which behaves equivalently to show_limit=10000. This value must be between- 1and- 10000.
- from_name (str, optional) – Fetch rows only following the first row whose object name matches the specified string. This is case-sensitive and does not have to be the full name. 
 
 - Examples - Showing all roles that you have access to see: - >>> roles = role_collection.iter() - Showing information of the exact role you want to see: - >>> roles = role_collection.iter(like="your-role-name") - Showing roles starting with ‘your-role-name-‘: - >>> roles = role_collection.iter(like="your-role-name-%") >>> roles = role_collection.iter(starts_with="your-role-name") - Using a for loop to retrieve information from iterator: - >>> for role in roles: ... print(role.name, role.comment) 
 - iter_async(*, like: str | None = None, limit: int | None = None, starts_with: str | None = None, from_name: str | None = None) PollingOperation[Iterator[RoleModel]]¶
- An asynchronous version of - iter().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - keys() KeysView[str]¶
 - update_reference(old_name: str, new_name: str, resource: T) None¶
- Update the collection with a new item. 
 - values() ValuesView[T]¶