Alexandre Teles (afterSt0rm) 45ef33741c
feat: API rewrite (#2)
* feat: sanic framework settings

* feat: initial implementation

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* refactor: backend changes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: docstrings out of place

* feat: more gh endpoints

* ci: fix pre-commit issues

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* feat: app info

* ci: merge CI and fix triggers

* chore: bump deps

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: typing issues

* chore: deps

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* refactor: clean up returns

* ci: spread jobs correctly

* ci: move to quodana

* ci: fix issues with python modules

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* chore: pycharm config

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* refactor: improve code quality

* feat: better README

* ci: add quodana baseline config

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* ci: fix quodana config

* ci: more qodana stuff

* ci: revert qodana changes

* ci: python interpreter detection is broken

* feat: tests

* ci: testing

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* ci: fix workflow names

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* chore: add deps

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: more tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* feat: /tools compat

* feat: donations endpoint

* feat: teams endpoint

* fix: lock pydantic version

* chore: deps

* ci: docker builds

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* ci: remove coverage action and others

* ci: pre-commit fixes

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-07-12 04:48:36 -03:00

92 lines
2.6 KiB
Python

from abc import abstractmethod
from typing import Any, Protocol
from api.backends.entities import *
class Backend(Protocol):
"""Interface for a generic backend.
Attributes:
name (str): Name of the backend.
base_url (str): Base URL of the backend.
Methods:
list_releases: Retrieve a list of releases.
get_release_by_tag_name: Retrieve a release by its tag name.
get_latest_release: Retrieve the latest release.
get_latest_pre_release: Retrieve the latest pre-release.
get_release_notes: Retrieve the release notes of a specific release.
get_contributors: Retrieve the list of contributors.
get_patches: Retrieve the patches of a specific release.
"""
name: str
base_url: str
def __init__(self, name: str, base_url: str):
self.name = name
self.base_url = base_url
@abstractmethod
async def list_releases(self, *args: Any, **kwargs: Any) -> list[Release]:
raise NotImplementedError
@abstractmethod
async def get_release_by_tag_name(self, *args: Any, **kwargs: Any) -> Release:
raise NotImplementedError
@abstractmethod
async def get_latest_release(self, *args: Any, **kwargs: Any) -> Release:
raise NotImplementedError
@abstractmethod
async def get_latest_pre_release(self, *args: Any, **kwargs: Any) -> Release:
raise NotImplementedError
@abstractmethod
async def get_contributors(self, *args: Any, **kwargs: Any) -> list[Contributor]:
raise NotImplementedError
@abstractmethod
async def get_patches(self, *args: Any, **kwargs: Any) -> list[dict]:
raise NotImplementedError
@abstractmethod
async def get_team_members(self, *args: Any, **kwargs: Any) -> list[Contributor]:
raise NotImplementedError
class Repository:
"""A repository that communicates with a specific backend.
Attributes:
backend (Backend): The backend instance used to communicate with the repository.
"""
def __init__(self, backend: Backend):
self.backend = backend
class AppInfoProvider(Protocol):
"""Interface for a generic app info provider.
Attributes:
name (str): Name of the app info provider.
base_url (str): Base URL of the app info provider.
Methods:
get_app_info: Retrieve information about an app.
"""
name: str
base_url: str
def __init__(self, name: str, base_url: str):
self.name = name
self.base_url = base_url
@abstractmethod
async def get_app_info(self, *args: Any, **kwargs: Any) -> AppInfo:
raise NotImplementedError