aixplain.v2.integration
Integration module for managing external service integrations.
ActionInputsProxy Objects
class ActionInputsProxy()
Proxy object that provides both dict-like and dot notation access to action input parameters.
This proxy dynamically fetches action input specifications from the container resource when needed, allowing for runtime discovery and validation of action inputs.
__init__
def __init__(container, action_name: str)
Initialize ActionInputsProxy with container and action name.
__getitem__
def __getitem__(key: str)
Get input value by key.
__setitem__
def __setitem__(key: str, value)
Set input value by key.
__contains__
def __contains__(key: str) -> bool
Check if input parameter exists.
__len__
def __len__() -> int
Return the number of input parameters.
__iter__
def __iter__()
Iterate over input parameter keys.
__getattr__
def __getattr__(name: str)
Get input value by attribute name.
__setattr__
def __setattr__(name: str, value)
Set input value by attribute name.
get
def get(key: str, default=None)
Get input value with optional default.
update
def update(**kwargs)
Update multiple inputs at once.
keys
def keys()
Get input parameter codes.
values
def values()
Get input parameter values.
items
def items()
Get input parameter code-value pairs.
reset_input
def reset_input(input_code: str)
Reset an input parameter to its backend default value.
reset_all_inputs
def reset_all_inputs()
Reset all input parameters to their backend default values.
__repr__
def __repr__()
Return string representation of the proxy.
Input Objects
@dataclass_json
@dataclass
class Input()
Input parameter for an action.
Action Objects
@dataclass_json
@dataclass(repr=False)
class Action()
Container for tool action information and inputs.
__repr__
def __repr__() -> str
Return a string representation showing name and input parameters.
get_inputs_proxy
def get_inputs_proxy(container) -> ActionInputsProxy
Get an ActionInputsProxy for this action from a container.
Arguments:
container- The container resource (Tool or Integration) that can fetch action specs
Returns:
ActionInputsProxy- A proxy object for accessing action inputs
ToolId Objects
@dataclass_json
@dataclass
class ToolId()
Result for tool operations.
IntegrationResult Objects
@dataclass_json
@dataclass
class IntegrationResult(Result)
Result for connection operations.
The backend returns the connection ID in data.id.
IntegrationSearchParams Objects
class IntegrationSearchParams(BaseSearchParams)
Parameters for listing integrations.
ActionMixin Objects
class ActionMixin()
Mixin class providing action-related functionality for integrations and tools.
list_actions
def list_actions() -> List[Action]
List available actions for the integration.
list_inputs
def list_inputs(*actions: str) -> List[Action]
List available inputs for the integration.
actions
@cached_property
def actions()
Get a proxy object that provides access to actions with their inputs.
This enables the syntax: mytool.actions['ACTION_NAME'].channel = 'value'
Returns:
ActionsProxy- A proxy object for accessing actions and their inputs
set_inputs
def set_inputs(inputs_dict: Dict[str, Dict[str, Any]]) -> None
Set multiple action inputs in bulk using a dictionary tree structure.
This method allows you to set inputs for multiple actions at once. Action names are automatically converted to lowercase for consistent lookup.
Arguments:
inputs_dict- Dictionary in the format: {"ACTION_NAME"- {"input_param1"- "value1","input_param2"- "value2", ... },"ANOTHER_ACTION"- {"input_param1"- "value1", ... } }
Example:
tool.set_inputs({
'slack_send_message'- { # Will work regardless of case'channel'- 'general','text'- 'Hello from bulk set!','username'- 'MyBot' },'SLACK_SEND_MESSAGE'- { # Will also work'channel'- 'general','text'- 'Hello from bulk set!','username'- 'MyBot' },'uploadFile'- { # Will also work'channels'- 'general','file'- 'document.pdf' } })
Raises:
ValueError- If an action name is not found or invalidKeyError- If an input parameter is not found for an action
ActionsProxy Objects
class ActionsProxy()
Proxy object that provides access to actions with their inputs.
This enables the syntax: mytool.actions['ACTION_NAME'].channel = 'value'
__init__
def __init__(container)
Initialize ActionsProxy with container resource.
__getitem__
def __getitem__(action_name: str)
Get an action with its inputs proxy.
Converts action name to lowercase for consistent lookup.
__getattr__
def __getattr__(attr_name: str)
Get an action with its inputs proxy using attribute notation.
Converts attribute name to lowercase for consistent lookup.
__contains__
def __contains__(action_name: str) -> bool
Check if an action exists.
get_available_actions
def get_available_actions() -> List[str]
Get a list of available action names.
refresh_cache
def refresh_cache()
Clear the actions cache to force re-fetching.
Integration Objects
class Integration(Model, ActionMixin)
Resource for integrations.
Integrations are a subtype of models with Function.CONNECTOR. All connection logic is centralized here.
run
def run(**kwargs: Any) -> IntegrationResult
Run the integration with validation.
connect
def connect(**kwargs: Any) -> "Tool"
Connect the integration.
handle_run_response
def handle_run_response(response: dict, **kwargs: Any) -> IntegrationResult
Handle the response from the integration.