Composio server object collections

to_trigger_names

Get trigger names as a string.

Parameters

triggers
t.Union[t.List[str], t.List[Trigger], t.List[TriggerType]]Required

No description provided

Returns

returns
str

No description provided

References

1def to_trigger_names(
2 triggers: t.Union[t.List[str], t.List[Trigger], t.List[TriggerType]],
3) -> str:
4 """Get trigger names as a string."""
5 return ",".join([Trigger(trigger).slug for trigger in triggers])

class AuthConnectionParamsModel

Authentication connection parameters.

Properties

scope
t.Optional[str]

Class property

base_url
t.Optional[str]

Class property

client_id
t.Optional[str]

Class property

token_type
t.Optional[str]

Class property

access_token
t.Optional[str]

Class property

refresh_token
t.Optional[str]

Class property

client_secret
t.Optional[str]

Class property

consumer_id
t.Optional[str]

Class property

consumer_secret
t.Optional[str]

Class property

headers
t.Optional[dict]

Class property

queryParams
t.Optional[dict]

Class property


class ConnectedAccountModel

Connected account data model.

Properties

id
str

Class property

status
str

Class property

createdAt
str

Class property

updatedAt
str

Class property

appUniqueId
str

Class property

appName
str

Class property

integrationId
str

Class property

connectionParams
AuthConnectionParamsModel

Class property

clientUniqueUserId
t.Optional[str]

Class property

entityId
str

Class property

model_config
ConfigDict

Class property


class ConnectionRequestModel

Connection request model.

Properties

connectionStatus
str

Class property

connectedAccountId
str

Class property

redirectUrl
t.Optional[str]

Class property

Methods

def save_user_access_data

Save user access data.

Parameters

client
'Composio'Required

No description provided

field_inputs
t.DictRequired

No description provided

redirect_url
t.Optional[str]

No description provided

entity_id
t.Optional[str]

No description provided

Returns

returns
t.Dict

No description provided

1def save_user_access_data(self, client: 'Composio', field_inputs: t.Dict, redirect_url: t.Optional[str]=None, entity_id: t.Optional[str]=None) -> t.Dict:
2 """Save user access data."""
3 connected_account = client.connected_accounts.get(connection_id=self.connectedAccountId)
4 resp = client.http.post(url=str(v1 / 'connectedAccounts'), json={'integrationId': connected_account.integrationId, 'data': field_inputs, 'redirectUri': redirect_url, 'userUuid': entity_id})
5 return resp.json()

def wait_until_active

No description provided

Parameters

client
'Composio'Required

No description provided

timeout
floatDefaults to 60.0

No description provided

Returns

returns
'ConnectedAccountModel'

No description provided

1def wait_until_active(self, client: 'Composio', timeout: float=60.0) -> 'ConnectedAccountModel':
2 start_time = time.time()
3 while time.time() - start_time < timeout:
4 connection = client.connected_accounts.get(connection_id=self.connectedAccountId)
5 if connection.status == 'ACTIVE':
6 return connection
7 time.sleep(1)
8 raise SDKTimeoutError('Connection did not become active within the timeout period.')

class ConnectionAuthParam

No description provided

Properties

in_
str

Class property

name
str

Class property

value
str

Class property


class ConnectionParams

No description provided

Properties

body
t.Dict

Class property

base_url
str

Class property

parameters
t.List[ConnectionAuthParam]

Class property


class ConnectedAccounts

Collection of connected accounts.

Methods

def get

Get all connected accounts

Returns

returns
t.List[ConnectedAccountModel]

List of Connected accounts

1@t.overload
2def get(self) -> t.List[ConnectedAccountModel]:
3 """
4 Get all connected accounts
5
6 :return: List of Connected accounts
7 """

def get

Get an account by connection ID

Parameters

connection_id
strRequired

ID of the connection to filter by

Returns

returns
ConnectedAccountModel

Connected account

1@t.overload
2def get(self, connection_id: str) -> ConnectedAccountModel:
3 """
4 Get an account by connection ID
5
6 :param connection_id: ID of the connection to filter by
7 :return: Connected account
8 """

def get

Get a list of connected accounts by entity IDs

Returns

returns
t.List[ConnectedAccountModel]

List of connected accounts

1@t.overload
2def get(self, *, entity_ids: t.Optional[t.Sequence[str]]=None, active: bool=False) -> t.List[ConnectedAccountModel]:
3 """
4 Get a list of connected accounts by entity IDs
5
6 :param entity_ids: List of entity IDs to filter by
7 :param active: Returns account which are currently active
8 :return: List of connected accounts
9 """

def get

Get a list of connected accounts.

Parameters

connection_id
t.Optional[str]

Return the connected account by a specific

Returns

returns
t.Union[ConnectedAccountModel, t.List[ConnectedAccountModel]]

