|
|
|
@ -5,8 +5,7 @@ from rest_framework import mixins
|
|
|
|
|
|
|
|
|
|
from accounts import serializers
|
|
|
|
|
from accounts.const import AutomationTypes
|
|
|
|
|
from accounts.models import ChangeSecretAutomation, ChangeSecretRecord, AutomationExecution
|
|
|
|
|
from common.utils import get_object_or_none
|
|
|
|
|
from accounts.models import ChangeSecretAutomation, ChangeSecretRecord
|
|
|
|
|
from orgs.mixins.api import OrgBulkModelViewSet, OrgGenericViewSet
|
|
|
|
|
from .base import (
|
|
|
|
|
AutomationAssetsListApi, AutomationRemoveAssetApi, AutomationAddAssetApi,
|
|
|
|
@ -30,8 +29,8 @@ class ChangeSecretAutomationViewSet(OrgBulkModelViewSet):
|
|
|
|
|
|
|
|
|
|
class ChangeSecretRecordViewSet(mixins.ListModelMixin, OrgGenericViewSet):
|
|
|
|
|
serializer_class = serializers.ChangeSecretRecordSerializer
|
|
|
|
|
filter_fields = ['asset', 'execution_id']
|
|
|
|
|
search_fields = ['asset__hostname']
|
|
|
|
|
filter_fields = ('asset', 'execution_id')
|
|
|
|
|
search_fields = ('asset__address',)
|
|
|
|
|
|
|
|
|
|
def get_queryset(self):
|
|
|
|
|
return ChangeSecretRecord.objects.filter(
|
|
|
|
@ -41,10 +40,7 @@ class ChangeSecretRecordViewSet(mixins.ListModelMixin, OrgGenericViewSet):
|
|
|
|
|
def filter_queryset(self, queryset):
|
|
|
|
|
queryset = super().filter_queryset(queryset)
|
|
|
|
|
eid = self.request.query_params.get('execution_id')
|
|
|
|
|
execution = get_object_or_none(AutomationExecution, pk=eid)
|
|
|
|
|
if execution:
|
|
|
|
|
queryset = queryset.filter(execution=execution)
|
|
|
|
|
return queryset
|
|
|
|
|
return queryset.filter(execution_id=eid)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ChangSecretExecutionViewSet(AutomationExecutionViewSet):
|
|
|
|
|