Skip to content

Class swarmauri_core.agent_apis.IAgentRouterCRUD.IAgentRouterCRUD

swarmauri_core.agent_apis.IAgentRouterCRUD.IAgentRouterCRUD

Bases: ABC

Interface for managing API routes within a SwarmAgent.

create_route abstractmethod

create_route(path, method, handler)

Create a new route for the API.

Parameters: - path (str): The URL path for the route. - method (str): The HTTP method (e.g., 'GET', 'POST'). - handler (Callable[[Any], Any]): The function that handles requests to this route.

Source code in swarmauri_core/agent_apis/IAgentRouterCRUD.py
10
11
12
13
14
15
16
17
18
19
20
21
22
@abstractmethod
def create_route(
    self, path: str, method: str, handler: Callable[[Any], Any]
) -> None:
    """
    Create a new route for the API.

    Parameters:
    - path (str): The URL path for the route.
    - method (str): The HTTP method (e.g., 'GET', 'POST').
    - handler (Callable[[Any], Any]): The function that handles requests to this route.
    """
    pass

read_route abstractmethod

read_route(path, method)

Retrieve information about a specific route.

Parameters: - path (str): The URL path for the route. - method (str): The HTTP method.

Returns: - Dict: Information about the route, including path, method, and handler.

Source code in swarmauri_core/agent_apis/IAgentRouterCRUD.py
24
25
26
27
28
29
30
31
32
33
34
35
36
@abstractmethod
def read_route(self, path: str, method: str) -> Dict:
    """
    Retrieve information about a specific route.

    Parameters:
    - path (str): The URL path for the route.
    - method (str): The HTTP method.

    Returns:
    - Dict: Information about the route, including path, method, and handler.
    """
    pass

update_route abstractmethod

update_route(path, method, new_handler)

Update the handler function for an existing route.

Parameters: - path (str): The URL path for the route. - method (str): The HTTP method. - new_handler (Callable[[Any], Any]): The new function that handles requests to this route.

Source code in swarmauri_core/agent_apis/IAgentRouterCRUD.py
38
39
40
41
42
43
44
45
46
47
48
49
50
@abstractmethod
def update_route(
    self, path: str, method: str, new_handler: Callable[[Any], Any]
) -> None:
    """
    Update the handler function for an existing route.

    Parameters:
    - path (str): The URL path for the route.
    - method (str): The HTTP method.
    - new_handler (Callable[[Any], Any]): The new function that handles requests to this route.
    """
    pass

delete_route abstractmethod

delete_route(path, method)

Delete a specific route from the API.

Parameters: - path (str): The URL path for the route. - method (str): The HTTP method.

Source code in swarmauri_core/agent_apis/IAgentRouterCRUD.py
52
53
54
55
56
57
58
59
60
61
@abstractmethod
def delete_route(self, path: str, method: str) -> None:
    """
    Delete a specific route from the API.

    Parameters:
    - path (str): The URL path for the route.
    - method (str): The HTTP method.
    """
    pass