from typing import Optional
from .api import NextcloudTasksApi, TaskList, TaskFile
from .error import ApiError
from .request import AioBasicAuthenticator, AioRequester
__all__ = [
'AioBasicAuthenticator',
'AioRequester',
'NextcloudTasksApi',
'ApiError',
'TaskList',
'TaskFile',
'NextcloudTasksApiFactory',
]
class NextcloudTasksApiFactory:
def __init__(self, base_url: str, verify_ssl: bool = True, limit: int = 0, timeout: Optional[float] = None) -> None:
"""Convenience wrapper for yielding API instance on the given endpoint."""
self._base_url: str = base_url
self._verify_ssl: bool = verify_ssl
self._limit: int = limit
self._timeout: Optional[float] = timeout
async def create(self, username: str, password: str) -> NextcloudTasksApi:
"""Instance bound to certain credentials. Note that the API instance must be async entered before use."""
return NextcloudTasksApi(AioRequester(
base_url=self._base_url,
authenticator=AioBasicAuthenticator(username=username, password=password),
verify_ssl=self._verify_ssl,
limit=self._limit,
timeout=self._timeout,
))
@property
def base_url(self) -> str:
return self._base_url