Skip to main content

Small module to work with Userside ERP

Project description

Userside module for python

Install

You can install userside module via pip, from testPyPi for now

 python3 -m pip install --index-url https://test.pypi.org/simple/ 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.dateadd.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.4.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

pyuserside-0.0.4-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file pyuserside-0.0.4.tar.gz.

File metadata

  • Download URL: pyuserside-0.0.4.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.0

File hashes

Hashes for pyuserside-0.0.4.tar.gz
Algorithm Hash digest
SHA256 187edc434734a469e66ff582f55bd8db0a70fc9ee3dac0a4a213b0b853136f0c
MD5 bab3177d0cc630c27905c9d6b4d206a6
BLAKE2b-256 7179d4f4f1f1a6b46ffe17751be14f097fe854895813b8290e1de45eae4c1d36

See more details on using hashes here.

File details

Details for the file pyuserside-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: pyuserside-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.0

File hashes

Hashes for pyuserside-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 58c8fcf4372c042888721612f85f0cedadc1744557ac82eb87ba68412b5ec31e
MD5 7fbc812c491f71e77451e5174cca3d9b
BLAKE2b-256 ca51bf6860ba6df55273604e3925b5898b3c52a5dd8ad47177bd889c6c097a51

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page