
"""
    Highway Workflow Engine API

     ## Highway Workflow Engine  A production-grade durable workflow engine with: - **Workflow Orchestration**: Execute complex multi-step workflows with fault tolerance - **Durable Execution**: Automatic checkpointing and replay for disaster recovery - **Time-Travel Debugging**: Replay and simulate past workflow executions - **Multi-Tenancy**: Full tenant isolation with RBAC - **Distributed Locks**: PostgreSQL advisory locks for coordination - **Saga Patterns**: Compensation support for rollback scenarios  ### Authentication All endpoints require a valid JWT token in the `Authorization` header: ``` Authorization: Bearer <token> ```  ### Rate Limiting API requests are rate-limited per tenant. Check response headers for limits: - `X-RateLimit-Limit`: Maximum requests per window - `X-RateLimit-Remaining`: Remaining requests - `X-RateLimit-Reset`: Window reset timestamp     

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

    Do not edit the class manually.
"""


from __future__ import annotations

import json
import pprint
import re  # noqa: F401
from datetime import datetime
from typing import Any, ClassVar

from pydantic import BaseModel, ConfigDict, Field, StrictStr
from typing_extensions import Self

from highway_sdk.models.success_response_token_list_response_e7ebca9_token_status import (
    SuccessResponseTokenListResponseE7ebca9TokenStatus,
)


class SuccessResponseTokenListResponseE7ebca9TokenResponse(BaseModel):
    """
    Token details response (without secret).
    """
    created_at: datetime | None = None
    expires_at: datetime | None = None
    last_used_at: datetime | None = None
    name: StrictStr = Field(description="Token name")
    permissions: list[StrictStr] | None = Field(default=None, description="Permissions")
    status: SuccessResponseTokenListResponseE7ebca9TokenStatus = Field(description="Token status")
    token_id: StrictStr = Field(description="Token ID (UUID)")
    user_email: StrictStr = Field(description="Owner email")
    __properties: ClassVar[list[str]] = ["created_at", "expires_at", "last_used_at", "name", "permissions", "status", "token_id", "user_email"]

    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) -> Self | None:
        """Create an instance of SuccessResponseTokenListResponseE7ebca9TokenResponse 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 created_at (nullable) is None
        # and model_fields_set contains the field
        if self.created_at is None and "created_at" in self.model_fields_set:
            _dict["created_at"] = None

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "created_at": obj.get("created_at"),
            "expires_at": obj.get("expires_at"),
            "last_used_at": obj.get("last_used_at"),
            "name": obj.get("name"),
            "permissions": obj.get("permissions"),
            "status": obj.get("status"),
            "token_id": obj.get("token_id"),
            "user_email": obj.get("user_email")
        })
        return _obj


