Reference for hub_sdk/modules/users.py
Note
This file is available at https://github.com/ultralytics/hub-sdk/blob/main/hub_sdk/modules/users.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
hub_sdk.modules.users.Users
Users(user_id: Optional[str] = None, headers: Optional[Dict[str, Any]] = None)
Bases: CRUDClient
A class representing a client for interacting with Users through CRUD operations.
This class extends the CRUDClient class and provides specific methods for working with Users.
Attributes:
Name | Type | Description |
---|---|---|
id |
str | None
|
The unique identifier of the user, if available. |
data |
Dict
|
A dictionary to store user data. |
Methods:
Name | Description |
---|---|
get_data |
Retrieves data for the current user instance. |
create_user |
Creates a new user with the provided data. |
delete |
Deletes the user resource represented by this instance. |
update |
Updates the user resource represented by this instance. |
Note
The 'id' attribute is set during initialization and can be used to uniquely identify a user. The 'data' attribute is used to store user data fetched from the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user_id
|
str
|
The unique identifier of the user. |
None
|
headers
|
Dict[str, Any]
|
A dictionary of HTTP headers to be included in API requests. |
None
|
Source code in hub_sdk/modules/users.py
31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
create_user
create_user(user_data: Dict) -> None
Create a new user with the provided data and set the user ID for the current instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user_data
|
Dict
|
A dictionary containing the data for creating the user. |
required |
Source code in hub_sdk/modules/users.py
80 81 82 83 84 85 86 87 88 89 |
|
delete
delete(hard: bool = False) -> Optional[Response]
Delete the user resource represented by this instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hard
|
bool
|
If True, perform a hard delete. |
False
|
Note
The 'hard' parameter determines whether to perform a soft delete (default) or a hard delete. In a soft delete, the model might be marked as deleted but retained in the system. In a hard delete, the model is permanently removed from the system.
Returns:
Type | Description |
---|---|
Optional[Response]
|
Response object from the delete request, or None if delete fails |
Source code in hub_sdk/modules/users.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|
get_data
get_data() -> None
Retrieve data for the current user instance.
If a valid user ID has been set, it sends a request to fetch the user data and stores it in the instance. If no user ID has been set, it logs an error message.
Source code in hub_sdk/modules/users.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|
update
update(data: Dict) -> Optional[Response]
Update the user resource represented by this instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
Dict
|
The updated data for the user resource. |
required |
Returns:
Type | Description |
---|---|
Optional[Response]
|
Response object from the update request, or None if update fails |
Source code in hub_sdk/modules/users.py
108 109 110 111 112 113 114 115 116 117 118 |
|