2022-01-10 11:02:18 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
2023-01-16 11:02:09 +00:00
|
|
|
from accounts import serializers
|
2024-12-03 10:54:10 +00:00
|
|
|
from accounts.const import AutomationTypes
|
2023-01-16 11:02:09 +00:00
|
|
|
from accounts.models import (
|
2024-12-03 10:54:10 +00:00
|
|
|
BackupAccountAutomation
|
2022-01-10 11:02:18 +00:00
|
|
|
)
|
2023-02-17 06:34:51 +00:00
|
|
|
from orgs.mixins.api import OrgBulkModelViewSet
|
2024-12-03 10:54:10 +00:00
|
|
|
from .base import AutomationExecutionViewSet
|
2022-01-10 11:02:18 +00:00
|
|
|
|
|
|
|
__all__ = [
|
2024-12-04 08:28:49 +00:00
|
|
|
'BackupAccountViewSet', 'BackupAccountExecutionViewSet'
|
2022-01-10 11:02:18 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
2024-12-04 08:28:49 +00:00
|
|
|
class BackupAccountViewSet(OrgBulkModelViewSet):
|
2024-12-03 10:54:10 +00:00
|
|
|
model = BackupAccountAutomation
|
2024-03-05 02:47:05 +00:00
|
|
|
filterset_fields = ('name',)
|
|
|
|
search_fields = filterset_fields
|
2024-12-03 10:54:10 +00:00
|
|
|
serializer_class = serializers.BackupAccountSerializer
|
2022-01-10 11:02:18 +00:00
|
|
|
|
|
|
|
|
2024-12-03 10:54:10 +00:00
|
|
|
class BackupAccountExecutionViewSet(AutomationExecutionViewSet):
|
2024-12-04 08:28:49 +00:00
|
|
|
rbac_perms = (
|
|
|
|
("list", "accounts.view_backupaccountexecution"),
|
|
|
|
("retrieve", "accounts.view_backupaccountexecution"),
|
|
|
|
("create", "accounts.add_backupaccountexecution"),
|
|
|
|
("report", "accounts.view_backupaccountexecution"),
|
|
|
|
)
|
|
|
|
|
2024-12-03 10:54:10 +00:00
|
|
|
tp = AutomationTypes.backup_account
|
2022-01-10 11:02:18 +00:00
|
|
|
|
|
|
|
def get_queryset(self):
|
2024-12-03 10:54:10 +00:00
|
|
|
queryset = super().get_queryset()
|
|
|
|
queryset = queryset.filter(automation__type=self.tp)
|
2022-01-10 11:02:18 +00:00
|
|
|
return queryset
|