Small module to work with Userside ERP
Project description
Userside module for python
Install
You can install userside module via pip
pip install pyuserside
Examples
Sync API
.. code:: python
from pyuserside.api.synchronous import UsersideAPI
# Create UsersideAPI instance
uapi = UsersideAPI(url='https://localhost/api.php', key='my_secret_key')
# Find some device and get information about it
device_id = uapi.device.get_device_id(object_type='switch', data_typer='ip', data_value='10.90.90.90')
device = uapi.device.get_data(object_type='switch', object_id=device_id)[0]
# We can access device name (raw text), ...
print(device.name)
# ..., date when device was added (converted to datetime), ...
print(device.activity_time.isoformat())
# .., or device IP-address (converted to ipaddress.ip_address)
print(device.ip.exploded)
Or use 'with' statement:
.. code:: python
from pyuserside.api.synchronous import UsersideAPI
with UsersideAPI(url='https://localhost/api.php', key='my_secret_key') as uapi:
device_id = uapi.device.get_device_id(object_type='switch', data_typer='ip', data_value='10.90.90.90')
device = uapi.device.get_data(object_type='switch', object_id=device_id)[0]
Async API
Same categories, same methods, same respose models, except for asynchronous!
.. code:: python
from pyuserside.api.asynchronous import UsersideAPI
import asyncio
# Create UsersideAPI instance
uapi = UsersideAPI(url='https://localhost/api.php', key='my_secret_key')
# Find some task and get information about it
tasks = asyncio.run(uapi.task.get_list(type_id=157, state_id=1))
interested_task_id = tasks[0]
task = asyncio.run(uapi.task.show(id=interested_task_id))
# We can access task description (raw text), ...
print(task.description)
# ..., date of creation/complete/etc (converted to datetime object), ...
print(task.date.create.isoformat())
print(task.date.complete.isoformat())
# .., or device address (converted to Address object)
print(task.address.text)
print(task.address.addressId)
Or use 'async with' statement:
.. code:: python
from pyuserside.api.asynchronous import UsersideAPI
import asyncio
async def main():
async with UsersideAPI(url='https://localhost/api.php', key='my_secret_key') as uapi:
tasks = await uapi.task.get_list(type_id=157, state_id=1)
interested_task_id = tasks[0]
task = await uapi.task.show(id=interested_task_id)
asyncio.run(main())
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyuserside-0.0.5.tar.gz
(10.0 kB
view details)
Built Distribution
File details
Details for the file pyuserside-0.0.5.tar.gz
.
File metadata
- Download URL: pyuserside-0.0.5.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a487c133bb8c5a9dfbdde99d515b0b0fa6580133140d0adff7c3ab8ff6bb8663 |
|
MD5 | e15748465af40e0793f0d087accbf106 |
|
BLAKE2b-256 | 45569f5e50eab5f0f1b472dbda44e14cfd81c0f73757477d2353ac0696a960b2 |
File details
Details for the file pyuserside-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: pyuserside-0.0.5-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89714ce98cc1ce8a03f770a76df45f2c97e9cacd8d9ad339a55874221eb7efc3 |
|
MD5 | 199f98df6321b93508d0595cbb77ecab |
|
BLAKE2b-256 | 59cadd7f44d79e0b33038134f8131e75a6d53d3c8d15a6975856eaba781ba78c |