diff --git a/backend/migrations/20250128201251_teams_workspace_command_script.down.sql b/backend/migrations/20250128201251_teams_workspace_command_script.down.sql new file mode 100644 index 0000000000..ab1cb53a17 --- /dev/null +++ b/backend/migrations/20250128201251_teams_workspace_command_script.down.sql @@ -0,0 +1,2 @@ +ALTER TABLE workspace_settings DROP COLUMN teams_command_script; +ALTER TABLE workspace_settings DROP COLUMN teams_team_id; \ No newline at end of file diff --git a/backend/migrations/20250128201251_teams_workspace_command_script.up.sql b/backend/migrations/20250128201251_teams_workspace_command_script.up.sql new file mode 100644 index 0000000000..d142315f3e --- /dev/null +++ b/backend/migrations/20250128201251_teams_workspace_command_script.up.sql @@ -0,0 +1,2 @@ +ALTER TABLE workspace_settings ADD COLUMN teams_command_script TEXT DEFAULT NULL; +ALTER TABLE workspace_settings ADD COLUMN teams_team_id TEXT DEFAULT NULL; diff --git a/backend/windmill-api/openapi.yaml b/backend/windmill-api/openapi.yaml index d975b2239a..a168c7dcc0 100644 --- a/backend/windmill-api/openapi.yaml +++ b/backend/windmill-api/openapi.yaml @@ -3278,6 +3278,37 @@ paths: items: $ref: '#/components/schemas/TeamInfo' + /teams/activities: + post: + summary: send update to Microsoft Teams activity + description: Respond to a Microsoft Teams activity after a workspace command is run + operationId: updateActivity + tags: + - teams + requestBody: + required: true + content: + application/json: + schema: + type: object + required: + - activity_id + - text + properties: + activity_id: + type: string + description: The ID of the Teams conversation/activity + success: + type: boolean + description: Indicates if the activity was successful and used for styling the card conditionally + default: true + text: + type: string + description: The message text to be sent in the Teams card + responses: + '200': + description: Activity processed successfully + /w/{workspace}/resources/create: post: summary: create resource diff --git a/backend/windmill-api/src/workspaces.rs b/backend/windmill-api/src/workspaces.rs index 3758f5def4..95149799c4 100644 --- a/backend/windmill-api/src/workspaces.rs +++ b/backend/windmill-api/src/workspaces.rs @@ -166,8 +166,10 @@ struct Workspace { pub struct WorkspaceSettings { pub workspace_id: String, pub slack_team_id: Option, + pub teams_team_id: Option, pub slack_name: Option, pub slack_command_script: Option, + pub teams_command_script: Option, pub slack_email: String, pub auto_invite_domain: Option, pub auto_invite_operator: Option, diff --git a/python-client/wmill/wmill/client.py b/python-client/wmill/wmill/client.py index 738ede1bbe..cce02548e5 100644 --- a/python-client/wmill/wmill/client.py +++ b/python-client/wmill/wmill/client.py @@ -708,6 +708,13 @@ class Windmill: Indeed, in the viewer context WM_USERNAME is set to the username of the viewer but WM_EMAIL is set to the email of the creator of the app. """ return self.get(f"/w/{self.workspace}/users/username_to_email/{username}").text + + + def update_teams_activity(self, activity_id: str, text: str, success: bool = True): + """ + Send an update to a Microsoft Teams activity after a workspace command is run + """ + return self.post(f"/teams/activities", json={"activity_id": activity_id, "text": text, "success": success}) def init_global_client(f): @@ -1068,6 +1075,10 @@ def request_interactive_slack_approval( dynamic_enums_json=dynamic_enums_json, ) +@init_global_client +def update_teams_activity(activity_id: str, text: str, success: bool): + return _client.update_teams_activity(activity_id, text, success) + @init_global_client def cancel_running() -> dict: """Cancel currently running executions of the same script.""" diff --git a/typescript-client/client.ts b/typescript-client/client.ts index ba816cb7f5..e6e7c8584e 100644 --- a/typescript-client/client.ts +++ b/typescript-client/client.ts @@ -6,6 +6,7 @@ import { MetricsService, OidcService, UserService, + TeamsService } from "./index"; import { OpenAPI } from "./index"; // import type { DenoS3LightClientSettings } from "./index"; @@ -25,6 +26,7 @@ export { SettingsService, UserService, WorkspaceService, + TeamsService, } from "./index"; export type Sql = string;