List of connected accounts

1def get(self, connection_id: t.Optional[str]=None, *, entity_ids: t.Optional[t.Sequence[str]]=None, active: bool=False) -> t.Union[ConnectedAccountModel, t.List[ConnectedAccountModel]]:
2 """
3 Get a list of connected accounts.
4
5 :param entity_ids: List of entity IDs to filter by
6 :param connection_id: Return the connected account by a specific
7 connection ID
8 :param active: Returns account which are currently active
9 :return: List of connected accounts
10 """
11 entity_ids = entity_ids or ()
12 if connection_id is not None and len(entity_ids) > 0:
13 raise InvalidParams(message='Cannot use both `connection_id` and `entity_ids` parameters as filter')
14 if connection_id is not None:
15 response = self._raise_if_required(self.client.http.get(url=str(self.endpoint / connection_id)))
16 return self.model(**response.json())
17 queries = {'pageSize': '99999999'}
18 if len(entity_ids) > 0:
19 queries['user_uuid'] = ','.join(entity_ids)
20 if active:
21 queries['showActiveOnly'] = 'true'
22 response = self._raise_if_required(self.client.http.get(url=str(self.endpoint(queries=queries))))
23 return [self.model(**account) for account in response.json().get('items', [])]

def initiate

Initiate a new connected account.

Parameters

integration_id
strRequired

No description provided

entity_id
t.Optional[str]

No description provided

params
t.Optional[t.Dict]

No description provided

labels
t.Optional[t.List]

No description provided

redirect_url
t.Optional[str]

No description provided

Returns

returns
ConnectionRequestModel

No description provided

1def initiate(self, integration_id: str, entity_id: t.Optional[str]=None, params: t.Optional[t.Dict]=None, labels: t.Optional[t.List]=None, redirect_url: t.Optional[str]=None) -> ConnectionRequestModel:
2 """Initiate a new connected account."""
3 response = self._raise_if_required(response=self.client.http.post(url=str(self.endpoint), json={'integrationId': integration_id, 'userUuid': entity_id, 'data': params or {}, 'labels': labels or [], 'redirectUri': redirect_url}))
4 return ConnectionRequestModel(**response.json())

def info

No description provided

Parameters

connection_id
strRequired

No description provided

Returns

returns
ConnectionParams

No description provided

1def info(self, connection_id: str) -> ConnectionParams:
2 response = self._raise_if_required(self.client.http.get(url=str(self.endpoint / connection_id / 'info')))
3 return ConnectionParams(**response.json())

class AuthSchemeField

Auth scheme field.

Properties

name
str

Class property

display_name
t.Optional[str]

Class property

description
str

Class property

type
str

Class property

default
t.Optional[str]

Class property

required
bool

Class property

expected_from_customer
bool

Class property

get_current_user_endpoint
t.Optional[str]

Class property


class AppAuthScheme

App authenticatio scheme.

Properties

scheme_name
str

Class property

auth_mode
AuthSchemeType

Class property

fields
t.List[AuthSchemeField]

Class property

proxy
t.Optional[t.Dict]

Class property

authorization_url
t.Optional[str]

Class property

token_url
t.Optional[str]

Class property

default_scopes
t.Optional[t.List]

Class property

token_response_metadata
t.Optional[t.List]

Class property

client_id
t.Optional[str]

Class property

client_secret
t.Optional[str]

Class property


class AppModel

App data model.

Properties

name
str

Class property

key
str

Class property

appId
str

Class property

description
str

Class property

categories
t.List[str]

Class property

meta
t.Dict

Class property

logo
t.Optional[str]

Class property

docs
t.Optional[str]

Class property

group
t.Optional[str]

Class property

status
t.Optional[str]

Class property

enabled
bool

Class property

no_auth
bool

Class property

auth_schemes
t.Optional[t.List[AppAuthScheme]]

Class property

testConnectors
t.Optional[t.List[t.Dict[str, t.Any]]]

Class property

documentation_doc_text
t.Optional[str]

Class property

configuration_docs_text
t.Optional[str]

Class property


class Apps

Collection of composio apps..

Methods

def get

Get available apps.

Returns

returns
t.List[AppModel]

No description provided

1@t.overload
2def get(self) -> t.List[AppModel]:
3 """Get available apps."""

def get

Get a specific app.

Parameters

name
t.Optional[str]

No description provided

Returns

returns
AppModel

No description provided

1@t.overload
2def get(self, name: t.Optional[str]=None) -> AppModel:
3 """Get a specific app."""

def get

Get apps.

Parameters

name
t.Optional[str]

No description provided

Returns

returns
t.Union[AppModel, t.List[AppModel]]

No description provided

