2022-10-25 04:57:34 +00:00
|
|
|
from rest_framework import viewsets
|
2022-10-25 11:31:13 +00:00
|
|
|
from rest_framework.decorators import action
|
2022-10-25 04:57:34 +00:00
|
|
|
|
2022-10-25 11:31:13 +00:00
|
|
|
from orgs.utils import tmp_to_root_org
|
|
|
|
from orgs.models import Organization
|
|
|
|
from assets.models import Host
|
2022-10-25 04:57:34 +00:00
|
|
|
from terminal import serializers, models
|
|
|
|
|
|
|
|
__all__ = ['AppletHostViewSet', 'AppletHostDeploymentViewSet']
|
|
|
|
|
|
|
|
|
|
|
|
class AppletHostViewSet(viewsets.ModelViewSet):
|
|
|
|
queryset = models.AppletHost.objects.all()
|
|
|
|
serializer_class = serializers.AppletHostSerializer
|
|
|
|
|
2022-10-25 11:31:13 +00:00
|
|
|
@action(methods=['get'], detail=False)
|
|
|
|
def hosts(self, request):
|
|
|
|
with tmp_to_root_org():
|
|
|
|
kwargs = {
|
|
|
|
'platform__name': 'RemoteAppHost',
|
|
|
|
'org_id': Organization.SYSTEM_ID
|
|
|
|
}
|
|
|
|
return Host.objects.filter(**kwargs)
|
|
|
|
|
2022-10-25 04:57:34 +00:00
|
|
|
|
|
|
|
class AppletHostDeploymentViewSet(viewsets.ModelViewSet):
|
|
|
|
queryset = models.AppletHostDeployment.objects.all()
|
|
|
|
serializer_class = serializers.AppletHostDeploymentSerializer
|
|
|
|
|