"""
merge_any
=========
Autogenerated DPF operator classes.
"""
from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
from ansys.dpf.core.outputs import Output, _Outputs
from ansys.dpf.core.operators.specification import PinSpecification, Specification


class merge_any(Operator):
    """Merges a list of objects having the same data types. Once the data
    type is found, the merge operation is forwarded to the correct
    merge Operator.

    Parameters
    ----------
    any1 : Any
        Either a vector of objects (sharing the same
        data types) or objects from pin 0 to
        ... to merge. supported types rely on
        existing type specific merge
        operators.
    any2 : Any
        Either a vector of objects (sharing the same
        data types) or objects from pin 0 to
        ... to merge. supported types rely on
        existing type specific merge
        operators.


    Examples
    --------
    >>> from ansys.dpf import core as dpf

    >>> # Instantiate operator
    >>> op = dpf.operators.utility.merge_any()

    >>> # Make input connections
    >>> my_any1 = dpf.Any()
    >>> op.inputs.any1.connect(my_any1)
    >>> my_any2 = dpf.Any()
    >>> op.inputs.any2.connect(my_any2)

    >>> # Instantiate operator and connect inputs in one line
    >>> op = dpf.operators.utility.merge_any(
    ...     any1=my_any1,
    ...     any2=my_any2,
    ... )

    >>> # Get output data
    >>> result_any = op.outputs.any()
    """

    def __init__(self, any1=None, any2=None, config=None, server=None):
        super().__init__(name="merge::any", config=config, server=server)
        self._inputs = InputsMergeAny(self)
        self._outputs = OutputsMergeAny(self)
        if any1 is not None:
            self.inputs.any1.connect(any1)
        if any2 is not None:
            self.inputs.any2.connect(any2)

    @staticmethod
    def _spec():
        description = """Merges a list of objects having the same data types. Once the data
            type is found, the merge operation is forwarded to the
            correct merge Operator."""
        spec = Specification(
            description=description,
            map_input_pin_spec={
                0: PinSpecification(
                    name="any",
                    type_names=["any"],
                    optional=False,
                    document="""Either a vector of objects (sharing the same
        data types) or objects from pin 0 to
        ... to merge. supported types rely on
        existing type specific merge
        operators.""",
                ),
                1: PinSpecification(
                    name="any",
                    type_names=["any"],
                    optional=False,
                    document="""Either a vector of objects (sharing the same
        data types) or objects from pin 0 to
        ... to merge. supported types rely on
        existing type specific merge
        operators.""",
                ),
            },
            map_output_pin_spec={
                0: PinSpecification(
                    name="any",
                    type_names=["any"],
                    optional=False,
                    document="""""",
                ),
            },
        )
        return spec

    @staticmethod
    def default_config(server=None):
        """Returns the default config of the operator.

        This config can then be changed to the user needs and be used to
        instantiate the operator. The Configuration allows to customize
        how the operation will be processed by the operator.

        Parameters
        ----------
        server : server.DPFServer, optional
            Server with channel connected to the remote or local instance. When
            ``None``, attempts to use the global server.
        """
        return Operator.default_config(name="merge::any", server=server)

    @property
    def inputs(self):
        """Enables to connect inputs to the operator

        Returns
        --------
        inputs : InputsMergeAny
        """
        return super().inputs

    @property
    def outputs(self):
        """Enables to get outputs of the operator by evaluating it

        Returns
        --------
        outputs : OutputsMergeAny
        """
        return super().outputs


class InputsMergeAny(_Inputs):
    """Intermediate class used to connect user inputs to
    merge_any operator.

    Examples
    --------
    >>> from ansys.dpf import core as dpf
    >>> op = dpf.operators.utility.merge_any()
    >>> my_any1 = dpf.Any()
    >>> op.inputs.any1.connect(my_any1)
    >>> my_any2 = dpf.Any()
    >>> op.inputs.any2.connect(my_any2)
    """

    def __init__(self, op: Operator):
        super().__init__(merge_any._spec().inputs, op)
        self._any1 = Input(merge_any._spec().input_pin(0), 0, op, 0)
        self._inputs.append(self._any1)
        self._any2 = Input(merge_any._spec().input_pin(1), 1, op, 1)
        self._inputs.append(self._any2)

    @property
    def any1(self):
        """Allows to connect any1 input to the operator.

        Either a vector of objects (sharing the same
        data types) or objects from pin 0 to
        ... to merge. supported types rely on
        existing type specific merge
        operators.

        Parameters
        ----------
        my_any1 : Any

        Examples
        --------
        >>> from ansys.dpf import core as dpf
        >>> op = dpf.operators.utility.merge_any()
        >>> op.inputs.any1.connect(my_any1)
        >>> # or
        >>> op.inputs.any1(my_any1)
        """
        return self._any1

    @property
    def any2(self):
        """Allows to connect any2 input to the operator.

        Either a vector of objects (sharing the same
        data types) or objects from pin 0 to
        ... to merge. supported types rely on
        existing type specific merge
        operators.

        Parameters
        ----------
        my_any2 : Any

        Examples
        --------
        >>> from ansys.dpf import core as dpf
        >>> op = dpf.operators.utility.merge_any()
        >>> op.inputs.any2.connect(my_any2)
        >>> # or
        >>> op.inputs.any2(my_any2)
        """
        return self._any2


class OutputsMergeAny(_Outputs):
    """Intermediate class used to get outputs from
    merge_any operator.

    Examples
    --------
    >>> from ansys.dpf import core as dpf
    >>> op = dpf.operators.utility.merge_any()
    >>> # Connect inputs : op.inputs. ...
    >>> result_any = op.outputs.any()
    """

    def __init__(self, op: Operator):
        super().__init__(merge_any._spec().outputs, op)
        self._any = Output(merge_any._spec().output_pin(0), 0, op)
        self._outputs.append(self._any)

    @property
    def any(self):
        """Allows to get any output of the operator

        Returns
        ----------
        my_any : Any

        Examples
        --------
        >>> from ansys.dpf import core as dpf
        >>> op = dpf.operators.utility.merge_any()
        >>> # Connect inputs : op.inputs. ...
        >>> result_any = op.outputs.any()
        """  # noqa: E501
        return self._any
