Component Management API
The Component Management API module provides querying and management functionality for plugin components, enabling plugins to obtain and use component-related information.
Import Method
from src.plugin_system.apis import component_manage_api
# or
from src.plugin_system import component_manage_apiFunction Overview
The Component Management API mainly provides the following functions:
- Plugin Information Query - Get information about all plugins or specified plugins.
- Component Query - Query component information by name or type.
- Component Management - Enable or disable components, supporting global and local operations.
Main Functions
1. Get All Plugin Information
def get_all_plugin_info() -> Dict[str, PluginInfo]:Get information about all plugins.
Returns:
Dict[str, PluginInfo]- Dictionary containing all plugin information, keys are plugin names, values arePluginInfoobjects.
2. Get Specified Plugin Information
def get_plugin_info(plugin_name: str) -> Optional[PluginInfo]:Get information about specified plugin.
Args:
plugin_name(str): Plugin name.
Returns:
Optional[PluginInfo]: Plugin information object, returnsNoneif plugin doesn't exist.
3. Get Specified Component Information
def get_component_info(component_name: str, component_type: ComponentType) -> Optional[Union[CommandInfo, ActionInfo, EventHandlerInfo]]:Get information about specified component.
Args:
component_name(str): Component name.component_type(ComponentType): Component type.
Returns:
Optional[Union[CommandInfo, ActionInfo, EventHandlerInfo]]: Component information object, returnsNoneif component doesn't exist.
4. Get All Component Information of Specified Type
def get_components_info_by_type(component_type: ComponentType) -> Dict[str, Union[CommandInfo, ActionInfo, EventHandlerInfo]]:Get all component information of specified type.
Args:
component_type(ComponentType): Component type.
Returns:
Dict[str, Union[CommandInfo, ActionInfo, EventHandlerInfo]]: Dictionary containing component information of specified type, keys are component names, values are corresponding component information objects.
5. Get All Enabled Component Information of Specified Type
def get_enabled_components_info_by_type(component_type: ComponentType) -> Dict[str, Union[CommandInfo, ActionInfo, EventHandlerInfo]]:Get all enabled component information of specified type.
Args:
component_type(ComponentType): Component type.
Returns:
Dict[str, Union[CommandInfo, ActionInfo, EventHandlerInfo]]: Dictionary containing enabled component information of specified type, keys are component names, values are corresponding component information objects.
6. Get Registered Action Information
def get_registered_action_info(action_name: str) -> Optional[ActionInfo]:Get registered information for specified Action.
Args:
action_name(str): Action name.
Returns:
Optional[ActionInfo]- Action information object, returnsNoneif Action doesn't exist.
7. Get Registered Command Information
def get_registered_command_info(command_name: str) -> Optional[CommandInfo]:Get registered information for specified Command.
Args:
command_name(str): Command name.
Returns:
Optional[CommandInfo]- Command information object, returnsNoneif Command doesn't exist.
8. Get Registered Tool Information
def get_registered_tool_info(tool_name: str) -> Optional[ToolInfo]:Get registered information for specified Tool.
Args:
tool_name(str): Tool name.
Returns:
Optional[ToolInfo]- Tool information object, returnsNoneif Tool doesn't exist.
9. Get Registered EventHandler Information
def get_registered_event_handler_info(event_handler_name: str) -> Optional[EventHandlerInfo]:Get registered information for specified EventHandler.
Args:
event_handler_name(str): EventHandler name.
Returns:
Optional[EventHandlerInfo]- EventHandler information object, returnsNoneif EventHandler doesn't exist.
10. Globally Enable Specified Component
def globally_enable_component(component_name: str, component_type: ComponentType) -> bool:Globally enable specified component.
Args:
component_name(str): Component name.component_type(ComponentType): Component type.
Returns:
bool- ReturnsTrueif enabling successful, otherwiseFalse.
11. Globally Disable Specified Component
async def globally_disable_component(component_name: str, component_type: ComponentType) -> bool:Globally disable specified component.
This function is asynchronous, ensure calling in asynchronous environment.
Args:
component_name(str): Component name.component_type(ComponentType): Component type.
Returns:
bool- ReturnsTrueif disabling successful, otherwiseFalse.
12. Locally Enable Specified Component
def locally_enable_component(component_name: str, component_type: ComponentType, stream_id: str) -> bool:Locally enable specified component.
Args:
component_name(str): Component name.component_type(ComponentType): Component type.stream_id(str): Message stream ID.
Returns:
bool- ReturnsTrueif enabling successful, otherwiseFalse.
13. Locally Disable Specified Component
def locally_disable_component(component_name: str, component_type: ComponentType, stream_id: str) -> bool:Locally disable specified component.
Args:
component_name(str): Component name.component_type(ComponentType): Component type.stream_id(str): Message stream ID.
Returns:
bool- ReturnsTrueif disabling successful, otherwiseFalse.
14. Get Locally Disabled Component List for Specified Message Stream
def get_locally_disabled_components(stream_id: str, component_type: ComponentType) -> list[str]:Get locally disabled component list for specified message stream.
Args:
stream_id(str): Message stream ID.component_type(ComponentType): Component type.
Returns:
list[str]- Disabled component name list.