1def get(self, name: t.Optional[str]=None) -> t.Union[AppModel, t.List[AppModel]]:
2 """Get apps."""
3 if name is not None:
4 return self.model(**self._raise_if_required(response=self.client.http.get(url=str(self.endpoint / name))).json())
5 return super().get(queries={})

class TypeModel

No description provided

Properties

type
str

Class property


class TriggerPayloadPropertyModel

Trigger payload property data model.

Properties

description
str

Class property

title
t.Optional[str]

Class property

type
t.Optional[str]

Class property

anyOf
t.Optional[t.List[TypeModel]]

Class property

examples
t.Optional[t.List]

Class property


class TriggerPayloadModel

Trigger payload data model.

Properties

properties
t.Dict[str, TriggerPayloadPropertyModel]

Class property

title
t.Optional[str]

Class property

type
t.Optional[str]

Class property

anyOf
t.Optional[t.List[TypeModel]]

Class property

required
t.Optional[t.List[str]]

Class property


class TriggerConfigPropertyModel

Trigger config property data model.

Properties

description
str

Class property

title
str

Class property

default
t.Any

Class property

type
t.Optional[str]

Class property


class TriggerConfigModel

Trigger config data model.

Properties

properties
t.Dict[str, TriggerConfigPropertyModel]

Class property

title
str

Class property

type
t.Optional[str]

Class property

required
t.Optional[t.List[str]]

Class property


class CallbackModel

Trigger callback model.


class CallbackCollection

Callback collection for triggers.

Methods

def set

Set callback URL.

Parameters

url
strRequired

No description provided

Returns

returns
CallbackModel

No description provided

1def set(self, url: str) -> CallbackModel:
2 """Set callback URL."""
3 response = self._raise_if_required(response=self.client.http.post(url=str(self.endpoint / 'setCallbackURL'), json={'callbackURL': url}))
4 return response.json()

def get

Get current callback URL.

Returns

returns
str

No description provided

1def get(self) -> str:
2 """Get current callback URL."""
3 response = self._raise_if_required(response=self.client.http.get(url=str(self.endpoint / 'callback_url')))
4 return response.json().get('callbackURL')

class TriggerModel

Trigger data model.

Properties

name
str

Class property

display_name
str

Class property

description
str

Class property

payload
TriggerPayloadModel

Class property

config
TriggerConfigModel

Class property

instructions
str

Class property

appId
str

Class property

appKey
str

Class property

appName
str

Class property

count
int

Class property

enabled
bool

Class property

logo
t.Optional[str]

Class property


class SuccessExecuteActionResponseModel

Success execute action response data model.

Properties

successfull
bool

Class property

data
t.Dict

Class property

error
t.Optional[str]

Class property


class FileType

No description provided

Properties

name
str

Class property

content
str

Class property


class Connection

No description provided

Properties

id
str

Class property

integrationId
str

Class property

clientUniqueUserId
str

Class property

status
str

Class property


class Metadata

No description provided

Properties

id
str

Class property

connectionId
str

Class property

triggerName
str

Class property

triggerData
str

Class property

triggerConfig
t.Dict[str, t.Any]

Class property

connection
Connection

Class property


class TriggerEventData

Trigger event payload.

Properties

appName
str

Class property

payload
dict

Class property

originalPayload
t.Dict[str, t.Any]

Class property

metadata
Metadata

Class property

clientId
t.Optional[int]

Class property


class TriggerSubscription

Trigger subscription.

Properties

_pusher
pysher.Pusher

Class property

_channel
PusherChannel

Class property

_connection
PusherConnection

Class property

_alive
bool

Class property

Methods

def validate_filters

No description provided

Parameters

filters
_TriggerEventFiltersRequired

No description provided

