"""
fc_get_attribute
================
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.outputs import _modify_output_spec_with_one_type
from ansys.dpf.core.operators.specification import PinSpecification, Specification


class fc_get_attribute(Operator):
    """Uses the FieldsContainer APIs to return a given attribute of the mesh
    in input.

    Parameters
    ----------
    fields_container : FieldsContainer
    property_name : str
        Supported property names are:
        "label_scoping", "label_values",
        "time_freq_support", "labels",
        "field_scoping" .
    property_identifier : str or int, optional
        Additional pin for some property : the label
        name for "label_scoping" or
        "label_values", the field index
        (default 0) for "field_scoping".


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

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

    >>> # Make input connections
    >>> my_fields_container = dpf.FieldsContainer()
    >>> op.inputs.fields_container.connect(my_fields_container)
    >>> my_property_name = str()
    >>> op.inputs.property_name.connect(my_property_name)
    >>> my_property_identifier = str()
    >>> op.inputs.property_identifier.connect(my_property_identifier)

    >>> # Instantiate operator and connect inputs in one line
    >>> op = dpf.operators.utility.fc_get_attribute(
    ...     fields_container=my_fields_container,
    ...     property_name=my_property_name,
    ...     property_identifier=my_property_identifier,
    ... )

    >>> # Get output data
    >>> result_property = op.outputs.property()
    """

    def __init__(
        self,
        fields_container=None,
        property_name=None,
        property_identifier=None,
        config=None,
        server=None,
    ):
        super().__init__(
            name="fieldscontainer::get_attribute", config=config, server=server
        )
        self._inputs = InputsFcGetAttribute(self)
        self._outputs = OutputsFcGetAttribute(self)
        if fields_container is not None:
            self.inputs.fields_container.connect(fields_container)
        if property_name is not None:
            self.inputs.property_name.connect(property_name)
        if property_identifier is not None:
            self.inputs.property_identifier.connect(property_identifier)

    @staticmethod
    def _spec():
        description = """Uses the FieldsContainer APIs to return a given attribute of the mesh
            in input."""
        spec = Specification(
            description=description,
            map_input_pin_spec={
                0: PinSpecification(
                    name="fields_container",
                    type_names=["fields_container"],
                    optional=False,
                    document="""""",
                ),
                1: PinSpecification(
                    name="property_name",
                    type_names=["string"],
                    optional=False,
                    document="""Supported property names are:
        "label_scoping", "label_values",
        "time_freq_support", "labels",
        "field_scoping" .""",
                ),
                2: PinSpecification(
                    name="property_identifier",
                    type_names=["string", "int32"],
                    optional=True,
                    document="""Additional pin for some property : the label
        name for "label_scoping" or
        "label_values", the field index
        (default 0) for "field_scoping".""",
                ),
            },
            map_output_pin_spec={
                0: PinSpecification(
                    name="property",
                    type_names=[
                        "scoping",
                        "vector<int32>",
                        "time_freq_support",
                        "vector<string>",
                        "label_space",
                    ],
                    optional=False,
                    document="""Returns a scoping for property:
        "label_scoping", a vector of int for
        "label_values", a time freq support
        for "time_freq_support", a vector of
        string for "labels", a labelspace for
        "field_scoping".""",
                ),
            },
        )
        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="fieldscontainer::get_attribute", server=server
        )

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

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

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

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


class InputsFcGetAttribute(_Inputs):
    """Intermediate class used to connect user inputs to
    fc_get_attribute operator.

    Examples
    --------
    >>> from ansys.dpf import core as dpf
    >>> op = dpf.operators.utility.fc_get_attribute()
    >>> my_fields_container = dpf.FieldsContainer()
    >>> op.inputs.fields_container.connect(my_fields_container)
    >>> my_property_name = str()
    >>> op.inputs.property_name.connect(my_property_name)
    >>> my_property_identifier = str()
    >>> op.inputs.property_identifier.connect(my_property_identifier)
    """

    def __init__(self, op: Operator):
        super().__init__(fc_get_attribute._spec().inputs, op)
        self._fields_container = Input(fc_get_attribute._spec().input_pin(0), 0, op, -1)
        self._inputs.append(self._fields_container)
        self._property_name = Input(fc_get_attribute._spec().input_pin(1), 1, op, -1)
        self._inputs.append(self._property_name)
        self._property_identifier = Input(
            fc_get_attribute._spec().input_pin(2), 2, op, -1
        )
        self._inputs.append(self._property_identifier)

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

        Parameters
        ----------
        my_fields_container : FieldsContainer

        Examples
        --------
        >>> from ansys.dpf import core as dpf
        >>> op = dpf.operators.utility.fc_get_attribute()
        >>> op.inputs.fields_container.connect(my_fields_container)
        >>> # or
        >>> op.inputs.fields_container(my_fields_container)
        """
        return self._fields_container

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

        Supported property names are:
        "label_scoping", "label_values",
        "time_freq_support", "labels",
        "field_scoping" .

        Parameters
        ----------
        my_property_name : str

        Examples
        --------
        >>> from ansys.dpf import core as dpf
        >>> op = dpf.operators.utility.fc_get_attribute()
        >>> op.inputs.property_name.connect(my_property_name)
        >>> # or
        >>> op.inputs.property_name(my_property_name)
        """
        return self._property_name

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

        Additional pin for some property : the label
        name for "label_scoping" or
        "label_values", the field index
        (default 0) for "field_scoping".

        Parameters
        ----------
        my_property_identifier : str or int

        Examples
        --------
        >>> from ansys.dpf import core as dpf
        >>> op = dpf.operators.utility.fc_get_attribute()
        >>> op.inputs.property_identifier.connect(my_property_identifier)
        >>> # or
        >>> op.inputs.property_identifier(my_property_identifier)
        """
        return self._property_identifier


class OutputsFcGetAttribute(_Outputs):
    """Intermediate class used to get outputs from
    fc_get_attribute operator.

    Examples
    --------
    >>> from ansys.dpf import core as dpf
    >>> op = dpf.operators.utility.fc_get_attribute()
    >>> # Connect inputs : op.inputs. ...
    >>> result_property = op.outputs.property()
    """

    def __init__(self, op: Operator):
        super().__init__(fc_get_attribute._spec().outputs, op)
        self.property_as_scoping = Output(
            _modify_output_spec_with_one_type(
                fc_get_attribute._spec().output_pin(0), "scoping"
            ),
            0,
            op,
        )
        self._outputs.append(self.property_as_scoping)
        self.property_as_vector_int32_ = Output(
            _modify_output_spec_with_one_type(
                fc_get_attribute._spec().output_pin(0), "vector_int32_"
            ),
            0,
            op,
        )
        self._outputs.append(self.property_as_vector_int32_)
        self.property_as_time_freq_support = Output(
            _modify_output_spec_with_one_type(
                fc_get_attribute._spec().output_pin(0), "time_freq_support"
            ),
            0,
            op,
        )
        self._outputs.append(self.property_as_time_freq_support)
        self.property_as_vector_string_ = Output(
            _modify_output_spec_with_one_type(
                fc_get_attribute._spec().output_pin(0), "vector_string_"
            ),
            0,
            op,
        )
        self._outputs.append(self.property_as_vector_string_)
        self.property_as_label_space = Output(
            _modify_output_spec_with_one_type(
                fc_get_attribute._spec().output_pin(0), "label_space"
            ),
            0,
            op,
        )
        self._outputs.append(self.property_as_label_space)
