dhisana 0.0.1.dev278__py3-none-any.whl → 0.0.1.dev279__py3-none-any.whl
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.
- dhisana/utils/test_connect.py +197 -0
- {dhisana-0.0.1.dev278.dist-info → dhisana-0.0.1.dev279.dist-info}/METADATA +1 -1
- {dhisana-0.0.1.dev278.dist-info → dhisana-0.0.1.dev279.dist-info}/RECORD +6 -6
- {dhisana-0.0.1.dev278.dist-info → dhisana-0.0.1.dev279.dist-info}/WHEEL +0 -0
- {dhisana-0.0.1.dev278.dist-info → dhisana-0.0.1.dev279.dist-info}/entry_points.txt +0 -0
- {dhisana-0.0.1.dev278.dist-info → dhisana-0.0.1.dev279.dist-info}/top_level.txt +0 -0
dhisana/utils/test_connect.py
CHANGED
|
@@ -1869,6 +1869,151 @@ async def test_datagma(api_key: str) -> Dict[str, Any]:
|
|
|
1869
1869
|
return {"success": False, "status_code": 0, "error_message": str(e)}
|
|
1870
1870
|
|
|
1871
1871
|
|
|
1872
|
+
###############################################################################
|
|
1873
|
+
# MICROSOFT DATAVERSE CONNECTIVITY
|
|
1874
|
+
###############################################################################
|
|
1875
|
+
|
|
1876
|
+
async def test_dataverse(
|
|
1877
|
+
environment_url: str,
|
|
1878
|
+
tenant_id: str,
|
|
1879
|
+
client_id: str,
|
|
1880
|
+
client_secret: str,
|
|
1881
|
+
api_version: str = "v9.2",
|
|
1882
|
+
) -> Dict[str, Any]:
|
|
1883
|
+
"""
|
|
1884
|
+
Validate Microsoft Dataverse connectivity using client credentials OAuth.
|
|
1885
|
+
|
|
1886
|
+
Uses the OAuth 2.0 client credentials flow to obtain an access token from
|
|
1887
|
+
Microsoft Entra ID, then makes a test API call to fetch sample accounts.
|
|
1888
|
+
|
|
1889
|
+
Required:
|
|
1890
|
+
• environment_url (e.g. https://org12345.crm.dynamics.com)
|
|
1891
|
+
• tenant_id (Microsoft Entra tenant GUID)
|
|
1892
|
+
• client_id (Application/client ID from app registration)
|
|
1893
|
+
• client_secret (Client secret from app registration)
|
|
1894
|
+
|
|
1895
|
+
Optional:
|
|
1896
|
+
• api_version (default: v9.2)
|
|
1897
|
+
"""
|
|
1898
|
+
if not environment_url:
|
|
1899
|
+
return {
|
|
1900
|
+
"success": False,
|
|
1901
|
+
"status_code": 0,
|
|
1902
|
+
"error_message": "Missing environment_url for Dataverse.",
|
|
1903
|
+
}
|
|
1904
|
+
if not tenant_id:
|
|
1905
|
+
return {
|
|
1906
|
+
"success": False,
|
|
1907
|
+
"status_code": 0,
|
|
1908
|
+
"error_message": "Missing tenant_id for Dataverse.",
|
|
1909
|
+
}
|
|
1910
|
+
if not client_id:
|
|
1911
|
+
return {
|
|
1912
|
+
"success": False,
|
|
1913
|
+
"status_code": 0,
|
|
1914
|
+
"error_message": "Missing client_id for Dataverse.",
|
|
1915
|
+
}
|
|
1916
|
+
if not client_secret:
|
|
1917
|
+
return {
|
|
1918
|
+
"success": False,
|
|
1919
|
+
"status_code": 0,
|
|
1920
|
+
"error_message": "Missing client_secret for Dataverse.",
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
# Normalize environment URL
|
|
1924
|
+
environment_url = environment_url.rstrip("/")
|
|
1925
|
+
|
|
1926
|
+
# Token endpoint and scope for client credentials flow
|
|
1927
|
+
token_url = f"https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token"
|
|
1928
|
+
scope = f"{environment_url}/.default"
|
|
1929
|
+
|
|
1930
|
+
try:
|
|
1931
|
+
timeout = aiohttp.ClientTimeout(total=15)
|
|
1932
|
+
async with aiohttp.ClientSession(timeout=timeout) as session:
|
|
1933
|
+
# Step 1: Get access token using client credentials
|
|
1934
|
+
token_data = {
|
|
1935
|
+
"client_id": client_id,
|
|
1936
|
+
"client_secret": client_secret,
|
|
1937
|
+
"grant_type": "client_credentials",
|
|
1938
|
+
"scope": scope,
|
|
1939
|
+
}
|
|
1940
|
+
|
|
1941
|
+
async with session.post(
|
|
1942
|
+
token_url,
|
|
1943
|
+
data=token_data,
|
|
1944
|
+
headers={"Content-Type": "application/x-www-form-urlencoded"},
|
|
1945
|
+
) as token_response:
|
|
1946
|
+
token_status = token_response.status
|
|
1947
|
+
token_json = await safe_json(token_response)
|
|
1948
|
+
|
|
1949
|
+
if token_status != 200:
|
|
1950
|
+
error_msg = None
|
|
1951
|
+
if isinstance(token_json, dict):
|
|
1952
|
+
error_msg = (
|
|
1953
|
+
token_json.get("error_description")
|
|
1954
|
+
or token_json.get("error")
|
|
1955
|
+
or token_json.get("message")
|
|
1956
|
+
)
|
|
1957
|
+
return {
|
|
1958
|
+
"success": False,
|
|
1959
|
+
"status_code": token_status,
|
|
1960
|
+
"error_message": error_msg or f"Token acquisition failed: {token_status}",
|
|
1961
|
+
}
|
|
1962
|
+
|
|
1963
|
+
access_token = token_json.get("access_token") if token_json else None
|
|
1964
|
+
if not access_token:
|
|
1965
|
+
return {
|
|
1966
|
+
"success": False,
|
|
1967
|
+
"status_code": token_status,
|
|
1968
|
+
"error_message": "No access_token in token response.",
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1971
|
+
# Step 2: Test API access by fetching sample accounts
|
|
1972
|
+
api_url = f"{environment_url}/api/data/{api_version}/accounts"
|
|
1973
|
+
headers = {
|
|
1974
|
+
"Authorization": f"Bearer {access_token}",
|
|
1975
|
+
"Accept": "application/json",
|
|
1976
|
+
"OData-MaxVersion": "4.0",
|
|
1977
|
+
"OData-Version": "4.0",
|
|
1978
|
+
}
|
|
1979
|
+
params = {"$top": "5", "$select": "name,accountid"}
|
|
1980
|
+
|
|
1981
|
+
async with session.get(api_url, headers=headers, params=params) as api_response:
|
|
1982
|
+
api_status = api_response.status
|
|
1983
|
+
api_data = await safe_json(api_response)
|
|
1984
|
+
|
|
1985
|
+
if api_status != 200:
|
|
1986
|
+
error_msg = None
|
|
1987
|
+
if isinstance(api_data, dict):
|
|
1988
|
+
# Dataverse error format
|
|
1989
|
+
error_obj = api_data.get("error", {})
|
|
1990
|
+
if isinstance(error_obj, dict):
|
|
1991
|
+
error_msg = error_obj.get("message")
|
|
1992
|
+
else:
|
|
1993
|
+
error_msg = api_data.get("message") or api_data.get("error")
|
|
1994
|
+
return {
|
|
1995
|
+
"success": False,
|
|
1996
|
+
"status_code": api_status,
|
|
1997
|
+
"error_message": error_msg or f"Dataverse API error: {api_status}",
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
# Success - check if we got valid data
|
|
2001
|
+
if isinstance(api_data, dict) and "value" in api_data:
|
|
2002
|
+
record_count = len(api_data.get("value", []))
|
|
2003
|
+
return {
|
|
2004
|
+
"success": True,
|
|
2005
|
+
"status_code": api_status,
|
|
2006
|
+
"error_message": None,
|
|
2007
|
+
"message": f"Connected successfully. Found {record_count} sample accounts.",
|
|
2008
|
+
}
|
|
2009
|
+
|
|
2010
|
+
return {"success": True, "status_code": api_status, "error_message": None}
|
|
2011
|
+
|
|
2012
|
+
except Exception as exc:
|
|
2013
|
+
logger.error(f"Dataverse connectivity test failed: {exc}")
|
|
2014
|
+
return {"success": False, "status_code": 0, "error_message": str(exc)}
|
|
2015
|
+
|
|
2016
|
+
|
|
1872
2017
|
###############################################################################
|
|
1873
2018
|
# MAIN CONNECTIVITY FUNCTION
|
|
1874
2019
|
###############################################################################
|
|
@@ -1902,6 +2047,7 @@ async def test_connectivity(tool_config: List[Dict[str, Any]]) -> Dict[str, Dict
|
|
|
1902
2047
|
"hunter": test_hunter,
|
|
1903
2048
|
"findymail": test_findyemail,
|
|
1904
2049
|
"datagma": test_datagma,
|
|
2050
|
+
"dataverse": test_dataverse,
|
|
1905
2051
|
"jinaai": test_jinaai,
|
|
1906
2052
|
"firefliesai": test_firefliesai,
|
|
1907
2053
|
"firecrawl": test_firecrawl,
|
|
@@ -2145,6 +2291,57 @@ async def test_connectivity(tool_config: List[Dict[str, Any]]) -> Dict[str, Dict
|
|
|
2145
2291
|
results[tool_name] = await test_twilio(account_sid, auth_token)
|
|
2146
2292
|
continue
|
|
2147
2293
|
|
|
2294
|
+
# ------------------------------------------------------------------ #
|
|
2295
|
+
# Special-case: Dataverse (client credentials OAuth)
|
|
2296
|
+
# ------------------------------------------------------------------ #
|
|
2297
|
+
if tool_name == "dataverse":
|
|
2298
|
+
environment_url = next(
|
|
2299
|
+
(c["value"] for c in config_entries if c["name"] in ("environment_url", "environmentUrl")),
|
|
2300
|
+
None,
|
|
2301
|
+
)
|
|
2302
|
+
tenant_id = next(
|
|
2303
|
+
(c["value"] for c in config_entries if c["name"] in ("tenant_id", "tenantId")),
|
|
2304
|
+
None,
|
|
2305
|
+
)
|
|
2306
|
+
client_id = next(
|
|
2307
|
+
(c["value"] for c in config_entries if c["name"] in ("client_id", "clientId")),
|
|
2308
|
+
None,
|
|
2309
|
+
)
|
|
2310
|
+
client_secret = next(
|
|
2311
|
+
(c["value"] for c in config_entries if c["name"] in ("client_secret", "clientSecret")),
|
|
2312
|
+
None,
|
|
2313
|
+
)
|
|
2314
|
+
api_version = next(
|
|
2315
|
+
(c["value"] for c in config_entries if c["name"] in ("api_version", "apiVersion")),
|
|
2316
|
+
"v9.2",
|
|
2317
|
+
)
|
|
2318
|
+
|
|
2319
|
+
if not all([environment_url, tenant_id, client_id, client_secret]):
|
|
2320
|
+
missing = []
|
|
2321
|
+
if not environment_url:
|
|
2322
|
+
missing.append("environment_url")
|
|
2323
|
+
if not tenant_id:
|
|
2324
|
+
missing.append("tenant_id")
|
|
2325
|
+
if not client_id:
|
|
2326
|
+
missing.append("client_id")
|
|
2327
|
+
if not client_secret:
|
|
2328
|
+
missing.append("client_secret")
|
|
2329
|
+
results[tool_name] = {
|
|
2330
|
+
"success": False,
|
|
2331
|
+
"status_code": 0,
|
|
2332
|
+
"error_message": f"Missing required fields: {', '.join(missing)}",
|
|
2333
|
+
}
|
|
2334
|
+
else:
|
|
2335
|
+
logger.info("Testing connectivity for Dataverse…")
|
|
2336
|
+
results[tool_name] = await test_dataverse(
|
|
2337
|
+
environment_url,
|
|
2338
|
+
tenant_id,
|
|
2339
|
+
client_id,
|
|
2340
|
+
client_secret,
|
|
2341
|
+
api_version,
|
|
2342
|
+
)
|
|
2343
|
+
continue
|
|
2344
|
+
|
|
2148
2345
|
# ------------------------------------------------------------------ #
|
|
2149
2346
|
# All other tools – expect an apiKey by default
|
|
2150
2347
|
# ------------------------------------------------------------------ #
|
|
@@ -81,7 +81,7 @@ dhisana/utils/serperdev_google_jobs.py,sha256=m5_2f_5y79FOFZz1A_go6m0hIUfbbAoZ0Y
|
|
|
81
81
|
dhisana/utils/serperdev_local_business.py,sha256=JoZfTg58Hojv61cyuwA2lcnPdLT1lawnWaBNrUYWnuQ,6447
|
|
82
82
|
dhisana/utils/serperdev_search.py,sha256=_iBKIfHMq4gFv5StYz58eArriygoi1zW6VnLlux8vto,9363
|
|
83
83
|
dhisana/utils/smtp_email_tools.py,sha256=peW0dKMUW5s_yso9uhLb6DGOM3Aj028zshqBWlQKviE,21990
|
|
84
|
-
dhisana/utils/test_connect.py,sha256=
|
|
84
|
+
dhisana/utils/test_connect.py,sha256=PFwCQ6ODzXGdUV0kXREed8U2FG_emizlDF-wG9r51wQ,100367
|
|
85
85
|
dhisana/utils/trasform_json.py,sha256=7V72XNDpuxUX0GHN5D83z4anj_gIf5zabaHeQm7b1_E,6979
|
|
86
86
|
dhisana/utils/web_download_parse_tools.py,sha256=ouXwH7CmjcRjoBfP5BWat86MvcGO-8rLCmWQe_eZKjc,7810
|
|
87
87
|
dhisana/utils/workflow_code_model.py,sha256=YPWse5vBb3O6Km2PvKh1Q3AB8qBkzLt1CrR5xOL9Mro,99
|
|
@@ -95,8 +95,8 @@ dhisana/workflow/agent.py,sha256=esv7_i_XuMkV2j1nz_UlsHov_m6X5WZZiZm_tG4OBHU,565
|
|
|
95
95
|
dhisana/workflow/flow.py,sha256=xWE3qQbM7j2B3FH8XnY3zOL_QXX4LbTW4ArndnEYJE0,1638
|
|
96
96
|
dhisana/workflow/task.py,sha256=HlWz9mtrwLYByoSnePOemBUBrMEcj7KbgNjEE1oF5wo,1830
|
|
97
97
|
dhisana/workflow/test.py,sha256=E7lRnXK0PguTNzyasHytLzTJdkqIPxG5_4qk4hMEeKc,3399
|
|
98
|
-
dhisana-0.0.1.
|
|
99
|
-
dhisana-0.0.1.
|
|
100
|
-
dhisana-0.0.1.
|
|
101
|
-
dhisana-0.0.1.
|
|
102
|
-
dhisana-0.0.1.
|
|
98
|
+
dhisana-0.0.1.dev279.dist-info/METADATA,sha256=6Zksvpdsjon8UlBdVEoWtlHjoRFVxfI8HwOyFWwmWoE,1190
|
|
99
|
+
dhisana-0.0.1.dev279.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
100
|
+
dhisana-0.0.1.dev279.dist-info/entry_points.txt,sha256=jujxteZmNI9EkEaK-pOCoWuBujU8TCevdkfl9ZcKHek,49
|
|
101
|
+
dhisana-0.0.1.dev279.dist-info/top_level.txt,sha256=NETTHt6YifG_P7XtRHbQiXZlgSFk9Qh9aR-ng1XTf4s,8
|
|
102
|
+
dhisana-0.0.1.dev279.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|