# coding: utf-8

"""
Perigon API

The Perigon API provides access to comprehensive news and web content data. To use the API, simply sign up for a Perigon Business Solutions account to obtain your API key. Your available features may vary based on your plan. See the Authentication section for details on how to use your API key.

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

Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations

import json
import pprint
import re  # noqa: F401
from typing import Any, ClassVar, Dict, List, Optional, Set

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


class AuthExceptionCauseStackTraceInner(BaseModel):
    """
    AuthExceptionCauseStackTraceInner
    """  # noqa: E501

    class_loader_name: Optional[StrictStr] = Field(
        default=None, alias="classLoaderName"
    )
    module_name: Optional[StrictStr] = Field(default=None, alias="moduleName")
    module_version: Optional[StrictStr] = Field(default=None, alias="moduleVersion")
    method_name: Optional[StrictStr] = Field(default=None, alias="methodName")
    file_name: Optional[StrictStr] = Field(default=None, alias="fileName")
    line_number: Optional[StrictInt] = Field(default=None, alias="lineNumber")
    native_method: Optional[StrictBool] = Field(default=None, alias="nativeMethod")
    class_name: Optional[StrictStr] = Field(default=None, alias="className")
    __properties: ClassVar[List[str]] = [
        "classLoaderName",
        "moduleName",
        "moduleVersion",
        "methodName",
        "fileName",
        "lineNumber",
        "nativeMethod",
        "className",
    ]

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

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

        _obj = cls.model_validate(
            {
                "classLoaderName": obj.get("classLoaderName"),
                "moduleName": obj.get("moduleName"),
                "moduleVersion": obj.get("moduleVersion"),
                "methodName": obj.get("methodName"),
                "fileName": obj.get("fileName"),
                "lineNumber": obj.get("lineNumber"),
                "nativeMethod": obj.get("nativeMethod"),
                "className": obj.get("className"),
            }
        )
        return _obj
