Certificates API¶
The CertificatesAPI
client provides methods for managing Incus certificates.
Usage¶
from incus_sdk import Client
async with Client() as client:
# List all certificates
certificates = await client.certificates.list()
# Get a certificate by fingerprint
certificate = await client.certificates.get("abcdef123456")
# Create a new certificate
with open("client.crt", "r") as f:
cert_data = f.read()
await client.certificates.create(
certificate=cert_data,
name="my-client",
type="client",
restricted=True,
projects=["default"]
)
# Update a certificate
await client.certificates.update(
"abcdef123456",
{
"name": "updated-client",
"restricted": False
}
)
# Delete a certificate
await client.certificates.delete("abcdef123456")
Class Documentation¶
API client for Incus certificates.
Source code in incus_sdk/api/certificates.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 |
|
__init__(client)
¶
Initialize a new CertificatesAPI client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client
|
APIClient
|
The base API client. |
required |
Source code in incus_sdk/api/certificates.py
14 15 16 17 18 19 20 21 |
|
create(certificate, name=None, type='client', restricted=False, projects=None, password=None)
async
¶
Create a new certificate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
certificate
|
str
|
Certificate data. |
required |
name
|
str
|
Name of the certificate. |
None
|
type
|
str
|
Type of certificate. |
'client'
|
restricted
|
bool
|
Whether the certificate is restricted. |
False
|
projects
|
List[str]
|
List of projects the certificate has access to. |
None
|
password
|
str
|
Password for the certificate. |
None
|
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dict[str, Any]: The operation response. |
Source code in incus_sdk/api/certificates.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 84 85 86 87 |
|
delete(fingerprint)
async
¶
Delete a certificate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fingerprint
|
str
|
Fingerprint of the certificate. |
required |
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dict[str, Any]: The operation response. |
Source code in incus_sdk/api/certificates.py
89 90 91 92 93 94 95 96 97 98 99 |
|
get(fingerprint)
async
¶
Get a certificate by fingerprint.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fingerprint
|
str
|
Fingerprint of the certificate. |
required |
Returns:
Name | Type | Description |
---|---|---|
Certificate |
Certificate
|
The certificate. |
Source code in incus_sdk/api/certificates.py
42 43 44 45 46 47 48 49 50 51 52 53 |
|
list(recursion=1)
async
¶
List all certificates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
recursion
|
int
|
Level of recursion for the response. |
1
|
Returns:
Type | Description |
---|---|
List[Certificate]
|
List[Certificate]: List of certificates. |
Source code in incus_sdk/api/certificates.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
|
update(fingerprint, data)
async
¶
Update a certificate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fingerprint
|
str
|
Fingerprint of the certificate. |
required |
data
|
Dict[str, Any]
|
New certificate data. |
required |
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dict[str, Any]: The operation response. |
Source code in incus_sdk/api/certificates.py
101 102 103 104 105 106 107 108 109 110 111 112 |
|
Methods¶
list¶
async def list(recursion: int = 1) -> List[Certificate]
List all certificates.
Parameters:
- recursion
: Level of recursion for the response (default: 1).
Returns:
- A list of Certificate
objects.
get¶
async def get(fingerprint: str) -> Certificate
Get a certificate by fingerprint.
Parameters:
- fingerprint
: Fingerprint of the certificate.
Returns:
- A Certificate
object.
create¶
async def create(
certificate: str,
name: str = None,
type: str = "client",
restricted: bool = False,
projects: List[str] = None,
password: str = None,
) -> Dict[str, Any]
Create a new certificate.
Parameters:
- certificate
: Certificate data as a string.
- name
: Name of the certificate (optional).
- type
: Type of certificate (default: "client").
- restricted
: Whether the certificate is restricted (default: False).
- projects
: List of projects the certificate has access to (optional).
- password
: Password for the certificate (optional).
Returns: - The operation response as a dictionary.
Example:
# Create a client certificate
with open("client.crt", "r") as f:
cert_data = f.read()
await client.certificates.create(
certificate=cert_data,
name="my-client",
type="client",
restricted=True,
projects=["default", "production"]
)
delete¶
async def delete(
fingerprint: str
) -> Dict[str, Any]
Delete a certificate.
Parameters:
- fingerprint
: Fingerprint of the certificate.
Returns: - The operation response as a dictionary.
update¶
async def update(
fingerprint: str,
data: Dict[str, Any]
) -> Dict[str, Any]
Update a certificate.
Parameters:
- fingerprint
: Fingerprint of the certificate.
- data
: New certificate data as a dictionary.
Returns: - The operation response as a dictionary.
Example:
# Update a certificate
await client.certificates.update(
"abcdef123456",
{
"name": "updated-client",
"restricted": False,
"projects": ["default", "staging", "production"]
}
)