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 import serializers
|
||||||
from assets.exceptions import NotSupportedTemporarilyError
|
from assets.exceptions import NotSupportedTemporarilyError
|
||||||
from assets.filters import IpInFilterBackend, LabelFilterBackend, NodeFilterBackend
|
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 assets.tasks import test_assets_connectivity_manual, update_assets_hardware_info_manual
|
||||||
from common.api import SuggestionMixin
|
from common.api import SuggestionMixin
|
||||||
from common.drf.filters import BaseFilterSet
|
from common.drf.filters import BaseFilterSet
|
||||||
|
from common.permissions import IsValidUser
|
||||||
from common.utils import get_logger, is_uuid
|
from common.utils import get_logger, is_uuid
|
||||||
from orgs.mixins import generics
|
from orgs.mixins import generics
|
||||||
from orgs.mixins.api import OrgBulkModelViewSet
|
from orgs.mixins.api import OrgBulkModelViewSet
|
||||||
|
@ -25,7 +26,8 @@ from ...notifications import BulkUpdatePlatformSkipAssetUserMsg
|
||||||
logger = get_logger(__file__)
|
logger = get_logger(__file__)
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"AssetViewSet", "AssetTaskCreateApi",
|
"AssetViewSet", "AssetTaskCreateApi",
|
||||||
"AssetsTaskCreateApi", 'AssetFilterSet'
|
"AssetsTaskCreateApi", 'AssetFilterSet',
|
||||||
|
"AutomationExecutionRetrieveApi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -258,3 +260,9 @@ class AssetsTaskCreateApi(AssetsTaskMixin, generics.CreateAPIView):
|
||||||
has = self.request.user.has_perm(perm_required)
|
has = self.request.user.has_perm(perm_required)
|
||||||
if not has:
|
if not has:
|
||||||
self.permission_denied(request)
|
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 django.utils.translation import ugettext as _
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from ops.mixin import PeriodTaskSerializerMixin
|
|
||||||
from assets.models import Asset, Node, BaseAutomation, AutomationExecution
|
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.const.choices import Trigger
|
||||||
from common.serializers.fields import ObjectRelatedField, LabeledChoiceField
|
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__)
|
logger = get_logger(__file__)
|
||||||
|
|
||||||
|
@ -48,9 +48,12 @@ class AutomationExecutionSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_snapshot(obj):
|
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']
|
tp = obj.snapshot['type']
|
||||||
snapshot = {
|
snapshot = {
|
||||||
'type': tp,
|
'type': {'value': tp, 'label': tp_dict.get(tp, tp)},
|
||||||
'name': obj.snapshot['name'],
|
'name': obj.snapshot['name'],
|
||||||
'comment': obj.snapshot['comment'],
|
'comment': obj.snapshot['comment'],
|
||||||
'accounts': obj.snapshot['accounts'],
|
'accounts': obj.snapshot['accounts'],
|
||||||
|
|
|
@ -47,6 +47,7 @@ urlpatterns = [
|
||||||
|
|
||||||
path('gateways/<uuid:pk>/test-connective/', api.GatewayTestConnectionApi.as_view(), name='test-gateway-connective'),
|
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('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
|
urlpatterns += router.urls
|
||||||
|
|
Loading…
Reference in New Issue