# coding: utf-8

"""
    Kestra EE

    All API operations, except for Superadmin-only endpoints, require a tenant identifier in the HTTP path.<br/> Endpoints designated as Superadmin-only are not tenant-scoped.

    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import regex as re
import json

from pydantic import BaseModel, ConfigDict, Field, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from kestrapy.models.property_boolean import PropertyBoolean
from kestrapy.models.property_double import PropertyDouble
from kestrapy.models.property_list_string import PropertyListString
from kestrapy.models.property_object import PropertyObject
from kestrapy.models.property_string import PropertyString
from typing import Optional, Set
from typing_extensions import Self

class Assertion(BaseModel):
    """
    Assertion
    """ # noqa: E501
    value: PropertyObject
    task_id: Optional[StrictStr] = Field(default=None, alias="taskId")
    error_message: Optional[PropertyString] = Field(default=None, alias="errorMessage")
    description: Optional[PropertyString] = None
    ends_with: Optional[PropertyString] = Field(default=None, alias="endsWith")
    starts_with: Optional[PropertyString] = Field(default=None, alias="startsWith")
    contains: Optional[PropertyString] = None
    equal_to: Optional[PropertyObject] = Field(default=None, alias="equalTo")
    not_equal_to: Optional[PropertyObject] = Field(default=None, alias="notEqualTo")
    greater_than: Optional[PropertyDouble] = Field(default=None, alias="greaterThan")
    greater_than_or_equal_to: Optional[PropertyDouble] = Field(default=None, alias="greaterThanOrEqualTo")
    less_than: Optional[PropertyDouble] = Field(default=None, alias="lessThan")
    less_than_or_equal_to: Optional[PropertyDouble] = Field(default=None, alias="lessThanOrEqualTo")
    var_in: Optional[PropertyListString] = Field(default=None, alias="in")
    not_in: Optional[PropertyListString] = Field(default=None, alias="notIn")
    is_null: Optional[PropertyBoolean] = Field(default=None, alias="isNull")
    is_not_null: Optional[PropertyBoolean] = Field(default=None, alias="isNotNull")
    additional_properties: Dict[str, Any] = {}
    __properties: ClassVar[List[str]] = ["value", "taskId", "errorMessage", "description", "endsWith", "startsWith", "contains", "equalTo", "notEqualTo", "greaterThan", "greaterThanOrEqualTo", "lessThan", "lessThanOrEqualTo", "in", "notIn", "isNull", "isNotNull"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of Assertion from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        * Fields in `self.additional_properties` are added to the output dict.
        """
        excluded_fields: Set[str] = set([
            "additional_properties",
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of value
        if self.value:
            _dict['value'] = self.value.to_dict()
        # override the default output from pydantic by calling `to_dict()` of error_message
        if self.error_message:
            _dict['errorMessage'] = self.error_message.to_dict()
        # override the default output from pydantic by calling `to_dict()` of description
        if self.description:
            _dict['description'] = self.description.to_dict()
        # override the default output from pydantic by calling `to_dict()` of ends_with
        if self.ends_with:
            _dict['endsWith'] = self.ends_with.to_dict()
        # override the default output from pydantic by calling `to_dict()` of starts_with
        if self.starts_with:
            _dict['startsWith'] = self.starts_with.to_dict()
        # override the default output from pydantic by calling `to_dict()` of contains
        if self.contains:
            _dict['contains'] = self.contains.to_dict()
        # override the default output from pydantic by calling `to_dict()` of equal_to
        if self.equal_to:
            _dict['equalTo'] = self.equal_to.to_dict()
        # override the default output from pydantic by calling `to_dict()` of not_equal_to
        if self.not_equal_to:
            _dict['notEqualTo'] = self.not_equal_to.to_dict()
        # override the default output from pydantic by calling `to_dict()` of greater_than
        if self.greater_than:
            _dict['greaterThan'] = self.greater_than.to_dict()
        # override the default output from pydantic by calling `to_dict()` of greater_than_or_equal_to
        if self.greater_than_or_equal_to:
            _dict['greaterThanOrEqualTo'] = self.greater_than_or_equal_to.to_dict()
        # override the default output from pydantic by calling `to_dict()` of less_than
        if self.less_than:
            _dict['lessThan'] = self.less_than.to_dict()
        # override the default output from pydantic by calling `to_dict()` of less_than_or_equal_to
        if self.less_than_or_equal_to:
            _dict['lessThanOrEqualTo'] = self.less_than_or_equal_to.to_dict()
        # override the default output from pydantic by calling `to_dict()` of var_in
        if self.var_in:
            _dict['in'] = self.var_in.to_dict()
        # override the default output from pydantic by calling `to_dict()` of not_in
        if self.not_in:
            _dict['notIn'] = self.not_in.to_dict()
        # override the default output from pydantic by calling `to_dict()` of is_null
        if self.is_null:
            _dict['isNull'] = self.is_null.to_dict()
        # override the default output from pydantic by calling `to_dict()` of is_not_null
        if self.is_not_null:
            _dict['isNotNull'] = self.is_not_null.to_dict()
        # puts key-value pairs in additional_properties in the top level
        if self.additional_properties is not None:
            for _key, _value in self.additional_properties.items():
                _dict[_key] = _value

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of Assertion from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "value": PropertyObject.from_dict(obj["value"]) if obj.get("value") is not None else None,
            "taskId": obj.get("taskId"),
            "errorMessage": PropertyString.from_dict(obj["errorMessage"]) if obj.get("errorMessage") is not None else None,
            "description": PropertyString.from_dict(obj["description"]) if obj.get("description") is not None else None,
            "endsWith": PropertyString.from_dict(obj["endsWith"]) if obj.get("endsWith") is not None else None,
            "startsWith": PropertyString.from_dict(obj["startsWith"]) if obj.get("startsWith") is not None else None,
            "contains": PropertyString.from_dict(obj["contains"]) if obj.get("contains") is not None else None,
            "equalTo": PropertyObject.from_dict(obj["equalTo"]) if obj.get("equalTo") is not None else None,
            "notEqualTo": PropertyObject.from_dict(obj["notEqualTo"]) if obj.get("notEqualTo") is not None else None,
            "greaterThan": PropertyDouble.from_dict(obj["greaterThan"]) if obj.get("greaterThan") is not None else None,
            "greaterThanOrEqualTo": PropertyDouble.from_dict(obj["greaterThanOrEqualTo"]) if obj.get("greaterThanOrEqualTo") is not None else None,
            "lessThan": PropertyDouble.from_dict(obj["lessThan"]) if obj.get("lessThan") is not None else None,
            "lessThanOrEqualTo": PropertyDouble.from_dict(obj["lessThanOrEqualTo"]) if obj.get("lessThanOrEqualTo") is not None else None,
            "in": PropertyListString.from_dict(obj["in"]) if obj.get("in") is not None else None,
            "notIn": PropertyListString.from_dict(obj["notIn"]) if obj.get("notIn") is not None else None,
            "isNull": PropertyBoolean.from_dict(obj["isNull"]) if obj.get("isNull") is not None else None,
            "isNotNull": PropertyBoolean.from_dict(obj["isNotNull"]) if obj.get("isNotNull") is not None else None
        })
        # store additional fields in additional_properties
        for _key in obj.keys():
            if _key not in cls.__properties:
                _obj.additional_properties[_key] = obj.get(_key)

        return _obj


