mirror of https://github.com/jumpserver/jumpserver
perf: Remove push account extra api
parent
a904e59252
commit
792b552e25
|
@ -2,19 +2,17 @@
|
||||||
#
|
#
|
||||||
from accounts import serializers
|
from accounts import serializers
|
||||||
from accounts.const import AutomationTypes
|
from accounts.const import AutomationTypes
|
||||||
from accounts.models import PushAccountAutomation, ChangeSecretRecord
|
from accounts.models import PushAccountAutomation
|
||||||
from orgs.mixins.api import OrgBulkModelViewSet
|
from orgs.mixins.api import OrgBulkModelViewSet
|
||||||
|
|
||||||
from .base import (
|
from .base import (
|
||||||
AutomationAssetsListApi, AutomationRemoveAssetApi, AutomationAddAssetApi,
|
AutomationAssetsListApi, AutomationRemoveAssetApi, AutomationAddAssetApi,
|
||||||
AutomationNodeAddRemoveApi, AutomationExecutionViewSet
|
AutomationNodeAddRemoveApi, AutomationExecutionViewSet
|
||||||
)
|
)
|
||||||
from .change_secret import ChangeSecretRecordViewSet
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'PushAccountAutomationViewSet', 'PushAccountAssetsListApi', 'PushAccountRemoveAssetApi',
|
'PushAccountAutomationViewSet', 'PushAccountAssetsListApi', 'PushAccountRemoveAssetApi',
|
||||||
'PushAccountAddAssetApi', 'PushAccountNodeAddRemoveApi', 'PushAccountExecutionViewSet',
|
'PushAccountAddAssetApi', 'PushAccountNodeAddRemoveApi', 'PushAccountExecutionViewSet',
|
||||||
'PushAccountRecordViewSet'
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,23 +39,6 @@ class PushAccountExecutionViewSet(AutomationExecutionViewSet):
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
|
|
||||||
class PushAccountRecordViewSet(ChangeSecretRecordViewSet):
|
|
||||||
serializer_class = serializers.ChangeSecretRecordSerializer
|
|
||||||
tp = AutomationTypes.push_account
|
|
||||||
|
|
||||||
rbac_perms = {
|
|
||||||
'list': 'accounts.view_pushsecretrecord',
|
|
||||||
'execute': 'accounts.add_pushsecretexecution',
|
|
||||||
'secret': 'accounts.view_pushsecretrecord',
|
|
||||||
}
|
|
||||||
|
|
||||||
def get_queryset(self):
|
|
||||||
qs = ChangeSecretRecord.get_valid_records()
|
|
||||||
return qs.filter(
|
|
||||||
execution__automation__type=self.tp
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class PushAccountAssetsListApi(AutomationAssetsListApi):
|
class PushAccountAssetsListApi(AutomationAssetsListApi):
|
||||||
model = PushAccountAutomation
|
model = PushAccountAutomation
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
# Generated by Django 4.1.13 on 2024-12-10 11:29
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('accounts', '0022_alter_changesecretrecord_options_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='changesecretrecord',
|
||||||
|
options={'verbose_name': 'Change secret record'},
|
||||||
|
),
|
||||||
|
]
|
|
@ -46,10 +46,6 @@ class ChangeSecretRecord(JMSBaseModel):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("Change secret record")
|
verbose_name = _("Change secret record")
|
||||||
permissions = [
|
|
||||||
('view_pushsecretrecord', _('Can view change secret execution')),
|
|
||||||
('add_pushsecretexecution', _('Can add change secret execution')),
|
|
||||||
]
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f'{self.account.username}@{self.asset}'
|
return f'{self.account.username}@{self.asset}'
|
||||||
|
|
|
@ -23,7 +23,6 @@ router.register(r'gather-account-automations', api.GatherAccountsAutomationViewS
|
||||||
router.register(r'gather-account-executions', api.GatherAccountsExecutionViewSet, 'gather-account-execution')
|
router.register(r'gather-account-executions', api.GatherAccountsExecutionViewSet, 'gather-account-execution')
|
||||||
router.register(r'push-account-automations', api.PushAccountAutomationViewSet, 'push-account-automation')
|
router.register(r'push-account-automations', api.PushAccountAutomationViewSet, 'push-account-automation')
|
||||||
router.register(r'push-account-executions', api.PushAccountExecutionViewSet, 'push-account-execution')
|
router.register(r'push-account-executions', api.PushAccountExecutionViewSet, 'push-account-execution')
|
||||||
router.register(r'push-account-records', api.PushAccountRecordViewSet, 'push-account-record')
|
|
||||||
router.register(r'check-account-automations', api.CheckAccountAutomationViewSet, 'check-account-automation')
|
router.register(r'check-account-automations', api.CheckAccountAutomationViewSet, 'check-account-automation')
|
||||||
router.register(r'check-account-executions', api.CheckAccountExecutionViewSet, 'check-account-execution')
|
router.register(r'check-account-executions', api.CheckAccountExecutionViewSet, 'check-account-execution')
|
||||||
router.register(r'account-check-engines', api.CheckAccountEngineViewSet, 'account-check-engine')
|
router.register(r'account-check-engines', api.CheckAccountEngineViewSet, 'account-check-engine')
|
||||||
|
|
Loading…
Reference in New Issue