# coding: utf-8

"""
    Mixpeek API

    This is the Mixpeek API, providing access to various endpoints for data processing and retrieval.

    The version of the OpenAPI document: 1.3.0
    Contact: info@mixpeek.com
    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, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self

class PathAnalysisRequest(BaseModel):
    """
    API request model for multi-step path analysis.  Discovers the most common sequences of intermediate steps documents take when progressing from from_step to to_step.  Unlike the transitions endpoint which only analyzes direct A→B progressions, this endpoint reveals the actual paths taken (e.g., A → X → Y → B).  Example:     ```json     {         \"collection_id\": \"col_emails\",         \"taxonomy_id\": \"tax_sales_stages\",         \"from_step\": \"inquiry\",         \"to_step\": \"closed_won\",         \"max_path_length\": 10,         \"min_support\": 5     }     ```  Response includes:     - Most common paths sorted by frequency     - Count and percentage for each path     - Average duration per path
    """ # noqa: E501
    collection_id: StrictStr = Field(description="Collection to analyze")
    taxonomy_id: StrictStr = Field(description="Taxonomy ID")
    from_step: StrictStr = Field(description="Starting step")
    to_step: StrictStr = Field(description="Ending step")
    max_path_length: Optional[Annotated[int, Field(le=20, strict=True, ge=2)]] = Field(default=10, description="Maximum number of steps in a path")
    min_support: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=5, description="Minimum sequences required to include a path")
    max_window_days: Optional[StrictInt] = Field(default=None, description="Maximum duration for path completion (in days)")
    filters: Optional[Dict[str, Any]] = Field(default=None, description="Optional event filters")
    __properties: ClassVar[List[str]] = ["collection_id", "taxonomy_id", "from_step", "to_step", "max_path_length", "min_support", "max_window_days", "filters"]

    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 PathAnalysisRequest 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,
        )
        return _dict

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

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

        _obj = cls.model_validate({
            "collection_id": obj.get("collection_id"),
            "taxonomy_id": obj.get("taxonomy_id"),
            "from_step": obj.get("from_step"),
            "to_step": obj.get("to_step"),
            "max_path_length": obj.get("max_path_length") if obj.get("max_path_length") is not None else 10,
            "min_support": obj.get("min_support") if obj.get("min_support") is not None else 5,
            "max_window_days": obj.get("max_window_days"),
            "filters": obj.get("filters")
        })
        return _obj


