# 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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from mixpeek.models.session_status import SessionStatus
from typing import Optional, Set
from typing_extensions import Self

class CreateSessionResponse(BaseModel):
    """
    Response for session creation.  Attributes:     session_id: Unique session identifier     namespace_id: Namespace identifier     internal_id: Organization internal ID     session_name: Auto-generated session name (null until first message)     status: Session status     created_at: Session creation timestamp     expires_at: Session expiration timestamp  Example:     ```python     response = CreateSessionResponse(         session_id=\"ses_abc123\",         namespace_id=\"ns_xyz789\",         internal_id=\"int_abc123\",         session_name=None,  # Will be set after first message         status=\"active\",         created_at=datetime.utcnow(),         expires_at=datetime.utcnow() + timedelta(days=7)     )     ```
    """ # noqa: E501
    session_id: StrictStr = Field(description="Unique session identifier")
    namespace_id: StrictStr = Field(description="Namespace identifier")
    internal_id: StrictStr = Field(description="Organization internal ID")
    session_name: Optional[StrictStr] = Field(default=None, description="Auto-generated session name based on first conversation (set after first message)")
    status: SessionStatus = Field(description="Session status")
    created_at: datetime = Field(description="Session creation timestamp")
    expires_at: datetime = Field(description="Session expiration timestamp")
    __properties: ClassVar[List[str]] = ["session_id", "namespace_id", "internal_id", "session_name", "status", "created_at", "expires_at"]

    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 CreateSessionResponse 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 CreateSessionResponse from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "session_id": obj.get("session_id"),
            "namespace_id": obj.get("namespace_id"),
            "internal_id": obj.get("internal_id"),
            "session_name": obj.get("session_name"),
            "status": obj.get("status"),
            "created_at": obj.get("created_at"),
            "expires_at": obj.get("expires_at")
        })
        return _obj


