mirror of
https://github.com/arcan1s/ahriman.git
synced 2026-04-01 06:03:39 +00:00
feat: brand-new interface (#158)
This was initally generated by ai, but later has been heavily edited. The reason why it has been implemented is that there are plans to implement more features to ui, but it becomes hard to add new features to plain js, so I decided to rewrite it in typescript. Yet because it is still ai slop, it is still possible to enable old interface via configuration, even though new interface is turned on by default to get feedback
This commit is contained in:
@@ -17,10 +17,10 @@
|
||||
# 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, HTTPNotFound, Request, StreamResponse, View
|
||||
from aiohttp.web import HTTPBadRequest, HTTPNotFound, Request, Response, StreamResponse, View, json_response
|
||||
from aiohttp_cors import CorsViewMixin
|
||||
from collections.abc import Awaitable, Callable
|
||||
from typing import ClassVar, TypeVar
|
||||
from typing import Any, ClassVar, TypeVar
|
||||
|
||||
from ahriman.core.auth import Auth
|
||||
from ahriman.core.configuration import Configuration
|
||||
@@ -29,6 +29,7 @@ from ahriman.core.exceptions import UnknownPackageError
|
||||
from ahriman.core.sign.gpg import GPG
|
||||
from ahriman.core.spawn import Spawn
|
||||
from ahriman.core.status.watcher import Watcher
|
||||
from ahriman.core.utils import filter_json
|
||||
from ahriman.models.repository_id import RepositoryId
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.keys import AuthKey, ConfigurationKey, SpawnKey, WatcherKey, WorkersKey
|
||||
@@ -162,6 +163,20 @@ class BaseView(View, CorsViewMixin):
|
||||
raise KeyError(f"Key {key} is missing or empty") from None
|
||||
return value
|
||||
|
||||
@staticmethod
|
||||
def json_response(data: dict[str, Any] | list[Any], **kwargs: Any) -> Response:
|
||||
"""
|
||||
filter and convert data and return :class:`aiohttp.web.Response` object
|
||||
|
||||
Args:
|
||||
data(dict[str, Any] | list[Any]): response in json format
|
||||
**kwargs(Any): keyword arguments for :func:`aiohttp.web.json_response` function
|
||||
|
||||
Returns:
|
||||
Response: generated response object
|
||||
"""
|
||||
return json_response(filter_json(data), **kwargs)
|
||||
|
||||
# pylint: disable=not-callable,protected-access
|
||||
async def head(self) -> StreamResponse:
|
||||
"""
|
||||
|
||||
@@ -19,12 +19,11 @@
|
||||
#
|
||||
import aiohttp_jinja2
|
||||
|
||||
from typing import Any, ClassVar
|
||||
from aiohttp.web import Response
|
||||
from typing import ClassVar
|
||||
|
||||
from ahriman.core.auth.helpers import authorized_userid
|
||||
from ahriman.core.utils import pretty_interval
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.apispec import aiohttp_apispec
|
||||
from ahriman.web.server_info import server_info
|
||||
from ahriman.web.views.base import BaseView
|
||||
|
||||
|
||||
@@ -48,6 +47,7 @@ class IndexView(BaseView):
|
||||
* id - unique repository identifier, string, required
|
||||
* repository - repository name, string, required
|
||||
* architecture - repository architecture, string, required
|
||||
* version - service version, string, required
|
||||
|
||||
Attributes:
|
||||
GET_PERMISSION(UserAccess): (class attribute) get permissions of self
|
||||
@@ -56,41 +56,14 @@ class IndexView(BaseView):
|
||||
GET_PERMISSION: ClassVar[UserAccess] = UserAccess.Unauthorized
|
||||
ROUTES = ["/", "/index.html"]
|
||||
|
||||
@aiohttp_jinja2.template("build-status.jinja2")
|
||||
async def get(self) -> dict[str, Any]:
|
||||
async def get(self) -> Response:
|
||||
"""
|
||||
process get request. No parameters supported here
|
||||
|
||||
Returns:
|
||||
dict[str, Any]: parameters for jinja template
|
||||
Response: 200 with rendered index page
|
||||
"""
|
||||
auth_username = await authorized_userid(self.request)
|
||||
auth = {
|
||||
"control": self.validator.auth_control,
|
||||
"enabled": self.validator.enabled,
|
||||
"username": auth_username,
|
||||
}
|
||||
context = await server_info(self)
|
||||
|
||||
autorefresh_intervals = [
|
||||
{
|
||||
"interval": interval * 1000, # milliseconds
|
||||
"is_active": index == 0, # first element is always default
|
||||
"text": pretty_interval(interval),
|
||||
}
|
||||
for index, interval in enumerate(self.configuration.getintlist("web", "autorefresh_intervals", fallback=[]))
|
||||
if interval > 0 # special case if 0 exists and first, refresh will not be turned on by default
|
||||
]
|
||||
|
||||
return {
|
||||
"auth": auth,
|
||||
"autorefresh_intervals": sorted(autorefresh_intervals, key=lambda interval: interval["interval"]),
|
||||
"docs_enabled": aiohttp_apispec is not None,
|
||||
"index_url": self.configuration.get("web", "index_url", fallback=None),
|
||||
"repositories": [
|
||||
{
|
||||
"id": repository.id,
|
||||
**repository.view(),
|
||||
}
|
||||
for repository in sorted(self.services)
|
||||
]
|
||||
}
|
||||
template = self.configuration.get("web", "template", fallback="build-status.jinja2")
|
||||
return aiohttp_jinja2.render_template(template, self.request, context)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# 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, HTTPNoContent, Response, json_response
|
||||
from aiohttp.web import HTTPBadRequest, HTTPNoContent, Response
|
||||
from typing import ClassVar
|
||||
|
||||
from ahriman.models.event import Event
|
||||
@@ -70,7 +70,7 @@ class EventsView(BaseView):
|
||||
events = self.service().event_get(event, object_id, from_date, to_date, limit, offset)
|
||||
response = [event.view() for event in events]
|
||||
|
||||
return json_response(response)
|
||||
return self.json_response(response)
|
||||
|
||||
@apidocs(
|
||||
tags=["Audit log"],
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# 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, HTTPNoContent, Response, json_response
|
||||
from aiohttp.web import HTTPBadRequest, HTTPNoContent, Response
|
||||
from collections.abc import Callable
|
||||
from typing import ClassVar
|
||||
|
||||
@@ -78,7 +78,7 @@ class WorkersView(BaseView):
|
||||
comparator: Callable[[Worker], Comparable] = lambda item: item.identifier
|
||||
response = [worker.view() for worker in sorted(workers, key=comparator)]
|
||||
|
||||
return json_response(response)
|
||||
return self.json_response(response)
|
||||
|
||||
@apidocs(
|
||||
tags=["Distributed"],
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# 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, HTTPNoContent, Response, json_response
|
||||
from aiohttp.web import HTTPBadRequest, HTTPNoContent, Response
|
||||
from typing import ClassVar
|
||||
|
||||
from ahriman.models.changes import Changes
|
||||
@@ -65,7 +65,7 @@ class ChangesView(StatusViewGuard, BaseView):
|
||||
|
||||
changes = self.service(package_base=package_base).package_changes_get(package_base)
|
||||
|
||||
return json_response(changes.view())
|
||||
return self.json_response(changes.view())
|
||||
|
||||
@apidocs(
|
||||
tags=["Packages"],
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# 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, HTTPNoContent, Response, json_response
|
||||
from aiohttp.web import HTTPBadRequest, HTTPNoContent, Response
|
||||
from typing import ClassVar
|
||||
|
||||
from ahriman.models.dependencies import Dependencies
|
||||
@@ -65,7 +65,7 @@ class DependenciesView(StatusViewGuard, BaseView):
|
||||
|
||||
dependencies = self.service(package_base=package_base).package_dependencies_get(package_base)
|
||||
|
||||
return json_response(dependencies.view())
|
||||
return self.json_response(dependencies.view())
|
||||
|
||||
@apidocs(
|
||||
tags=["Packages"],
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# 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, HTTPNoContent, HTTPNotFound, Response, json_response
|
||||
from aiohttp.web import HTTPBadRequest, HTTPNoContent, HTTPNotFound, Response
|
||||
from typing import ClassVar
|
||||
|
||||
from ahriman.core.exceptions import UnknownPackageError
|
||||
@@ -99,7 +99,7 @@ class LogsView(StatusViewGuard, BaseView):
|
||||
"status": status.view(),
|
||||
"logs": "\n".join(f"[{pretty_datetime(log_record.created)}] {log_record.message}" for log_record in logs)
|
||||
}
|
||||
return json_response(response)
|
||||
return self.json_response(response)
|
||||
|
||||
@apidocs(
|
||||
tags=["Packages"],
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# 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, HTTPNoContent, HTTPNotFound, Response, json_response
|
||||
from aiohttp.web import HTTPBadRequest, HTTPNoContent, HTTPNotFound, Response
|
||||
from typing import ClassVar
|
||||
|
||||
from ahriman.core.exceptions import UnknownPackageError
|
||||
@@ -105,7 +105,7 @@ class PackageView(StatusViewGuard, BaseView):
|
||||
"repository": repository_id.view(),
|
||||
}
|
||||
]
|
||||
return json_response(response)
|
||||
return self.json_response(response)
|
||||
|
||||
@apidocs(
|
||||
tags=["Packages"],
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#
|
||||
import itertools
|
||||
|
||||
from aiohttp.web import HTTPNoContent, Response, json_response
|
||||
from aiohttp.web import HTTPNoContent, Response
|
||||
from collections.abc import Callable
|
||||
from typing import ClassVar
|
||||
|
||||
@@ -78,7 +78,7 @@ class PackagesView(StatusViewGuard, BaseView):
|
||||
} for package, status in itertools.islice(sorted(packages, key=comparator), offset, stop)
|
||||
]
|
||||
|
||||
return json_response(response)
|
||||
return self.json_response(response)
|
||||
|
||||
@apidocs(
|
||||
tags=["Packages"],
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# 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 HTTPNoContent, HTTPNotFound, Response, json_response
|
||||
from aiohttp.web import HTTPNoContent, HTTPNotFound, Response
|
||||
from typing import ClassVar
|
||||
|
||||
from ahriman.models.user_access import UserAccess
|
||||
@@ -89,4 +89,4 @@ class PatchView(StatusViewGuard, BaseView):
|
||||
if selected is None:
|
||||
raise HTTPNotFound(reason=f"Patch {variable} is unknown")
|
||||
|
||||
return json_response(selected.view())
|
||||
return self.json_response(selected.view())
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# 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, HTTPNoContent, Response, json_response
|
||||
from aiohttp.web import HTTPBadRequest, HTTPNoContent, Response
|
||||
from typing import ClassVar
|
||||
|
||||
from ahriman.models.pkgbuild_patch import PkgbuildPatch
|
||||
@@ -60,7 +60,7 @@ class PatchesView(StatusViewGuard, BaseView):
|
||||
patches = self.service().package_patches_get(package_base, None)
|
||||
|
||||
response = [patch.view() for patch in patches]
|
||||
return json_response(response)
|
||||
return self.json_response(response)
|
||||
|
||||
@apidocs(
|
||||
tags=["Packages"],
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# 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, Response, json_response
|
||||
from aiohttp.web import HTTPBadRequest, Response
|
||||
from typing import ClassVar
|
||||
|
||||
from ahriman.models.pkgbuild_patch import PkgbuildPatch
|
||||
@@ -78,4 +78,4 @@ class AddView(BaseView):
|
||||
refresh=data.get("refresh", False),
|
||||
)
|
||||
|
||||
return json_response({"process_id": process_id})
|
||||
return self.json_response({"process_id": process_id})
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# 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 HTTPNoContent, Response, json_response
|
||||
from aiohttp.web import HTTPNoContent, Response
|
||||
from typing import ClassVar
|
||||
|
||||
from ahriman.core.formatters import ConfigurationPrinter
|
||||
@@ -64,7 +64,7 @@ class ConfigView(BaseView):
|
||||
for key, value in values.items()
|
||||
if key not in ConfigurationPrinter.HIDE_KEYS
|
||||
]
|
||||
return json_response(response)
|
||||
return self.json_response(response)
|
||||
|
||||
@apidocs(
|
||||
tags=["Actions"],
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# 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, HTTPNotFound, Response, json_response
|
||||
from aiohttp.web import HTTPBadRequest, HTTPNotFound, Response
|
||||
from typing import ClassVar
|
||||
|
||||
from ahriman.models.user_access import UserAccess
|
||||
@@ -71,7 +71,7 @@ class PGPView(BaseView):
|
||||
except Exception:
|
||||
raise HTTPNotFound(reason=f"Key {key} is unknown")
|
||||
|
||||
return json_response({"key": key})
|
||||
return self.json_response({"key": key})
|
||||
|
||||
@apidocs(
|
||||
tags=["Actions"],
|
||||
@@ -100,4 +100,4 @@ class PGPView(BaseView):
|
||||
|
||||
process_id = self.spawner.key_import(key, data.get("server"))
|
||||
|
||||
return json_response({"process_id": process_id})
|
||||
return self.json_response({"process_id": process_id})
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# 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 HTTPNotFound, Response, json_response
|
||||
from aiohttp.web import HTTPNotFound, Response
|
||||
from typing import ClassVar
|
||||
|
||||
from ahriman.models.user_access import UserAccess
|
||||
@@ -66,4 +66,4 @@ class ProcessView(BaseView):
|
||||
"is_alive": is_alive,
|
||||
}
|
||||
|
||||
return json_response(response)
|
||||
return self.json_response(response)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# 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, Response, json_response
|
||||
from aiohttp.web import HTTPBadRequest, Response
|
||||
from typing import ClassVar
|
||||
|
||||
from ahriman.models.user_access import UserAccess
|
||||
@@ -74,4 +74,4 @@ class RebuildView(BaseView):
|
||||
increment=data.get("increment", True),
|
||||
)
|
||||
|
||||
return json_response({"process_id": process_id})
|
||||
return self.json_response({"process_id": process_id})
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# 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, Response, json_response
|
||||
from aiohttp.web import HTTPBadRequest, Response
|
||||
from typing import ClassVar
|
||||
|
||||
from ahriman.models.user_access import UserAccess
|
||||
@@ -67,4 +67,4 @@ class RemoveView(BaseView):
|
||||
repository_id = self.repository_id()
|
||||
process_id = self.spawner.packages_remove(repository_id, packages)
|
||||
|
||||
return json_response({"process_id": process_id})
|
||||
return self.json_response({"process_id": process_id})
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# 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, Response, json_response
|
||||
from aiohttp.web import HTTPBadRequest, Response
|
||||
from typing import ClassVar
|
||||
|
||||
from ahriman.models.pkgbuild_patch import PkgbuildPatch
|
||||
@@ -78,4 +78,4 @@ class RequestView(BaseView):
|
||||
refresh=False, # refresh doesn't work here
|
||||
)
|
||||
|
||||
return json_response({"process_id": process_id})
|
||||
return self.json_response({"process_id": process_id})
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# 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, HTTPNotFound, Response, json_response
|
||||
from aiohttp.web import HTTPBadRequest, HTTPNotFound, Response
|
||||
from collections.abc import Callable
|
||||
from typing import ClassVar
|
||||
|
||||
@@ -83,4 +83,4 @@ class SearchView(BaseView):
|
||||
"description": package.description,
|
||||
} for package in sorted(packages, key=comparator)
|
||||
]
|
||||
return json_response(response)
|
||||
return self.json_response(response)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# 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, Response, json_response
|
||||
from aiohttp.web import HTTPBadRequest, Response
|
||||
from typing import ClassVar
|
||||
|
||||
from ahriman.models.user_access import UserAccess
|
||||
@@ -75,4 +75,4 @@ class UpdateView(BaseView):
|
||||
refresh=data.get("refresh", False),
|
||||
)
|
||||
|
||||
return json_response({"process_id": process_id})
|
||||
return self.json_response({"process_id": process_id})
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
# 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 Response, json_response
|
||||
from aiohttp.web import Response
|
||||
from typing import ClassVar
|
||||
|
||||
from ahriman import __version__
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.apispec.decorators import apidocs
|
||||
from ahriman.web.schemas import InfoSchema
|
||||
from ahriman.web.server_info import server_info
|
||||
from ahriman.web.views.base import BaseView
|
||||
|
||||
|
||||
@@ -52,13 +52,11 @@ class InfoView(BaseView):
|
||||
Returns:
|
||||
Response: 200 with service information object
|
||||
"""
|
||||
info = await server_info(self)
|
||||
response = {
|
||||
"auth": self.validator.enabled,
|
||||
"repositories": [
|
||||
repository_id.view()
|
||||
for repository_id in sorted(self.services)
|
||||
],
|
||||
"version": __version__,
|
||||
"auth": info["auth"]["enabled"],
|
||||
"repositories": info["repositories"],
|
||||
"version": info["version"],
|
||||
}
|
||||
|
||||
return json_response(response)
|
||||
return self.json_response(response)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# 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 Response, json_response
|
||||
from aiohttp.web import Response
|
||||
from typing import ClassVar
|
||||
|
||||
from ahriman.models.user_access import UserAccess
|
||||
@@ -56,4 +56,4 @@ class RepositoriesView(BaseView):
|
||||
for repository_id in sorted(self.services)
|
||||
]
|
||||
|
||||
return json_response(repositories)
|
||||
return self.json_response(repositories)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# 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, HTTPNoContent, Response, json_response
|
||||
from aiohttp.web import HTTPBadRequest, HTTPNoContent, Response
|
||||
from typing import ClassVar
|
||||
|
||||
from ahriman import __version__
|
||||
@@ -75,7 +75,7 @@ class StatusView(StatusViewGuard, BaseView):
|
||||
version=__version__,
|
||||
)
|
||||
|
||||
return json_response(status.view())
|
||||
return self.json_response(status.view())
|
||||
|
||||
@apidocs(
|
||||
tags=["Status"],
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#
|
||||
import itertools
|
||||
|
||||
from aiohttp.web import Response, json_response
|
||||
from aiohttp.web import Response
|
||||
from dataclasses import replace
|
||||
from typing import ClassVar
|
||||
|
||||
@@ -31,8 +31,7 @@ from ahriman.web.views.status_view_guard import StatusViewGuard
|
||||
|
||||
|
||||
class LogsView(StatusViewGuard, BaseView):
|
||||
""" else:
|
||||
|
||||
"""
|
||||
package logs web view
|
||||
|
||||
Attributes:
|
||||
@@ -80,4 +79,4 @@ class LogsView(StatusViewGuard, BaseView):
|
||||
]
|
||||
|
||||
response = [log_record.view() for log_record in logs]
|
||||
return json_response(response)
|
||||
return self.json_response(response)
|
||||
|
||||
19
src/ahriman/web/views/v2/status/__init__.py
Normal file
19
src/ahriman/web/views/v2/status/__init__.py
Normal file
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
56
src/ahriman/web/views/v2/status/info.py
Normal file
56
src/ahriman/web/views/v2/status/info.py
Normal file
@@ -0,0 +1,56 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# 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 Response
|
||||
from typing import ClassVar
|
||||
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.apispec.decorators import apidocs
|
||||
from ahriman.web.schemas import InfoV2Schema
|
||||
from ahriman.web.server_info import server_info
|
||||
from ahriman.web.views.base import BaseView
|
||||
|
||||
|
||||
class InfoView(BaseView):
|
||||
"""
|
||||
web service information view
|
||||
|
||||
Attributes:
|
||||
GET_PERMISSION(UserAccess): (class attribute) get permissions of self
|
||||
"""
|
||||
|
||||
GET_PERMISSION: ClassVar[UserAccess] = UserAccess.Unauthorized
|
||||
ROUTES = ["/api/v2/info"]
|
||||
|
||||
@apidocs(
|
||||
tags=["Status"],
|
||||
summary="Service information",
|
||||
description="Perform basic service health check and returns its information",
|
||||
permission=GET_PERMISSION,
|
||||
schema=InfoV2Schema,
|
||||
)
|
||||
async def get(self) -> Response:
|
||||
"""
|
||||
get service information
|
||||
|
||||
Returns:
|
||||
Response: 200 with service information object
|
||||
"""
|
||||
response = await server_info(self)
|
||||
return self.json_response(response)
|
||||
Reference in New Issue
Block a user