Profiles API¶
The ProfilesAPI
client provides methods for managing Incus profiles.
Usage¶
from incus_sdk import Client
async with Client() as client:
# List all profiles
profiles = await client.profiles.list()
# Get a profile by name
profile = await client.profiles.get("default")
# Create a new profile
await client.profiles.create(
name="my-profile",
config={
"limits.cpu": "2",
"limits.memory": "2GB"
},
devices={
"eth0": {
"name": "eth0",
"nictype": "bridged",
"parent": "lxdbr0",
"type": "nic"
}
},
description="My custom profile"
)
# Update a profile
await client.profiles.update(
name="my-profile",
config={
"limits.cpu": "4",
"limits.memory": "4GB"
}
)
# Delete a profile
await client.profiles.delete("my-profile")
Class Documentation¶
API client for Incus profiles.
Source code in incus_sdk/api/profiles.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
|
__init__(client)
¶
Initialize a new ProfilesAPI client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client
|
APIClient
|
The base API client. |
required |
Source code in incus_sdk/api/profiles.py
14 15 16 17 18 19 20 21 |
|
create(name, config=None, description=None, devices=None)
async
¶
Create a new profile.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the profile. |
required |
config
|
Dict[str, Any]
|
Profile configuration. |
None
|
description
|
str
|
Description of the profile. |
None
|
devices
|
Dict[str, Dict[str, Any]]
|
Profile devices. |
None
|
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dict[str, Any]: The operation response. |
Source code in incus_sdk/api/profiles.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|
delete(name)
async
¶
Delete a profile.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the profile. |
required |
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dict[str, Any]: The operation response. |
Source code in incus_sdk/api/profiles.py
111 112 113 114 115 116 117 118 119 120 121 |
|
get(name)
async
¶
Get a profile by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the profile. |
required |
Returns:
Name | Type | Description |
---|---|---|
Profile |
Profile
|
The profile. |
Source code in incus_sdk/api/profiles.py
42 43 44 45 46 47 48 49 50 51 52 53 |
|
list(recursion=1)
async
¶
List all profiles.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
recursion
|
int
|
Level of recursion for the response. |
1
|
Returns:
Type | Description |
---|---|
List[Profile]
|
List[Profile]: List of profiles. |
Source code in incus_sdk/api/profiles.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
|
rename(name, new_name)
async
¶
Rename a profile.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Current name of the profile. |
required |
new_name
|
str
|
New name for the profile. |
required |
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dict[str, Any]: The operation response. |
Source code in incus_sdk/api/profiles.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
|
replace(name, config)
async
¶
Replace a profile configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the profile. |
required |
config
|
Dict[str, Any]
|
New configuration. |
required |
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dict[str, Any]: The operation response. |
Source code in incus_sdk/api/profiles.py
98 99 100 101 102 103 104 105 106 107 108 109 |
|
update(name, config)
async
¶
Update a profile.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the profile. |
required |
config
|
Dict[str, Any]
|
New configuration. |
required |
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dict[str, Any]: The operation response. |
Source code in incus_sdk/api/profiles.py
85 86 87 88 89 90 91 92 93 94 95 96 |
|
Methods¶
list¶
async def list(recursion: int = 1) -> List[Profile]
List all profiles.
Parameters:
- recursion
: Level of recursion for the response (default: 1).
Returns:
- A list of Profile
objects.
get¶
async def get(name: str) -> Profile
Get a profile by name.
Parameters:
- name
: Name of the profile.
Returns:
- A Profile
object.
create¶
async def create(
name: str,
config: Dict[str, Any] = None,
description: str = None,
devices: Dict[str, Dict[str, Any]] = None,
) -> Dict[str, Any]
Create a new profile.
Parameters:
- name
: Name of the profile.
- config
: Profile configuration as a dictionary (optional).
- description
: Description of the profile (optional).
- devices
: Profile devices as a dictionary (optional).
Returns: - The operation response as a dictionary.
Example:
# Create a profile with resource limits and a network device
await client.profiles.create(
name="web-server",
config={
"limits.cpu": "2",
"limits.memory": "2GB",
"security.nesting": "true"
},
devices={
"eth0": {
"name": "eth0",
"nictype": "bridged",
"parent": "lxdbr0",
"type": "nic"
},
"root": {
"path": "/",
"pool": "default",
"type": "disk"
}
},
description="Profile for web servers"
)
update¶
async def update(
name: str,
config: Dict[str, Any]
) -> Dict[str, Any]
Update a profile.
Parameters:
- name
: Name of the profile.
- config
: New configuration as a dictionary.
Returns: - The operation response as a dictionary.
Note: This method performs a partial update of the profile configuration, only modifying the specified fields.
replace¶
async def replace(
name: str,
config: Dict[str, Any]
) -> Dict[str, Any]
Replace a profile configuration.
Parameters:
- name
: Name of the profile.
- config
: New configuration as a dictionary.
Returns: - The operation response as a dictionary.
Note: This method replaces the entire profile configuration with the provided configuration.
delete¶
async def delete(
name: str
) -> Dict[str, Any]
Delete a profile.
Parameters:
- name
: Name of the profile.
Returns: - The operation response as a dictionary.
rename¶
async def rename(
name: str,
new_name: str
) -> Dict[str, Any]
Rename a profile.
Parameters:
- name
: Current name of the profile.
- new_name
: New name for the profile.
Returns: - The operation response as a dictionary.