mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-05-05 04:33:50 +00:00
Compare commits
2 Commits
ee70c9e327
...
df283f4c60
Author | SHA1 | Date | |
---|---|---|---|
df283f4c60 | |||
2d5382fae7 |
@ -120,12 +120,12 @@ class Client:
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def package_dependencies_get(self, package_base: str | None) -> list[Dependencies]:
|
||||
def package_dependencies_get(self, package_base: str) -> list[Dependencies]:
|
||||
"""
|
||||
get package dependencies
|
||||
|
||||
Args:
|
||||
package_base(str | None): package base to retrieve
|
||||
package_base(str): package base to retrieve
|
||||
|
||||
Returns:
|
||||
list[Dependencies]: package implicit dependencies if available
|
||||
|
@ -81,12 +81,12 @@ class LocalClient(Client):
|
||||
"""
|
||||
self.database.changes_insert(package_base, changes, self.repository_id)
|
||||
|
||||
def package_dependencies_get(self, package_base: str | None) -> list[Dependencies]:
|
||||
def package_dependencies_get(self, package_base: str) -> list[Dependencies]:
|
||||
"""
|
||||
get package dependencies
|
||||
|
||||
Args:
|
||||
package_base(str | None): package base to retrieve
|
||||
package_base(str): package base to retrieve
|
||||
|
||||
Returns:
|
||||
list[Dependencies]: package implicit dependencies if available
|
||||
|
@ -97,17 +97,17 @@ class WebClient(Client, SyncAhrimanClient):
|
||||
"""
|
||||
return f"{self.address}/api/v1/packages/{urlencode(package_base)}/changes"
|
||||
|
||||
def _dependencies_url(self, package_base: str = "") -> str:
|
||||
def _dependencies_url(self, package_base: str) -> str:
|
||||
"""
|
||||
get url for the dependencies api
|
||||
|
||||
Args:
|
||||
package_base(str, optional): package base (Default value = "")
|
||||
package_base(str): package base
|
||||
|
||||
Returns:
|
||||
str: full url for web service for dependencies
|
||||
"""
|
||||
return f"{self.address}/api/v1/dependencies/{urlencode(package_base)}"
|
||||
return f"{self.address}/api/v1/packages/{urlencode(package_base)}/dependencies"
|
||||
|
||||
def _logs_url(self, package_base: str) -> str:
|
||||
"""
|
||||
@ -204,18 +204,18 @@ class WebClient(Client, SyncAhrimanClient):
|
||||
self.make_request("POST", self._changes_url(package_base),
|
||||
params=self.repository_id.query(), json=changes.view())
|
||||
|
||||
def package_dependencies_get(self, package_base: str | None) -> list[Dependencies]:
|
||||
def package_dependencies_get(self, package_base: str) -> list[Dependencies]:
|
||||
"""
|
||||
get package dependencies
|
||||
|
||||
Args:
|
||||
package_base(str | None): package base to retrieve
|
||||
package_base(str): package base to retrieve
|
||||
|
||||
Returns:
|
||||
list[Dependencies]: package implicit dependencies if available
|
||||
"""
|
||||
with contextlib.suppress(Exception):
|
||||
response = self.make_request("GET", self._dependencies_url(package_base or ""),
|
||||
response = self.make_request("GET", self._dependencies_url(package_base),
|
||||
params=self.repository_id.query())
|
||||
response_json = response.json()
|
||||
|
||||
|
@ -1,66 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2021-2024 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/>.
|
||||
#
|
||||
import aiohttp_apispec # type: ignore[import-untyped]
|
||||
|
||||
from aiohttp.web import Response, json_response
|
||||
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.schemas import AuthSchema, DependenciesSchema, ErrorSchema, RepositoryIdSchema
|
||||
from ahriman.web.views.base import BaseView
|
||||
from ahriman.web.views.status_view_guard import StatusViewGuard
|
||||
|
||||
|
||||
class DependenciesView(StatusViewGuard, BaseView):
|
||||
"""
|
||||
packages dependencies web view
|
||||
|
||||
Attributes:
|
||||
GET_PERMISSION(UserAccess): (class attribute) get permissions of self
|
||||
"""
|
||||
|
||||
GET_PERMISSION = UserAccess.Reporter
|
||||
POST_PERMISSION = UserAccess.Full
|
||||
ROUTES = ["/api/v1/dependencies"]
|
||||
|
||||
@aiohttp_apispec.docs(
|
||||
tags=["Build"],
|
||||
summary="Get dependencies for all packages",
|
||||
description="Retrieve implicit dependencies for all known packages",
|
||||
responses={
|
||||
200: {"description": "Success response", "schema": DependenciesSchema(many=True)},
|
||||
401: {"description": "Authorization required", "schema": ErrorSchema},
|
||||
403: {"description": "Access is forbidden", "schema": ErrorSchema},
|
||||
404: {"description": "Package base and/or repository are unknown", "schema": ErrorSchema},
|
||||
500: {"description": "Internal server error", "schema": ErrorSchema},
|
||||
},
|
||||
security=[{"token": [GET_PERMISSION]}],
|
||||
)
|
||||
@aiohttp_apispec.cookies_schema(AuthSchema)
|
||||
@aiohttp_apispec.querystring_schema(RepositoryIdSchema)
|
||||
async def get(self) -> Response:
|
||||
"""
|
||||
get dependencies for all packages
|
||||
|
||||
Returns:
|
||||
Response: 200 with package implicit dependencies on success
|
||||
"""
|
||||
dependencies = self.service().client.package_dependencies_get(None)
|
||||
|
||||
return json_response([dependency.view() for dependency in dependencies])
|
@ -40,7 +40,7 @@ class DependencyView(StatusViewGuard, BaseView):
|
||||
|
||||
GET_PERMISSION = UserAccess.Reporter
|
||||
POST_PERMISSION = UserAccess.Full
|
||||
ROUTES = ["/api/v1/dependencies/{package}"]
|
||||
ROUTES = ["/api/v1/packages/{package}/dependencies"]
|
||||
|
||||
@aiohttp_apispec.docs(
|
||||
tags=["Build"],
|
||||
|
Loading…
x
Reference in New Issue
Block a user