definite-sdk 0.1.12__tar.gz → 0.1.15__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.
- {definite_sdk-0.1.12 → definite_sdk-0.1.15}/PKG-INFO +4 -2
- {definite_sdk-0.1.12 → definite_sdk-0.1.15}/definite_sdk/__init__.py +2 -2
- {definite_sdk-0.1.12 → definite_sdk-0.1.15}/definite_sdk/client.py +23 -14
- {definite_sdk-0.1.12 → definite_sdk-0.1.15}/definite_sdk/integration.py +19 -1
- {definite_sdk-0.1.12 → definite_sdk-0.1.15}/definite_sdk/message.py +13 -13
- {definite_sdk-0.1.12 → definite_sdk-0.1.15}/pyproject.toml +1 -1
- {definite_sdk-0.1.12 → definite_sdk-0.1.15}/LICENSE +0 -0
- {definite_sdk-0.1.12 → definite_sdk-0.1.15}/README.md +0 -0
- {definite_sdk-0.1.12 → definite_sdk-0.1.15}/definite_sdk/dlt.py +0 -0
- {definite_sdk-0.1.12 → definite_sdk-0.1.15}/definite_sdk/py.typed +0 -0
- {definite_sdk-0.1.12 → definite_sdk-0.1.15}/definite_sdk/secret.py +0 -0
- {definite_sdk-0.1.12 → definite_sdk-0.1.15}/definite_sdk/sql.py +0 -0
- {definite_sdk-0.1.12 → definite_sdk-0.1.15}/definite_sdk/store.py +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: definite-sdk
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.15
|
|
4
4
|
Summary: Definite SDK for Python
|
|
5
5
|
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
6
7
|
Author: Definite
|
|
7
8
|
Author-email: hello@definite.app
|
|
8
9
|
Requires-Python: >=3.9,<4.0
|
|
@@ -13,6 +14,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
13
14
|
Classifier: Programming Language :: Python :: 3.11
|
|
14
15
|
Classifier: Programming Language :: Python :: 3.12
|
|
15
16
|
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
18
|
Provides-Extra: dlt
|
|
17
19
|
Requires-Dist: dlt (>=1.0,<2.0) ; extra == "dlt"
|
|
18
20
|
Requires-Dist: duckdb (>=1.0,<2.0) ; extra == "dlt"
|
|
@@ -11,7 +11,7 @@ from definite_sdk.secret import DefiniteSecretStore
|
|
|
11
11
|
from definite_sdk.sql import DefiniteSqlClient
|
|
12
12
|
from definite_sdk.store import DefiniteKVStore
|
|
13
13
|
|
|
14
|
-
__version__ = "0.1.
|
|
14
|
+
__version__ = "0.1.14"
|
|
15
15
|
__all__ = [
|
|
16
16
|
"DefiniteClient",
|
|
17
17
|
"DefiniteIntegrationStore",
|
|
@@ -19,4 +19,4 @@ __all__ = [
|
|
|
19
19
|
"DefiniteSecretStore",
|
|
20
20
|
"DefiniteSqlClient",
|
|
21
21
|
"DefiniteKVStore",
|
|
22
|
-
]
|
|
22
|
+
]
|
|
@@ -69,36 +69,45 @@ class DefiniteClient:
|
|
|
69
69
|
|
|
70
70
|
def attach_ducklake(self, alias: str = "lake") -> str:
|
|
71
71
|
"""Generates SQL statements to attach DuckLake to a DuckDB connection.
|
|
72
|
-
|
|
72
|
+
|
|
73
73
|
This method fetches the team's DuckLake integration credentials and generates
|
|
74
74
|
the necessary SQL statements to create a GCS secret and attach DuckLake.
|
|
75
|
-
|
|
75
|
+
|
|
76
76
|
Args:
|
|
77
77
|
alias: The alias name for the attached DuckLake database (default: "lake")
|
|
78
|
-
|
|
78
|
+
|
|
79
79
|
Returns:
|
|
80
80
|
str: SQL statements to execute for attaching DuckLake
|
|
81
|
-
|
|
81
|
+
|
|
82
82
|
Example:
|
|
83
83
|
>>> client = DefiniteClient(os.environ["DEFINITE_API_KEY"])
|
|
84
84
|
>>> sql = client.attach_ducklake()
|
|
85
85
|
>>> conn.execute(sql)
|
|
86
86
|
"""
|
|
87
87
|
# Fetch DuckLake integration details
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
try:
|
|
89
|
+
response = requests.get(
|
|
90
|
+
f"{self.api_url}/v1/api/integration/Ducklake",
|
|
91
|
+
headers={"Authorization": f"Bearer {self.api_key}"},
|
|
92
|
+
)
|
|
93
|
+
response.raise_for_status()
|
|
94
|
+
dl_integration = response.json()
|
|
95
|
+
except requests.exceptions.HTTPError as e:
|
|
96
|
+
if response.status_code == 404:
|
|
97
|
+
raise ValueError(
|
|
98
|
+
"DuckLake integration not found. Please ensure you have a DuckLake integration "
|
|
99
|
+
"configured in your Definite account at https://ui.definite.app"
|
|
100
|
+
) from e
|
|
101
|
+
else:
|
|
102
|
+
raise
|
|
103
|
+
|
|
95
104
|
# Generate SQL statements
|
|
96
105
|
create_secret_sql = f"""CREATE SECRET (
|
|
97
106
|
TYPE gcs,
|
|
98
107
|
KEY_ID '{dl_integration['gcs_access_key_id']}',
|
|
99
108
|
SECRET '{dl_integration['gcs_secret_access_key']}'
|
|
100
109
|
);"""
|
|
101
|
-
|
|
110
|
+
|
|
102
111
|
# Build PostgreSQL connection string
|
|
103
112
|
pg_conn_str = (
|
|
104
113
|
f"postgresql://{dl_integration['pg_user']}:"
|
|
@@ -107,13 +116,13 @@ class DefiniteClient:
|
|
|
107
116
|
f"{dl_integration['pg_port']}/"
|
|
108
117
|
f"{dl_integration['pg_database']}"
|
|
109
118
|
)
|
|
110
|
-
|
|
119
|
+
|
|
111
120
|
attach_sql = (
|
|
112
121
|
f"ATTACH 'ducklake:postgres:{pg_conn_str}' AS {alias} "
|
|
113
122
|
f"(DATA_PATH 'gs://{dl_integration['gcs_bucket_path']}', "
|
|
114
123
|
f"METADATA_SCHEMA '{dl_integration['pg_schema']}');"
|
|
115
124
|
)
|
|
116
|
-
|
|
125
|
+
|
|
117
126
|
return f"{create_secret_sql}\n\n{attach_sql}"
|
|
118
127
|
|
|
119
128
|
# Alias methods for consistency
|
|
@@ -16,6 +16,7 @@ class DefiniteIntegrationStore:
|
|
|
16
16
|
Accessing values:
|
|
17
17
|
>>> integration_store.list_integrations()
|
|
18
18
|
>>> integration_store.get_integration("name")
|
|
19
|
+
>>> integration_store.get_integration_by_id("integration_id")
|
|
19
20
|
"""
|
|
20
21
|
|
|
21
22
|
def __init__(self, api_key: str, api_url: str):
|
|
@@ -59,10 +60,27 @@ class DefiniteIntegrationStore:
|
|
|
59
60
|
response.raise_for_status()
|
|
60
61
|
return dict(response.json())
|
|
61
62
|
|
|
63
|
+
def get_integration_by_id(self, integration_id: str) -> dict:
|
|
64
|
+
"""
|
|
65
|
+
Retrieves an integration by ID.
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
integration_id (str): The ID of the integration.
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
dict: The integration details.
|
|
72
|
+
"""
|
|
73
|
+
response = requests.get(
|
|
74
|
+
self._integration_store_url + f"/id/{integration_id}",
|
|
75
|
+
headers={"Authorization": "Bearer " + self._api_key},
|
|
76
|
+
)
|
|
77
|
+
response.raise_for_status()
|
|
78
|
+
return dict(response.json())
|
|
79
|
+
|
|
62
80
|
def lookup_duckdb_integration(self) -> Optional[Tuple[str, str]]:
|
|
63
81
|
"""
|
|
64
82
|
Look up the team's DuckDB integration.
|
|
65
|
-
|
|
83
|
+
|
|
66
84
|
Note: Currently, the API only returns extractor (source) integrations.
|
|
67
85
|
Destination integrations like DuckDB are not yet exposed through this endpoint.
|
|
68
86
|
This method is provided for future compatibility when the API is updated.
|
|
@@ -21,7 +21,7 @@ class DefiniteMessageClient:
|
|
|
21
21
|
... to="C0920MVPWFN", # channel_id
|
|
22
22
|
... content="Hello from Definite SDK!"
|
|
23
23
|
... )
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
>>> # Send a Slack message with blocks and thread
|
|
26
26
|
>>> result = message_client.send_message(
|
|
27
27
|
... channel="slack",
|
|
@@ -53,7 +53,7 @@ class DefiniteMessageClient:
|
|
|
53
53
|
subject: Optional[str] = None,
|
|
54
54
|
blocks: Optional[List[Dict[str, Any]]] = None,
|
|
55
55
|
thread_ts: Optional[str] = None,
|
|
56
|
-
**kwargs: Any
|
|
56
|
+
**kwargs: Any,
|
|
57
57
|
) -> Dict[str, Any]:
|
|
58
58
|
"""
|
|
59
59
|
Sends a message through the specified channel.
|
|
@@ -83,7 +83,7 @@ class DefiniteMessageClient:
|
|
|
83
83
|
... to="C0920MVPWFN",
|
|
84
84
|
... content="Hello team!"
|
|
85
85
|
... )
|
|
86
|
-
|
|
86
|
+
|
|
87
87
|
>>> # Slack message with blocks
|
|
88
88
|
>>> result = message_client.send_message(
|
|
89
89
|
... channel="slack",
|
|
@@ -97,7 +97,7 @@ class DefiniteMessageClient:
|
|
|
97
97
|
... )
|
|
98
98
|
"""
|
|
99
99
|
channel_lower = channel.lower()
|
|
100
|
-
|
|
100
|
+
|
|
101
101
|
if channel_lower == "slack":
|
|
102
102
|
return self._send_slack_message(
|
|
103
103
|
integration_id=integration_id,
|
|
@@ -105,7 +105,7 @@ class DefiniteMessageClient:
|
|
|
105
105
|
text=content,
|
|
106
106
|
blocks=blocks,
|
|
107
107
|
thread_ts=thread_ts,
|
|
108
|
-
**kwargs
|
|
108
|
+
**kwargs,
|
|
109
109
|
)
|
|
110
110
|
else:
|
|
111
111
|
raise ValueError(f"Unsupported channel: {channel}")
|
|
@@ -117,7 +117,7 @@ class DefiniteMessageClient:
|
|
|
117
117
|
text: str,
|
|
118
118
|
blocks: Optional[List[Dict[str, Any]]] = None,
|
|
119
119
|
thread_ts: Optional[str] = None,
|
|
120
|
-
**kwargs: Any
|
|
120
|
+
**kwargs: Any,
|
|
121
121
|
) -> Dict[str, Any]:
|
|
122
122
|
"""
|
|
123
123
|
Internal method to send a Slack message.
|
|
@@ -134,18 +134,18 @@ class DefiniteMessageClient:
|
|
|
134
134
|
Dict[str, Any]: The API response.
|
|
135
135
|
"""
|
|
136
136
|
url = f"{self._message_url}/slack/message"
|
|
137
|
-
|
|
137
|
+
|
|
138
138
|
payload = {
|
|
139
139
|
"integration_id": integration_id,
|
|
140
140
|
"channel_id": channel_id,
|
|
141
|
-
"text": text
|
|
141
|
+
"text": text,
|
|
142
142
|
}
|
|
143
|
-
|
|
143
|
+
|
|
144
144
|
if blocks:
|
|
145
145
|
payload["blocks"] = blocks
|
|
146
146
|
if thread_ts:
|
|
147
147
|
payload["thread_ts"] = thread_ts
|
|
148
|
-
|
|
148
|
+
|
|
149
149
|
# Add any additional kwargs to the payload
|
|
150
150
|
payload.update(kwargs)
|
|
151
151
|
|
|
@@ -164,7 +164,7 @@ class DefiniteMessageClient:
|
|
|
164
164
|
text: str,
|
|
165
165
|
blocks: Optional[List[Dict[str, Any]]] = None,
|
|
166
166
|
thread_ts: Optional[str] = None,
|
|
167
|
-
**kwargs: Any
|
|
167
|
+
**kwargs: Any,
|
|
168
168
|
) -> Dict[str, Any]:
|
|
169
169
|
"""
|
|
170
170
|
Convenience method to send a Slack message directly.
|
|
@@ -195,5 +195,5 @@ class DefiniteMessageClient:
|
|
|
195
195
|
content=text,
|
|
196
196
|
blocks=blocks,
|
|
197
197
|
thread_ts=thread_ts,
|
|
198
|
-
**kwargs
|
|
199
|
-
)
|
|
198
|
+
**kwargs,
|
|
199
|
+
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|