1def validate_filters(self, filters: _TriggerEventFilters):
2 docs_link_msg = '\nRead more here: https://docs.composio.dev/introduction/intro/quickstart_3'
3 if not isinstance(filters, dict):
4 raise InvalidParams('Expected filters to be a dictionary' + docs_link_msg)
5 expected_filters = list(_TriggerEventFilters.__annotations__)
6 for filter, value in filters.items():
7 if filter not in expected_filters:
8 error_msg = f'Unexpected filter {filter!r}'
9 possible_values = difflib.get_close_matches(filter, expected_filters, n=1)
10 if possible_values:
11 possible_value, = possible_values
12 error_msg += f' Did you mean {possible_value!r}?'
13 raise InvalidTriggerFilters(error_msg + docs_link_msg)
14 if filter == 'app_name':
15 if isinstance(value, App):
16 slug = value.slug
17 elif isinstance(value, str):
18 slug = value
19 else:
20 raise InvalidTriggerFilters(f"Expected 'app_name' to be App or str, found {value!r}" + docs_link_msg)
21 slug = slug.upper()
22 app_names = list(App.iter())
23 if slug not in app_names:
24 error_msg = f'App {slug!r} does not exist.'
25 possible_values = difflib.get_close_matches(slug, app_names, n=1)
26 if possible_values:
27 possible_value, = possible_values
28 error_msg += f' Did you mean {possible_value!r}?'
29 raise InvalidTriggerFilters(error_msg + docs_link_msg)
30 active_triggers = [trigger.triggerName for trigger in self.client.active_triggers.get()]
31 apps_for_triggers = {Trigger(trigger).app.upper() for trigger in active_triggers}
32 if slug not in apps_for_triggers:
33 error_msg = f'App {slug!r} has no triggers enabled on your account.\nFind the possible triggers by running `composio triggers`.'
34 raise InvalidTriggerFilters(error_msg + docs_link_msg)
35 if filter == 'trigger_name':
36 if isinstance(value, Trigger):
37 slug = value.slug
38 elif isinstance(value, str):
39 slug = value
40 else:
41 raise InvalidTriggerFilters(f"Expected 'trigger_name' to be Trigger or str, found {value!r}" + docs_link_msg)
42 slug = slug.upper()
43 trigger_names = list(Trigger.iter())
44 if slug not in trigger_names:
45 error_msg = f'Trigger {slug!r} does not exist.'
46 possible_values = difflib.get_close_matches(slug, trigger_names, n=1)
47 if possible_values:
48 possible_value, = possible_values
49 error_msg += f' Did you mean {possible_value!r}?'
50 raise InvalidTriggerFilters(error_msg + docs_link_msg)
51 active_triggers = [trigger.triggerName for trigger in self.client.active_triggers.get()]
52 if slug not in active_triggers:
53 error_msg = f'Trigger {slug!r} is not enabled on your account.\nEnable the trigger by doing `composio triggers enable {slug}`.'
54 raise InvalidTriggerFilters(error_msg + docs_link_msg)

def callback

Register a trigger callaback.

Parameters

filters
t.Optional[_TriggerEventFilters]

No description provided

Returns

returns
t.Callable[[TriggerCallback], TriggerCallback]

No description provided

1def callback(self, filters: t.Optional[_TriggerEventFilters]=None) -> t.Callable[[TriggerCallback], TriggerCallback]:
2 """Register a trigger callaback."""
3 if filters is not None:
4 self.validate_filters(filters)
5
6 def _wrap(f: TriggerCallback) -> TriggerCallback:
7 self._callbacks.append((f, filters or {}))
8 return f
9 return _wrap

def handle_event

Filter events and call the callback function.

Parameters

event
strRequired

No description provided

1def handle_event(self, event: str) -> None:
2 """Filter events and call the callback function."""
3 data = self._parse_payload(event=event)
4 if data is None:
5 self.logger.error(f'Error parsing trigger payload: {event}')
6 return
7 self.logger.debug(f'Received trigger event with trigger ID: {data.metadata.id} and trigger name: {data.metadata.triggerName}')
8 awaitables: t.List[Future] = []
9 with ThreadPoolExecutor() as executor:
10 for callback, filters in self._callbacks:
11 awaitables.append(executor.submit(self._handle_callback, callback, data, filters))
12 _ = [future.result() for future in awaitables]

def handle_chunked_events

Handle chunked events.

Parameters

event
strRequired

No description provided

1def handle_chunked_events(self, event: str) -> None:
2 """Handle chunked events."""
3 data = _ChunkedTriggerEventData(**json.loads(event))
4 if data.id not in self._chunks:
5 self._chunks[data.id] = {}
6 self._chunks[data.id][data.index] = data.chunk
7 if data.final:
8 _chunks = self._chunks.pop(data.id)
9 self.handle_event(event=''.join([_chunks[idx] for idx in sorted(_chunks)]))

def is_alive

Check if subscription is live.

Returns

returns
bool

No description provided

1def is_alive(self) -> bool:
2 """Check if subscription is live."""
3 return self._alive

def has_errored

Check if the connection errored and disconnected.

Returns

returns
bool

No description provided

1def has_errored(self) -> bool:
2 """Check if the connection errored and disconnected."""
3 return self._connection.socket is None or self._connection.socket.has_errored

def set_alive

Set _alive to True.

1def set_alive(self) -> None:
2 """Set `_alive` to True."""
3 self._alive = True

def listen

Wait infinitely.

1@te.deprecated('Use `wait_forever` instead')
2def listen(self) -> None:
3 """Wait infinitely."""
4 self.wait_forever()

def wait_forever

Wait infinitely.

1def wait_forever(self) -> None:
2 """Wait infinitely."""
3 while self.is_alive() and (not self.has_errored()):
4 time.sleep(1)

def stop

Stop the trigger listener.

1def stop(self) -> None:
2 """Stop the trigger listener."""
3 self._connection.disconnect()
4 self._alive = False

