Source code for influxdb_client.client.users_api

Users are those with access to InfluxDB.

To grant a user permission to access data, add them as a member of an organization
and provide them with an authentication token.

from typing import Union
from influxdb_client import UsersService, User, Users, UserResponse

[docs]class UsersApi(object): """Implementation for '/api/v2/users' endpoint.""" def __init__(self, influxdb_client): """Initialize defaults.""" self._influxdb_client = influxdb_client self._service = UsersService(influxdb_client.api_client)
[docs] def me(self) -> User: """Return the current authenticated user.""" user = self._service.get_me() return user
[docs] def create_user(self, name: str) -> User: """Create a user.""" user = User(name=name) return self._service.post_users(user=user)
[docs] def update_user(self, user: User) -> UserResponse: """Update a user. :param user: User update to apply (required) :return: User """ return self._service.patch_users_id(, user=user)
[docs] def delete_user(self, user: Union[str, User, UserResponse]) -> None: """Delete a user. :param user: user id or User :return: User """ if isinstance(user, User): user_id = elif isinstance(user, UserResponse): user_id = else: user_id = user return self._service.delete_users_id(user_id=user_id)
[docs] def find_users(self, **kwargs) -> Users: """List all users. :key int offset: Offset for pagination :key int limit: Limit for pagination :key str after: The last resource ID from which to seek from (but not including). This is to be used instead of `offset`. :key str name: The user name. :key str id: The user ID. :return: Buckets """ return self._service.get_users(**kwargs)