Files
goose/api_clients/python/goose_api/models/extension_entry.py
2025-10-02 20:13:20 -04:00

145 lines
5.1 KiB
Python

# coding: utf-8
"""
goose-server
An AI agent
The version of the OpenAPI document: 1.9.0
Contact: ai-oss-tools@block.xyz
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 ConfigDict, StrictBool
from typing import Any, ClassVar, Dict, List
from goose_api.models.extension_config import ExtensionConfig
from goose_api.models.tool import Tool
from typing import Optional, Set
from typing_extensions import Self
class ExtensionEntry(ExtensionConfig):
"""
ExtensionEntry
""" # noqa: E501
enabled: StrictBool
__properties: ClassVar[List[str]] = ["available_tools", "bundled", "description", "env_keys", "envs", "name", "timeout", "type", "uri", "args", "cmd", "display_name", "headers", "instructions", "tools", "code", "dependencies", "enabled"]
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 ExtensionEntry 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,
)
# override the default output from pydantic by calling `to_dict()` of each item in tools (list)
_items = []
if self.tools:
for _item_tools in self.tools:
if _item_tools:
_items.append(_item_tools.to_dict())
_dict['tools'] = _items
# set to None if bundled (nullable) is None
# and model_fields_set contains the field
if self.bundled is None and "bundled" in self.model_fields_set:
_dict['bundled'] = None
# set to None if description (nullable) is None
# and model_fields_set contains the field
if self.description is None and "description" in self.model_fields_set:
_dict['description'] = None
# set to None if timeout (nullable) is None
# and model_fields_set contains the field
if self.timeout is None and "timeout" in self.model_fields_set:
_dict['timeout'] = None
# set to None if display_name (nullable) is None
# and model_fields_set contains the field
if self.display_name is None and "display_name" in self.model_fields_set:
_dict['display_name'] = None
# set to None if instructions (nullable) is None
# and model_fields_set contains the field
if self.instructions is None and "instructions" in self.model_fields_set:
_dict['instructions'] = None
# set to None if dependencies (nullable) is None
# and model_fields_set contains the field
if self.dependencies is None and "dependencies" in self.model_fields_set:
_dict['dependencies'] = None
return _dict
@classmethod
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"""Create an instance of ExtensionEntry from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return cls.model_validate(obj)
_obj = cls.model_validate({
"available_tools": obj.get("available_tools"),
"bundled": obj.get("bundled"),
"description": obj.get("description"),
"env_keys": obj.get("env_keys"),
"envs": obj.get("envs"),
"name": obj.get("name"),
"timeout": obj.get("timeout"),
"type": obj.get("type"),
"uri": obj.get("uri"),
"args": obj.get("args"),
"cmd": obj.get("cmd"),
"display_name": obj.get("display_name"),
"headers": obj.get("headers"),
"instructions": obj.get("instructions"),
"tools": [Tool.from_dict(_item) for _item in obj["tools"]] if obj.get("tools") is not None else None,
"code": obj.get("code"),
"dependencies": obj.get("dependencies"),
"enabled": obj.get("enabled")
})
return _obj