def restart

Restart the subscription connection

1def restart(self) -> None:
2 """Restart the subscription connection"""
3 self._connection.disconnect()
4 self._connection._connect()

class Triggers

Collection of triggers.

Properties

callbacks
CallbackCollection

Class property

Methods

def get

List active triggers

Parameters

trigger_names
t.Optional[t.List[TriggerType]]

Trigger names to filter by, can be a list of strings or Trigger objects

apps
t.Optional[t.List[str]]

No description provided

Returns

returns
t.List[TriggerModel]

List of triggers filtered by provided parameters

1def get(self, trigger_names: t.Optional[t.List[TriggerType]]=None, apps: t.Optional[t.List[str]]=None) -> t.List[TriggerModel]:
2 """
3 List active triggers
4
5 :param trigger_names: Trigger names to filter by, can be a list of strings or Trigger objects
6 :param app_names: App names to filter by
7 :return: List of triggers filtered by provided parameters
8 """
9 queries = {}
10 if trigger_names is not None and len(trigger_names) > 0:
11 queries['triggerIds'] = to_trigger_names(trigger_names)
12 if apps is not None and len(apps) > 0:
13 queries['appNames'] = ','.join(apps)
14 return super().get(queries=queries)

def enable

Enable a trigger

Parameters

name
strRequired

Name of the trigger

connected_account_id
strRequired

ID of the relevant connected account

config
t.Dict[str, t.Any]Required

No description provided

Returns

returns
t.Dict

No description provided

1def enable(self, name: str, connected_account_id: str, config: t.Dict[str, t.Any]) -> t.Dict:
2 """
3 Enable a trigger
4
5 :param name: Name of the trigger
6 :param connected_account_id: ID of the relevant connected account
7 """
8 response = self._raise_if_required(self.client.http.post(url=str(self.endpoint.enable / connected_account_id / name), json={'triggerConfig': config}))
9 return response.json()

def disable

Disable a trigger

Parameters

id
strRequired

No description provided

Returns

returns
t.Dict

No description provided

1def disable(self, id: str) -> t.Dict:
2 """
3 Disable a trigger
4
5 :param name: Name of the trigger
6 :param connected_account_id: ID of the relevant connected account
7 """
8 response = self._raise_if_required(self.client.http.patch(url=str(self.endpoint / 'instance' / id / 'status'), json={'enabled': False}))
9 return response.json()

def delete

Delete a trigger

Parameters

id
strRequired

ID of the trigger to be deleted

Returns

returns
t.Dict

No description provided

1def delete(self, id: str) -> t.Dict:
2 """
3 Delete a trigger
4
5 :param id: ID of the trigger to be deleted
6 """
7 response = self._raise_if_required(self.client.http.delete(url=str(self.endpoint / 'instance' / id)))
8 return response.json()

def subscribe

Subscribe to a trigger and receive trigger events.

Parameters

timeout
floatDefaults to 15.0

No description provided

Returns

returns
TriggerSubscription

No description provided

1def subscribe(self, timeout: float=15.0) -> TriggerSubscription:
2 """Subscribe to a trigger and receive trigger events."""
3 self.logger.debug('Creating trigger subscription')
4 response = self._raise_if_required(response=self.client.http.get(url='/v1/client/auth/client_info'))
5 client_id = response.json().get('client', {}).get('id')
6 if client_id is None:
7 raise TriggerSubscriptionError('Error fetching client ID')
8 pusher = _PusherClient(client_id=client_id, client=self.client)
9 return pusher.connect(timeout=timeout)

class ActiveTriggerModel

Active trigger data model.

Properties

id
str

Class property

connectionId
str

Class property

triggerName
str

Class property

triggerConfig
dict

Class property


class ActiveTriggers

Collection of active triggers.

Methods

def get

List active triggers.

Parameters

trigger_ids
t.Optional[t.List[str]]

No description provided

connected_account_ids
t.Optional[t.List[str]]

No description provided

integration_ids
t.Optional[t.List[str]]

No description provided

trigger_names
t.Optional[t.List[t.Union[str, Trigger]]]

No description provided

Returns

returns
t.List[ActiveTriggerModel]

No description provided

1def get(self, trigger_ids: t.Optional[t.List[str]]=None, connected_account_ids: t.Optional[t.List[str]]=None, integration_ids: t.Optional[t.List[str]]=None, trigger_names: t.Optional[t.List[t.Union[str, Trigger]]]=None) -> t.List[ActiveTriggerModel]:
2 """List active triggers."""
3 trigger_ids = trigger_ids or []
4 connected_account_ids = connected_account_ids or []
5 integration_ids = integration_ids or []
6 trigger_names = trigger_names or []
7 queries = {}
8 if len(trigger_ids) > 0:
9 queries['triggerIds'] = ','.join(trigger_ids)
10 if len(connected_account_ids) > 0:
11 queries['connectedAccountIds'] = ','.join(connected_account_ids)
12 if len(integration_ids) > 0:
13 queries['integrationIds'] = ','.join(integration_ids)
14 if len(trigger_names) > 0:
15 queries['triggerNames'] = to_trigger_names(trigger_names)
16 return super().get(queries=queries)

