mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-08-28 04:19:57 +00:00
handle service status
This commit is contained in:
@ -33,6 +33,8 @@ def setup_routes(application: Application) -> None:
|
||||
GET / get build status page
|
||||
GET /index.html same as above
|
||||
|
||||
POST /api/v1/ahriman update service status
|
||||
|
||||
POST /api/v1/packages force update every package from repository
|
||||
|
||||
POST /api/v1/package/:base update package base status
|
||||
|
51
src/ahriman/web/views/ahriman.py
Normal file
51
src/ahriman/web/views/ahriman.py
Normal file
@ -0,0 +1,51 @@
|
||||
#
|
||||
# Copyright (c) 2021 Evgenii Alekseev.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from aiohttp.web import HTTPBadRequest, HTTPOk, Response
|
||||
|
||||
from ahriman.models.build_status import BuildStatusEnum
|
||||
from ahriman.web.views.base import BaseView
|
||||
|
||||
|
||||
class AhrimanView(BaseView):
|
||||
'''
|
||||
service status web view
|
||||
'''
|
||||
|
||||
async def post(self) -> Response:
|
||||
'''
|
||||
update service status
|
||||
|
||||
JSON body must be supplied, the following model is used:
|
||||
{
|
||||
"status": "unknown", # service status string, must be valid `BuildStatusEnum`
|
||||
}
|
||||
|
||||
:return: 200 on success
|
||||
'''
|
||||
data = await self.request.json()
|
||||
|
||||
try:
|
||||
status = BuildStatusEnum(data['status'])
|
||||
except Exception as e:
|
||||
raise HTTPBadRequest(text=str(e))
|
||||
|
||||
self.service.update_self(status)
|
||||
|
||||
return HTTPOk()
|
@ -36,6 +36,7 @@ class IndexView(BaseView):
|
||||
packages - sorted list of packages properties: base, packages (sorted list), status,
|
||||
timestamp, version, web_url. Required
|
||||
repository - repository name, string, required
|
||||
service - service status properties: status, timestamp. Required
|
||||
version - ahriman version, string, required
|
||||
'''
|
||||
|
||||
@ -56,10 +57,15 @@ class IndexView(BaseView):
|
||||
'web_url': package.web_url
|
||||
} for package, status in sorted(self.service.packages, key=lambda item: item[0].base)
|
||||
]
|
||||
service = {
|
||||
'status': self.service.status.status.value,
|
||||
'timestamp': self.service.status.timestamp
|
||||
}
|
||||
|
||||
return {
|
||||
'architecture': self.service.architecture,
|
||||
'packages': packages,
|
||||
'repository': self.service.repository.name,
|
||||
'service': service,
|
||||
'version': version.__version__,
|
||||
}
|
||||
|
Reference in New Issue
Block a user