Files
oxipy/oxi/core.py
IluaAir 7e8446389e Add reload method to OxiAPI class
- Implemented a new `reload` method to fetch the reload status from the API.
- The method raises an error for unsuccessful responses and returns the status code on success.
2026-03-12 20:15:52 +03:00

34 lines
855 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()
def reload(self):
reload_response = self._session.get(f"{self.base_url}/reload")
reload_response.raise_for_status()
return reload_response.status_code