in firebase_admin/_auth_client.py [0:0]
def get_users(self, identifiers):
"""Gets the user data corresponding to the specified identifiers.
There are no ordering guarantees; in particular, the nth entry in the
result list is not guaranteed to correspond to the nth entry in the input
parameters list.
A maximum of 100 identifiers may be supplied. If more than 100
identifiers are supplied, this method raises a `ValueError`.
Args:
identifiers (list[Identifier]): A list of ``Identifier`` instances used
to indicate which user records should be returned. Must have <= 100
entries.
Returns:
GetUsersResult: A ``GetUsersResult`` instance corresponding to the
specified identifiers.
Raises:
ValueError: If any of the identifiers are invalid or if more than 100
identifiers are specified.
"""
response = self._user_manager.get_users(identifiers=identifiers)
def _matches(identifier, user_record):
if isinstance(identifier, _user_identifier.UidIdentifier):
return identifier.uid == user_record.uid
if isinstance(identifier, _user_identifier.EmailIdentifier):
return identifier.email == user_record.email
if isinstance(identifier, _user_identifier.PhoneIdentifier):
return identifier.phone_number == user_record.phone_number
if isinstance(identifier, _user_identifier.ProviderIdentifier):
return next((
True
for user_info in user_record.provider_data
if identifier.provider_id == user_info.provider_id
and identifier.provider_uid == user_info.uid
), False)
raise TypeError("Unexpected type: {}".format(type(identifier)))
def _is_user_found(identifier, user_records):
return any(_matches(identifier, user_record) for user_record in user_records)
users = [_user_mgt.UserRecord(user) for user in response]
not_found = [
identifier for identifier in identifiers if not _is_user_found(identifier, users)]
return _user_mgt.GetUsersResult(users=users, not_found=not_found)