# coding: utf-8

"""
    Guardrails Hub Types

    Data structures used in the Guardrails Hub

    The version of the OpenAPI document: 0.0.0
    Generated by OpenAPI Generator (https://openapi-generator.tech)

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


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from typing import Set
from typing_extensions import Self

class Applicator(BaseModel):
    """
    Applicator
    """ # noqa: E501
    prefix_items: Optional[Annotated[List[Any], Field(min_length=1)]] = Field(default=None, alias="prefixItems")
    items: Optional[Any] = None
    contains: Optional[Any] = None
    additional_properties: Optional[Any] = Field(default=None, alias="additionalProperties")
    properties: Optional[Dict[str, Any]] = None
    pattern_properties: Optional[Dict[str, Any]] = Field(default=None, alias="patternProperties")
    dependent_schemas: Optional[Dict[str, Any]] = Field(default=None, alias="dependentSchemas")
    property_names: Optional[Any] = Field(default=None, alias="propertyNames")
    var_if: Optional[Any] = Field(default=None, alias="if")
    then: Optional[Any] = None
    var_else: Optional[Any] = Field(default=None, alias="else")
    all_of: Optional[Annotated[List[Any], Field(min_length=1)]] = Field(default=None, alias="allOf")
    any_of: Optional[Annotated[List[Any], Field(min_length=1)]] = Field(default=None, alias="anyOf")
    one_of: Optional[Annotated[List[Any], Field(min_length=1)]] = Field(default=None, alias="oneOf")
    var_not: Optional[Any] = Field(default=None, alias="not")
    __properties: ClassVar[List[str]] = ["prefixItems", "items", "contains", "additionalProperties", "properties", "patternProperties", "dependentSchemas", "propertyNames", "if", "then", "else", "allOf", "anyOf", "oneOf", "not"]

    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 Applicator 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.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # set to None if items (nullable) is None
        # and model_fields_set contains the field
        if self.items is None and "items" in self.model_fields_set:
            _dict['items'] = None

        # set to None if contains (nullable) is None
        # and model_fields_set contains the field
        if self.contains is None and "contains" in self.model_fields_set:
            _dict['contains'] = None

        # set to None if additional_properties (nullable) is None
        # and model_fields_set contains the field
        if self.additional_properties is None and "additional_properties" in self.model_fields_set:
            _dict['additionalProperties'] = None

        # set to None if property_names (nullable) is None
        # and model_fields_set contains the field
        if self.property_names is None and "property_names" in self.model_fields_set:
            _dict['propertyNames'] = None

        # set to None if var_if (nullable) is None
        # and model_fields_set contains the field
        if self.var_if is None and "var_if" in self.model_fields_set:
            _dict['if'] = None

        # set to None if then (nullable) is None
        # and model_fields_set contains the field
        if self.then is None and "then" in self.model_fields_set:
            _dict['then'] = None

        # set to None if var_else (nullable) is None
        # and model_fields_set contains the field
        if self.var_else is None and "var_else" in self.model_fields_set:
            _dict['else'] = None

        # set to None if var_not (nullable) is None
        # and model_fields_set contains the field
        if self.var_not is None and "var_not" in self.model_fields_set:
            _dict['not'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "prefixItems": obj.get("prefixItems"),
            "items": obj.get("items"),
            "contains": obj.get("contains"),
            "additionalProperties": obj.get("additionalProperties"),
            "propertyNames": obj.get("propertyNames"),
            "if": obj.get("if"),
            "then": obj.get("then"),
            "else": obj.get("else"),
            "allOf": obj.get("allOf"),
            "anyOf": obj.get("anyOf"),
            "oneOf": obj.get("oneOf"),
            "not": obj.get("not")
        })
        return _obj


