swarmauri_tool_zapierhook 0.6.0.dev154__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- swarmauri_tool_zapierhook-0.6.0.dev154/PKG-INFO +19 -0
- swarmauri_tool_zapierhook-0.6.0.dev154/README.md +1 -0
- swarmauri_tool_zapierhook-0.6.0.dev154/pyproject.toml +53 -0
- swarmauri_tool_zapierhook-0.6.0.dev154/swarmauri_tool_zapierhook/ZapierHookTool.py +84 -0
- swarmauri_tool_zapierhook-0.6.0.dev154/swarmauri_tool_zapierhook/__init__.py +12 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: swarmauri_tool_zapierhook
|
|
3
|
+
Version: 0.6.0.dev154
|
|
4
|
+
Summary: Zapier Hook Tool
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
Author: Jacob Stewart
|
|
7
|
+
Author-email: jacob@swarmauri.com
|
|
8
|
+
Requires-Python: >=3.10,<3.13
|
|
9
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Requires-Dist: swarmauri_base (>=0.6.0.dev154,<0.7.0)
|
|
15
|
+
Requires-Dist: swarmauri_core (>=0.6.0.dev154,<0.7.0)
|
|
16
|
+
Project-URL: Repository, http://github.com/swarmauri/swarmauri-sdk
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# Swarmauri Example Community Package
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Swarmauri Example Community Package
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "swarmauri_tool_zapierhook"
|
|
3
|
+
version = "0.6.0.dev154"
|
|
4
|
+
description = "Zapier Hook Tool"
|
|
5
|
+
authors = ["Jacob Stewart <jacob@swarmauri.com>"]
|
|
6
|
+
license = "Apache-2.0"
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
repository = "http://github.com/swarmauri/swarmauri-sdk"
|
|
9
|
+
classifiers = [
|
|
10
|
+
"License :: OSI Approved :: Apache Software License",
|
|
11
|
+
"Programming Language :: Python :: 3.10",
|
|
12
|
+
"Programming Language :: Python :: 3.11",
|
|
13
|
+
"Programming Language :: Python :: 3.12"
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
[tool.poetry.dependencies]
|
|
17
|
+
python = ">=3.10,<3.13"
|
|
18
|
+
|
|
19
|
+
# Swarmauri
|
|
20
|
+
swarmauri_core = {version = "^0.6.0.dev154"}
|
|
21
|
+
swarmauri_base = {version = "^0.6.0.dev154"}
|
|
22
|
+
|
|
23
|
+
[tool.poetry.group.dev.dependencies]
|
|
24
|
+
flake8 = "^7.0"
|
|
25
|
+
pytest = "^8.0"
|
|
26
|
+
pytest-asyncio = ">=0.24.0"
|
|
27
|
+
pytest-xdist = "^3.6.1"
|
|
28
|
+
pytest-json-report = "^1.5.0"
|
|
29
|
+
python-dotenv = "*"
|
|
30
|
+
requests = "^2.32.3"
|
|
31
|
+
|
|
32
|
+
[build-system]
|
|
33
|
+
requires = ["poetry-core>=1.0.0"]
|
|
34
|
+
build-backend = "poetry.core.masonry.api"
|
|
35
|
+
|
|
36
|
+
[tool.pytest.ini_options]
|
|
37
|
+
norecursedirs = ["combined", "scripts"]
|
|
38
|
+
|
|
39
|
+
markers = [
|
|
40
|
+
"test: standard test",
|
|
41
|
+
"unit: Unit tests",
|
|
42
|
+
"integration: Integration tests",
|
|
43
|
+
"acceptance: Acceptance tests",
|
|
44
|
+
"experimental: Experimental tests"
|
|
45
|
+
]
|
|
46
|
+
log_cli = true
|
|
47
|
+
log_cli_level = "INFO"
|
|
48
|
+
log_cli_format = "%(asctime)s [%(levelname)s] %(message)s"
|
|
49
|
+
log_cli_date_format = "%Y-%m-%d %H:%M:%S"
|
|
50
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
51
|
+
|
|
52
|
+
[tool.poetry.plugins."swarmauri.tools"]
|
|
53
|
+
ZapierHookTool = "swarmauri_tool_zapierhook.ZapierHookTool:ZapierHookTool"
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import requests
|
|
3
|
+
from typing import Dict, List, Literal
|
|
4
|
+
from swarmauri_core.ComponentBase import ComponentBase
|
|
5
|
+
from swarmauri_base.tools.ToolBase import ToolBase
|
|
6
|
+
from swarmauri_standard.tools.Parameter import Parameter
|
|
7
|
+
from pydantic import Field
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
"""
|
|
11
|
+
- Zapier's webhooks do not require authentication for basic usage,
|
|
12
|
+
as they are designed to be secure via their unique URLs.
|
|
13
|
+
- The webhook URL (https://hooks.zapier.com/hooks/catch/{zap_id}/) includes
|
|
14
|
+
a randomly generated identifier that is private to you,
|
|
15
|
+
ensuring that only those with the specific URL can trigger the Zap.
|
|
16
|
+
|
|
17
|
+
Reference
|
|
18
|
+
---------------
|
|
19
|
+
- https://www.switchlabs.dev/resources/locating-your-webhook-url-in-zapier
|
|
20
|
+
- https://zapier.com/apps/webhook/integrations
|
|
21
|
+
- https://zapier.com/engineering/webhook-design/
|
|
22
|
+
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
@ComponentBase.register_type(ToolBase, "ZapierHookTool")
|
|
26
|
+
class ZapierHookTool(ToolBase):
|
|
27
|
+
version: str = "1.0.0"
|
|
28
|
+
parameters: List[Parameter] = Field(
|
|
29
|
+
default_factory=lambda: [
|
|
30
|
+
Parameter(
|
|
31
|
+
name="payload",
|
|
32
|
+
type="string",
|
|
33
|
+
description="A Payload to send when triggering the Zapier webhook",
|
|
34
|
+
required=True,
|
|
35
|
+
)
|
|
36
|
+
]
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
name: str = "ZapierTool"
|
|
40
|
+
description: str = "Tool to authenticate with Zapier and execute zaps."
|
|
41
|
+
type: Literal["ZapierHookTool"] = "ZapierHookTool"
|
|
42
|
+
|
|
43
|
+
content_type: str = "application/json"
|
|
44
|
+
zap_url: str
|
|
45
|
+
|
|
46
|
+
def execute_zap(self, payload: str) -> str:
|
|
47
|
+
"""Execute a zap with given payload.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
payload (str): The data payload to send to the Zap.
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
str: The response from Zapier API.
|
|
54
|
+
"""
|
|
55
|
+
headers = {"Content-Type": self.content_type}
|
|
56
|
+
|
|
57
|
+
response = requests.post(
|
|
58
|
+
self.zap_url,
|
|
59
|
+
json={"data": payload},
|
|
60
|
+
headers=headers,
|
|
61
|
+
)
|
|
62
|
+
# Checking the HTTP response status for success or failure
|
|
63
|
+
if response.status_code == 200:
|
|
64
|
+
return json.dumps(response.json())
|
|
65
|
+
else:
|
|
66
|
+
response.raise_for_status() # This will raise an error for non-200 responses
|
|
67
|
+
|
|
68
|
+
def __call__(self, payload: str) -> Dict[str, str]:
|
|
69
|
+
"""
|
|
70
|
+
Enable the tool to be called directly with the given payload and return the zap response.
|
|
71
|
+
|
|
72
|
+
Parameters:
|
|
73
|
+
payload (str): The input string to be processed by the tool.
|
|
74
|
+
|
|
75
|
+
Returns:
|
|
76
|
+
Dict[str, str]: A dictionary with a single key "zap_response", containing the result of executing the zap.
|
|
77
|
+
|
|
78
|
+
Example:
|
|
79
|
+
>>> tool = YourToolClass()
|
|
80
|
+
>>> result = tool("some payload")
|
|
81
|
+
>>> print(result)
|
|
82
|
+
{'zap_response': 'processed result'}
|
|
83
|
+
"""
|
|
84
|
+
return {"zap_response": self.execute_zap(payload)}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from .ZapierHookTool import ZapierHookTool
|
|
2
|
+
|
|
3
|
+
__version__ = "0.6.0.dev26"
|
|
4
|
+
__long_desc__ = """
|
|
5
|
+
|
|
6
|
+
# Swarmauri ZapierHook Tool Plugin
|
|
7
|
+
|
|
8
|
+
Visit us at: https://swarmauri.com
|
|
9
|
+
Follow us at: https://github.com/swarmauri
|
|
10
|
+
Star us at: https://github.com/swarmauri/swarmauri-sdk
|
|
11
|
+
|
|
12
|
+
"""
|