Devices
airvpn.api.devices
Device
Represents a registered device associated with the account.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
Unique identifier for the device. |
|
name |
Display name of the device. |
|
description |
Description of the device. |
|
version |
Version of the client/software associated with the device. |
|
renew_first_unix |
Unix timestamp of the device's first renewal. |
|
renew_first_date |
Human-readable date of the device's first renewal. |
|
renew_last_unix |
Unix timestamp of the device's most recent renewal. |
|
renew_last_date |
Human-readable date of the device's most recent renewal. |
|
renew_counter |
Number of times the device has been renewed. |
|
wireguard_public_key |
The device's WireGuard public key. |
|
wireguard_ipv4 |
IPv4 address assigned to the device over WireGuard. |
|
wireguard_ipv6 |
IPv6 address assigned to the device over WireGuard. |
|
vpn_last_from_unix |
Unix timestamp of the start of the device's last VPN session. |
|
vpn_last_from_date |
Human-readable start date of the device's last VPN session. |
|
vpn_last_to_unix |
Unix timestamp of the end of the device's last VPN session. |
|
vpn_last_to_date |
Human-readable end date of the device's last VPN session. |
|
vpn_attempt_unix |
Unix timestamp of the device's last connection attempt. |
|
vpn_attempt_date |
Human-readable date of the device's last connection attempt. |
|
vpn_attempt_message |
Message/result associated with the last connection attempt. |
|
status |
Current status of the device. |
DeviceAction
Bases: StrEnum
Actions available for managing devices via the devices endpoint.
Devices
Manages registered devices/keys associated with the account.
Access type
User-specific, API KEY required
Attributes:
| Name | Type | Description |
|---|---|---|
devices |
A list of devices |
devices
property
A list of Devices.
action(action: DeviceAction, id: str | None = None, name: str | None = None, description: str | None = None) -> dict
Send a raw devices action request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
DeviceAction
|
The device action to perform. |
required |
id
|
str | None
|
The device's ID. Required for delete, renew, and modify. |
None
|
name
|
str | None
|
The device's name. Used for add and modify. |
None
|
description
|
str | None
|
The device's description. Used for add and modify. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
The parsed JSON response from the devices endpoint. |
Raises:
| Type | Description |
|---|---|
RateLimited
|
If the response gets rate limited. |
APIError
|
If the response contains an error. |
add() -> str | None
Register a new device.
Returns:
| Type | Description |
|---|---|
str | None
|
The ID of the newly created device, or None if not returned. |
delete(id: str) -> bool
Delete a device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The ID of the device to delete. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if successful in deleting the device. |
Note
Rate limited. If this is called within _delete_rate_limit
seconds of the previous delete() call, this call blocks
until that interval has elapsed before sending the request.
get(name: str, create: bool = False) -> Device | None
Get/create a device using a name
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name to search for. |
required |
create
|
bool
|
If it cannot find the device it will create it. |
False
|
Returns:
| Type | Description |
|---|---|
Device | None
|
The Device object or None |
list() -> list[Device]
modify(id: str, name: str | None = None, description: str | None = None) -> bool
Modify a device's name and/or description.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The ID of the device to modify. |
required |
name
|
str | None
|
The new name for the device, if changing it. |
None
|
description
|
str | None
|
The new description for the device, if changing it. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful in modifying the device. |
Raises:
| Type | Description |
|---|---|
DeviceValidationError
|
If neither name nor description is provided. |
renew(id: str) -> bool
Renew a device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The ID of the device to renew. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if successful in renewing the device. |