definite-sdk 0.1.16__tar.gz → 0.1.17__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: definite-sdk
3
- Version: 0.1.16
3
+ Version: 0.1.17
4
4
  Summary: Definite SDK for Python
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -128,3 +128,63 @@ class DefiniteIntegrationStore:
128
128
  raise Exception("Integration with type `duckdb` not found")
129
129
  integration = integrations[0]
130
130
  return integration.get("details", {})
131
+
132
+ def get_syncs(
133
+ self,
134
+ integration_id: str,
135
+ *,
136
+ limit: int = 50,
137
+ offset: int = 0,
138
+ desc: bool = True,
139
+ status: Optional[str] = None,
140
+ ) -> List[Dict]:
141
+ """
142
+ Retrieves sync runs (DAG runs) for an integration.
143
+
144
+ Args:
145
+ integration_id (str): The ID of the integration.
146
+ limit (int): Maximum number of results to return (default: 50, max: 100).
147
+ offset (int): Number of results to skip for pagination (default: 0).
148
+ desc (bool): Sort by created_at descending if True (default: True).
149
+ status (str): Optional filter by status ("STARTED", "SUCCESS", "FAILED").
150
+
151
+ Returns:
152
+ List[Dict]: List of DAG run records with keys:
153
+ - dag_name: Name of the DAG
154
+ - run_id: Unique ID for this run
155
+ - created_at: ISO datetime when created
156
+ - updated_at: ISO datetime when updated
157
+ - src_integration_id: Source integration UUID
158
+ - dst_integration_id: Destination integration UUID
159
+ - status: Run status (STARTED, SUCCESS, FAILED)
160
+ - details: Additional run details
161
+ """
162
+ params: Dict = {
163
+ "limit": limit,
164
+ "offset": offset,
165
+ "desc": str(desc).lower(),
166
+ }
167
+ if status:
168
+ params["status"] = status
169
+
170
+ response = requests.get(
171
+ f"{self._integrations_url}/{integration_id}/syncs",
172
+ params=params,
173
+ headers={"Authorization": "Bearer " + self._api_key},
174
+ )
175
+ response.raise_for_status()
176
+ cursor_page = response.json()
177
+ return cast(List[Dict], cursor_page.get("data", []))
178
+
179
+ def get_latest_sync(self, integration_id: str) -> Optional[Dict]:
180
+ """
181
+ Retrieves the most recent sync run for an integration.
182
+
183
+ Args:
184
+ integration_id (str): The ID of the integration.
185
+
186
+ Returns:
187
+ Optional[Dict]: The most recent DAG run, or None if no syncs exist.
188
+ """
189
+ syncs = self.get_syncs(integration_id, limit=1, desc=True)
190
+ return syncs[0] if syncs else None
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "definite-sdk"
3
- version = "0.1.16"
3
+ version = "0.1.17"
4
4
  description = "Definite SDK for Python"
5
5
  authors = ["Definite <hello@definite.app>"]
6
6
  license = "MIT"
File without changes
File without changes