# coding: utf-8

"""
    Logto API references

    API references for Logto services. To learn more about how to interact with Logto APIs, see [Interact with Management API](https://docs.logto.io/docs/recipes/interact-with-management-api/).

    The version of the OpenAPI document: Cloud
    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
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class ApiConfigsJwtCustomizerTokenTypePathPutRequest(BaseModel):
    """
    ApiConfigsJwtCustomizerTokenTypePathPutRequest
    """ # noqa: E501
    script: Optional[Any] = Field(default=None, description="The script of the JWT customizer.")
    environment_variables: Optional[Any] = Field(default=None, description="The environment variables for the JWT customizer.", alias="environmentVariables")
    context_sample: Optional[Any] = Field(default=None, description="The sample context for the JWT customizer script testing purpose.", alias="contextSample")
    token_sample: Optional[Any] = Field(default=None, description="The sample raw token payload for the JWT customizer script testing purpose.", alias="tokenSample")
    __properties: ClassVar[List[str]] = ["script", "environmentVariables", "contextSample", "tokenSample"]

    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 ApiConfigsJwtCustomizerTokenTypePathPutRequest 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 script (nullable) is None
        # and model_fields_set contains the field
        if self.script is None and "script" in self.model_fields_set:
            _dict['script'] = None

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "script": obj.get("script"),
            "environmentVariables": obj.get("environmentVariables"),
            "contextSample": obj.get("contextSample"),
            "tokenSample": obj.get("tokenSample")
        })
        return _obj


