User#

Classes related to user endpoints

class metabase_tools.models.user_model.UserItem(*, id, common_name, email, first_name, last_name, date_joined, last_login=None, updated_at=None, is_qbnewb, is_superuser, ldap_auth=None, google_auth=None, is_active=None, locale=None, group_ids=None, login_attributes=None, personal_collection_id=None, has_invited_second_user=None, user_group_memberships=None, first_login=None, has_question_and_dashboard=None, is_installer=None, sso_source=None)#

User object class with related methods

Parameters:
  • id (int | str) –

  • common_name (str) –

  • email (str) –

  • first_name (str) –

  • last_name (str) –

  • date_joined (datetime) –

  • last_login (datetime | None) –

  • updated_at (datetime | None) –

  • is_qbnewb (bool) –

  • is_superuser (bool) –

  • ldap_auth (bool | None) –

  • google_auth (bool | None) –

  • is_active (bool | None) –

  • locale (str | None) –

  • group_ids (list[int] | None) –

  • login_attributes (list[dict[str, Any]] | None) –

  • personal_collection_id (int | None) –

  • has_invited_second_user (bool | None) –

  • user_group_memberships (list[dict[str, int]] | None) –

  • first_login (datetime | None) –

  • has_question_and_dashboard (bool | None) –

  • is_installer (bool | None) –

  • sso_source (str | None) –

archive()#

Generic method for archiving an object

Raises:

InvalidParameters – Targets and jsons are both None

Returns:

Object of the relevant type

Return type:

T

Parameters:

self (T) –

classmethod construct(_fields_set=None, **values)#

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values

Parameters:
  • _fields_set (SetStr | None) –

  • values (Any) –

Return type:

Model

copy(*, include=None, exclude=None, update=None, deep=False)#

Duplicate a model, optionally choose which fields to include, exclude and change.

Parameters:
  • include (AbstractSetIntStr | MappingIntStrAny | None) – fields to include in new model

  • exclude (AbstractSetIntStr | MappingIntStrAny | None) – fields to exclude from new model, as with values this takes precedence over include

  • update (DictStrAny | None) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep (bool) – set to True to make a deep copy of the model

  • self (Model) –

Returns:

new model instance

Return type:

Model

delete()#

Method to delete an object

Raises:

InvalidParameters – Invalid target

Return type:

None

dict(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False)#

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

Parameters:
  • include (AbstractSetIntStr | MappingIntStrAny | None) –

  • exclude (AbstractSetIntStr | MappingIntStrAny | None) –

  • by_alias (bool) –

  • skip_defaults (bool | None) –

  • exclude_unset (bool) –

  • exclude_defaults (bool) –

  • exclude_none (bool) –

Return type:

DictStrAny

disable()#

Disables user

Return type:

None

enable()#

Enable user

Returns:

Enabled users

Return type:

UserItem

json(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, encoder=None, models_as_dict=True, **dumps_kwargs)#

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

Parameters:
  • include (AbstractSetIntStr | MappingIntStrAny | None) –

  • exclude (AbstractSetIntStr | MappingIntStrAny | None) –

  • by_alias (bool) –

  • skip_defaults (bool | None) –

  • exclude_unset (bool) –

  • exclude_defaults (bool) –

  • exclude_none (bool) –

  • encoder (Callable[[Any], Any] | None) –

  • models_as_dict (bool) –

  • dumps_kwargs (Any) –

Return type:

unicode

qbnewb()#

Indicate that a user has been informed about Query Builder.

Returns:

User with query builder toggle set

Return type:

UserItem

refresh()#

Returns refreshed copy of the user

Returns:

self

Return type:

UserItem

Parameters:

self (UserItem) –

resend_invite()#

Resent user invites

Returns:

User with a resent invite

Return type:

UserItem

set_adapter(adapter)#

Sets the adapter on an object

Parameters:

adapter (MetabaseApi) – Connection to MetabaseApi

Return type:

None

unarchive()#

Generic method for unarchiving an object

Raises:

InvalidParameters – Targets and jsons are both None

Returns:

Object of the relevant type

Return type:

T

Parameters:

self (T) –

update(email=MissingParam(), first_name=MissingParam(), is_group_manager=MissingParam(), locale=MissingParam(), user_group_memberships=MissingParam(), is_superuser=MissingParam(), login_attributes=MissingParam(), last_name=MissingParam(), **kwargs)#

Updates a user using the provided parameters

Parameters:
  • self (UserItem) –

  • email (str, optional) –

  • first_name (str, optional) –

  • is_group_manager (bool, optional) –

  • locale (str, optional) –

  • user_group_memberships (list[int], optional) –

  • is_superuser (bool, optional) –

  • login_attributes (str, optional) –

  • last_name (str, optional) –

  • kwargs (Any) –

Returns:

UserItem

Return type:

UserItem

classmethod update_forward_refs(**localns)#

Try to update ForwardRefs on fields based on this Model, globalns and localns.

Parameters:

localns (Any) –

Return type:

None

update_password(payload)#

Updates passwords for users

Parameters:
  • payload (dict) – New password

  • self (UserItem) –

Returns:

User with reset passwords

Return type:

UserItem

Classes related to card endpoints

class metabase_tools.endpoints.users_endpoint.Users(adapter)#

Card related endpoint methods

Parameters:

adapter (MetabaseApi) –

create(first_name=MissingParam(), last_name=MissingParam(), email=MissingParam(), password=MissingParam(), group_ids=MissingParam(), login_attributes=MissingParam(), **kwargs)#

_summary_

Parameters:
  • first_name (str, optional) –

  • last_name (str, optional) –

  • email (str, optional) –

  • password (str, optional) –

  • group_ids (list[int], optional) –

  • login_attributes (str, optional) –

  • kwargs (Any) –

Returns:

_description_

Return type:

UserItem

current()#

Current user details

Raises:

RequestFailure – Invalid response from API

Returns:

Current user details

Return type:

User

get(targets=None)#

Fetch list of users

Parameters:

targets (list[int], optional) – If provided, the list of users to fetch

Returns:

list[UserItem]

Return type:

list[UserItem]

search(search_params, search_list=None)#

Method to search a list of users meeting a list of parameters

Parameters:
  • search_params (list[dict]) – Each dict contains search criteria and returns 1 result

  • search_list (list[UserItem], optional) – Provide to search an existing list, by default pulls from API

Returns:

List of users of the relevant type

Return type:

list[UserItem]