Skip to main content

Asynchronous api module for 3x-ui

Reason this release was yanked:

bugs

Project description

asyncapixui

Asynchronous api module for 3x-ui

Simple usage

import asyncio
from datetime import datetime, timedelta
from logging import DEBUG, getLogger, basicConfig
from uuid import uuid4

from asycnapixui.api import Api
from asycnapixui.models import Client
from asycnapixui.utils import ExpiryTime


async def main():
    async with Api(url="https://example.com:port/path/",
                   login="admin", password="admin", token="") as api:
        """
        create api session
        """

        clients = []
        emails = ['Petya', 'Vasya', 'Egor']

        """get inbound by id"""
        inbound = await api.get_inbound(1)

        """create clients list"""
        for email in emails:
            key = str(uuid4())
            clients.append(Client(id=key, email=email, subId=key))

        """add clients to inbound """
        await api.post_add_client_inbound(clients, inbound.id)

        """
        enable clients in inbound 
        and add date to end = now + 10 days
        """
        for client in clients:
            client.enable = True
            client.expiryTime = ExpiryTime(date=datetime.now() + timedelta(days=10)).expiryTime
            await api.post_update_client(client, inbound.id, client.id)


"""
logs with information about responses
"""

logger = getLogger()
FORMAT = '%(asctime)s : %(levelname)s:%(name)s : %(funcName)s:%(message)s'
basicConfig(level=DEBUG, format=FORMAT)

if __name__ == "__main__":
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
    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

asycnapixui-0.0.3.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

asycnapixui-0.0.3-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file asycnapixui-0.0.3.tar.gz.

File metadata

  • Download URL: asycnapixui-0.0.3.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.4

File hashes

Hashes for asycnapixui-0.0.3.tar.gz
Algorithm Hash digest
SHA256 881da4c79b5651c233acd12717c6011c79676b267001097134cc11263b82c40e
MD5 25727288450c82533b809bc6dbcd1d83
BLAKE2b-256 ec5c480051e76e2e4bf958b496c58d8625410d6da171fe26be3e407fc46fbc7d

See more details on using hashes here.

File details

Details for the file asycnapixui-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: asycnapixui-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.4

File hashes

Hashes for asycnapixui-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d603762ca31732a9ba9ebdbc3392fabf40b4d4aa4a11e5547be4ae0067c278b3
MD5 8e9c6d4d24e83153b137299801c253b2
BLAKE2b-256 84836d1e2f8f7ca615f9d60202e8b7f8b3a14e04ce093625533f71d965aaa686

See more details on using hashes here.

Supported by

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