Complete package renaming and platform migration: Package Name Changes: - Rename package from 'wikijs-python-sdk' to 'py-wikijs' - Update setup.py package name - Update pyproject.toml package name - Users can now install with: pip install py-wikijs URL Migration (Gitea → GitHub): - Replace all Gitea URLs with GitHub URLs - Update repository: github.com/l3ocho/py-wikijs - Update issue tracker: github.com/l3ocho/py-wikijs/issues - Update documentation links - Fix URL path format (/src/branch/main/ → /blob/main/) Documentation Updates: - Update README.md badges (PyPI, GitHub) - Update installation instructions (pip install py-wikijs) - Update all doc references to new package name - Update all examples with GitHub URLs - Update DEPLOYMENT_READY.md with new package name - Update deployment.md with new package name Testing: - Successfully built py_wikijs-0.1.0.tar.gz (138 KB) - Successfully built py_wikijs-0.1.0-py3-none-any.whl (66 KB) - Package installs correctly: pip install py-wikijs - Imports work: from wikijs import WikiJSClient - Package metadata correct (Home-page: github.com/l3ocho/py-wikijs) Breaking Changes: - Package name changed from wikijs-python-sdk to py-wikijs - Repository migrated from Gitea to GitHub - All URLs updated to GitHub Users should now: pip install py-wikijs # Instead of wikijs-python-sdk 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
141 lines
3.8 KiB
Python
141 lines
3.8 KiB
Python
"""Base async endpoint class for py-wikijs."""
|
|
|
|
from typing import TYPE_CHECKING, Any, Dict, Optional
|
|
|
|
if TYPE_CHECKING:
|
|
from ..client import AsyncWikiJSClient
|
|
|
|
|
|
class AsyncBaseEndpoint:
|
|
"""Base class for all async API endpoints.
|
|
|
|
This class provides common functionality for making async API requests
|
|
and handling responses across all endpoint implementations.
|
|
|
|
Args:
|
|
client: The async WikiJS client instance
|
|
"""
|
|
|
|
def __init__(self, client: "AsyncWikiJSClient"):
|
|
"""Initialize endpoint with client reference.
|
|
|
|
Args:
|
|
client: Async WikiJS client instance
|
|
"""
|
|
self._client = client
|
|
|
|
async def _request(
|
|
self,
|
|
method: str,
|
|
endpoint: str,
|
|
params: Optional[Dict[str, Any]] = None,
|
|
json_data: Optional[Dict[str, Any]] = None,
|
|
**kwargs: Any,
|
|
) -> Any:
|
|
"""Make async HTTP request through the client.
|
|
|
|
Args:
|
|
method: HTTP method (GET, POST, PUT, DELETE)
|
|
endpoint: API endpoint path
|
|
params: Query parameters
|
|
json_data: JSON data for request body
|
|
**kwargs: Additional request parameters
|
|
|
|
Returns:
|
|
Parsed response data
|
|
"""
|
|
return await self._client._request(
|
|
method=method,
|
|
endpoint=endpoint,
|
|
params=params,
|
|
json_data=json_data,
|
|
**kwargs,
|
|
)
|
|
|
|
async def _get(
|
|
self, endpoint: str, params: Optional[Dict[str, Any]] = None, **kwargs: Any
|
|
) -> Any:
|
|
"""Make async GET request.
|
|
|
|
Args:
|
|
endpoint: API endpoint path
|
|
params: Query parameters
|
|
**kwargs: Additional request parameters
|
|
|
|
Returns:
|
|
Parsed response data
|
|
"""
|
|
return await self._request("GET", endpoint, params=params, **kwargs)
|
|
|
|
async def _post(
|
|
self,
|
|
endpoint: str,
|
|
json_data: Optional[Dict[str, Any]] = None,
|
|
params: Optional[Dict[str, Any]] = None,
|
|
**kwargs: Any,
|
|
) -> Any:
|
|
"""Make async POST request.
|
|
|
|
Args:
|
|
endpoint: API endpoint path
|
|
json_data: JSON data for request body
|
|
params: Query parameters
|
|
**kwargs: Additional request parameters
|
|
|
|
Returns:
|
|
Parsed response data
|
|
"""
|
|
return await self._request(
|
|
"POST", endpoint, params=params, json_data=json_data, **kwargs
|
|
)
|
|
|
|
async def _put(
|
|
self,
|
|
endpoint: str,
|
|
json_data: Optional[Dict[str, Any]] = None,
|
|
params: Optional[Dict[str, Any]] = None,
|
|
**kwargs: Any,
|
|
) -> Any:
|
|
"""Make async PUT request.
|
|
|
|
Args:
|
|
endpoint: API endpoint path
|
|
json_data: JSON data for request body
|
|
params: Query parameters
|
|
**kwargs: Additional request parameters
|
|
|
|
Returns:
|
|
Parsed response data
|
|
"""
|
|
return await self._request(
|
|
"PUT", endpoint, params=params, json_data=json_data, **kwargs
|
|
)
|
|
|
|
async def _delete(
|
|
self, endpoint: str, params: Optional[Dict[str, Any]] = None, **kwargs: Any
|
|
) -> Any:
|
|
"""Make async DELETE request.
|
|
|
|
Args:
|
|
endpoint: API endpoint path
|
|
params: Query parameters
|
|
**kwargs: Additional request parameters
|
|
|
|
Returns:
|
|
Parsed response data
|
|
"""
|
|
return await self._request("DELETE", endpoint, params=params, **kwargs)
|
|
|
|
def _build_endpoint(self, *parts: str) -> str:
|
|
"""Build endpoint path from parts.
|
|
|
|
Args:
|
|
*parts: Path components
|
|
|
|
Returns:
|
|
Formatted endpoint path
|
|
"""
|
|
# Remove empty parts and join with /
|
|
clean_parts = [str(part).strip("/") for part in parts if part]
|
|
return "/" + "/".join(clean_parts)
|