Hub API Reference
xovis.api.hub.client
Xovis SDK - HUB Cloud Client
This module resides within the State & Topology Plane, serving as the primary entry point for fleet orchestration via the Xovis HUB Cloud. It coordinates OAuth2 authentication, dynamic OpenAPI device tunneling, and concurrent bulk operations across distributed edge sensors.
Classes
HubClient
Asynchronous client for interacting with the Xovis HUB Cloud.
Manages the complete lifecycle of the Xovis fleet, including automated OAuth2 token rotation, client-side state caching, and secure Hub-to-Edge tunneling. Acts as the definitive orchestrator for distributed sensor networks.
Source code in src/xovis/api/hub/client.py
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 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
Methods:
__aenter__()
async
Enables asynchronous context management and triggers initial sync.
Returns:
| Name | Type | Description |
|---|---|---|
HubClient |
HubClient
|
The initialized and synchronized client. |
Source code in src/xovis/api/hub/client.py
200 201 202 203 204 205 206 207 208 209 210 | |
__aexit__(exc_type, exc_val, exc_tb)
async
Ensures graceful teardown of the HTTP connection pool.
Source code in src/xovis/api/hub/client.py
212 213 214 215 216 | |
__aiter__()
async
Enables asynchronous iteration over the cached fleet devices.
Yields:
| Name | Type | Description |
|---|---|---|
DeviceClient |
AsyncIterator[DeviceClient]
|
A connected DeviceClient for each device in the fleet. |
Source code in src/xovis/api/hub/client.py
188 189 190 191 192 193 194 195 196 197 198 | |
__init__(client_id=None, client_secret=None, token=None, base_url='https://api.xovis.cloud', token_url='https://login.xovis.cloud/oauth/token', tunnel_base_url=None, timeout=15.0, max_retries=5, fleet_filter=None, **kwargs)
Initializes the HubClient and mounts architectural pillars.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client_id
|
Optional[str]
|
The OAuth2 Client ID provided by Xovis. If not provided, resolves from XOVIS_HUB_CLIENT_ID env var. |
None
|
client_secret
|
Optional[str]
|
The OAuth2 Client Secret provided by Xovis. If not provided, resolves from XOVIS_HUB_CLIENT_SECRET env var. |
None
|
token
|
Optional[str]
|
Optional static API token. |
None
|
base_url
|
str
|
The base URL for the Xovis HUB Cloud API. Defaults to "https://api.xovis.cloud". |
'https://api.xovis.cloud'
|
token_url
|
str
|
The Auth0 token endpoint. Defaults to "https://login.xovis.cloud/oauth/token". |
'https://login.xovis.cloud/oauth/token'
|
tunnel_base_url
|
Optional[str]
|
Optional override for the
device tunnel base URL. If not provided, the |
None
|
timeout
|
float
|
Default timeout for HTTP operations. Defaults to 15.0. |
15.0
|
max_retries
|
int
|
Maximum retry attempts for resilient networking. Defaults to 5. |
5
|
fleet_filter
|
Optional[Dict[str, Any]]
|
Client-side filter to restrict the visible fleet scope. |
None
|
**kwargs
|
Any
|
Additional configuration for the HTTP engine. |
{}
|
Source code in src/xovis/api/hub/client.py
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 | |
aclose()
async
Manually releases all underlying network resources.
Source code in src/xovis/api/hub/client.py
218 219 220 221 222 | |
bulk_execute(func, fleet_filter=None)
async
Maps an asynchronous function across the fleet.
Executes the provided coroutine concurrently across devices in the cache using strict fault isolation. Failures on individual devices do not interrupt the execution of the remaining fleet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[[DeviceClient], Coroutine[Any, Any, T]]
|
The async configuration function to execute. Receives a connected DeviceClient as its primary argument. |
required |
fleet_filter
|
Optional[Dict[str, Any]]
|
Dictionary to restrict execution. Supported keys: 'macs' (List[str]) to target specific devices. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, BulkResult[T]]
|
Dict[str, BulkResult[T]]: A mapping of MAC addresses to their respective execution outcomes. |
Source code in src/xovis/api/hub/client.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
connect_device(id_or_name)
async
Spawns a DeviceClient routed through the Hub's dynamic secure tunnel.
Enables seamless transition from fleet-level management to specific edge sensor configuration. Intercepts OAuth2 tokens to authenticate the proxied connection.
The tunnel URL is dynamically constructed per the OpenAPI specification:
{base_url}/devices/{mac_address}/tunnel. The DeviceClient will then
append its own paths (e.g., /api/v5/...).
CRITICAL: The returned client MUST be used as an asynchronous context manager to prevent connection pooling leaks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_or_name
|
str
|
The MAC address (ID) or human-readable name of the target device. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
DeviceClient |
DeviceClient
|
A fully hydrated client instance routed via the HUB. |
Source code in src/xovis/api/hub/client.py
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 137 138 139 140 | |
xovis.api.hub.cache
Xovis SDK - Hub Configuration Cache Manager
This module resides within the State & Topology Plane, providing a client-side cache for the Xovis HUB Cloud fleet. It manages device and license state synchronization, implementing robust client-side filtering and dot-notation accessors for interactive environments.
Classes
HubCacheManager
Client-side cache manager for the Xovis HUB Cloud fleet.
Coordinates the synchronization of fleet-wide metadata (devices, licenses)
from the HUB Cloud API. Supports high-performance client-side filtering
via fleet_filter and provides dot-notation accessors for rapid
discovery in REPL environments.
Source code in src/xovis/api/hub/cache.py
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 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 | |
Attributes
devices
property
Accessor for devices mapped by their human-readable name.
Returns:
| Type | Description |
|---|---|
REPLAccessor[Device]
|
REPLAccessor[Device]: A dynamic accessor for name-based device discovery. |
devices_by_mac
property
Accessor for devices mapped by their unique MAC address.
Returns:
| Type | Description |
|---|---|
REPLAccessor[Device]
|
REPLAccessor[Device]: A dynamic accessor for MAC-based device discovery. |
licenses
property
Accessor for licenses mapped by device ID.
Returns:
| Type | Description |
|---|---|
REPLAccessor[LicenseStatus]
|
REPLAccessor[LicenseStatus]: A dynamic accessor for license status. |
Methods:
__init__(http_client, fleet_filter=None, auto_persist_path=None)
Initializes the HubCacheManager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
http_client
|
XovisHTTPClient
|
The resilient Hub API engine. |
required |
fleet_filter
|
Optional[Dict[str, Any]]
|
A dictionary of attributes and values to filter the fleet by (e.g., {"group": "EMEA"}). Supports list-based "any-of" matching. |
None
|
auto_persist_path
|
Optional[str]
|
Custom path for cache persistence. |
None
|
Source code in src/xovis/api/hub/cache.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
_ensure_directory_or_fallback(path)
Ensures the directory for the given path is writeable or falls back.
Implements the 3-Tier cache folder creation and fallback strategy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
The desired target file path. |
required |
Returns:
| Type | Description |
|---|---|
Optional[Path]
|
Optional[Path]: The writeable target path, or None if falling back to memory-only. |
Source code in src/xovis/api/hub/cache.py
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
_matches_filter(device)
Evaluates if a device matches the configured fleet filter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device
|
Device
|
The device model to evaluate. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the device matches all filter criteria, False otherwise. |
Source code in src/xovis/api/hub/cache.py
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 | |
_resolve_persist_path()
Resolves the final persistence path for the Hub fleet.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Optional[str]: The absolute path to the state file, or None. |
Source code in src/xovis/api/hub/cache.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | |
export_to_file(file_path, custom_bucket=None)
Writes the current hub state or a custom bucket to an offline JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
The target file path for the JSON workspace. |
required |
custom_bucket
|
Optional[HubStateBucket]
|
A filtered bucket to export instead of the full internal state. Defaults to None. |
None
|
Source code in src/xovis/api/hub/cache.py
285 286 287 288 289 290 291 292 293 294 295 296 | |
load_from_disk()
async
Deserializes the HubStateBucket from disk.
Source code in src/xovis/api/hub/cache.py
424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 | |
load_from_file(file_path, merge=False)
Reads a JSON workspace file and replaces or merges the internal state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
The source file path to load from. |
required |
merge
|
bool
|
If True, merges the loaded state into the current state instead of replacing it. Defaults to False. |
False
|
Source code in src/xovis/api/hub/cache.py
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | |
save_to_disk()
async
Safely serializes the HubStateBucket to disk.
Source code in src/xovis/api/hub/cache.py
410 411 412 413 414 415 416 417 418 419 420 421 422 | |
sync(preserve_topology=True)
async
Synchronizes the Hub fleet state with the Cloud API.
Fetches all devices and licenses, applies client-side filtering based on
the fleet_filter configuration, and populates the internal state bucket.
Warns if the filter is overly restrictive (dropping >90% of devices).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
preserve_topology
|
bool
|
If True, retains any topological roles and parents discovered during the current session's Deep Dive. Defaults to True. |
True
|
Raises:
| Type | Description |
|---|---|
HTTPError
|
If the Hub API is unreachable or returns an error. |
Source code in src/xovis/api/hub/cache.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |
HubStateBucket
Bases: BaseModel
Root state container for the Xovis HUB Cloud fleet.
Aggregates collections of devices and their corresponding license statuses fetched from the Hub API, enabling efficient client-side filtering and lookup.
Source code in src/xovis/api/hub/cache.py
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 | |
Methods:
normalize_parents(v)
classmethod
Normalizes parent MAC address lists to consistent uppercase formats.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
Any
|
Raw parent mapping. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Normalized parent dictionary. |
Source code in src/xovis/api/hub/cache.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
normalize_roles_keys(v)
classmethod
Ensures all topology role keys are normalized to uppercase MAC addresses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
Any
|
Raw role mapping. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Normalized role dictionary. |
Source code in src/xovis/api/hub/cache.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
Resources
xovis.api.hub.resources.hub_device
Xovis SDK - HUB Cloud Device Management Resource
Provides the implementation for managing fleet-wide device metadata, UI access, and categorical assignments on the Xovis HUB Cloud. Operates within the Control Plane and State & Topology Plane.
Classes
HubDevicesManager
Bases: HubResourceManager
Manages device operations on the Xovis HUB Cloud.
This manager orchestrates fleet-wide operations, including metadata synchronization and secure UI tunneling. It utilizes the HubCacheManager to resolve human-readable names to MAC addresses.
Source code in src/xovis/api/hub/resources/hub_device.py
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 | |
Methods:
__init__(http_client, cache=None)
Initializes the HubDevicesManager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
http_client
|
XovisHTTPClient
|
The resilient HTTP client. |
required |
cache
|
Optional[HubCacheManager]
|
The HUB-level cache manager. |
None
|
Source code in src/xovis/api/hub/resources/hub_device.py
33 34 35 36 37 38 39 40 41 42 | |
assign_customer(id_or_name, customer_name)
async
Assigns a customer identifier to a list of devices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_or_name
|
Union[str, List[str]]
|
Target device MAC(s) or name(s). |
required |
customer_name
|
str
|
The customer name to assign. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The response from the HUB Cloud. |
Source code in src/xovis/api/hub/resources/hub_device.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
get_device_ui_access(id_or_name)
async
Generates secure, temporary UI access links for specific devices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_or_name
|
Union[str, List[str]]
|
Target device MAC(s) or name(s). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
DeviceUiAccess |
DeviceUiAccess
|
Secure access URLs for the requested devices. |
Source code in src/xovis/api/hub/resources/hub_device.py
54 55 56 57 58 59 60 61 62 63 64 65 66 | |
get_devices()
async
Retrieves all devices associated with the current HUB tenant.
Returns:
| Name | Type | Description |
|---|---|---|
DevicesResponse |
DevicesResponse
|
A collection of device metadata. |
Source code in src/xovis/api/hub/resources/hub_device.py
44 45 46 47 48 49 50 51 52 | |
update_categories(id_or_name, categories_to_add=None, categories_to_remove=None)
async
Modifies categorical tags for a list of devices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_or_name
|
Union[str, List[str]]
|
Target device MAC(s) or name(s). |
required |
categories_to_add
|
Optional[List[str]]
|
Tags to append. |
None
|
categories_to_remove
|
Optional[List[str]]
|
Tags to strip. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The response from the HUB Cloud. |
Source code in src/xovis/api/hub/resources/hub_device.py
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 | |
xovis.api.hub.resources.hub_license
Xovis SDK - HUB Cloud License Management Resource
Provides the implementation for managing fleet-wide license status and provisioning on the Xovis HUB Cloud. Operates within the Control Plane and State & Topology Plane.
Classes
HubLicensesManager
Bases: HubResourceManager
Manages license provisioning and status on the Xovis HUB Cloud.
This manager orchestrates the distribution and verification of software licenses across the device fleet. It utilizes the HubCacheManager to resolve human-readable names to MAC addresses.
Source code in src/xovis/api/hub/resources/hub_license.py
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 | |
Methods:
__init__(http_client, cache=None)
Initializes the HubLicensesManager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
http_client
|
XovisHTTPClient
|
The resilient HTTP client. |
required |
cache
|
Optional[HubCacheManager]
|
The HUB-level cache manager. |
None
|
Source code in src/xovis/api/hub/resources/hub_license.py
28 29 30 31 32 33 34 35 36 37 | |
create(id_or_name, bundle_types)
async
Provisions new license bundles to a set of devices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_or_name
|
Union[str, List[str]]
|
Target device MAC(s) or name(s). |
required |
bundle_types
|
List[BundleType]
|
The license bundles to provision. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The response from the HUB Cloud. |
Source code in src/xovis/api/hub/resources/hub_license.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
get_status()
async
Retrieves the license status for all devices in the current HUB tenant.
Returns:
| Name | Type | Description |
|---|---|---|
LicenseStatusResponse |
LicenseStatusResponse
|
A collection of license status metadata. |
Source code in src/xovis/api/hub/resources/hub_license.py
39 40 41 42 43 44 45 46 47 | |