perf: swagger api

This commit is contained in:
ibuler 2025-04-15 19:06:01 +08:00 committed by Eric_Lee
parent 5c61a11d82
commit 01a6019022
3 changed files with 18 additions and 10 deletions

View File

@ -15,7 +15,13 @@ class CustomSchemaGenerator(OpenAPISchemaGenerator):
@staticmethod
def exclude_some_paths(path):
# 这里可以对 paths 进行处理
excludes = ['/report/', '/render-to-json/', '/suggestions/', 'executions', 'automations']
excludes = [
'/report/', '/render-to-json/', '/suggestions/',
'executions', 'automations', 'change-secret-records',
'change-secret-dashboard', '/copy-to-assets/',
'/move-to-assets/', 'dashboard',
]
for p in excludes:
if path.find(p) >= 0:
return True

View File

@ -2,17 +2,18 @@
#
from functools import lru_cache
from rest_framework import generics
from django.db.models import F
from django.shortcuts import get_object_or_404
from rest_framework import generics
from rest_framework import mixins
from rest_framework.viewsets import GenericViewSet
from orgs.mixins.api import OrgRelationMixin
from orgs.mixins.api import OrgBulkModelViewSet
from orgs.utils import current_org
from perms import serializers
from perms import models
from perms.utils import AssetPermissionPermAssetUtil
from accounts.serializers import AccountSerializer
from orgs.mixins.api import OrgRelationMixin
from orgs.utils import current_org
from perms import models
from perms import serializers
from perms.utils import AssetPermissionPermAssetUtil
__all__ = [
'AssetPermissionUserRelationViewSet', 'AssetPermissionUserGroupRelationViewSet',
@ -22,8 +23,9 @@ __all__ = [
]
class RelationMixin(OrgRelationMixin, OrgBulkModelViewSet):
class RelationMixin(OrgRelationMixin, generics.ListCreateAPIView, mixins.DestroyModelMixin, GenericViewSet):
perm_model = models.AssetPermission
http_method_names = ['get', 'post', 'delete']
def get_queryset(self):
queryset = super().get_queryset()

View File

@ -281,7 +281,7 @@ class Applet(JMSBaseModel):
if not self.is_available_on_host(host):
logger.debug('No available applet {} for applet host: {}'.format(self.name, host.name))
return None
valid_accounts = host.accounts.all().filter(is_active=True, privileged=False)
valid_accounts = host.all_valid_accounts.all().filter(privileged=False)
account = self.try_to_use_same_account(user, host)
if not account:
logger.debug('No same account, try to use private account')