Used by Variable/Connection.

https://github.com/apache/airflow/blob/894741e311ffd642e036b80d3b1b5d53c3747cad/airflow/secrets/metastore.py#L32

try:
                    return model_cls.model_validate(var).model_dump()  
                except AttributeError:  
                    return model_cls.from_orm(var).dict()  
            if isinstance(var, Job):
                return cls._encode(_pydantic_model_dump(JobPydantic, var), type_=DAT.BASE_JOB)
            elif isinstance(var, TaskInstance):
                return cls._encode(_pydantic_model_dump(TaskInstancePydantic, var), type_=DAT.TASK_INSTANCE)
            elif isinstance(var, DagRun):
                return cls._encode(_pydantic_model_dump(DagRunPydantic, var), type_=DAT.DAG_RUN)
            elif isinstance(var, Dataset):
                return cls._encode(_pydantic_model_dump(DatasetPydantic, var), type_=DAT.DATA_SET)
            else:
                return cls.default_serialization(strict, var)
        elif isinstance(var, ArgNotSet):
            return cls._encode(None, type_=DAT.ARG_NOT_SET)
        else:
            return cls.default_serialization(strict, var)
    @classmethod
    def default_serialization(cls, strict, var) -> str: