Commit 4fc38a91 authored by BaiJiangJie's avatar BaiJiangJie

[Feature] 应用管理: Database 添加获取数据库认证信息的API

parent dcd1c119
# coding: utf-8
#
from rest_framework import generics
from rest_framework.pagination import LimitOffsetPagination
from rest_framework_bulk import BulkModelViewSet
from ..hands import IsOrgAdmin
from ..hands import IsOrgAdmin, IsAppUser
from ..models import Database
from ..serializers import DatabaseSerializer
from ..serializers import DatabaseSerializer, DatabaseAuthInfoSerializer
__all__ = ['DataBaseViewSet']
__all__ = ['DataBaseViewSet', 'DatabaseAuthInfoApi']
class DataBaseViewSet(BulkModelViewSet):
......@@ -18,3 +19,9 @@ class DataBaseViewSet(BulkModelViewSet):
queryset = Database.objects.all()
serializer_class = DatabaseSerializer
pagination_class = LimitOffsetPagination
class DatabaseAuthInfoApi(generics.RetrieveAPIView):
queryset = Database.objects.all()
permission_classes = (IsAppUser,)
serializer_class = DatabaseAuthInfoSerializer
......@@ -7,7 +7,7 @@ from common.serializers import AdaptedBulkListSerializer
from orgs.mixins import BulkOrgResourceModelSerializer
from ..models import Database
__all__ = ['DatabaseSerializer']
__all__ = ['DatabaseSerializer', 'DatabaseAuthInfoSerializer']
class DatabaseSerializer(BulkOrgResourceModelSerializer):
......@@ -45,3 +45,8 @@ class DatabaseSerializer(BulkOrgResourceModelSerializer):
self.clean_password(validated_data)
return super().update(instance, validated_data)
class DatabaseAuthInfoSerializer(serializers.ModelSerializer):
class Meta:
model = Database
fields = ['password']
......@@ -16,7 +16,11 @@ router.register(r'databases', api.DataBaseViewSet, 'database')
urlpatterns = [
path('remote-apps/<uuid:pk>/connection-info/',
api.RemoteAppConnectionInfoApi.as_view(),
name='remote-app-connection-info')
name='remote-app-connection-info'),
path('databases/<uuid:pk>/auth-info/',
api.DatabaseAuthInfoApi.as_view(),
name='database-auth-info'),
]
old_version_urlpatterns = [
re_path('(?P<resource>remote-app|database)/.*', capi.redirect_plural_name_api)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment