mirror of https://github.com/jumpserver/jumpserver
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
#
|
|
from accounts import serializers
|
|
from accounts.const import AutomationTypes
|
|
from accounts.models import GatherAccountsAutomation
|
|
from orgs.mixins.api import OrgBulkModelViewSet
|
|
from .base import AutomationExecutionViewSet
|
|
|
|
__all__ = [
|
|
'GatherAccountsAutomationViewSet', 'GatherAccountsExecutionViewSet'
|
|
]
|
|
|
|
|
|
class GatherAccountsAutomationViewSet(OrgBulkModelViewSet):
|
|
model = GatherAccountsAutomation
|
|
filter_fields = ('name',)
|
|
search_fields = filter_fields
|
|
ordering_fields = ('name',)
|
|
serializer_class = serializers.GatherAccountAutomationSerializer
|
|
|
|
|
|
class GatherAccountsExecutionViewSet(AutomationExecutionViewSet):
|
|
rbac_perms = (
|
|
("list", "accounts.view_gatheraccountsexecution"),
|
|
("retrieve", "accounts.view_gatheraccountsexecution"),
|
|
("create", "accounts.add_gatheraccountsexecution"),
|
|
)
|
|
|
|
tp = AutomationTypes.gather_accounts
|
|
|
|
def get_queryset(self):
|
|
queryset = super().get_queryset()
|
|
queryset = queryset.filter(automation__type=self.tp)
|
|
return queryset
|