Python client library for the Hudu API
Reason this release was yanked:
Yanked- this was Pre-Versioning Convention
Project description
hudu-magic
A tiny, enum-driven, class-based Python API client for Hudu.
- Minimal dependencies
- Generated from OpenAPI
- Low Maintenance
- Designed for clarity and maintainability
Installing Python
Windows 11 Windows 10 version 2004 or newer with (May 2020 Update, which contains winget) Windows 8.1 (non-ARM architecture) with (May 2020 Update, which contains winget)
. .\install-python.ps1
Linux and MacOS
Ubuntu, Debian, Linux mint, MX Linux, Zorin OS, Pop! OS, KDE Neon, Antix, or any other Debian-based distro that uses apt for package management can run the start.sh bash script.
chmod +x ./install-python.sh && ./install-python.sh
Quick Start
from hudu_magic import HuduClient
client = HuduClient(
api_key="your_api_key",
instance_url="https://yourinstance.huducloud.com"
)
company = client.companies.create(name="Test Company")
asset = client.assets.create(
company_id=company.id,
name="Router",
asset_layout_id=1,
)
asset.name = "Updated Router"
asset.save()
asset.delete()
Installation
Install package
pip install hudu-magic
Until published:
./build.sh
pip install dist/*.whl
Usage Info and Guide
There are several examples in the examples folder that might be helpful if you're just starting out
Core Concepts
Client
Handles auth, requests, pagination, wrapping.
client.assets.list()
Collections
Collection-level operations:
- list()
- get()
- create()
- delete()
- archive()
- unarchive()
assetsforcompany.save()
assetsforcompany.delete()
assetsforcompany.archive()
Models (HuduObject)
Instance-level operations:
- save()
- delete()
- refresh()
- relate_to()
- list_photos()
- list_uploads()
- relate_to()
- upload_to()
asset.save()
asset.delete()
Special Model Methods
Companies
mycompany.list_assets()
mycompany.list_articles()
mycompany.list_passwords()
mycompany.list_procedures()
mycompany.list_websites()
mycompany.create_website
Creating Objects
The create base method for all objects is simple. you can specify properties in either the payload object (standard dictionary) or as kwargs (just propertyname=value)
This means you can use either:
kwargs (recommended)
client.assets.create(name="Router", company_id=1)
dict payload
client.assets.create(payload={"name": "Router", "company_id": 1})
Updating Objects
asset.name = "New Name"
asset.save()
or
asset.update(name="New Name")
Relations
asset.relate_to(website)
or
client.relations.create(from_obj=asset, to_obj=website)
Uploads
asset.upload_to("file.zip")
uploads = asset.list_uploads()
Photos
asset.add_photo("image.png")
photos = asset.list_photos()
Generating builds for new Hudu versions or previous versions
-
Place openapi spec file https://yoururl.huducloud.com/api-docs.json in project directory as hudu-openapiv1.json
-
run
python generate-endpoints.pyafter sourcing virtual environment (that has dev dependencies installed) -
run
./build.sh
todo: .\build.ps1
this is designed to be suyper simple so that subsequent releases can eventually just be automatically generated, tested, validated, and pushed to pypi.
Note on Building:
unit tests and integration tests run during build, so if you want the integration tests to actually run (and succeed), ensure you've filled out testenv from template testenv.example.
Error Handling, Additional Info / Help
If more information is needed, you can call this method on class members to get all associated info from hudu's API spec-
huduobject.help()
for resources like client.huduobject / client.assets, you can call either of these to get information from hudu's OpenAPI spec-
client.huduobjecttype.describe() / client.huduobjecttype.describe()
or for more-verbose info-
client.huduobjecttype.help()
if an object type or resource doesnt support a method call or payload param, you'll be notified of which one(s), if any, are invalid.
Special Class Methods
Advanced Use Possibilities
Multi-Client
You can instantiate two or more client objects, like above, to transfer data from, say, your dev instance to production. This hasn't been extensively tested expecially for objects dependent on companies (assets, passwordfolders)
client2.assets.create(
**client1.assets.get(6).to_dict()
)
Philosophy
- Simple > clever
- Explicit > implicit
- Thin wrapper over Hudu API
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hudu_magic-0.1.0.tar.gz.
File metadata
- Download URL: hudu_magic-0.1.0.tar.gz
- Upload date:
- Size: 41.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54e6451129f70f419695c3745fe2de4d761ed562e00fc811d3c5234009a45487
|
|
| MD5 |
23473369b8b72c3153c2c4dacde54840
|
|
| BLAKE2b-256 |
9eb4b9387d19d9e4fbe1b8d33116ff72c25f66f2ea7f5e9e3adabd5ccc993a6d
|
File details
Details for the file hudu_magic-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hudu_magic-0.1.0-py3-none-any.whl
- Upload date:
- Size: 42.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12750d41659a6bdec92e9a11ed50640acd682ebe19646e8454b3197b928e8084
|
|
| MD5 |
022b8d1cad3353d0d2dc79da45ac76d9
|
|
| BLAKE2b-256 |
e3be49d97490c33b0e0186f50585cfe49cd0e1bb384fef8c3080b697cc04d146
|