feat: change icon edit method from POST to PUT for tools and shared tools
This commit is contained in:
parent
61359e078f
commit
64e26dd2cc
@ -236,3 +236,42 @@ class PylintAPI(APIMixin):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_request():
|
def get_request():
|
||||||
return PylintInstance
|
return PylintInstance
|
||||||
|
|
||||||
|
|
||||||
|
class EditIconAPI(APIMixin):
|
||||||
|
@staticmethod
|
||||||
|
def get_parameters():
|
||||||
|
return [
|
||||||
|
OpenApiParameter(
|
||||||
|
name="workspace_id",
|
||||||
|
description="工作空间id",
|
||||||
|
type=OpenApiTypes.STR,
|
||||||
|
location='path',
|
||||||
|
required=True,
|
||||||
|
),
|
||||||
|
OpenApiParameter(
|
||||||
|
name="tool_id",
|
||||||
|
description="工具id",
|
||||||
|
type=OpenApiTypes.STR,
|
||||||
|
location='path',
|
||||||
|
required=True,
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_request():
|
||||||
|
return {
|
||||||
|
'multipart/form-data': {
|
||||||
|
'type': 'object',
|
||||||
|
'properties': {
|
||||||
|
'icon': {
|
||||||
|
'type': 'string',
|
||||||
|
'format': 'binary' # Tells Swagger it's a file
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_response():
|
||||||
|
return DefaultResultSerializer
|
||||||
@ -9,7 +9,7 @@ from common.auth.authentication import has_permissions
|
|||||||
from common.constants.permission_constants import PermissionConstants
|
from common.constants.permission_constants import PermissionConstants
|
||||||
from common.result import result
|
from common.result import result
|
||||||
from tools.api.tool import ToolCreateAPI, ToolEditAPI, ToolReadAPI, ToolDeleteAPI, ToolTreeReadAPI, ToolDebugApi, \
|
from tools.api.tool import ToolCreateAPI, ToolEditAPI, ToolReadAPI, ToolDeleteAPI, ToolTreeReadAPI, ToolDebugApi, \
|
||||||
ToolExportAPI, ToolImportAPI, ToolPageAPI, PylintAPI
|
ToolExportAPI, ToolImportAPI, ToolPageAPI, PylintAPI, EditIconAPI
|
||||||
from tools.serializers.tool import ToolSerializer, ToolTreeSerializer
|
from tools.serializers.tool import ToolSerializer, ToolTreeSerializer
|
||||||
|
|
||||||
|
|
||||||
@ -198,6 +198,16 @@ class ToolView(APIView):
|
|||||||
authentication_classes = [TokenAuth]
|
authentication_classes = [TokenAuth]
|
||||||
parser_classes = [MultiPartParser]
|
parser_classes = [MultiPartParser]
|
||||||
|
|
||||||
|
@extend_schema(
|
||||||
|
methods=['PUT'],
|
||||||
|
summary=_('Edit tool icon'),
|
||||||
|
operation_id=_('Edit tool icon'), # type: ignore
|
||||||
|
description=_('Edit tool icon'),
|
||||||
|
request=EditIconAPI.get_request(),
|
||||||
|
responses=EditIconAPI.get_response(),
|
||||||
|
parameters=EditIconAPI.get_parameters(),
|
||||||
|
tags=[_('Tool')] # type: ignore
|
||||||
|
)
|
||||||
@has_permissions(PermissionConstants.TOOL_EDIT.get_workspace_permission())
|
@has_permissions(PermissionConstants.TOOL_EDIT.get_workspace_permission())
|
||||||
def put(self, request: Request, id: str, workspace_id: str):
|
def put(self, request: Request, id: str, workspace_id: str):
|
||||||
return result.success(ToolSerializer.IconOperate(data={
|
return result.success(ToolSerializer.IconOperate(data={
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user