Finally, an official Python client for Hudu's API For users on Windows, Linux, or Mac!
What even is Python? I dislike snakes!
python is a high-level, interpreted programming language known for its simple, English-like syntax. It's very readable and intuitive.
hudu-magic is a Python package that wraps the Hudu API in a small, class-based client so you can stay in one language, with types and structure that match how Hudu thinks about resources.
we also have an examples section that make starting out as easy as possible!
Why another client?
Thin stack — basically
requestsand the standard library (plustyping-extensionson older Pythons). No heavy framework tax. You'll find it's quite fast.Pleasant to use — a
HuduClientwith resources likecompanies,assets,articles, and models you cansave(),delete(), andrefresh()Honest to the API — the surface is driven from OpenAPI, so everything sent is exactly as Hudu's API defines.
How do I get it?
First, make sure you have python installed. If you want a handy oneliner for this to happen with your Windows, Mac or Linux machine, look no further than install-python help page in community
Once you have python installed and your virtual environment is created (installer above does this for you), you can simply run:python -m pip install hudu-magic
or to upgrade your hudu-magic packagepython -m pip install hudu-magic --upgrade --no-cache
How do I use it?
It's easy -
first, you make sure your script imports hudu_magic and the HuduClient class.
Then, define your client using your instance URL and API key
from hudu_magic import HuduClient
client = HuduClient(
api_key="your_api_key",
instance_url="https://yourinstance.huducloud.com"
)Then? Whatever you want.
to create a company, you mightmycompany = client.companies.create(name="Test Company")
to create an asset, you mightmyasset = client.assets.create(payload={"name": "Router", "company_id": 1, "asset_layout_id": 10})
And Once you have an object (via create or get), you can interact with or modify it directly. For Example.mycompany.list_assets() or mycompany.list_articles()
or myasset.update(name="New Name") or myasset.relate_to(myotherasset)
These methods and more are also allowed on collections or lists of objects - just be careful! Collection methods are powerful, so ALWAYS make sure to have a current backup.
The following would delete all assets for a given company.mycompany.list_assets().delete()
If you want specific help with a specific class, endpoint, or resource, you can call describe() or help() methods, such as:client.assets.describe() or myasset.describe()
or for more detailed information:client.passwords.help() or myarticle.help()
depending on what you're doing, you may need to wrap help/describe methods in a print() statement.
For detailed instructions, see community README or pypi (python package index) page
It's still a pretty new project, so any ideas, questions, or issues are encouraged!
You can submit new issues on the community scripts issues section if you have trouble!