Files
oxipy/oxi/core.py
IluaAir b60182ef3c Add ttp dependency and refactor OxiAPI and NodeConfig classes
- Added `ttp` as a dependency in `pyproject.toml` and `uv.lock`.
- Updated `NodeConfig` to store model names in lowercase.
- Refactored `OxiAPI` to always create a new session and added a `close` method.
- Removed unnecessary logging in `Node` class.
- Introduced interfaces for device registration with a new `BaseDevice` class and a `register_parser` function.
- Created initial structure for device models, including a `Mikrotik` parser.
2026-02-14 21:31:02 +03:00

29 lines
675 B
Python

from typing import Optional
from requests import Session
from .node import Node
class OxiAPI:
def __init__(
self,
url: str,
username: Optional[str] = None,
password: Optional[str] = None,
verify: bool = True,
):
self.base_url = url.rstrip("/")
self._session = Session()
self._session.verify = verify
if username and password:
self._session.auth = (username, password)
self.node = Node(self._session, self.base_url)
def __enter__(self):
return self
def __exit__(self, *args):
self.close()
def close(self):
return self._session.close()