-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy pathresource_mapping.py
More file actions
37 lines (32 loc) · 1.34 KB
/
resource_mapping.py
File metadata and controls
37 lines (32 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# coding=utf-8
"""
@project: MaxKB
@Author:虎虎
@file: resource_mapping.py
@date:2025/12/25 15:28
@desc:
"""
from django.utils.translation import gettext_lazy as _
from drf_spectacular.utils import extend_schema
from rest_framework.request import Request
from rest_framework.views import APIView
from common import result
from common.auth import TokenAuth
from system_manage.api.resource_mapping import ResourceMappingAPI
from system_manage.serializers.resource_mapping_serializers import ResourceMappingSerializer
class ResourceMappingView(APIView):
authentication_classes = [TokenAuth]
@extend_schema(
methods=['GET'],
description=_('Retrieve the pagination list of resource relationships'),
operation_id=_('Retrieve the pagination list of resource relationships'), # type: ignore
responses=ResourceMappingAPI.get_response(),
parameters=ResourceMappingAPI.get_parameters(),
tags=[_('Resources mapping')] # type: ignore
)
def get(self, request: Request, workspace_id: str, resource: str, resource_id: str, current_page, page_size):
return result.success(ResourceMappingSerializer({
'resource': resource,
'resource_id': resource_id,
'resource_name': request.query_params.get('resource_name')
}).page(current_page, page_size))