From cf655f26d93c7447c567d7b862872b553cdcc94d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Arag=C3=B3n?= Date: Thu, 10 Oct 2024 17:30:06 +0200 Subject: [PATCH 1/2] fix: add files to update-component-version workflow (#1512) --- .github/workflows/update-component-versions.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/update-component-versions.yaml b/.github/workflows/update-component-versions.yaml index 54ead635f..786811a00 100644 --- a/.github/workflows/update-component-versions.yaml +++ b/.github/workflows/update-component-versions.yaml @@ -44,6 +44,8 @@ jobs: sed -i "s/ray-node:${OLDNUM}/ray-node:${NEWNUM}/" charts/qiskit-serverless/values.yaml sed -i "s/version: ${OLDNUM}/version: ${NEWNUM}/" charts/qiskit-serverless/values.yaml sed -i "s/qiskit-serverless\/ray-node:${OLDNUM}/qiskit-serverless\/ray-node:${NEWNUM}/" docs/deployment/custom_function/Sample-Dockerfile + sed -i "s/FROM icr.io\/quantum-public\/qiskit-serverless\/ray-node${OLDNUM}/FROM icr.io\/quantum-public\/qiskit-serverless\/ray-node${NEWNUM}/" docs/deployment/deploying_custom_image_function.rst + sed -i "s/FROM icr.io\/quantum-public\/qiskit-serverless\/ray-node${OLDNUM}/FROM icr.io\/quantum-public\/qiskit-serverless\/ray-node${NEWNUM}/" docs/deployment/example_custom_image_function.rst sed -i "s/qiskit-serverless\/ray-node:${OLDNUM}/qiskit-serverless\/ray-node:${NEWNUM}/" gateway/main/settings.py cd charts/qiskit-serverless helm dependency update From b1050b4a6fb56a2fad64a16c2c367a782088fa20 Mon Sep 17 00:00:00 2001 From: David <9059044+Tansito@users.noreply.github.com> Date: Tue, 15 Oct 2024 17:51:42 -0400 Subject: [PATCH 2/2] Swagger refactor (#1516) * Files refactor * Added actions to the v1 files --- gateway/api/v1/views/files.py | 77 +++++++++++++++++++++++++++++++++++ gateway/api/views/files.py | 61 --------------------------- 2 files changed, 77 insertions(+), 61 deletions(-) diff --git a/gateway/api/v1/views/files.py b/gateway/api/v1/views/files.py index 45f3e7e15..faa5a3150 100644 --- a/gateway/api/v1/views/files.py +++ b/gateway/api/v1/views/files.py @@ -2,7 +2,10 @@ Files view api for V1. """ +from drf_yasg import openapi +from drf_yasg.utils import swagger_auto_schema from rest_framework import permissions +from rest_framework.decorators import action from api.permissions import IsOwner from api import views @@ -14,3 +17,77 @@ class FilesViewSet(views.FilesViewSet): """ permission_classes = [permissions.IsAuthenticated, IsOwner] + + @swagger_auto_schema( + operation_description="List of available for user files", + manual_parameters=[ + openapi.Parameter( + "provider", + openapi.IN_QUERY, + description="provider name", + type=openapi.TYPE_STRING, + required=False, + ), + ], + ) + def list(self, request): + return super().list(request) + + @swagger_auto_schema( + operation_description="Download a specific file", + manual_parameters=[ + openapi.Parameter( + "file", + openapi.IN_QUERY, + description="file name", + type=openapi.TYPE_STRING, + required=True, + ), + openapi.Parameter( + "provider", + openapi.IN_QUERY, + description="provider name", + type=openapi.TYPE_STRING, + required=False, + ), + ], + ) + @action(methods=["GET"], detail=False) + def download(self, request): + return super().download(request) + + @swagger_auto_schema( + operation_description="Deletes file uploaded or produced by the programs", + request_body=openapi.Schema( + type=openapi.TYPE_OBJECT, + properties={ + "file": openapi.Schema( + type=openapi.TYPE_STRING, description="file name" + ), + "provider": openapi.Schema( + type=openapi.TYPE_STRING, description="provider name" + ), + }, + required=["file"], + ), + ) + @action(methods=["DELETE"], detail=False) + def delete(self, request): + return super().delete(request) + + @swagger_auto_schema( + operation_description="Upload selected file", + request_body=openapi.Schema( + type=openapi.TYPE_OBJECT, + properties={ + "file": openapi.Schema(type=openapi.TYPE_FILE, description="file name"), + "provider": openapi.Schema( + type=openapi.TYPE_STRING, description="provider name" + ), + }, + required=["file"], + ), + ) + @action(methods=["POST"], detail=False) + def upload(self, request): + return super().upload(request) diff --git a/gateway/api/views/files.py b/gateway/api/views/files.py index 6d61e3e16..10a54a4dc 100644 --- a/gateway/api/views/files.py +++ b/gateway/api/views/files.py @@ -9,8 +9,6 @@ import os from wsgiref.util import FileWrapper -from drf_yasg import openapi -from drf_yasg.utils import swagger_auto_schema from django.conf import settings from django.http import StreamingHttpResponse @@ -69,18 +67,6 @@ def check_user_has_provider(self, user, provider_name): """check if user has the provider""" return provider_name in self.list_user_providers(user) - @swagger_auto_schema( - operation_description="List of available for user files", - manual_parameters=[ - openapi.Parameter( - "provider", - openapi.IN_QUERY, - description="provider name", - type=openapi.TYPE_STRING, - required=False, - ), - ], - ) def list(self, request): """List of available for user files.""" response = Response( @@ -115,25 +101,6 @@ def list(self, request): return Response({"results": files}) - @swagger_auto_schema( - operation_description="List of available for user files", - manual_parameters=[ - openapi.Parameter( - "file", - openapi.IN_QUERY, - description="file name", - type=openapi.TYPE_STRING, - required=True, - ), - openapi.Parameter( - "provider", - openapi.IN_QUERY, - description="provider name", - type=openapi.TYPE_STRING, - required=False, - ), - ], - ) @action(methods=["GET"], detail=False) def download(self, request): # pylint: disable=invalid-name """Download selected file.""" @@ -179,21 +146,6 @@ def download(self, request): # pylint: disable=invalid-name response["Content-Disposition"] = f"attachment; filename={filename}" return response - @swagger_auto_schema( - operation_description="Deletes file uploaded or produced by the programs", - request_body=openapi.Schema( - type=openapi.TYPE_OBJECT, - properties={ - "file": openapi.Schema( - type=openapi.TYPE_STRING, description="file name" - ), - "provider": openapi.Schema( - type=openapi.TYPE_STRING, description="provider name" - ), - }, - required=["file"], - ), - ) @action(methods=["DELETE"], detail=False) def delete(self, request): # pylint: disable=invalid-name """Deletes file uploaded or produced by the programs,""" @@ -230,19 +182,6 @@ def delete(self, request): # pylint: disable=invalid-name ) return response - @swagger_auto_schema( - operation_description="Upload selected file", - request_body=openapi.Schema( - type=openapi.TYPE_OBJECT, - properties={ - "file": openapi.Schema(type=openapi.TYPE_FILE, description="file name"), - "provider": openapi.Schema( - type=openapi.TYPE_STRING, description="provider name" - ), - }, - required=["file"], - ), - ) @action(methods=["POST"], detail=False) def upload(self, request): # pylint: disable=invalid-name """Upload selected file."""