# 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, StrictStr
from typing import Any, ClassVar, Dict, List
from typing_extensions import Annotated
from mixpeek.models.step_info import StepInfo
from typing import Optional, Set
from typing_extensions import Self

class AvailableStepsResponse(BaseModel):
    """
    Response containing all available steps for a taxonomy/collection.  This endpoint helps users discover what steps exist in their analytics data before querying transitions or paths.  Example Response:     ```json     {         \"taxonomy_id\": \"tax_sales_stages\",         \"collection_id\": \"col_emails\",         \"total_events\": 5432,         \"total_sequences\": 1000,         \"steps\": [             {                 \"step_key\": \"inquiry\",                 \"event_count\": 1000,                 \"sequence_count\": 1000,                 \"first_seen\": \"2025-11-01T00:00:00Z\",                 \"last_seen\": \"2025-12-07T00:00:00Z\"             },             {                 \"step_key\": \"followup\",                 \"event_count\": 450,                 \"sequence_count\": 450,                 \"first_seen\": \"2025-11-02T00:00:00Z\",                 \"last_seen\": \"2025-12-06T00:00:00Z\"             },             {                 \"step_key\": \"closed_won\",                 \"event_count\": 350,                 \"sequence_count\": 350,                 \"first_seen\": \"2025-11-05T00:00:00Z\",                 \"last_seen\": \"2025-12-07T00:00:00Z\"             }         ]     }     ```
    """ # noqa: E501
    taxonomy_id: StrictStr = Field(description="Taxonomy ID")
    collection_id: StrictStr = Field(description="Collection ID")
    total_events: Annotated[int, Field(strict=True, ge=0)] = Field(description="Total events in dataset")
    total_sequences: Annotated[int, Field(strict=True, ge=0)] = Field(description="Total unique sequences")
    steps: List[StepInfo] = Field(description="Available steps sorted by count")
    __properties: ClassVar[List[str]] = ["taxonomy_id", "collection_id", "total_events", "total_sequences", "steps"]

    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 AvailableStepsResponse 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,
        )
        # override the default output from pydantic by calling `to_dict()` of each item in steps (list)
        _items = []
        if self.steps:
            for _item_steps in self.steps:
                if _item_steps:
                    _items.append(_item_steps.to_dict())
            _dict['steps'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "taxonomy_id": obj.get("taxonomy_id"),
            "collection_id": obj.get("collection_id"),
            "total_events": obj.get("total_events"),
            "total_sequences": obj.get("total_sequences"),
            "steps": [StepInfo.from_dict(_item) for _item in obj["steps"]] if obj.get("steps") is not None else None
        })
        return _obj