class OpenAPISchema

No description provided

Properties

properties
t.Dict[str, t.Any]

Class property

title
str

Class property

type
str

Class property

required
t.Optional[t.List[str]]

Class property

examples
t.Optional[t.List[t.Any]]

Class property


class ActionParametersModel

Action parameter data models.


class ActionResponseModel

Action response data model.


class ActionModel

Action data model.

Properties

name
str

Class property

description
str

Class property

parameters
ActionParametersModel

Class property

response
ActionResponseModel

Class property

appName
str

Class property

appId
str

Class property

version
str

Class property

available_versions
t.List[str]

Class property

tags
t.List[str]

Class property

logo
t.Optional[str]

Class property

display_name
t.Optional[str]

Class property

enabled
bool

Class property


class CustomAuthParameter

No description provided

Properties

in_
ParamPlacement

Class property

name
str

Class property

value
str

Class property


class CustomAuthObject

No description provided

Properties

body
t.Dict

Class property

base_url
t.Optional[str]

Class property

parameters
t.List[CustomAuthParameter]

Class property


class SearchResultTask

No description provided

Properties

app
str

Class property

actions
list[str]

Class property

description
str

Class property

order
int

Class property


class CreateUploadURLResponse

No description provided

Properties

id
str

Class property

url
str

Class property

key
str

Class property

exists
bool

Class property


class Actions

Collection of composio actions..

Methods

def get

No description provided

Returns

returns
t.List[ActionModel]

No description provided

1@t.overload
2def get(self) -> t.List[ActionModel]:
3 ...

def get

No description provided

Parameters

action
t.Optional[ActionType]

No description provided

Returns

returns
ActionModel

No description provided

1@t.overload
2def get(self, action: t.Optional[ActionType]=None) -> ActionModel:
3 ...

def get

No description provided

Parameters

actions
t.Optional[t.Sequence[ActionType]]

No description provided

apps
t.Optional[t.Sequence[AppType]]

No description provided

tags
t.Optional[t.Sequence[TagType]]

No description provided

limit
t.Optional[int]

No description provided

use_case
t.Optional[str]

No description provided

allow_all
boolDefaults to False

No description provided

Returns

returns
t.List[ActionModel]

No description provided

1@t.overload
2def get(self, actions: t.Optional[t.Sequence[ActionType]]=None, apps: t.Optional[t.Sequence[AppType]]=None, tags: t.Optional[t.Sequence[TagType]]=None, limit: t.Optional[int]=None, use_case: t.Optional[str]=None, allow_all: bool=False) -> t.List[ActionModel]:
3 ...

def get

Get a list of apps by the specified filters.

Parameters

action
t.Optional[ActionType]

Get data for this action.

Returns

returns
t.Union[ActionModel, t.List[ActionModel]]

List of actions

1def get(self, action: t.Optional[ActionType]=None, *, actions: t.Optional[t.Sequence[ActionType]]=None, apps: t.Optional[t.Sequence[AppType]]=None, tags: t.Optional[t.Sequence[TagType]]=None, limit: t.Optional[int]=None, use_case: t.Optional[str]=None, allow_all: bool=False) -> t.Union[ActionModel, t.List[ActionModel]]:
2 """
3 Get a list of apps by the specified filters.
4
5 :param actions: Filter by the list of Actions.
6 :param action: Get data for this action.
7 :param apps: Filter by the list of Apps.
8 :param tags: Filter by the list of given Tags.
9 :param limit: Limit the number of actions to a specific number.
10 :param use_case: Filter by use case.
11 :param allow_all: Allow querying all of the actions for a specific
12 app
13 :return: List of actions
14 """
15 if action is not None:
16 return self._get_action(action=action)
17 return self._get_actions(actions=actions, apps=apps, tags=tags, limit=limit, use_case=use_case, allow_all=allow_all)

def execute

Execute an action on the specified entity with optional connected account.

Parameters

action
ActionRequired

The Action object to be executed.

params
t.DictRequired

A dictionary of parameters to be passed to the action.

entity_id
strDefaults to 'default'

The unique identifier of the entity on which the action is executed.

connected_account
t.Optional[str]

Optional connected account ID if required for the action.

session_id
t.Optional[str]

ID of the current workspace session

text
t.Optional[str]

No description provided

auth
t.Optional[CustomAuthObject]

No description provided

allow_tracing
boolDefaults to False

No description provided

Returns

