Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add separate method for customer expected fields #721

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions python/composio/tools/toolset.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
ActionModel,
AppAuthScheme,
AppModel,
AuthSchemeField,
ConnectedAccountModel,
ConnectionParams,
ConnectionRequestModel,
Expand Down Expand Up @@ -978,7 +977,7 @@ def get_entity(self, id: t.Optional[str] = None) -> Entity:
"""Get entity object for given ID."""
return self.client.get_entity(id=id or self.entity_id)

def get_expected_params(
def get_auth_scheme_for_app(
self,
app: t.Optional[AppType] = None,
auth_scheme: t.Optional[
Expand All @@ -989,9 +988,9 @@ def get_expected_params(
"BASIC",
]
] = None,
) -> t.List[AuthSchemeField]:
) -> AppAuthScheme:
auth_schemes = {
scheme.auth_mode: scheme.fields
scheme.auth_mode: scheme
for scheme in self.client.apps.get(name=str(app)).auth_schemes or []
}

Expand Down Expand Up @@ -1019,6 +1018,35 @@ def get_expected_params(
)
)

def get_expected_params_for_user(
self,
app: t.Optional[AppType] = None,
integration_id: t.Optional[str] = None,
entity_id: t.Optional[str] = None,
) -> t.List[ExpectedFieldInput]:
if integration_id is None and app is None:
raise ComposioSDKError(
message="Both `integration_id` and `app` cannot be None"
)

if integration_id is None:
try:
integration_id = (
self.get_entity(id=entity_id or self.entity_id)
.get_connection(app=app)
.integrationId
)
except NoItemsFound as e:
raise ComposioSDKError(
message=(
f"No existing integration found for `{str(app)}`, "
"Please create an integration and use the ID to "
"initiate connection."
)
) from e

return self.get_integration(id=integration_id).expectedInputFields

def create_integration(
self,
app: AppType,
Expand Down
Loading