mirror of https://github.com/jumpserver/jumpserver
perf: 自动化执行详情数据
parent
737032418a
commit
9802aec881
|
@ -12,10 +12,11 @@ from accounts.tasks import push_accounts_to_assets_task, verify_accounts_connect
|
|||
from assets import serializers
|
||||
from assets.exceptions import NotSupportedTemporarilyError
|
||||
from assets.filters import IpInFilterBackend, LabelFilterBackend, NodeFilterBackend
|
||||
from assets.models import Asset, Gateway, Platform
|
||||
from assets.models import Asset, Gateway, Platform, AutomationExecution
|
||||
from assets.tasks import test_assets_connectivity_manual, update_assets_hardware_info_manual
|
||||
from common.api import SuggestionMixin
|
||||
from common.drf.filters import BaseFilterSet
|
||||
from common.permissions import IsValidUser
|
||||
from common.utils import get_logger, is_uuid
|
||||
from orgs.mixins import generics
|
||||
from orgs.mixins.api import OrgBulkModelViewSet
|
||||
|
@ -25,7 +26,8 @@ from ...notifications import BulkUpdatePlatformSkipAssetUserMsg
|
|||
logger = get_logger(__file__)
|
||||
__all__ = [
|
||||
"AssetViewSet", "AssetTaskCreateApi",
|
||||
"AssetsTaskCreateApi", 'AssetFilterSet'
|
||||
"AssetsTaskCreateApi", 'AssetFilterSet',
|
||||
"AutomationExecutionRetrieveApi",
|
||||
]
|
||||
|
||||
|
||||
|
@ -258,3 +260,9 @@ class AssetsTaskCreateApi(AssetsTaskMixin, generics.CreateAPIView):
|
|||
has = self.request.user.has_perm(perm_required)
|
||||
if not has:
|
||||
self.permission_denied(request)
|
||||
|
||||
|
||||
class AutomationExecutionRetrieveApi(generics.RetrieveAPIView):
|
||||
permission_classes = (IsValidUser,)
|
||||
model = AutomationExecution
|
||||
serializer_class = serializers.AutomationExecutionSerializer
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
from django.utils.translation import ugettext as _
|
||||
from rest_framework import serializers
|
||||
|
||||
from ops.mixin import PeriodTaskSerializerMixin
|
||||
from assets.models import Asset, Node, BaseAutomation, AutomationExecution
|
||||
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
|
||||
from common.utils import get_logger
|
||||
from common.const.choices import Trigger
|
||||
from common.serializers.fields import ObjectRelatedField, LabeledChoiceField
|
||||
from common.utils import get_logger
|
||||
from ops.mixin import PeriodTaskSerializerMixin
|
||||
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
|
||||
|
||||
logger = get_logger(__file__)
|
||||
|
||||
|
@ -48,9 +48,12 @@ class AutomationExecutionSerializer(serializers.ModelSerializer):
|
|||
|
||||
@staticmethod
|
||||
def get_snapshot(obj):
|
||||
from assets.const import AutomationTypes as AssetTypes
|
||||
from accounts.const import AutomationTypes as AccountTypes
|
||||
tp_dict = dict(AssetTypes.choices) | dict(AccountTypes.choices)
|
||||
tp = obj.snapshot['type']
|
||||
snapshot = {
|
||||
'type': tp,
|
||||
'type': {'value': tp, 'label': tp_dict.get(tp, tp)},
|
||||
'name': obj.snapshot['name'],
|
||||
'comment': obj.snapshot['comment'],
|
||||
'accounts': obj.snapshot['accounts'],
|
||||
|
|
|
@ -47,6 +47,7 @@ urlpatterns = [
|
|||
|
||||
path('gateways/<uuid:pk>/test-connective/', api.GatewayTestConnectionApi.as_view(), name='test-gateway-connective'),
|
||||
path('platform-automation-methods/', api.PlatformAutomationMethodsApi.as_view(), name='platform-automation-methods'),
|
||||
path('automations-execution/<uuid:pk>/', api.AutomationExecutionRetrieveApi.as_view(), name='automation-execution'),
|
||||
]
|
||||
|
||||
urlpatterns += router.urls
|
||||
|
|
Loading…
Reference in New Issue