returns
t.Dict

A dictionary containing the response from the executed action.

1def execute(self, action: Action, params: t.Dict, entity_id: str='default', connected_account: t.Optional[str]=None, session_id: t.Optional[str]=None, text: t.Optional[str]=None, auth: t.Optional[CustomAuthObject]=None, allow_tracing: bool=False) -> t.Dict:
2 """
3 Execute an action on the specified entity with optional connected account.
4
5 :param action: The Action object to be executed.
6 :param params: A dictionary of parameters to be passed to the action.
7 :param entity_id: The unique identifier of the entity on which the action is executed.
8 :param connected_account: Optional connected account ID if required for the action.
9 :param session_id: ID of the current workspace session
10 :return: A dictionary containing the response from the executed action.
11 """
12 if action.no_auth:
13 return self._raise_if_required(self.client.long_timeout_http.post(url=str(self.endpoint / action.slug / 'execute'), json={'appName': action.app, 'input': params, 'text': text, 'version': action.version, 'sessionInfo': {'sessionId': session_id}, 'allowTracing': allow_tracing})).json()
14 if connected_account is None and auth is None:
15 raise InvalidParams('`connected_account` cannot be `None` when executing an app which requires authentication')
16 return self._raise_if_required(self.client.long_timeout_http.post(url=str(self.endpoint / action.slug / 'execute'), json={'connectedAccountId': connected_account, 'entityId': entity_id, 'appName': action.app, 'input': params, 'text': text, 'version': action.version, 'authConfig': self._serialize_auth(auth=auth), 'sessionInfo': {'sessionId': session_id}, 'allowTracing': allow_tracing})).json()

def request

No description provided

Parameters

connection_id
strRequired

No description provided

endpoint
strRequired

No description provided

method
strRequired

No description provided

body
t.Optional[t.Dict]

No description provided

parameters
t.Optional[t.List[CustomAuthParameter]]

No description provided

Returns

returns
t.Dict

No description provided

1def request(self, connection_id: str, endpoint: str, method: str, body: t.Optional[t.Dict]=None, parameters: t.Optional[t.List[CustomAuthParameter]]=None) -> t.Dict:
2 return self.client.http.post(url=str(self.endpoint / 'proxy'), json={'connectedAccountId': connection_id, 'body': body, 'method': method.upper(), 'endpoint': endpoint, 'parameters': [{'in': param['in_'], 'name': param['name'], 'value': param['value']} for param in parameters or []]}).json()

def search_for_a_task

No description provided

Parameters

use_case
strRequired

No description provided

limit
t.Optional[int]

No description provided

min_actions_per_task
t.Optional[int]

No description provided

max_actions_per_task
t.Optional[int]

No description provided

apps
t.Optional[t.List[str]]

No description provided

Returns

returns
t.List[SearchResultTask]

No description provided

1def search_for_a_task(self, use_case: str, limit: t.Optional[int]=None, min_actions_per_task: t.Optional[int]=None, max_actions_per_task: t.Optional[int]=None, apps: t.Optional[t.List[str]]=None) -> t.List[SearchResultTask]:
2 params: t.Dict[str, t.Any] = {'useCase': use_case}
3 if limit is not None:
4 params['limit'] = limit
5 if min_actions_per_task is not None:
6 params['minActionsPerTask'] = min_actions_per_task
7 if max_actions_per_task is not None:
8 params['maxActionsPerTask'] = max_actions_per_task
9 if apps is not None:
10 params['apps'] = ','.join(apps)
11 response = self._raise_if_required(response=self.client.http.get(str(self.endpoint / 'search' / 'advanced'), params=params))
12 return [SearchResultTask.model_validate(task) for task in response.json().get('items', [])]

def create_file_upload

No description provided

Parameters

app
strRequired

No description provided

action
strRequired

No description provided

filename
strRequired

No description provided

mimetype
strRequired

No description provided

md5
strRequired

No description provided

Returns

returns
CreateUploadURLResponse

No description provided

1def create_file_upload(self, app: str, action: str, filename: str, mimetype: str, md5: str) -> CreateUploadURLResponse:
2 return CreateUploadURLResponse(**self._raise_if_required(response=self.client.http.post(url=str(self.endpoint / 'files' / 'upload' / 'request'), json={'md5': md5, 'app': app, 'action': action, 'filename': filename, 'mimetype': mimetype})).json())

class ExpectedFieldInput

No description provided

Properties

name
str

Class property

type
str

Class property

description
str

Class property

displayName
str

Class property

is_secret
bool

Class property

required
bool

Class property

expected_from_customer
bool

Class property

default
t.Optional[str]

Class property

get_current_user_endpoint
t.Optional[str]

Class property


class IntegrationModel

Integration data model.

Properties

id
str

Class property

name
str

Class property

authScheme
str

