truto-python-sdk 0.1.7__tar.gz → 0.3.0__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.
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/PKG-INFO +21 -4
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/README.md +20 -3
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/pyproject.toml +1 -1
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/__init__.py +3 -2
- truto_python_sdk-0.3.0/truto_python_sdk/analytics.py +33 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/environment.py +1 -1
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/environment_integration.py +9 -1
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/environment_unified_model.py +9 -1
- truto_python_sdk-0.3.0/truto_python_sdk/environment_unified_model_resource_method.py +26 -0
- truto_python_sdk-0.3.0/truto_python_sdk/errors.py +106 -0
- truto_python_sdk-0.3.0/truto_python_sdk/integrated_account.py +97 -0
- truto_python_sdk-0.3.0/truto_python_sdk/integration.py +52 -0
- truto_python_sdk-0.3.0/truto_python_sdk/observability_destination.py +32 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/pagination_result.py +2 -1
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/proxy_api.py +7 -7
- truto_python_sdk-0.3.0/truto_python_sdk/sync_job_run_state.py +26 -0
- truto_python_sdk-0.3.0/truto_python_sdk/sync_job_template.py +26 -0
- truto_python_sdk-0.3.0/truto_python_sdk/tenant.py +30 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/truto_api.py +39 -24
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/unified_api.py +17 -7
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/unified_model.py +10 -3
- truto_python_sdk-0.3.0/truto_python_sdk/unified_model_resource_method.py +26 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/webhook.py +8 -3
- truto_python_sdk-0.1.7/truto_python_sdk/integrated_account.py +0 -37
- truto_python_sdk-0.1.7/truto_python_sdk/integration.py +0 -33
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/LICENSE +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/alarm.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/api_token.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/base_resource.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/batch_request.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/category.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/custom_api.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/daemon.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/daemon_job.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/daemon_job_cron_trigger.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/daemon_job_run.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/datastore.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/dict_to_query_string.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/documentation.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/environment_integration_webhook.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/integrated_account_webhook.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/link_token.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/log.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/mcp.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/sandbox_integrated_account.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/static_gate.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/sync_job.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/sync_job_cron_trigger.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/sync_job_run.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/team.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/user.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/workflow.py +0 -0
- {truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/workflow_run.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: truto-python-sdk
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Python3 SDK for the Truto API
|
|
5
5
|
License-File: LICENSE
|
|
6
6
|
Author: Roopendra Talekar
|
|
@@ -26,7 +26,7 @@ Description-Content-Type: text/markdown
|
|
|
26
26
|
|
|
27
27
|
## Requires
|
|
28
28
|
|
|
29
|
-
Python 3.
|
|
29
|
+
Python 3.12+
|
|
30
30
|
|
|
31
31
|
## Installation
|
|
32
32
|
|
|
@@ -111,9 +111,26 @@ page = await truto_api.unified_api.list(
|
|
|
111
111
|
).next_page()
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
-
##
|
|
114
|
+
## Errors
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
A 4xx or 5xx response raises `TrutoApiError`. It subclasses `aiohttp.ClientResponseError`, so `.status`, `.message` and `.headers` work as before, and it also carries the response body Truto sent:
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from truto_python_sdk import TrutoApiError
|
|
120
|
+
|
|
121
|
+
try:
|
|
122
|
+
await truto_api.integrated_accounts.get("missing-id")
|
|
123
|
+
except TrutoApiError as e:
|
|
124
|
+
print(e.status) # 404
|
|
125
|
+
print(e.error) # Truto's error message, if the body is JSON
|
|
126
|
+
print(e.truto_error_insight) # extra detail Truto attaches to some errors, or None
|
|
127
|
+
print(e.data) # the full parsed JSON body, or None
|
|
128
|
+
print(e.body) # the raw body as text
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Full reference
|
|
132
|
+
|
|
133
|
+
Every resource and method, with examples, is documented at **[truto.one/docs/sdks/python](https://truto.one/docs/sdks/python)**: the Unified, Proxy and Custom APIs, MCP, integrated accounts, tenants, integrations, unified models and mappings, sync jobs, webhooks, workflows, datastores, analytics, and more.
|
|
117
134
|
|
|
118
135
|
## Contributing
|
|
119
136
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
## Requires
|
|
8
8
|
|
|
9
|
-
Python 3.
|
|
9
|
+
Python 3.12+
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
@@ -91,9 +91,26 @@ page = await truto_api.unified_api.list(
|
|
|
91
91
|
).next_page()
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
-
##
|
|
94
|
+
## Errors
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
A 4xx or 5xx response raises `TrutoApiError`. It subclasses `aiohttp.ClientResponseError`, so `.status`, `.message` and `.headers` work as before, and it also carries the response body Truto sent:
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
from truto_python_sdk import TrutoApiError
|
|
100
|
+
|
|
101
|
+
try:
|
|
102
|
+
await truto_api.integrated_accounts.get("missing-id")
|
|
103
|
+
except TrutoApiError as e:
|
|
104
|
+
print(e.status) # 404
|
|
105
|
+
print(e.error) # Truto's error message, if the body is JSON
|
|
106
|
+
print(e.truto_error_insight) # extra detail Truto attaches to some errors, or None
|
|
107
|
+
print(e.data) # the full parsed JSON body, or None
|
|
108
|
+
print(e.body) # the raw body as text
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Full reference
|
|
112
|
+
|
|
113
|
+
Every resource and method, with examples, is documented at **[truto.one/docs/sdks/python](https://truto.one/docs/sdks/python)**: the Unified, Proxy and Custom APIs, MCP, integrated accounts, tenants, integrations, unified models and mappings, sync jobs, webhooks, workflows, datastores, analytics, and more.
|
|
97
114
|
|
|
98
115
|
## Contributing
|
|
99
116
|
|
|
@@ -8,9 +8,10 @@ A Python3 SDK for the Truto API.
|
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
10
|
__title__ = 'truto_python_sdk'
|
|
11
|
-
__version__ = '0.
|
|
11
|
+
__version__ = '0.3.0'
|
|
12
12
|
__author__ = 'Roopendra Talekar <roopendra@truto.dev>'
|
|
13
13
|
__license__ = 'MIT'
|
|
14
14
|
__copyright__ = 'Copyright 2023 Yin Yang Inc.'
|
|
15
15
|
|
|
16
|
-
from .truto_api import TrutoApi
|
|
16
|
+
from .truto_api import TrutoApi
|
|
17
|
+
from .errors import TrutoApiError
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
class Analytics:
|
|
2
|
+
"""Analytics endpoints.
|
|
3
|
+
|
|
4
|
+
Every method takes query parameters as keyword arguments. Pass a dict as the
|
|
5
|
+
first argument for names that aren't valid Python identifiers, such as `from`:
|
|
6
|
+
`analytics.timeseries({"from": "2026-10-01"}, environment_id=..., metric=...)`.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
def __init__(self, api_client):
|
|
10
|
+
self.api_client = api_client
|
|
11
|
+
|
|
12
|
+
def _get(self, path: str, query_params: dict = None, **kwargs):
|
|
13
|
+
return self.api_client._get(f"analytics/{path}", params={**(query_params or {}), **kwargs})
|
|
14
|
+
|
|
15
|
+
def status(self, query_params: dict = None, **kwargs):
|
|
16
|
+
"""Check whether analytics is available for the environment."""
|
|
17
|
+
return self._get("status", query_params, **kwargs)
|
|
18
|
+
|
|
19
|
+
def metrics(self, query_params: dict = None, **kwargs):
|
|
20
|
+
"""List the metrics that can be queried."""
|
|
21
|
+
return self._get("metrics", query_params, **kwargs)
|
|
22
|
+
|
|
23
|
+
def dashboard(self, query_params: dict = None, **kwargs):
|
|
24
|
+
"""Get the summary dashboard (`range` or `from`/`to`, optional `environment_id`)."""
|
|
25
|
+
return self._get("dashboard", query_params, **kwargs)
|
|
26
|
+
|
|
27
|
+
def timeseries(self, query_params: dict = None, **kwargs):
|
|
28
|
+
"""Get a metric over time (`environment_id`, `metric`, optional `from`, `to`, `granularity`, `group_by`)."""
|
|
29
|
+
return self._get("timeseries", query_params, **kwargs)
|
|
30
|
+
|
|
31
|
+
def breakdown(self, query_params: dict = None, **kwargs):
|
|
32
|
+
"""Get a metric broken down by a dimension (`environment_id`, `metric`, `dimension`)."""
|
|
33
|
+
return self._get("breakdown", query_params, **kwargs)
|
{truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/environment_integration.py
RENAMED
|
@@ -14,4 +14,12 @@ class EnvironmentIntegration:
|
|
|
14
14
|
|
|
15
15
|
def update(self, environment_integration_id: str, environment_integration_data: dict):
|
|
16
16
|
"""Update an existing environment_integration."""
|
|
17
|
-
return self.api_client._patch(f"environment-integration/{environment_integration_id}", data=environment_integration_data)
|
|
17
|
+
return self.api_client._patch(f"environment-integration/{environment_integration_id}", data=environment_integration_data)
|
|
18
|
+
|
|
19
|
+
def create(self, environment_integration_data: dict):
|
|
20
|
+
"""Install an integration in the environment (`integration_id`, optional `is_enabled`, `override`)."""
|
|
21
|
+
return self.api_client._post("environment-integration", data=environment_integration_data)
|
|
22
|
+
|
|
23
|
+
def delete(self, environment_integration_id: str):
|
|
24
|
+
"""Uninstall an integration from the environment."""
|
|
25
|
+
return self.api_client._delete(f"environment-integration/{environment_integration_id}")
|
{truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/environment_unified_model.py
RENAMED
|
@@ -14,4 +14,12 @@ class EnvironmentUnifiedModel:
|
|
|
14
14
|
|
|
15
15
|
def update(self, environment_unified_model_id: str, environment_unified_model_data: dict):
|
|
16
16
|
"""Update an existing environment_unified_model."""
|
|
17
|
-
return self.api_client._patch(f"environment-unified-model/{environment_unified_model_id}", data=environment_unified_model_data)
|
|
17
|
+
return self.api_client._patch(f"environment-unified-model/{environment_unified_model_id}", data=environment_unified_model_data)
|
|
18
|
+
|
|
19
|
+
def create(self, environment_unified_model_data: dict):
|
|
20
|
+
"""Install a unified model in the environment (`unified_model_id`)."""
|
|
21
|
+
return self.api_client._post("environment-unified-model", data=environment_unified_model_data)
|
|
22
|
+
|
|
23
|
+
def delete(self, environment_unified_model_id: str):
|
|
24
|
+
"""Uninstall a unified model from the environment."""
|
|
25
|
+
return self.api_client._delete(f"environment-unified-model/{environment_unified_model_id}")
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from .pagination_result import PaginationResult
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class EnvironmentUnifiedModelResourceMethod:
|
|
5
|
+
def __init__(self, api_client):
|
|
6
|
+
self.api_client = api_client
|
|
7
|
+
|
|
8
|
+
def list(self, **query_params):
|
|
9
|
+
"""List all environment unified model resource methods with pagination support."""
|
|
10
|
+
return PaginationResult(self.api_client, "environment-unified-model-resource-method", query_params)
|
|
11
|
+
|
|
12
|
+
def get(self, environment_unified_model_resource_method_id: str, **query_params):
|
|
13
|
+
"""Get a specific environment unified model resource method by ID."""
|
|
14
|
+
return self.api_client._get(f"environment-unified-model-resource-method/{environment_unified_model_resource_method_id}", params=query_params)
|
|
15
|
+
|
|
16
|
+
def create(self, environment_unified_model_resource_method_data: dict, **query_params):
|
|
17
|
+
"""Create a new environment unified model resource method."""
|
|
18
|
+
return self.api_client._post("environment-unified-model-resource-method", data=environment_unified_model_resource_method_data, params=query_params)
|
|
19
|
+
|
|
20
|
+
def update(self, environment_unified_model_resource_method_id: str, environment_unified_model_resource_method_data: dict, **query_params):
|
|
21
|
+
"""Update an existing environment unified model resource method."""
|
|
22
|
+
return self.api_client._patch(f"environment-unified-model-resource-method/{environment_unified_model_resource_method_id}", data=environment_unified_model_resource_method_data, params=query_params)
|
|
23
|
+
|
|
24
|
+
def delete(self, environment_unified_model_resource_method_id: str, **query_params):
|
|
25
|
+
"""Delete a environment unified model resource method by ID."""
|
|
26
|
+
return self.api_client._delete(f"environment-unified-model-resource-method/{environment_unified_model_resource_method_id}", query_params)
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import codecs
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
import aiohttp
|
|
6
|
+
|
|
7
|
+
# Error bodies are kept on the exception, so cap how much of one we read.
|
|
8
|
+
MAX_ERROR_BODY_BYTES = 64 * 1024
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class TrutoApiError(aiohttp.ClientResponseError):
|
|
12
|
+
"""Raised when the Truto API responds with a 4xx or 5xx status.
|
|
13
|
+
|
|
14
|
+
Subclasses ``aiohttp.ClientResponseError``, so existing ``except
|
|
15
|
+
aiohttp.ClientResponseError`` handlers keep working, and ``.status``,
|
|
16
|
+
``.message``, ``.headers`` and ``.request_info`` are unchanged. On top of
|
|
17
|
+
that it carries the response body Truto sent back:
|
|
18
|
+
|
|
19
|
+
- ``body``: the raw response body as text (``None`` if it could not be read)
|
|
20
|
+
- ``data``: the body parsed as JSON, or ``None`` if it isn't JSON
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
def __init__(
|
|
24
|
+
self,
|
|
25
|
+
request_info,
|
|
26
|
+
history,
|
|
27
|
+
*,
|
|
28
|
+
status=None,
|
|
29
|
+
message="",
|
|
30
|
+
headers=None,
|
|
31
|
+
body=None,
|
|
32
|
+
data=None,
|
|
33
|
+
):
|
|
34
|
+
# Defaults match aiohttp.ClientResponseError: copy/pickle rebuild the
|
|
35
|
+
# error as ``cls(request_info, history)`` and then restore __dict__.
|
|
36
|
+
super().__init__(request_info, history, status=status, message=message, headers=headers)
|
|
37
|
+
self.body = body
|
|
38
|
+
self.data = data
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def error(self):
|
|
42
|
+
"""Truto's error message (the ``error`` field of a JSON error body), if any."""
|
|
43
|
+
if isinstance(self.data, dict):
|
|
44
|
+
for key in ("error", "message"):
|
|
45
|
+
value = self.data.get(key)
|
|
46
|
+
if isinstance(value, str) and value:
|
|
47
|
+
return value
|
|
48
|
+
return None
|
|
49
|
+
|
|
50
|
+
@property
|
|
51
|
+
def truto_error_insight(self):
|
|
52
|
+
"""Truto's ``truto_error_insight`` object from the error body, if any."""
|
|
53
|
+
if isinstance(self.data, dict):
|
|
54
|
+
return self.data.get("truto_error_insight")
|
|
55
|
+
return None
|
|
56
|
+
|
|
57
|
+
def __str__(self):
|
|
58
|
+
base = super().__str__()
|
|
59
|
+
detail = self.error
|
|
60
|
+
if detail is None and self.body:
|
|
61
|
+
detail = self.body[:500]
|
|
62
|
+
return f"{base}, body={detail!r}" if detail else base
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _codec(charset):
|
|
66
|
+
"""The response's charset if Python knows it, else utf-8."""
|
|
67
|
+
if charset:
|
|
68
|
+
try:
|
|
69
|
+
return codecs.lookup(charset).name
|
|
70
|
+
except LookupError:
|
|
71
|
+
pass
|
|
72
|
+
return "utf-8"
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
async def raise_for_status(response: aiohttp.ClientResponse):
|
|
76
|
+
"""Like ``response.raise_for_status()`` but reads the body first so the
|
|
77
|
+
raised ``TrutoApiError`` carries Truto's error message."""
|
|
78
|
+
if response.ok:
|
|
79
|
+
return
|
|
80
|
+
body = None
|
|
81
|
+
data = None
|
|
82
|
+
try:
|
|
83
|
+
# read(n) returns as soon as anything is buffered, so a body sent in
|
|
84
|
+
# several chunks would be cut short. readexactly waits for n bytes and
|
|
85
|
+
# hands back what arrived when the body ends first.
|
|
86
|
+
try:
|
|
87
|
+
raw = await response.content.readexactly(MAX_ERROR_BODY_BYTES)
|
|
88
|
+
except asyncio.IncompleteReadError as e:
|
|
89
|
+
raw = e.partial
|
|
90
|
+
body = raw.decode(_codec(response.charset), errors="replace")
|
|
91
|
+
except Exception:
|
|
92
|
+
body = None
|
|
93
|
+
if body:
|
|
94
|
+
try:
|
|
95
|
+
data = json.loads(body)
|
|
96
|
+
except ValueError:
|
|
97
|
+
data = None
|
|
98
|
+
raise TrutoApiError(
|
|
99
|
+
response.request_info,
|
|
100
|
+
response.history,
|
|
101
|
+
status=response.status,
|
|
102
|
+
message=response.reason or "",
|
|
103
|
+
headers=response.headers,
|
|
104
|
+
body=body,
|
|
105
|
+
data=data,
|
|
106
|
+
)
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
from .pagination_result import PaginationResult
|
|
2
|
+
|
|
3
|
+
class IntegratedAccount:
|
|
4
|
+
def __init__(self, api_client):
|
|
5
|
+
self.api_client = api_client
|
|
6
|
+
|
|
7
|
+
def list(self, **query_params):
|
|
8
|
+
"""List all integrated_accounts with pagination support."""
|
|
9
|
+
return PaginationResult(self.api_client, "integrated-account", query_params)
|
|
10
|
+
|
|
11
|
+
def get(self, integrated_account_id: str):
|
|
12
|
+
"""Get a specific integrated_account by ID."""
|
|
13
|
+
return self.api_client._get(f"integrated-account/{integrated_account_id}")
|
|
14
|
+
|
|
15
|
+
def _import(self, integrated_account_data: dict):
|
|
16
|
+
"""Create a new integrated_account."""
|
|
17
|
+
return self.api_client._post("integrated-account", data=integrated_account_data)
|
|
18
|
+
|
|
19
|
+
def update(self, integrated_account_id: str, integrated_account_data: dict):
|
|
20
|
+
"""Update an existing integrated_account."""
|
|
21
|
+
return self.api_client._patch(f"integrated-account/{integrated_account_id}", data=integrated_account_data)
|
|
22
|
+
|
|
23
|
+
def delete(self, integrated_account_id: str):
|
|
24
|
+
"""Delete an integrated_account by ID."""
|
|
25
|
+
return self.api_client._delete(f"integrated-account/{integrated_account_id}")
|
|
26
|
+
|
|
27
|
+
def create_integrated_account_token(self, integrated_account_id: str):
|
|
28
|
+
"""Create a new token for the integrated account."""
|
|
29
|
+
return self.api_client._post(f"integrated-account/token", data={"integrated_account_id": integrated_account_id})
|
|
30
|
+
|
|
31
|
+
def refresh_credentials(self, integrated_account_id: str):
|
|
32
|
+
"""Refresh the credentials for the integrated account."""
|
|
33
|
+
return self.api_client._post(f"integrated-account/refresh-credentials", data={"id": integrated_account_id})
|
|
34
|
+
|
|
35
|
+
def run_post_install_actions(self, integrated_account_id: str):
|
|
36
|
+
"""Run post install actions for the integrated account."""
|
|
37
|
+
return self.api_client._post(f"integrated-account/run-post-install-actions", data={"id": integrated_account_id})
|
|
38
|
+
|
|
39
|
+
def create(self, integrated_account_data: dict, **query_params):
|
|
40
|
+
"""Create (import) an integrated account with existing credentials."""
|
|
41
|
+
return self.api_client._post("integrated-account", data=integrated_account_data, params=query_params)
|
|
42
|
+
|
|
43
|
+
def update_credentials(self, integrated_account_id: str, credentials_data: dict, **query_params):
|
|
44
|
+
"""Replace the credentials of an integrated account."""
|
|
45
|
+
return self.api_client._patch(
|
|
46
|
+
f"integrated-account/{integrated_account_id}/credentials", data=credentials_data, params=query_params
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
def bulk_delete(self, bulk_delete_data: dict, **query_params):
|
|
50
|
+
"""Delete many integrated accounts at once, by `ids` or `tenant_id`."""
|
|
51
|
+
return self.api_client._post("integrated-account/bulk-delete", data=bulk_delete_data, params=query_params)
|
|
52
|
+
|
|
53
|
+
def refresh_mapping_cache(self, refresh_data: dict = None, **query_params):
|
|
54
|
+
"""Refresh cached unified API mappings (optionally scoped by `integration_id`, `environment_id`)."""
|
|
55
|
+
return self.api_client._post("integrated-account/refresh-mapping-cache", data=refresh_data or {}, params=query_params)
|
|
56
|
+
|
|
57
|
+
def create_form_token(self, integrated_account_id: str, **query_params):
|
|
58
|
+
"""Create a token for the integrated account's post-connect form."""
|
|
59
|
+
return self.api_client._post(
|
|
60
|
+
"integrated-account/form-token", data={"integrated_account_id": integrated_account_id}, params=query_params
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
def validate(self, integrated_account_id: str, **query_params):
|
|
64
|
+
"""Validate the integrated account's connection now."""
|
|
65
|
+
return self.api_client._post(f"integrated-account/{integrated_account_id}/validate", params=query_params)
|
|
66
|
+
|
|
67
|
+
def tools(self, integrated_account_id: str, **query_params):
|
|
68
|
+
"""Deprecated by Truto in favour of capabilities(). List the tools available on the integrated account."""
|
|
69
|
+
return self.api_client._get(f"integrated-account/{integrated_account_id}/tools", params=query_params)
|
|
70
|
+
|
|
71
|
+
def capabilities(self, integrated_account_id: str, **query_params):
|
|
72
|
+
"""Get the capabilities (resources and methods) available on the integrated account."""
|
|
73
|
+
return self.api_client._get(f"integrated-account/{integrated_account_id}/capabilities", params=query_params)
|
|
74
|
+
|
|
75
|
+
def list_mcp_servers(self, integrated_account_id: str, **query_params):
|
|
76
|
+
"""List the MCP servers created for the integrated account."""
|
|
77
|
+
return self.api_client._get(f"integrated-account/{integrated_account_id}/mcp", params=query_params)
|
|
78
|
+
|
|
79
|
+
def get_mcp_server(self, integrated_account_id: str, mcp_server_id: str, **query_params):
|
|
80
|
+
"""Get an MCP server of the integrated account."""
|
|
81
|
+
return self.api_client._get(f"integrated-account/{integrated_account_id}/mcp/{mcp_server_id}", params=query_params)
|
|
82
|
+
|
|
83
|
+
def create_mcp_server(self, integrated_account_id: str, mcp_server_data: dict, **query_params):
|
|
84
|
+
"""Create an MCP server for the integrated account (`name`, optional `config`)."""
|
|
85
|
+
return self.api_client._post(
|
|
86
|
+
f"integrated-account/{integrated_account_id}/mcp", data=mcp_server_data, params=query_params
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
def update_mcp_server(self, integrated_account_id: str, mcp_server_id: str, mcp_server_data: dict, **query_params):
|
|
90
|
+
"""Update an MCP server of the integrated account."""
|
|
91
|
+
return self.api_client._patch(
|
|
92
|
+
f"integrated-account/{integrated_account_id}/mcp/{mcp_server_id}", data=mcp_server_data, params=query_params
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
def delete_mcp_server(self, integrated_account_id: str, mcp_server_id: str, **query_params):
|
|
96
|
+
"""Delete an MCP server of the integrated account."""
|
|
97
|
+
return self.api_client._delete(f"integrated-account/{integrated_account_id}/mcp/{mcp_server_id}", query_params)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from .pagination_result import PaginationResult
|
|
2
|
+
|
|
3
|
+
class Integration:
|
|
4
|
+
def __init__(self, api_client):
|
|
5
|
+
self.api_client = api_client
|
|
6
|
+
|
|
7
|
+
def list(self, **query_params):
|
|
8
|
+
"""List all integrations with pagination support."""
|
|
9
|
+
return PaginationResult(self.api_client, "integration", query_params)
|
|
10
|
+
|
|
11
|
+
def get(self, integration_id: str):
|
|
12
|
+
"""Get a specific integration by ID."""
|
|
13
|
+
return self.api_client._get(f"integration/{integration_id}")
|
|
14
|
+
|
|
15
|
+
def create(self, integration_data: dict):
|
|
16
|
+
"""Create a new integration."""
|
|
17
|
+
return self.api_client._post("integration", data=integration_data)
|
|
18
|
+
|
|
19
|
+
def update(self, integration_id: str, integration_data: dict):
|
|
20
|
+
"""Update an existing integration."""
|
|
21
|
+
return self.api_client._patch(f"integration/{integration_id}", data=integration_data)
|
|
22
|
+
|
|
23
|
+
def delete(self, integration_id: str):
|
|
24
|
+
"""Delete an integration by ID."""
|
|
25
|
+
return self.api_client._delete(f"integration/{integration_id}")
|
|
26
|
+
|
|
27
|
+
def install(self, integration_id: str, is_enabled: bool = True):
|
|
28
|
+
"""Install an integration by ID."""
|
|
29
|
+
return self.api_client._post(f"environment-integration", data={"integration_id": integration_id, "is_enabled": is_enabled})
|
|
30
|
+
|
|
31
|
+
async def uninstall(self, integration_id: str):
|
|
32
|
+
"""Uninstall an integration by ID from the environment."""
|
|
33
|
+
# The delete route takes the environment integration ID, so look it up first.
|
|
34
|
+
environment_integrations = await PaginationResult(
|
|
35
|
+
self.api_client, "environment-integration", {"integration_id": integration_id}
|
|
36
|
+
).to_array()
|
|
37
|
+
return [
|
|
38
|
+
await self.api_client._delete(f"environment-integration/{environment_integration['id']}")
|
|
39
|
+
for environment_integration in environment_integrations
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
def capabilities(self, integration_id: str, **query_params):
|
|
43
|
+
"""Get the capabilities (resources and methods) of an integration by ID or name."""
|
|
44
|
+
return self.api_client._get(f"integration/{integration_id}/capabilities", params=query_params)
|
|
45
|
+
|
|
46
|
+
def tools(self, integration_id: str, **query_params):
|
|
47
|
+
"""Deprecated by Truto in favour of capabilities(). List the tools an integration exposes, by ID or name."""
|
|
48
|
+
return self.api_client._get(f"integration/{integration_id}/tools", params=query_params)
|
|
49
|
+
|
|
50
|
+
def unified_apis(self, integration_id: str, **query_params):
|
|
51
|
+
"""Deprecated by Truto in favour of capabilities(). List the unified APIs an integration supports, by ID or name."""
|
|
52
|
+
return self.api_client._get(f"integration/{integration_id}/unified-apis", params=query_params)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from .pagination_result import PaginationResult
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ObservabilityDestination:
|
|
5
|
+
def __init__(self, api_client):
|
|
6
|
+
self.api_client = api_client
|
|
7
|
+
|
|
8
|
+
def list(self, **query_params):
|
|
9
|
+
"""List all observability destinations with pagination support."""
|
|
10
|
+
return PaginationResult(self.api_client, "observability-destination", query_params)
|
|
11
|
+
|
|
12
|
+
def get(self, observability_destination_id: str, **query_params):
|
|
13
|
+
"""Get a specific observability destination by ID."""
|
|
14
|
+
return self.api_client._get(f"observability-destination/{observability_destination_id}", params=query_params)
|
|
15
|
+
|
|
16
|
+
def create(self, observability_destination_data: dict, **query_params):
|
|
17
|
+
"""Create a new observability destination."""
|
|
18
|
+
return self.api_client._post("observability-destination", data=observability_destination_data, params=query_params)
|
|
19
|
+
|
|
20
|
+
def update(self, observability_destination_id: str, observability_destination_data: dict, **query_params):
|
|
21
|
+
"""Update an existing observability destination."""
|
|
22
|
+
return self.api_client._patch(f"observability-destination/{observability_destination_id}", data=observability_destination_data, params=query_params)
|
|
23
|
+
|
|
24
|
+
def delete(self, observability_destination_id: str, **query_params):
|
|
25
|
+
"""Delete a observability destination by ID."""
|
|
26
|
+
return self.api_client._delete(f"observability-destination/{observability_destination_id}", query_params)
|
|
27
|
+
|
|
28
|
+
def test(self, observability_destination_id: str, **query_params):
|
|
29
|
+
"""Send a test event to a saved observability destination."""
|
|
30
|
+
return self.api_client._post(
|
|
31
|
+
f"observability-destination/{observability_destination_id}/test", params=query_params
|
|
32
|
+
)
|
|
@@ -4,7 +4,8 @@ class PaginationResult:
|
|
|
4
4
|
def __init__(self, api_client, endpoint, query_params):
|
|
5
5
|
self.api_client = api_client
|
|
6
6
|
self.endpoint = endpoint
|
|
7
|
-
|
|
7
|
+
# Copy so paging never writes next_cursor into the caller's dict.
|
|
8
|
+
self.query_params = dict(query_params or {})
|
|
8
9
|
self.next_cursor = None
|
|
9
10
|
self.items = []
|
|
10
11
|
self.initial_fetch_done = False # To check if we fetched the first page
|
|
@@ -4,26 +4,26 @@ class ProxyApi:
|
|
|
4
4
|
def __init__(self, api_client):
|
|
5
5
|
self.api_client = api_client
|
|
6
6
|
|
|
7
|
-
def list(self, resource: str, query_params: dict):
|
|
7
|
+
def list(self, resource: str, query_params: dict = None):
|
|
8
8
|
"""List all proxy api resources with pagination support."""
|
|
9
9
|
return PaginationResult(self.api_client, f"proxy/{resource}", query_params)
|
|
10
10
|
|
|
11
|
-
def get(self, resource: str, id: str, query_params: dict):
|
|
11
|
+
def get(self, resource: str, id: str, query_params: dict = None):
|
|
12
12
|
"""Get a specific proxy api resource by ID."""
|
|
13
13
|
return self.api_client._get(f"proxy/{resource}/{id}", params=query_params)
|
|
14
14
|
|
|
15
|
-
def create(self, resource: str, data: dict, query_params: dict):
|
|
15
|
+
def create(self, resource: str, data: dict, query_params: dict = None):
|
|
16
16
|
"""Create a new proxy api resource."""
|
|
17
17
|
return self.api_client._post(f"proxy/{resource}", data=data, params=query_params)
|
|
18
18
|
|
|
19
|
-
def update(self, resource: str, id: str, data: dict, query_params: dict):
|
|
19
|
+
def update(self, resource: str, id: str, data: dict, query_params: dict = None):
|
|
20
20
|
"""Update an existing proxy api resource."""
|
|
21
21
|
return self.api_client._patch(f"proxy/{resource}/{id}", data=data, params=query_params)
|
|
22
22
|
|
|
23
|
-
def delete(self, resource: str, id: str, query_params: dict):
|
|
23
|
+
def delete(self, resource: str, id: str, query_params: dict = None):
|
|
24
24
|
"""Delete a proxy api resource by ID."""
|
|
25
25
|
return self.api_client._delete(f"proxy/{resource}/{id}", query_params)
|
|
26
26
|
|
|
27
|
-
def custom_method(self, resource: str, method: str, data: dict, query_params: dict):
|
|
27
|
+
def custom_method(self, resource: str, method: str, data: dict, query_params: dict = None):
|
|
28
28
|
"""Call a custom method on a proxy api resource."""
|
|
29
|
-
return self.api_client._post(
|
|
29
|
+
return self.api_client._post(f"proxy/{resource}/{method}", data=data, params=query_params)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from .pagination_result import PaginationResult
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class SyncJobRunState:
|
|
5
|
+
def __init__(self, api_client):
|
|
6
|
+
self.api_client = api_client
|
|
7
|
+
|
|
8
|
+
def list(self, **query_params):
|
|
9
|
+
"""List all sync job run states with pagination support."""
|
|
10
|
+
return PaginationResult(self.api_client, "sync-job-run-state", query_params)
|
|
11
|
+
|
|
12
|
+
def get(self, sync_job_run_state_id: str, **query_params):
|
|
13
|
+
"""Get a specific sync job run state by ID."""
|
|
14
|
+
return self.api_client._get(f"sync-job-run-state/{sync_job_run_state_id}", params=query_params)
|
|
15
|
+
|
|
16
|
+
def create(self, sync_job_run_state_data: dict, **query_params):
|
|
17
|
+
"""Create a new sync job run state."""
|
|
18
|
+
return self.api_client._post("sync-job-run-state", data=sync_job_run_state_data, params=query_params)
|
|
19
|
+
|
|
20
|
+
def update(self, sync_job_run_state_id: str, sync_job_run_state_data: dict, **query_params):
|
|
21
|
+
"""Update an existing sync job run state."""
|
|
22
|
+
return self.api_client._patch(f"sync-job-run-state/{sync_job_run_state_id}", data=sync_job_run_state_data, params=query_params)
|
|
23
|
+
|
|
24
|
+
def delete(self, sync_job_run_state_id: str, **query_params):
|
|
25
|
+
"""Delete a sync job run state by ID."""
|
|
26
|
+
return self.api_client._delete(f"sync-job-run-state/{sync_job_run_state_id}", query_params)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from .pagination_result import PaginationResult
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class SyncJobTemplate:
|
|
5
|
+
def __init__(self, api_client):
|
|
6
|
+
self.api_client = api_client
|
|
7
|
+
|
|
8
|
+
def list(self, **query_params):
|
|
9
|
+
"""List all sync job templates with pagination support."""
|
|
10
|
+
return PaginationResult(self.api_client, "sync-job-template", query_params)
|
|
11
|
+
|
|
12
|
+
def get(self, sync_job_template_id: str, **query_params):
|
|
13
|
+
"""Get a specific sync job template by ID."""
|
|
14
|
+
return self.api_client._get(f"sync-job-template/{sync_job_template_id}", params=query_params)
|
|
15
|
+
|
|
16
|
+
def create(self, sync_job_template_data: dict, **query_params):
|
|
17
|
+
"""Create a new sync job template."""
|
|
18
|
+
return self.api_client._post("sync-job-template", data=sync_job_template_data, params=query_params)
|
|
19
|
+
|
|
20
|
+
def update(self, sync_job_template_id: str, sync_job_template_data: dict, **query_params):
|
|
21
|
+
"""Update an existing sync job template."""
|
|
22
|
+
return self.api_client._patch(f"sync-job-template/{sync_job_template_id}", data=sync_job_template_data, params=query_params)
|
|
23
|
+
|
|
24
|
+
def delete(self, sync_job_template_id: str, **query_params):
|
|
25
|
+
"""Delete a sync job template by ID."""
|
|
26
|
+
return self.api_client._delete(f"sync-job-template/{sync_job_template_id}", query_params)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from .pagination_result import PaginationResult
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Tenant:
|
|
5
|
+
def __init__(self, api_client):
|
|
6
|
+
self.api_client = api_client
|
|
7
|
+
|
|
8
|
+
def list(self, **query_params):
|
|
9
|
+
"""List all tenants with pagination support."""
|
|
10
|
+
return PaginationResult(self.api_client, "tenant", query_params)
|
|
11
|
+
|
|
12
|
+
def get(self, tenant_id: str, **query_params):
|
|
13
|
+
"""Get a specific tenant by ID."""
|
|
14
|
+
return self.api_client._get(f"tenant/{tenant_id}", params=query_params)
|
|
15
|
+
|
|
16
|
+
def create(self, tenant_data: dict, **query_params):
|
|
17
|
+
"""Create a new tenant."""
|
|
18
|
+
return self.api_client._post("tenant", data=tenant_data, params=query_params)
|
|
19
|
+
|
|
20
|
+
def update(self, tenant_id: str, tenant_data: dict, **query_params):
|
|
21
|
+
"""Update an existing tenant."""
|
|
22
|
+
return self.api_client._patch(f"tenant/{tenant_id}", data=tenant_data, params=query_params)
|
|
23
|
+
|
|
24
|
+
def delete(self, tenant_id: str, **query_params):
|
|
25
|
+
"""Delete a tenant by ID."""
|
|
26
|
+
return self.api_client._delete(f"tenant/{tenant_id}", query_params)
|
|
27
|
+
|
|
28
|
+
def bulk_create(self, bulk_data: dict, **query_params):
|
|
29
|
+
"""Create or upsert many tenants at once (`tenants`, optional `mode`)."""
|
|
30
|
+
return self.api_client._post("tenant/bulk", data=bulk_data, params=query_params)
|
|
@@ -1,40 +1,48 @@
|
|
|
1
1
|
import aiohttp
|
|
2
2
|
|
|
3
3
|
from .dict_to_query_string import dict_to_query_string
|
|
4
|
+
from .errors import raise_for_status
|
|
4
5
|
from .alarm import Alarm
|
|
5
|
-
from .api_token import ApiToken
|
|
6
|
-
from .batch_request import BatchRequest
|
|
7
|
-
from .category import Category
|
|
8
|
-
from .custom_api import CustomApi
|
|
9
6
|
from .daemon import Daemon
|
|
10
7
|
from .daemon_job import DaemonJob
|
|
11
8
|
from .daemon_job_cron_trigger import DaemonJobCronTrigger
|
|
12
9
|
from .daemon_job_run import DaemonJobRun
|
|
10
|
+
from .environment_integration_webhook import EnvironmentIntegrationWebhook
|
|
11
|
+
from .integrated_account_webhook import IntegratedAccountWebhook
|
|
12
|
+
from .sandbox_integrated_account import SandboxIntegratedAccount
|
|
13
|
+
from .team import Team
|
|
14
|
+
from .user import User
|
|
15
|
+
from .api_token import ApiToken
|
|
16
|
+
from .batch_request import BatchRequest
|
|
17
|
+
from .category import Category
|
|
18
|
+
from .custom_api import CustomApi
|
|
13
19
|
from .datastore import Datastore
|
|
14
20
|
from .documentation import Documentation
|
|
15
21
|
from .environment import Environment
|
|
16
22
|
from .environment_integration import EnvironmentIntegration
|
|
17
|
-
from .environment_integration_webhook import EnvironmentIntegrationWebhook
|
|
18
23
|
from .integrated_account import IntegratedAccount
|
|
19
|
-
from .integrated_account_webhook import IntegratedAccountWebhook
|
|
20
24
|
from .integration import Integration
|
|
21
25
|
from .link_token import LinkToken
|
|
22
26
|
from .log import Log
|
|
23
27
|
from .mcp import Mcp
|
|
24
28
|
from .proxy_api import ProxyApi
|
|
25
|
-
from .sandbox_integrated_account import SandboxIntegratedAccount
|
|
26
29
|
from .static_gate import StaticGate
|
|
27
30
|
from .sync_job import SyncJob
|
|
28
31
|
from .sync_job_cron_trigger import SyncJobCronTrigger
|
|
29
32
|
from .sync_job_run import SyncJobRun
|
|
30
|
-
from .team import Team
|
|
31
33
|
from .unified_api import UnifiedApi
|
|
32
|
-
from .user import User
|
|
33
34
|
from .unified_model import UnifiedModel
|
|
34
35
|
from .environment_unified_model import EnvironmentUnifiedModel
|
|
35
36
|
from .webhook import Webhook
|
|
36
37
|
from .workflow import Workflow
|
|
37
38
|
from .workflow_run import WorkflowRun
|
|
39
|
+
from .analytics import Analytics
|
|
40
|
+
from .environment_unified_model_resource_method import EnvironmentUnifiedModelResourceMethod
|
|
41
|
+
from .observability_destination import ObservabilityDestination
|
|
42
|
+
from .sync_job_run_state import SyncJobRunState
|
|
43
|
+
from .sync_job_template import SyncJobTemplate
|
|
44
|
+
from .tenant import Tenant
|
|
45
|
+
from .unified_model_resource_method import UnifiedModelResourceMethod
|
|
38
46
|
|
|
39
47
|
|
|
40
48
|
class TrutoApi:
|
|
@@ -46,29 +54,19 @@ class TrutoApi:
|
|
|
46
54
|
"Content-Type": "application/json",
|
|
47
55
|
"Accept": "application/json"
|
|
48
56
|
}
|
|
49
|
-
self.users = User(self)
|
|
50
|
-
self.teams = Team(self)
|
|
51
57
|
self.api_tokens = ApiToken(self)
|
|
52
58
|
self.environments = Environment(self)
|
|
53
59
|
self.categories = Category(self)
|
|
54
60
|
self.link_tokens = LinkToken(self)
|
|
55
61
|
self.integrated_accounts = IntegratedAccount(self)
|
|
56
|
-
self.sandbox_integrated_accounts = SandboxIntegratedAccount(self)
|
|
57
62
|
self.integrations = Integration(self)
|
|
58
63
|
self.environment_integrations = EnvironmentIntegration(self)
|
|
59
|
-
self.environment_integration_webhooks = EnvironmentIntegrationWebhook(self)
|
|
60
|
-
self.integrated_account_webhooks = IntegratedAccountWebhook(self)
|
|
61
64
|
self.unified_models = UnifiedModel(self)
|
|
62
65
|
self.environment_unified_models = EnvironmentUnifiedModel(self)
|
|
63
66
|
self.sync_jobs = SyncJob(self)
|
|
64
67
|
self.sync_job_runs = SyncJobRun(self)
|
|
65
68
|
self.sync_job_cron_triggers = SyncJobCronTrigger(self)
|
|
66
|
-
self.daemons = Daemon(self)
|
|
67
|
-
self.daemon_jobs = DaemonJob(self)
|
|
68
|
-
self.daemon_job_runs = DaemonJobRun(self)
|
|
69
|
-
self.daemon_job_cron_triggers = DaemonJobCronTrigger(self)
|
|
70
69
|
self.datastores = Datastore(self)
|
|
71
|
-
self.alarms = Alarm(self)
|
|
72
70
|
self.workflows = Workflow(self)
|
|
73
71
|
self.workflow_runs = WorkflowRun(self)
|
|
74
72
|
self.documentations = Documentation(self)
|
|
@@ -80,6 +78,23 @@ class TrutoApi:
|
|
|
80
78
|
self.custom_api = CustomApi(self)
|
|
81
79
|
self.unified_api = UnifiedApi(self)
|
|
82
80
|
self.proxy_api = ProxyApi(self)
|
|
81
|
+
self.tenants = Tenant(self)
|
|
82
|
+
self.unified_model_resource_methods = UnifiedModelResourceMethod(self)
|
|
83
|
+
self.environment_unified_model_resource_methods = EnvironmentUnifiedModelResourceMethod(self)
|
|
84
|
+
self.sync_job_run_states = SyncJobRunState(self)
|
|
85
|
+
self.sync_job_templates = SyncJobTemplate(self)
|
|
86
|
+
self.observability_destinations = ObservabilityDestination(self)
|
|
87
|
+
self.analytics = Analytics(self)
|
|
88
|
+
self.users = User(self)
|
|
89
|
+
self.teams = Team(self)
|
|
90
|
+
self.sandbox_integrated_accounts = SandboxIntegratedAccount(self)
|
|
91
|
+
self.environment_integration_webhooks = EnvironmentIntegrationWebhook(self)
|
|
92
|
+
self.integrated_account_webhooks = IntegratedAccountWebhook(self)
|
|
93
|
+
self.daemons = Daemon(self)
|
|
94
|
+
self.daemon_jobs = DaemonJob(self)
|
|
95
|
+
self.daemon_job_runs = DaemonJobRun(self)
|
|
96
|
+
self.daemon_job_cron_triggers = DaemonJobCronTrigger(self)
|
|
97
|
+
self.alarms = Alarm(self)
|
|
83
98
|
|
|
84
99
|
async def _process_response(self, response):
|
|
85
100
|
# Get the Content-Type header
|
|
@@ -100,7 +115,7 @@ class TrutoApi:
|
|
|
100
115
|
query_string = dict_to_query_string(params) if params else ""
|
|
101
116
|
async with aiohttp.ClientSession() as session:
|
|
102
117
|
async with session.get(f"{url}?{query_string}", headers=self.headers) as response:
|
|
103
|
-
|
|
118
|
+
await raise_for_status(response)
|
|
104
119
|
return await self._process_response(response)
|
|
105
120
|
|
|
106
121
|
async def _post(self, endpoint, data=None, params=None):
|
|
@@ -108,7 +123,7 @@ class TrutoApi:
|
|
|
108
123
|
query_string = dict_to_query_string(params) if params else ""
|
|
109
124
|
async with aiohttp.ClientSession() as session:
|
|
110
125
|
async with session.post(f"{url}?{query_string}", headers=self.headers, json=data) as response:
|
|
111
|
-
|
|
126
|
+
await raise_for_status(response)
|
|
112
127
|
return await self._process_response(response)
|
|
113
128
|
|
|
114
129
|
async def _patch(self, endpoint, data=None, params=None):
|
|
@@ -116,7 +131,7 @@ class TrutoApi:
|
|
|
116
131
|
query_string = dict_to_query_string(params) if params else ""
|
|
117
132
|
async with aiohttp.ClientSession() as session:
|
|
118
133
|
async with session.patch(f"{url}?{query_string}", headers=self.headers, json=data) as response:
|
|
119
|
-
|
|
134
|
+
await raise_for_status(response)
|
|
120
135
|
return await self._process_response(response)
|
|
121
136
|
|
|
122
137
|
async def _put(self, endpoint, data=None, params=None):
|
|
@@ -124,7 +139,7 @@ class TrutoApi:
|
|
|
124
139
|
query_string = dict_to_query_string(params) if params else ""
|
|
125
140
|
async with aiohttp.ClientSession() as session:
|
|
126
141
|
async with session.put(f"{url}?{query_string}", headers=self.headers, json=data) as response:
|
|
127
|
-
|
|
142
|
+
await raise_for_status(response)
|
|
128
143
|
return await self._process_response(response)
|
|
129
144
|
|
|
130
145
|
async def _delete(self, endpoint, params=None):
|
|
@@ -132,7 +147,7 @@ class TrutoApi:
|
|
|
132
147
|
query_string = dict_to_query_string(params) if params else ""
|
|
133
148
|
async with aiohttp.ClientSession() as session:
|
|
134
149
|
async with session.delete(f"{url}?{query_string}", headers=self.headers) as response:
|
|
135
|
-
|
|
150
|
+
await raise_for_status(response)
|
|
136
151
|
return await self._process_response(response)
|
|
137
152
|
|
|
138
153
|
async def ping(self):
|
|
@@ -4,26 +4,36 @@ class UnifiedApi:
|
|
|
4
4
|
def __init__(self, api_client):
|
|
5
5
|
self.api_client = api_client
|
|
6
6
|
|
|
7
|
-
def list(self, unified_model_name: str, unified_model_resource: str, query_params: dict):
|
|
7
|
+
def list(self, unified_model_name: str, unified_model_resource: str, query_params: dict = None):
|
|
8
8
|
"""List all unified api resources with pagination support."""
|
|
9
9
|
return PaginationResult(self.api_client, f"unified/{unified_model_name}/{unified_model_resource}", query_params)
|
|
10
10
|
|
|
11
|
-
def get(self, unified_model_name: str, unified_model_resource: str, id: str, query_params: dict):
|
|
11
|
+
def get(self, unified_model_name: str, unified_model_resource: str, id: str, query_params: dict = None):
|
|
12
12
|
"""Get a specific unified api resource by ID."""
|
|
13
13
|
return self.api_client._get(f"unified/{unified_model_name}/{unified_model_resource}/{id}", query_params)
|
|
14
14
|
|
|
15
|
-
def create(self, unified_model_name: str, unified_model_resource: str, data: dict, query_params: dict):
|
|
15
|
+
def create(self, unified_model_name: str, unified_model_resource: str, data: dict, query_params: dict = None):
|
|
16
16
|
"""Create a new unified api resource."""
|
|
17
17
|
return self.api_client._post(f"unified/{unified_model_name}/{unified_model_resource}", data=data, params=query_params)
|
|
18
18
|
|
|
19
|
-
def update(self, unified_model_name: str, unified_model_resource: str, id: str, data: dict, query_params: dict):
|
|
19
|
+
def update(self, unified_model_name: str, unified_model_resource: str, id: str, data: dict, query_params: dict = None):
|
|
20
20
|
"""Update an existing unified api resource."""
|
|
21
21
|
return self.api_client._patch(f"unified/{unified_model_name}/{unified_model_resource}/{id}", data=data, params=query_params)
|
|
22
22
|
|
|
23
|
-
def delete(self, unified_model_name: str, unified_model_resource: str, id: str, query_params: dict):
|
|
23
|
+
def delete(self, unified_model_name: str, unified_model_resource: str, id: str, query_params: dict = None):
|
|
24
24
|
"""Delete an unified api resource by ID."""
|
|
25
25
|
return self.api_client._delete(f"unified/{unified_model_name}/{unified_model_resource}/{id}", query_params)
|
|
26
26
|
|
|
27
|
-
def custom_method(self, unified_model_name: str, unified_model_resource: str, method: str, data: dict, query_params: dict):
|
|
27
|
+
def custom_method(self, unified_model_name: str, unified_model_resource: str, method: str, data: dict, query_params: dict = None):
|
|
28
28
|
"""Call a custom method on a unified api resource."""
|
|
29
|
-
return self.api_client._post(
|
|
29
|
+
return self.api_client._post(f"unified/{unified_model_name}/{unified_model_resource}/{method}", data=data, params=query_params)
|
|
30
|
+
|
|
31
|
+
def meta(self, unified_model_name: str, unified_model_resource: str, integration_name: str, method: str, query_params: dict = None):
|
|
32
|
+
"""Get an integration's mapping metadata (schema, supported parameters) for a unified api method."""
|
|
33
|
+
return self.api_client._get(
|
|
34
|
+
f"unified/{unified_model_name}/{unified_model_resource}/{integration_name}/meta/{method}", query_params
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
def model_meta(self, unified_model_name: str, integration_name: str, query_params: dict = None):
|
|
38
|
+
"""Get the resources and methods of a unified model that an integration supports."""
|
|
39
|
+
return self.api_client._get(f"unified/meta/{unified_model_name}/{integration_name}", query_params)
|
|
@@ -28,6 +28,13 @@ class UnifiedModel:
|
|
|
28
28
|
"""Install an unified_model by ID."""
|
|
29
29
|
return self.api_client._post(f"environment-unified-model", data={"unified_model_id": unified_model_id})
|
|
30
30
|
|
|
31
|
-
def uninstall(self, unified_model_id: str):
|
|
32
|
-
"""Uninstall
|
|
33
|
-
|
|
31
|
+
async def uninstall(self, unified_model_id: str):
|
|
32
|
+
"""Uninstall a unified_model by ID from the environment."""
|
|
33
|
+
# The delete route takes the environment unified model ID, so look it up first.
|
|
34
|
+
environment_unified_models = await PaginationResult(
|
|
35
|
+
self.api_client, "environment-unified-model", {"unified_model_id": unified_model_id}
|
|
36
|
+
).to_array()
|
|
37
|
+
return [
|
|
38
|
+
await self.api_client._delete(f"environment-unified-model/{environment_unified_model['id']}")
|
|
39
|
+
for environment_unified_model in environment_unified_models
|
|
40
|
+
]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from .pagination_result import PaginationResult
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class UnifiedModelResourceMethod:
|
|
5
|
+
def __init__(self, api_client):
|
|
6
|
+
self.api_client = api_client
|
|
7
|
+
|
|
8
|
+
def list(self, **query_params):
|
|
9
|
+
"""List all unified model resource methods with pagination support."""
|
|
10
|
+
return PaginationResult(self.api_client, "unified-model-resource-method", query_params)
|
|
11
|
+
|
|
12
|
+
def get(self, unified_model_resource_method_id: str, **query_params):
|
|
13
|
+
"""Get a specific unified model resource method by ID."""
|
|
14
|
+
return self.api_client._get(f"unified-model-resource-method/{unified_model_resource_method_id}", params=query_params)
|
|
15
|
+
|
|
16
|
+
def create(self, unified_model_resource_method_data: dict, **query_params):
|
|
17
|
+
"""Create a new unified model resource method."""
|
|
18
|
+
return self.api_client._post("unified-model-resource-method", data=unified_model_resource_method_data, params=query_params)
|
|
19
|
+
|
|
20
|
+
def update(self, unified_model_resource_method_id: str, unified_model_resource_method_data: dict, **query_params):
|
|
21
|
+
"""Update an existing unified model resource method."""
|
|
22
|
+
return self.api_client._patch(f"unified-model-resource-method/{unified_model_resource_method_id}", data=unified_model_resource_method_data, params=query_params)
|
|
23
|
+
|
|
24
|
+
def delete(self, unified_model_resource_method_id: str, **query_params):
|
|
25
|
+
"""Delete a unified model resource method by ID."""
|
|
26
|
+
return self.api_client._delete(f"unified-model-resource-method/{unified_model_resource_method_id}", query_params)
|
|
@@ -24,6 +24,11 @@ class Webhook:
|
|
|
24
24
|
"""Delete a webhook by ID."""
|
|
25
25
|
return self.api_client._delete(f"webhook/{webhook_id}")
|
|
26
26
|
|
|
27
|
-
def test(self, webhook_id: str):
|
|
28
|
-
"""
|
|
29
|
-
|
|
27
|
+
def test(self, webhook_id: str, event_type: str = None, integrated_account_id: str = None):
|
|
28
|
+
"""Send a test event to a webhook, optionally of a given `event_type` and for an integrated account."""
|
|
29
|
+
data = {"id": webhook_id}
|
|
30
|
+
if event_type is not None:
|
|
31
|
+
data["event_type"] = event_type
|
|
32
|
+
if integrated_account_id is not None:
|
|
33
|
+
data["integrated_account_id"] = integrated_account_id
|
|
34
|
+
return self.api_client._post("webhook/test", data=data)
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
from .pagination_result import PaginationResult
|
|
2
|
-
|
|
3
|
-
class IntegratedAccount:
|
|
4
|
-
def __init__(self, api_client):
|
|
5
|
-
self.api_client = api_client
|
|
6
|
-
|
|
7
|
-
def list(self, **query_params):
|
|
8
|
-
"""List all integrated_accounts with pagination support."""
|
|
9
|
-
return PaginationResult(self.api_client, "integrated-account", query_params)
|
|
10
|
-
|
|
11
|
-
def get(self, integrated_account_id: str):
|
|
12
|
-
"""Get a specific integrated_account by ID."""
|
|
13
|
-
return self.api_client._get(f"integrated-account/{integrated_account_id}")
|
|
14
|
-
|
|
15
|
-
def _import(self, integrated_account_data: dict):
|
|
16
|
-
"""Create a new integrated_account."""
|
|
17
|
-
return self.api_client._post("integrated-account", data=integrated_account_data)
|
|
18
|
-
|
|
19
|
-
def update(self, integrated_account_id: str, integrated_account_data: dict):
|
|
20
|
-
"""Update an existing integrated_account."""
|
|
21
|
-
return self.api_client._patch(f"integrated-account/{integrated_account_id}", data=integrated_account_data)
|
|
22
|
-
|
|
23
|
-
def delete(self, integrated_account_id: str):
|
|
24
|
-
"""Delete an integrated_account by ID."""
|
|
25
|
-
return self.api_client._delete(f"integrated-account/{integrated_account_id}")
|
|
26
|
-
|
|
27
|
-
def create_integrated_account_token(self, integrated_account_id: str):
|
|
28
|
-
"""Create a new token for the integrated account."""
|
|
29
|
-
return self.api_client._post(f"integrated-account/token", data={"integrated_account_id": integrated_account_id})
|
|
30
|
-
|
|
31
|
-
def refresh_credentials(self, integrated_account_id: str):
|
|
32
|
-
"""Refresh the credentials for the integrated account."""
|
|
33
|
-
return self.api_client._post(f"integrated-account/refresh-credentials", data={"id": integrated_account_id})
|
|
34
|
-
|
|
35
|
-
def run_post_install_actions(self, integrated_account_id: str):
|
|
36
|
-
"""Run post install actions for the integrated account."""
|
|
37
|
-
return self.api_client._post(f"integrated-account/run-post-install-actions", data={"id": integrated_account_id})
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
from .pagination_result import PaginationResult
|
|
2
|
-
|
|
3
|
-
class Integration:
|
|
4
|
-
def __init__(self, api_client):
|
|
5
|
-
self.api_client = api_client
|
|
6
|
-
|
|
7
|
-
def list(self, **query_params):
|
|
8
|
-
"""List all integrations with pagination support."""
|
|
9
|
-
return PaginationResult(self.api_client, "integration", query_params)
|
|
10
|
-
|
|
11
|
-
def get(self, integration_id: str):
|
|
12
|
-
"""Get a specific integration by ID."""
|
|
13
|
-
return self.api_client._get(f"integration/{integration_id}")
|
|
14
|
-
|
|
15
|
-
def create(self, integration_data: dict):
|
|
16
|
-
"""Create a new integration."""
|
|
17
|
-
return self.api_client._post("integration", data=integration_data)
|
|
18
|
-
|
|
19
|
-
def update(self, integration_id: str, integration_data: dict):
|
|
20
|
-
"""Update an existing integration."""
|
|
21
|
-
return self.api_client._patch(f"integration/{integration_id}", data=integration_data)
|
|
22
|
-
|
|
23
|
-
def delete(self, integration_id: str):
|
|
24
|
-
"""Delete an integration by ID."""
|
|
25
|
-
return self.api_client._delete(f"integration/{integration_id}")
|
|
26
|
-
|
|
27
|
-
def install(self, integration_id: str, is_enabled: bool = True):
|
|
28
|
-
"""Install an integration by ID."""
|
|
29
|
-
return self.api_client._post(f"environment-integration", data={"integration_id": integration_id, "is_enabled": is_enabled})
|
|
30
|
-
|
|
31
|
-
def uninstall(self, integration_id: str):
|
|
32
|
-
"""Uninstall an integration by ID."""
|
|
33
|
-
return self.api_client._delete(f"environment-integration/{integration_id}")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/daemon_job_cron_trigger.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/integrated_account_webhook.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{truto_python_sdk-0.1.7 → truto_python_sdk-0.3.0}/truto_python_sdk/sandbox_integrated_account.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|