From 1b26f5c86fa539080479c91b991cb550acb102ff Mon Sep 17 00:00:00 2001 From: Jakob Scheid Date: Wed, 29 Apr 2026 19:17:58 +0200 Subject: [PATCH] Add models for Gitea webhooks --- docs/CHANGELOG.md | 3 +- .../models/__init__.py | 19 +++++ src/jcloud_deployment_server/models/gitea.py | 81 +++++++++++++++++++ 3 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 src/jcloud_deployment_server/models/__init__.py create mode 100644 src/jcloud_deployment_server/models/gitea.py diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 680b425..d15afe4 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -5,4 +5,5 @@ ### Added - Add basic API structure -- Add configuration file template \ No newline at end of file +- Add configuration file template +- Add models for Gitea webhooks \ No newline at end of file diff --git a/src/jcloud_deployment_server/models/__init__.py b/src/jcloud_deployment_server/models/__init__.py new file mode 100644 index 0000000..25e52ae --- /dev/null +++ b/src/jcloud_deployment_server/models/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2026 jCloud Services GbR + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from . import gitea + +__all__ = [ + 'gitea' +] \ No newline at end of file diff --git a/src/jcloud_deployment_server/models/gitea.py b/src/jcloud_deployment_server/models/gitea.py new file mode 100644 index 0000000..4896627 --- /dev/null +++ b/src/jcloud_deployment_server/models/gitea.py @@ -0,0 +1,81 @@ +# Copyright 2026 jCloud Services GbR + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from pydantic import BaseModel, HttpUrl +from typing import Optional, List +from datetime import datetime + +__all__ = [ + 'User', + 'Repository', + 'ReleaseAsset', + 'Release', + 'ReleaseEvent' +] + +class User(BaseModel): + id: int + login: str + username: Optional[str] = None + full_name: Optional[str] = None + email: Optional[str] = None + + class Config: + extra = 'allow' + +class Repository(BaseModel): + id: int + name: str + full_name: str + clone_url: Optional[HttpUrl] = None + default_branch: Optional[str] = None + + class Config: + extra = 'allow' + +class ReleaseAsset(BaseModel): + id: int + name: str + size: Optional[int] = None + download_count: Optional[int] = None + browser_download_url: Optional[HttpUrl] = None + + class Config: + extra = 'allow' + +class Release(BaseModel): + id: int + tag_name: str + target_commitish: Optional[str] = None + name: Optional[str] = None + body: Optional[str] = None + draft: bool + prerelease: bool + created_at: Optional[datetime] = None + published_at: Optional[datetime] = None + + author: Optional[User] = None + assets: Optional[List[ReleaseAsset]] = None + + class Config: + extra = 'allow' + +class ReleaseEvent(BaseModel): + action: str # 'published', 'created', ... + release: Release + repository: Repository + sender: User + + class Config: + extra = 'allow' \ No newline at end of file