definite-sdk 0.1.12__py3-none-any.whl → 0.1.15__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.
definite_sdk/__init__.py CHANGED
@@ -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.9"
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
+ ]
definite_sdk/client.py CHANGED
@@ -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
- response = requests.get(
89
- f"{self.api_url}/v1/api/integration/DuckLake",
90
- headers={"Authorization": f"Bearer {self.api_key}"},
91
- )
92
- response.raise_for_status()
93
- dl_integration = response.json()
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.
definite_sdk/message.py CHANGED
@@ -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
+ )
@@ -1,8 +1,9 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: definite-sdk
3
- Version: 0.1.12
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"
@@ -0,0 +1,13 @@
1
+ definite_sdk/__init__.py,sha256=pzw1-eWBcD5mvWRxbo59dMUU8Wue4zNsdDYK0Pj1hXQ,606
2
+ definite_sdk/client.py,sha256=5v4mLIsvVf9SS3kE4_vfXjx9AegrGzNsUReIz_n4sxI,5420
3
+ definite_sdk/dlt.py,sha256=JC-S1jd6zqnpGSnvk9kYb8GQ1IPZRd1zVKTVYAbeA4w,7188
4
+ definite_sdk/integration.py,sha256=fkLBQyK4BMzwkkuR-Ih8AMbUf7mR7u2psknl5NmNy6E,3970
5
+ definite_sdk/message.py,sha256=k5TpAoPYSqK_w7ZOphnDz4ntTMmsYVNfG5ROCg6oqxg,6504
6
+ definite_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ definite_sdk/secret.py,sha256=3wvEnTZ946hOxJBdB29dxvppwJ0x-TJV_LxRcXGqtis,2503
8
+ definite_sdk/sql.py,sha256=o2ume-S7__wp8hMBy2aC6dmGYV4s-IXMlMAyEuyAP84,4705
9
+ definite_sdk/store.py,sha256=7VYvROIrlWyM_ZX3LpqWWAfVLNDm0XMccMLv6qi9id8,5575
10
+ definite_sdk-0.1.15.dist-info/METADATA,sha256=igYD7a9epwBJpNK6Tn2HftMRzHuJJNm8TbVxc2m6wjg,9209
11
+ definite_sdk-0.1.15.dist-info/WHEEL,sha256=M5asmiAlL6HEcOq52Yi5mmk9KmTVjY2RDPtO4p9DMrc,88
12
+ definite_sdk-0.1.15.dist-info/licenses/LICENSE,sha256=jMd7PtwNWiMoGIDgFutC1v4taO69W9SRZLKe9o470Vk,1064
13
+ definite_sdk-0.1.15.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.1.3
2
+ Generator: poetry-core 2.2.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,13 +0,0 @@
1
- definite_sdk/__init__.py,sha256=Y3GwfDOkpWt6EILoZ7PRT7nXuoVnk0zHrNOPHlkEHS4,604
2
- definite_sdk/client.py,sha256=mpXFpJVmK3JVYsNrn7f4bzqlxMbIsS3meRu3XMiXWZ4,5075
3
- definite_sdk/dlt.py,sha256=JC-S1jd6zqnpGSnvk9kYb8GQ1IPZRd1zVKTVYAbeA4w,7188
4
- definite_sdk/integration.py,sha256=v15QIpWm3eAZr-cmavfA39LXTjpskEEQ2SM_TBV4E1U,3395
5
- definite_sdk/message.py,sha256=I3qx2v9gIcC9NZyr5zEp_Seft8clRoER4WeUbAaDiFc,6549
6
- definite_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- definite_sdk/secret.py,sha256=3wvEnTZ946hOxJBdB29dxvppwJ0x-TJV_LxRcXGqtis,2503
8
- definite_sdk/sql.py,sha256=o2ume-S7__wp8hMBy2aC6dmGYV4s-IXMlMAyEuyAP84,4705
9
- definite_sdk/store.py,sha256=7VYvROIrlWyM_ZX3LpqWWAfVLNDm0XMccMLv6qi9id8,5575
10
- definite_sdk-0.1.12.dist-info/LICENSE,sha256=jMd7PtwNWiMoGIDgFutC1v4taO69W9SRZLKe9o470Vk,1064
11
- definite_sdk-0.1.12.dist-info/METADATA,sha256=mR32ZrkWtX_q7BBMF6dtE2f2lHicy2SBo1lkMxOTFto,9136
12
- definite_sdk-0.1.12.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
13
- definite_sdk-0.1.12.dist-info/RECORD,,