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>
This commit is contained in:
Alexandre Teles (afterSt0rm)
2023-07-12 04:48:36 -03:00
committed by GitHub
parent cb52684edb
commit 45ef33741c
45 changed files with 16359 additions and 86 deletions

0
api/models/__init__.py Normal file
View File

19
api/models/appinfo.py Normal file
View File

@@ -0,0 +1,19 @@
from pydantic import BaseModel
class AppInfoFields(BaseModel):
"""
Fields for the AppInfo endpoint.
"""
name: str
category: str
logo: str
class AppInfoModel(BaseModel):
"""
Response model app info.
"""
app_info: AppInfoFields

27
api/models/compat.py Normal file
View File

@@ -0,0 +1,27 @@
from pydantic import BaseModel
class ToolsResponseFields(BaseModel):
"""Implements the fields for the /tools endpoint.
Args:
BaseModel (pydantic.BaseModel): BaseModel from pydantic
"""
repository: str
version: str
timestamp: str
name: str
size: str | None = None
browser_download_url: str
content_type: str
class ToolsResponseModel(BaseModel):
"""Implements the JSON response model for the /tools endpoint.
Args:
BaseModel (pydantic.BaseModel): BaseModel from pydantic
"""
tools: list[ToolsResponseFields]

13
api/models/donations.py Normal file
View File

@@ -0,0 +1,13 @@
from pydantic import BaseModel
class DonationsResponseModel(BaseModel):
"""
A Pydantic BaseModel that represents a dictionary of donation links.
"""
donations: dict[str, str]
"""
A dictionary where the keys are the names of the donation destinations, and
the values are the links to services or wallet addresses.
"""

127
api/models/github.py Normal file
View File

@@ -0,0 +1,127 @@
from typing import Any, Optional
from pydantic import BaseModel
class MetadataFields(BaseModel):
"""
Metadata fields for a GitHub release.
"""
tag_name: str
name: str
draft: bool
prerelease: bool
created_at: str
published_at: str
body: str
class AssetFields(BaseModel):
"""
Asset fields for a GitHub release.
"""
name: str
content_type: str
browser_download_url: str
class ReleaseResponseModel(BaseModel):
"""
Response model for a GitHub release.
"""
metadata: MetadataFields
assets: list[AssetFields]
class SingleReleaseResponseModel(BaseModel):
"""
Response model for a GitHub release.
"""
release: ReleaseResponseModel
class ReleaseListResponseModel(BaseModel):
"""
Response model for a list of GitHub releases.
"""
releases: list[ReleaseResponseModel]
class CompatiblePackagesResponseFields(BaseModel):
"""
Implements the fields for compatible packages in the PatchesResponseFields class.
"""
name: str
versions: list[str] | None
class PatchesOptionsResponseFields(BaseModel):
key: str
title: str
description: str
required: bool
choices: list[Any] | None
class PatchesResponseFields(BaseModel):
"""
Implements the fields for the /patches endpoint.
"""
name: str
description: str
version: str
excluded: bool
dependencies: list[str] | None
options: list[PatchesOptionsResponseFields] | None
compatiblePackages: list[CompatiblePackagesResponseFields]
class PatchesModel(BaseModel):
"""
Response model for a list of GitHub releases.
"""
patches: list[PatchesResponseFields]
class ContributorsFields(BaseModel):
"""
Implements the fields for a contributor.
"""
login: str
avatar_url: str
html_url: str
contributions: Optional[int]
class ContributorsModel(BaseModel):
"""
Response model for a list of contributors.
"""
contributors: list[ContributorsFields]
class TeamMemberFields(BaseModel):
"""
Implements the fields for a team member.
"""
login: str
avatar_url: str
html_url: str
class TeamMembersModel(BaseModel):
"""
Responde model for a list of team members.
"""
members: list[TeamMemberFields]

13
api/models/socials.py Normal file
View File

@@ -0,0 +1,13 @@
from pydantic import BaseModel
class SocialsResponseModel(BaseModel):
"""
A Pydantic BaseModel that represents a dictionary of social links.
"""
socials: dict[str, str]
"""
A dictionary where the keys are the names of the social networks, and
the values are the links to the profiles or pages.
"""