#######################################################################################
# Copyright ETSI Contributors and Others.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#######################################################################################

from abc import abstractmethod
from dataclasses import dataclass

from osm_common.temporal.workflows.base import BaseWorkflow


class VimCreateWorkflow(BaseWorkflow):
    """Creates VIM account by validating the VIM connectivity."""

    @dataclass
    class Input:
        """
        Input dataclass for workflows that perform operations
        (create, update, delete) on VIMs.

        Attributes:
        -----------
        vim_uuid : str
            The UUID of the VIM account as stored in the OSM vim
            collection in Mongo

        op_id: str
            The operation (task) id for this workflow.  This is used
            by the workflow at the end to update the status of the
            operation in Mongo vim collection.
        """

        vim_uuid: str
        op_id: str

    @abstractmethod
    async def run(self, workflow_input: Input) -> None:
        pass


class VimUpdateWorkflow(VimCreateWorkflow):
    """Updates VIM account state by validating the VIM connectivity."""

    @dataclass
    class Input:
        """
        Input dataclass for workflows that perform operations
        (create, update, delete) on VIMs.

        Attributes:
        -----------
        vim_uuid : str
            The UUID of the VIM account as stored in the OSM vim
            collection in Mongo

        op_id: str
            The operation (task) id for this workflow.  This is used
            by the workflow at the end to update the status of the
            operation in Mongo vim collection.
        """

        vim_uuid: str
        op_id: str

    @abstractmethod
    async def run(self, workflow_input: Input) -> None:
        pass


class VimDeleteWorkflow(BaseWorkflow):
    """Deletes VIM accounts."""

    @dataclass
    class Input:
        """
        Input dataclass for workflows that perform operations
        (create, update, delete) on VIMs.

        Attributes:
        -----------
        vim_uuid : str
            The UUID of the VIM account as stored in the OSM vim
            collection in Mongo

        op_id: str
            The operation (task) id for this workflow.  This is used
            by the workflow at the end to update the status of the
            operation in Mongo vim collection.
        """

        vim_uuid: str
        op_id: str

    @abstractmethod
    async def run(self, workflow_input: Input) -> None:
        pass
