# 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: 0.81.1
    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, Optional
from typing_extensions import Annotated
from mixpeek.models.shared_triggers_models_trigger_status import SharedTriggersModelsTriggerStatus
from mixpeek.models.shared_triggers_models_trigger_type import SharedTriggersModelsTriggerType
from mixpeek.models.trigger_action_type import TriggerActionType
from typing import Optional, Set
from typing_extensions import Self

class SharedTriggersModelsListTriggersRequest(BaseModel):
    """
    Request to list triggers with filters.
    """ # noqa: E501
    action_type: Optional[TriggerActionType] = Field(default=None, description="Filter by action type")
    trigger_type: Optional[SharedTriggersModelsTriggerType] = Field(default=None, description="Filter by trigger type")
    status: Optional[SharedTriggersModelsTriggerStatus] = Field(default=None, description="Filter by status")
    resource_id: Optional[StrictStr] = Field(default=None, description="Filter by resource ID (cluster_id or taxonomy_id)")
    offset: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=0, description="Pagination offset")
    limit: Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]] = Field(default=50, description="Results per page")
    sort_by: Optional[StrictStr] = Field(default='created_at', description="Field to sort by")
    direction: Optional[StrictStr] = Field(default='desc', description="Sort direction (asc/desc)")
    __properties: ClassVar[List[str]] = ["action_type", "trigger_type", "status", "resource_id", "offset", "limit", "sort_by", "direction"]

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

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

        _obj = cls.model_validate({
            "action_type": obj.get("action_type"),
            "trigger_type": obj.get("trigger_type"),
            "status": obj.get("status"),
            "resource_id": obj.get("resource_id"),
            "offset": obj.get("offset") if obj.get("offset") is not None else 0,
            "limit": obj.get("limit") if obj.get("limit") is not None else 50,
            "sort_by": obj.get("sort_by") if obj.get("sort_by") is not None else 'created_at',
            "direction": obj.get("direction") if obj.get("direction") is not None else 'desc'
        })
        return _obj


