Skip to content

Commit

Permalink
Add functions.completeSuccess/Error APIs for remote functions
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch committed Nov 21, 2023
1 parent 750d97c commit a67c213
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
26 changes: 26 additions & 0 deletions slack_sdk/web/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3658,6 +3658,32 @@ async def files_completeUploadExternal(
)
return await self.api_call("files.completeUploadExternal", params=kwargs)

async def functions_completeSuccess(
self,
*,
function_execution_id: str,
outputs: Dict[str, Any],
**kwargs,
) -> AsyncSlackResponse:
"""Signal the successful completion of a function
https://api.slack.com/methods/functions.completeSuccess
"""
kwargs.update({"function_execution_id": function_execution_id, "outputs": outputs})
return await self.api_call("functions.completeSuccess", params=kwargs)

Check warning on line 3672 in slack_sdk/web/async_client.py

View check run for this annotation

Codecov / codecov/patch

slack_sdk/web/async_client.py#L3671-L3672

Added lines #L3671 - L3672 were not covered by tests

async def functions_completeError(
self,
*,
function_execution_id: str,
error: str,
**kwargs,
) -> AsyncSlackResponse:
"""Signal the failure to execute a function
https://api.slack.com/methods/functions.completeError
"""
kwargs.update({"function_execution_id": function_execution_id, "error": error})
return await self.api_call("functions.completeError", params=kwargs)

Check warning on line 3685 in slack_sdk/web/async_client.py

View check run for this annotation

Codecov / codecov/patch

slack_sdk/web/async_client.py#L3684-L3685

Added lines #L3684 - L3685 were not covered by tests

# --------------------------
# Deprecated: groups.*
# You can use conversations.* APIs instead.
Expand Down
26 changes: 26 additions & 0 deletions slack_sdk/web/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3649,6 +3649,32 @@ def files_completeUploadExternal(
)
return self.api_call("files.completeUploadExternal", params=kwargs)

def functions_completeSuccess(
self,
*,
function_execution_id: str,
outputs: Dict[str, Any],
**kwargs,
) -> SlackResponse:
"""Signal the successful completion of a function
https://api.slack.com/methods/functions.completeSuccess
"""
kwargs.update({"function_execution_id": function_execution_id, "outputs": outputs})
return self.api_call("functions.completeSuccess", params=kwargs)

Check warning on line 3663 in slack_sdk/web/client.py

View check run for this annotation

Codecov / codecov/patch

slack_sdk/web/client.py#L3662-L3663

Added lines #L3662 - L3663 were not covered by tests

def functions_completeError(
self,
*,
function_execution_id: str,
error: str,
**kwargs,
) -> SlackResponse:
"""Signal the failure to execute a function
https://api.slack.com/methods/functions.completeError
"""
kwargs.update({"function_execution_id": function_execution_id, "error": error})
return self.api_call("functions.completeError", params=kwargs)

Check warning on line 3676 in slack_sdk/web/client.py

View check run for this annotation

Codecov / codecov/patch

slack_sdk/web/client.py#L3675-L3676

Added lines #L3675 - L3676 were not covered by tests

# --------------------------
# Deprecated: groups.*
# You can use conversations.* APIs instead.
Expand Down
26 changes: 26 additions & 0 deletions slack_sdk/web/legacy_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3660,6 +3660,32 @@ def files_completeUploadExternal(
)
return self.api_call("files.completeUploadExternal", params=kwargs)

def functions_completeSuccess(
self,
*,
function_execution_id: str,
outputs: Dict[str, Any],
**kwargs,
) -> Union[Future, SlackResponse]:
"""Signal the successful completion of a function
https://api.slack.com/methods/functions.completeSuccess
"""
kwargs.update({"function_execution_id": function_execution_id, "outputs": outputs})
return self.api_call("functions.completeSuccess", params=kwargs)

Check warning on line 3674 in slack_sdk/web/legacy_client.py

View check run for this annotation

Codecov / codecov/patch

slack_sdk/web/legacy_client.py#L3673-L3674

Added lines #L3673 - L3674 were not covered by tests

def functions_completeError(
self,
*,
function_execution_id: str,
error: str,
**kwargs,
) -> Union[Future, SlackResponse]:
"""Signal the failure to execute a function
https://api.slack.com/methods/functions.completeError
"""
kwargs.update({"function_execution_id": function_execution_id, "error": error})
return self.api_call("functions.completeError", params=kwargs)

Check warning on line 3687 in slack_sdk/web/legacy_client.py

View check run for this annotation

Codecov / codecov/patch

slack_sdk/web/legacy_client.py#L3686-L3687

Added lines #L3686 - L3687 were not covered by tests

# --------------------------
# Deprecated: groups.*
# You can use conversations.* APIs instead.
Expand Down
6 changes: 6 additions & 0 deletions tests/slack_sdk_async/web/test_web_client_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,12 @@ async def run_method(self, method_name, method, async_method):
elif method_name == "files_completeUploadExternal":
self.api_methods_to_call.remove(method(files=[{"id": "F111"}])["method"])
await async_method(files=[{"id": "F111"}])
elif method_name == "functions_completeSuccess":
self.api_methods_to_call.remove(method(function_execution_id="Fn111", outputs={"num": 123}))
await async_method(function_execution_id="Fn111", outputs={"num": 123})
elif method_name == "functions_completeError":
self.api_methods_to_call.remove(method(function_execution_id="Fn111", error="something wrong"))
await async_method(function_execution_id="Fn111", error="something wrong")
elif method_name == "migration_exchange":
self.api_methods_to_call.remove(method(users="U123,U234")["method"])
method(users="U123,U234")
Expand Down

0 comments on commit a67c213

Please sign in to comment.