"""
Python SDK for OpenFGA

API version: 1.x
Website: https://openfga.dev
Documentation: https://openfga.dev/docs
Support: https://openfga.dev/community
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)

NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
"""

import pprint

from inspect import getfullargspec

from openfga_sdk.configuration import Configuration


class Node:
    """NOTE: This class is auto generated by OpenAPI Generator.
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """

    """
    Attributes:
      openapi_types (dict): The key is attribute name
                            and the value is attribute type.
      attribute_map (dict): The key is attribute name
                            and the value is json key in definition.
    """
    openapi_types: dict[str, str] = {
        "name": "str",
        "leaf": "Leaf",
        "difference": "UsersetTreeDifference",
        "union": "Nodes",
        "intersection": "Nodes",
    }

    attribute_map: dict[str, str] = {
        "name": "name",
        "leaf": "leaf",
        "difference": "difference",
        "union": "union",
        "intersection": "intersection",
    }

    def __init__(
        self,
        name=None,
        leaf=None,
        difference=None,
        union=None,
        intersection=None,
        local_vars_configuration=None,
    ):
        """Node - a model defined in OpenAPI"""
        if local_vars_configuration is None:
            local_vars_configuration = Configuration.get_default_copy()
        self.local_vars_configuration = local_vars_configuration

        self._name = None
        self._leaf = None
        self._difference = None
        self._union = None
        self._intersection = None
        self.discriminator = None

        self.name = name
        if leaf is not None:
            self.leaf = leaf
        if difference is not None:
            self.difference = difference
        if union is not None:
            self.union = union
        if intersection is not None:
            self.intersection = intersection

    @property
    def name(self):
        """Gets the name of this Node.


        :return: The name of this Node.
        :rtype: str
        """
        return self._name

    @name.setter
    def name(self, name):
        """Sets the name of this Node.


        :param name: The name of this Node.
        :type name: str
        """
        if self.local_vars_configuration.client_side_validation and name is None:
            raise ValueError("Invalid value for `name`, must not be `None`")

        self._name = name

    @property
    def leaf(self):
        """Gets the leaf of this Node.


        :return: The leaf of this Node.
        :rtype: Leaf
        """
        return self._leaf

    @leaf.setter
    def leaf(self, leaf):
        """Sets the leaf of this Node.


        :param leaf: The leaf of this Node.
        :type leaf: Leaf
        """

        self._leaf = leaf

    @property
    def difference(self):
        """Gets the difference of this Node.


        :return: The difference of this Node.
        :rtype: UsersetTreeDifference
        """
        return self._difference

    @difference.setter
    def difference(self, difference):
        """Sets the difference of this Node.


        :param difference: The difference of this Node.
        :type difference: UsersetTreeDifference
        """

        self._difference = difference

    @property
    def union(self):
        """Gets the union of this Node.


        :return: The union of this Node.
        :rtype: Nodes
        """
        return self._union

    @union.setter
    def union(self, union):
        """Sets the union of this Node.


        :param union: The union of this Node.
        :type union: Nodes
        """

        self._union = union

    @property
    def intersection(self):
        """Gets the intersection of this Node.


        :return: The intersection of this Node.
        :rtype: Nodes
        """
        return self._intersection

    @intersection.setter
    def intersection(self, intersection):
        """Sets the intersection of this Node.


        :param intersection: The intersection of this Node.
        :type intersection: Nodes
        """

        self._intersection = intersection

    def to_dict(self, serialize=False):
        """Returns the model properties as a dict"""
        result = {}

        def convert(x):
            if hasattr(x, "to_dict"):
                args = getfullargspec(x.to_dict).args
                if len(args) == 1:
                    return x.to_dict()
                else:
                    return x.to_dict(serialize)
            else:
                return x

        for attr, _ in self.openapi_types.items():
            value = getattr(self, attr)
            attr = self.attribute_map.get(attr, attr) if serialize else attr
            if isinstance(value, list):
                result[attr] = list(map(lambda x: convert(x), value))
            elif isinstance(value, dict):
                result[attr] = dict(
                    map(lambda item: (item[0], convert(item[1])), value.items())
                )
            else:
                result[attr] = convert(value)

        return result

    def to_str(self):
        """Returns the string representation of the model"""
        return pprint.pformat(self.to_dict())

    def __repr__(self):
        """For `print` and `pprint`"""
        return self.to_str()

    def __eq__(self, other):
        """Returns true if both objects are equal"""
        if not isinstance(other, Node):
            return False

        return self.to_dict() == other.to_dict()

    def __ne__(self, other):
        """Returns true if both objects are not equal"""
        if not isinstance(other, Node):
            return True

        return self.to_dict() != other.to_dict()
