Reference for hub_sdk/base/crud_client.py
Note
This file is available at https://github.com/ultralytics/hub-sdk/blob/main/hub_sdk/base/crud_client.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
hub_sdk.base.crud_client.CRUDClient
Bases: APIClient
Represents a CRUD (Create, Read, Update, Delete) client for interacting with a specific resource.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name associated with the CRUD operations (e.g., "User"). |
logger |
Logger
|
An instance of the logger for logging purposes. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_endpoint
|
str
|
The base endpoint URL for the API. |
required |
name
|
str
|
The name associated with the CRUD operations (e.g., "User"). |
required |
headers
|
dict
|
Headers to be included in API requests. |
required |
Source code in hub_sdk/base/crud_client.py
create
Create a new entity using the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
dict
|
The data to be sent as part of the creation request. |
required |
Returns:
Type | Description |
---|---|
Optional[Response]
|
Response object from the create request, or None if upload fails. |
Source code in hub_sdk/base/crud_client.py
delete
Delete an entity using the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
str
|
The unique identifier of the entity to delete. |
required |
hard
|
bool
|
If True, perform a hard delete. If False, perform a soft delete. |
False
|
Returns:
Type | Description |
---|---|
Optional[Response]
|
Response object from the delete request, or None if delete fails. |
Source code in hub_sdk/base/crud_client.py
list
List entities using the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
page
|
int
|
The page number to retrieve. |
0
|
limit
|
int
|
The maximum number of entities per page. |
10
|
Returns:
Type | Description |
---|---|
Optional[Response]
|
Response object from the list request, or None if it fails. |
Source code in hub_sdk/base/crud_client.py
read
Retrieve details of a specific entity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
str
|
The unique identifier of the entity to retrieve. |
required |
Returns:
Type | Description |
---|---|
Optional[Response]
|
Response object from the read request, or None if read fails. |
Source code in hub_sdk/base/crud_client.py
update
Update an existing entity using the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
str
|
The unique identifier of the entity to update. |
required |
data
|
dict
|
The updated data to be sent in the update request. |
required |
Returns:
Type | Description |
---|---|
Optional[Response]
|
Response object from the update request, or None if update fails. |