"""This file and its contents are licensed under the Apache License 2.0. Please see the included NOTICE for copyright information and LICENSE for a copy of the license.
"""
from django.utils.decorators import method_decorator
from drf_yasg.utils import swagger_auto_schema
from io_storages.gcs.models import GCSImportStorage, GCSExportStorage
from io_storages.gcs.serializers import GCSImportStorageSerializer, GCSExportStorageSerializer
from io_storages.api import (
    ImportStorageListAPI,
    ImportStorageDetailAPI,
    ImportStorageSyncAPI,
    ExportStorageListAPI,
    ExportStorageDetailAPI,
    ImportStorageValidateAPI,
    ExportStorageValidateAPI,
    ImportStorageFormLayoutAPI,
    ExportStorageFormLayoutAPI,
)


@method_decorator(
    name="get",
    decorator=swagger_auto_schema(
        tags=["Storage"],
        operation_summary="GCS: Get all import storage",
        operation_description="Get a list of all GCS import storage connections.",
    ),
)
@method_decorator(
    name="post",
    decorator=swagger_auto_schema(
        tags=["Storage"],
        operation_summary="GCS: Create import storage",
        operation_description="Create a new GCS import storage connection.",
    ),
)
class GCSImportStorageListAPI(ImportStorageListAPI):
    queryset = GCSImportStorage.objects.all()
    serializer_class = GCSImportStorageSerializer


@method_decorator(
    name="get",
    decorator=swagger_auto_schema(
        tags=["Storage"],
        operation_summary="GCS: Get import storage",
        operation_description="Get a specific GCS import storage connection.",
    ),
)
@method_decorator(
    name="patch",
    decorator=swagger_auto_schema(
        tags=["Storage"],
        operation_summary="GCS: Update import storage",
        operation_description="Update a specific GCS import storage connection.",
    ),
)
@method_decorator(
    name="delete",
    decorator=swagger_auto_schema(
        tags=["Storage"],
        operation_summary="GCS: Delete import storage",
        operation_description="Delete a specific GCS import storage connection.",
    ),
)
class GCSImportStorageDetailAPI(ImportStorageDetailAPI):
    queryset = GCSImportStorage.objects.all()
    serializer_class = GCSImportStorageSerializer


@method_decorator(
    name="post",
    decorator=swagger_auto_schema(
        tags=["Storage"],
        operation_summary="GCS: Sync import storage",
        operation_description="Sync tasks from an GCS import storage connection.",
    ),
)
class GCSImportStorageSyncAPI(ImportStorageSyncAPI):
    serializer_class = GCSImportStorageSerializer


@method_decorator(
    name="post",
    decorator=swagger_auto_schema(
        tags=["Storage"],
        operation_summary="GCS: Validate import storage",
        operation_description="Validate a specific GCS import storage connection.",
    ),
)
class GCSImportStorageValidateAPI(ImportStorageValidateAPI):
    serializer_class = GCSImportStorageSerializer


@method_decorator(
    name="post",
    decorator=swagger_auto_schema(
        tags=["Storage"],
        operation_summary="GCS: Validate export storage",
        operation_description="Validate a specific GCS export storage connection.",
    ),
)
class GCSExportStorageValidateAPI(ExportStorageValidateAPI):
    serializer_class = GCSExportStorageSerializer


@method_decorator(
    name="get",
    decorator=swagger_auto_schema(
        tags=["Storage"],
        operation_summary="GCS: Get all export storage",
        operation_description="Get a list of all GCS export storage connections.",
    ),
)
@method_decorator(
    name="post",
    decorator=swagger_auto_schema(
        tags=["Storage"],
        operation_summary="GCS: Create export storage",
        operation_description="Create a new GCS export storage connection to store annotations.",
    ),
)
class GCSExportStorageListAPI(ExportStorageListAPI):
    queryset = GCSExportStorage.objects.all()
    serializer_class = GCSExportStorageSerializer


@method_decorator(
    name="get",
    decorator=swagger_auto_schema(
        tags=["Storage"],
        operation_summary="GCS: Get export storage",
        operation_description="Get a specific GCS export storage connection.",
    ),
)
@method_decorator(
    name="patch",
    decorator=swagger_auto_schema(
        tags=["Storage"],
        operation_summary="GCS: Update export storage",
        operation_description="Update a specific GCS export storage connection.",
    ),
)
@method_decorator(
    name="delete",
    decorator=swagger_auto_schema(
        tags=["Storage"],
        operation_summary="GCS: Delete export storage",
        operation_description="Delete a specific GCS export storage connection.",
    ),
)
class GCSExportStorageDetailAPI(ExportStorageDetailAPI):
    queryset = GCSExportStorage.objects.all()
    serializer_class = GCSExportStorageSerializer


class GCSImportStorageFormLayoutAPI(ImportStorageFormLayoutAPI):
    pass


class GCSExportStorageFormLayoutAPI(ExportStorageFormLayoutAPI):
    pass
