UserApi¶
- class UserApi(api)[source]¶
Bases:
ModuleApiBaseAPI for working with users.
- Parameters:
- Usage Example:
import supervisely as sly api = sly.Api.from_env() users = api.user.get_list()
Methods
Invites User to Team with the given role.
Invite User to Team with given role by login.
Changes User role in the given Team.
Convert information about an entity to a dictionary.
Creates new User with given login and password.
Disables User with the given ID.
Enables User with the given ID.
Get User information by User ID.
Get User information by User login.
Get list of information about Users.
Get list of all or limited quantity entities from the Supervisely server.
This generator function retrieves a list of all or a limited quantity of entities from the Supervisely server, yielding batches of entities as they are retrieved
Get the list of items for a given page number.
Yields list of images in dataset asynchronously page by page.
Get User activity data.
Get information about team member by Team ID and User ID.
Get information about team member by Team ID and User login by login.
get_my_infoget_ssh_keysGet list of information about Team Users.
Get Team role for given User and Team IDs.
Get list with information about User Teams.
get_tokenSequence of fields that are returned by the API to represent UserInfo.
Name of the tuple that represents UserInfo.
Removes User from Team.
Updates User info.
Attributes
MAX_WAIT_ATTEMPTSMaximum number of attempts that will be made to wait for a certain condition to be met.
WAIT_ATTEMPT_TIMEOUT_SECNumber of seconds for intervals between attempts.
- InfoType¶
alias of
UserInfo
- class Membership(id, name, role_id, role)¶
Bases:
tupleCreate new instance of Membership(id, name, role_id, role)
-
index(value, start=
0, stop=9223372036854775807, /)¶ Return first index of value.
Raises ValueError if the value is not present.
- id¶
Alias for field number 0
- name¶
Alias for field number 1
- role¶
Alias for field number 3
- role_id¶
Alias for field number 2
-
index(value, start=
- static info_sequence()[source]¶
Sequence of fields that are returned by the API to represent UserInfo.
- Usage Example:
UserInfo( id=8, login="alex", role=None, role_id=None, name=None, email=None, logins=20, disabled=False, last_login="2021-03-24T15:06:26.804Z", created_at="2020-04-17T10:24:09.077Z", updated_at="2021-03-24T15:13:01.148Z", )
- add_to_team(user_id, team_id, role_id)[source]¶
Invites User to Team with the given role.
- Parameters:
- Returns:
None
- Return type:
None
- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() user_id = 8 team_id = 76 role_id = 5 api.user.add_to_team(user_id, team_id, role_id)
- add_to_team_by_login(user_login, team_id, role_id)[source]¶
Invite User to Team with given role by login.
- Parameters:
- Returns:
Information about new User in Team
- Return type:
- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() team_id = 13 role_id = 2 new_user_data = api.user.add_to_team_by_login('alex', team_id, role_id) print(new_user_data) # Output: {"userId": 8}
- change_team_role(user_id, team_id, role_id)[source]¶
Changes User role in the given Team.
- Parameters:
- Returns:
None
- Return type:
None
- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() user_id = 8 team_id = 64 new_role_id = 2 api.user.change_team_role(user_id, team_id, new_role_id)
-
create(login, password, is_restricted=
False, name='', email='')[source]¶ Creates new User with given login and password.
- Parameters:
- login : str¶
New User login.
- password : str¶
New User password.
- is_restricted : bool, optional¶
If True, new User will have no access to Explore section, won’t be able to create or switch Teams, and no personal Team will be created for this User during signup.
- name : str, optional¶
New User name.
- email : str, optional¶
New User email.
- Returns:
Information about new User.
- Return type:
UserInfo- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() new_user_info = api.user.create('John', 'qwerty', is_restricted=True, name='John Wick', email='excomunicado@gmail.com') print(new_user_info) # Output: [ # 274, # "John", # null, # null, # "John Wick", # "excomunicado@gmail.com", # 0, # false, # null, # "2021-03-24T16:20:03.110Z", # "2021-03-24T16:20:03.110Z" # ]
- disable(id)[source]¶
Disables User with the given ID.
- Parameters:
- Returns:
None
- Return type:
None
- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() user_id = 8 api.user.disable(user_id)
- enable(id)[source]¶
Enables User with the given ID.
- Parameters:
- Returns:
None
- Return type:
None
- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() user_id = 8 api.user.enable(user_id)
- get_info_by_id(id)[source]¶
Get User information by User ID.
- Parameters:
- Returns:
Information about User.
- Return type:
UserInfo- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() user_info = api.user.get_info_by_id(8) print(user_info) # Output: [ # 8, # "alex", # null, # null, # null, # null, # 20, # false, # "2021-03-24T15:06:26.804Z", # "2020-04-17T10:24:09.077Z", # "2021-03-24T15:13:01.148Z" # ]
- get_info_by_login(login)[source]¶
Get User information by User login.
- Parameters:
- Returns:
Information about User.
- Return type:
UserInfo- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() user_info = api.user.get_info_by_login('alex') print(user_info) # Output: [ # 8, # "alex", # null, # null, # null, # null, # 20, # false, # "2021-03-24T15:06:26.804Z", # "2020-04-17T10:24:09.077Z", # "2021-03-24T15:13:01.148Z" # ]
-
get_list(filters=
None)[source]¶ Get list of information about Users.
- Parameters:
- Returns:
List of information about Users.
- Return type:
List[UserInfo]- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() # Get list of Users with id = 8 user_info = api.user.get_list(filters=[{'field': 'id', 'operator': '=', 'value': '8'}]) print(user_info) # Output: [ # 8, # "alex", # "manager", # 3, # null, # null, # 20, # false, # "2021-03-24T15:06:26.804Z", # "2020-04-17T10:24:09.077Z", # "2021-03-24T15:13:01.148Z" # ]
-
get_list_all_pages(method, data, progress_cb=
None, convert_json_info_cb=None, limit=None, return_first_response=False)¶ Get list of all or limited quantity entities from the Supervisely server.
- Parameters:
- method : str¶
Request method name
- data : dict¶
Dictionary with request body info
- progress_cb : Progress, optional¶
Function for tracking download progress.
- convert_json_info_cb : Callable, optional¶
Function for convert json info
- limit : int, optional¶
Number of entity to retrieve
- return_first_response : bool, optional¶
Specify if return first response
- Returns:
List of entities.
- Return type:
List[dict]
-
get_list_all_pages_generator(method, data, progress_cb=
None, convert_json_info_cb=None, limit=None, return_first_response=False)¶ This generator function retrieves a list of all or a limited quantity of entities from the Supervisely server, yielding batches of entities as they are retrieved
- Parameters:
- method : str¶
Request method name
- data : dict¶
Dictionary with request body info
- progress_cb : Progress, optional¶
Function for tracking download progress.
- convert_json_info_cb : Callable, optional¶
Function for convert json info
- limit : int, optional¶
Number of entity to retrieve
- return_first_response : bool, optional¶
Specify if return first response
- async get_list_idx_page_async(method, data)¶
Get the list of items for a given page number. Page number is specified in the data dictionary.
-
async get_list_page_generator_async(method, data, pages_count=
None, semaphore=None)¶ Yields list of images in dataset asynchronously page by page.
- Parameters:
- method : str¶
Method to call for listing items.
- data : dict¶
Data to pass to the API method.
- pages_count : int, optional¶
Preferred number of pages to retrieve if used with a
per_pagelimit. Will be automatically adjusted if thepagesCountdiffers from the requested number.- semaphore=
None¶ Semaphore for limiting the number of simultaneous requests.
- Returns:
List of images in dataset.
- Return type:
AsyncGenerator[List[
ImageInfo]]- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() method = 'images.list' data = {'datasetId': 123456} loop = sly.utils.get_or_create_event_loop() images = loop.run_until_complete(api.image.get_list_generator_async(method, data))
-
get_member_activity(team_id, user_id, progress_cb=
None)[source]¶ Get User activity data.
- Parameters:
- Returns:
Activity data as pd.DataFrame
- Return type:
pd.DataFrame- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() activity = api.user.get_member_activity(64, 8) print(activity) # Output: # userId action date ... jobId tag tagId # 0 8 login_to_team 2021-03-13T08:57:26.832Z ... None None None # 1 8 annotation_duration 2021-03-02T13:16:23.833Z ... None None None # 2 8 login_to_team 2021-03-02T13:15:58.775Z ... None None None # 3 8 login_to_team 2021-02-06T09:47:22.999Z ... None None None # ................................................................................ # 38 8 create_workspace 2021-01-04T12:25:37.916Z ... None None None # 39 8 login_to_team 2021-01-04T12:24:58.257Z ... None None None # 40 8 login_to_team 2021-01-04T12:23:43.056Z ... None None None # 41 8 login_to_team 2021-01-04T11:53:56.447Z ... None None None # [42 rows x 18 columns]
- get_member_info_by_id(team_id, user_id)[source]¶
Get information about team member by Team ID and User ID.
- Parameters:
- Returns:
Information about User.
- Return type:
UserInfo- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() member_info = api.user.get_member_info_by_id(64, 8) print(member_info) # Output: [ # 8, # "alex", # "manager", # 3, # null, # null, # 20, # false, # "2021-03-24T15:06:26.804Z", # "2020-04-17T10:24:09.077Z", # "2021-03-24T15:13:01.148Z" # ]
- get_member_info_by_login(team_id, login)[source]¶
Get information about team member by Team ID and User login by login.
- Parameters:
- Returns:
Information about User.
- Return type:
UserInfo- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() member_info = api.user.get_member_info_by_login(64, 'alex') print(member_info) # Output: [ # 8, # "alex", # "manager", # 3, # null, # null, # 20, # false, # "2021-03-24T15:06:26.804Z", # "2020-04-17T10:24:09.077Z", # "2021-03-24T15:13:01.148Z" # ]
- get_team_members(team_id)[source]¶
Get list of information about Team Users.
- Parameters:
- Returns:
List of information about Team Users
- Return type:
List[UserInfo]- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() team_id = 9 team_members = api.user.get_team_members(team_id)
- get_team_role(user_id, team_id)[source]¶
Get Team role for given User and Team IDs.
- Parameters:
- Returns:
Membership information for the specified team (team id, name, and role).
- Return type:
UserInfo, optional- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() user_id = 8 team_id = 9 team_role = api.user.get_team_role(user_id, team_id) print(team_role) # Output: TeamMembership(id=9, name="alex", role_id=1, role="admin")
- get_teams(id)[source]¶
Get list with information about User Teams.
- Parameters:
- Returns:
List of teams where the user is a member (team id, name, and role).
- Return type:
List[
UserInfo]- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() teams = api.user.get_teams(8) print(teams) # Output: [ # [ # 9, # "alex", # 1, # "admin" # ], # [ # 64, # "test", # 3, # "manager" # ] # ]
- remove_from_team(user_id, team_id)[source]¶
Removes User from Team.
- Parameters:
- Returns:
None
- Return type:
None
- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() user_id = 8 team_id = 76 api.user.remove_from_team(user_id, team_id)
-
update(id, password=
None, name=None)[source]¶ Updates User info.
- Parameters:
- Returns:
New information about User.
- Return type:
UserInfo- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() user_info = api.user.update(8, name='Aleksey') print(user_info) # Output: [ # 8, # "alex", # null, # null, # "Aleksey", # null, # 21, # false, # "2021-03-25T08:06:03.498Z", # "2020-04-17T10:24:09.077Z", # "2021-03-25T08:37:17.257Z" # ]