snowflake.core.user.UserCollection | Snowflake Documentation (original) (raw)
class snowflake.core.user.UserCollection(root: Root)¶
Bases: AccountObjectCollectionParent
[UserResource]
Represents the collection operations on the Snowflake User resource.
With this collection, you can create, iterate through, and search for users that you have access to in the current context.
Examples
Creating a user instance:
sample_user = User(name="test_user") root.users.create(sample_user)
Attributes
root¶
The Root object this collection belongs to.
Methods
create(user: UserModel, *, mode: CreateMode = CreateMode.error_if_exists) → UserResource¶
Create a user in Snowflake account.
Parameters:
- user (User) – The
User
object, together with theUser
’s properties: name; password, login_name, display_name, first_name, middle_name, last_name, email, must_change_password, disabled, days_to_expiry, mins_to_unlock, default_warehouse, default_namespace, default_role, default_secondary_roles, mins_to_bypass_mfa, rsa_public_key, rsa_public_key_fp, rsa_public_key_2, rsa_public_key_2_fp, comment, type, enable_unredacted_query_syntax_error, network_policy are optional - mode (CreateMode, optional) –
One of the following enum values.CreateMode.error_if_exists
: Throw an snowflake.core.exceptions.ConflictErrorif the user already exists in Snowflake. Equivalent to SQLcreate user <name> ...
.CreateMode.or_replace
: Replace if the user already exists in Snowflake. Equivalent to SQLcreate or replace user <name> ...
.CreateMode.if_not_exists
: Do nothing if the user already exists in Snowflake. Equivalent to SQLcreate user <name> if not exists...
Default isCreateMode.error_if_exists
.
Examples
Creating a user, replacing any existing user with the same name:
sample_user = User(name = "test_user") root.users.create(sample_user, mode = CreateMode.or_replace)
create_async(user: UserModel, *, mode: CreateMode = CreateMode.error_if_exists) → PollingOperation[UserResource]¶
An asynchronous version of create().
Refer to PollingOperation for 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[UserModel]¶
iter_async(like: str | None = None, limit: int | None = None, starts_with: str | None = None, from_name: str | None = None) → PollingOperation[Iterator[UserModel]]¶
An asynchronous version of iter().
Refer to PollingOperation for more information on asynchronous execution and the return type.
keys() → KeysView[str]¶
values() → ValuesView[T]¶