Class property

createdAt
str

Class property

updatedAt
str

Class property

enabled
bool

Class property

deleted
bool

Class property

appId
str

Class property

appName
str

Class property

expectedInputFields
t.List[ExpectedFieldInput]

Class property

_count
t.Dict

Class property

logo
t.Optional[str]

Class property

defaultConnectorId
t.Optional[str]

Class property

connections
t.Optional[t.List[t.Dict]]

Class property


class Integrations

Collection of composio integrations.

Methods

def create

Create a new integration

Parameters

app_id
strRequired

App ID string.

name
t.Optional[str]

Name of the integration.

auth_mode
t.Optional['AuthSchemeType']

No description provided

auth_config
t.Optional[t.Dict[str, t.Any]]

Authentication configuration.

use_composio_auth
boolDefaults to False

Whether to use default composio auth or not

force_new_integration
boolDefaults to False

No description provided

Returns

returns
IntegrationModel

Integration model created by the request.

1def create(self, app_id: str, name: t.Optional[str]=None, auth_mode: t.Optional['AuthSchemeType']=None, auth_config: t.Optional[t.Dict[str, t.Any]]=None, use_composio_auth: bool=False, force_new_integration: bool=False) -> IntegrationModel:
2 """
3 Create a new integration
4
5 :param app_id: App ID string.
6 :param name: Name of the integration.
7 :param auth_param: Auth mode string.
8 :param auth_config: Authentication configuration.
9 :param use_composio_auth: Whether to use default composio auth or not
10 :return: Integration model created by the request.
11 """
12 request = {'appId': app_id, 'useComposioAuth': use_composio_auth}
13 if name is not None:
14 request['name'] = name
15 if auth_mode is not None:
16 request['authScheme'] = auth_mode
17 if auth_config is not None:
18 request['authConfig'] = auth_config or {}
19 if force_new_integration:
20 request['forceNewIntegration'] = force_new_integration
21 response = self._raise_if_required(response=self.client.http.post(url=str(self.endpoint), json=request))
22 return IntegrationModel(**response.json())

def remove

No description provided

Parameters

id
strRequired

No description provided

1def remove(self, id: str) -> None:
2 self.client.http.delete(url=str(self.endpoint / id))

def get

No description provided

Returns

returns
t.List[IntegrationModel]

No description provided

1@t.overload
2def get(self, *, page_size: t.Optional[int]=None, page: t.Optional[int]=None, app_id: t.Optional[str]=None, app_name: t.Optional[str]=None, show_disabled: t.Optional[bool]=None) -> t.List[IntegrationModel]:
3 ...

def get

No description provided

Parameters

id
t.Optional[str]

No description provided

Returns

returns
IntegrationModel

No description provided

1@t.overload
2def get(self, id: t.Optional[str]=None) -> IntegrationModel:
3 ...

def get

No description provided

Parameters

id
t.Optional[str]

No description provided

Returns

returns
t.Union[t.List[IntegrationModel], IntegrationModel]

No description provided

1def get(self, id: t.Optional[str]=None, *, page_size: t.Optional[int]=None, page: t.Optional[int]=None, app_id: t.Optional[str]=None, app_name: t.Optional[str]=None, show_disabled: t.Optional[bool]=None) -> t.Union[t.List[IntegrationModel], IntegrationModel]:
2 if id is not None:
3 return IntegrationModel(**self._raise_if_required(self.client.http.get(url=str(self.endpoint / id))).json())
4 quries = {}
5 if page_size is not None:
6 quries['pageSize'] = json.dumps(page_size)
7 if page is not None:
8 quries['page'] = json.dumps(page)
9 if app_id is not None:
10 quries['appId'] = app_id
11 if app_name is not None:
12 quries['appName'] = app_name
13 if show_disabled is not None:
14 quries['showDisabled'] = json.dumps(show_disabled)
15 return super().get(queries=quries)

def get_by_id

Get an integration by its ID.

Parameters

integration_id
strRequired

Integration ID string.

Returns

returns
IntegrationModel

Integration model.

1@te.deprecated('`get_id` is deprecated, use `get(id=id)`')
2def get_by_id(self, integration_id: str) -> IntegrationModel:
3 """
4 Get an integration by its ID.
5
6 :param integration_id: Integration ID string.
7 :return: Integration model.
8 """
9 response = self._raise_if_required(self.client.http.get(url=str(self.endpoint / integration_id)))
10 return IntegrationModel(**response.json())

class LogRecord

No description provided


class Logs

Logs endpoint.

Methods

def push

Push logs to composio.

Parameters

record
t.DictRequired

No description provided

1def push(self, record: t.Dict) -> None:
2 """Push logs to composio."""
3 if self.client._api_key is None:
4 return
5 self.client.http.post(url=str(self.endpoint), json=record)