Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions kuma/rest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Union
import logging
from typing import Union, Optional

from kuma.rest._base import KumaRestAPIBase
from kuma.rest.active_lists import KumaRestAPIActiveLists
Expand Down Expand Up @@ -47,8 +48,10 @@ def __init__(
token: str,
verify: Union[bool, str],
timeout: int = KumaRestAPIBase.DEFAULT_TIMEOUT,
logger: Optional[logging.Logger] = None,
version: str = "",
):
super().__init__(url, token, verify, timeout)
super().__init__(url, token, verify, timeout, logger, version)
self._modules = {}

def _get_module(self, name: str):
Expand Down
13 changes: 8 additions & 5 deletions kuma/rest/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@ def __init__(
verify: Union[bool, str] = False,
timeout: int = DEFAULT_TIMEOUT,
logger: Optional[logging.Logger] = None,
version: str = "",
):
"""Initialize the API client.

Args:
url: Base server URL (e.g., "kumacore.local" or "https://kumacore.local:7223")
token: Bearer token for authentication
url: Base server URL (e.g., "kumacore.local" or "https://kumacore.local:7223").
token: Bearer token for authentication.
verify: SSL certificate verification. Set False to disable warnings.
timeout: Request timeout in seconds (default: 30)
logger: Custom logger instance (optional)
timeout: Request timeout in seconds (default: 30).
logger: Custom logger instance (optional).
version: Version of KUMA API.

Raises:
ValueError: If URL is malformed
Expand All @@ -52,6 +54,7 @@ def __init__(

self.timeout = timeout
self.logger = logger or self._create_default_logger()
self.v = version or _api_version

self._configure_url(url)
self._configure_session(token)
Expand Down Expand Up @@ -126,7 +129,7 @@ def _make_request(
"""
Unified request method with error handling and logging.
"""
url = f"{self.url}/api/{_api_version}/{endpoint.lstrip('/')}"
url = f"{self.url}/api/{self.v}/{endpoint.lstrip('/')}"
headers = {**self.session.headers, **(headers or {})}

self.logger.debug(f"Request: {method} {url}")
Expand Down