collibra-connector 1.0.19__tar.gz → 1.1.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.
- collibra_connector-1.1.0/PKG-INFO +540 -0
- collibra_connector-1.1.0/README.md +481 -0
- collibra_connector-1.1.0/collibra_connector/__init__.py +319 -0
- {collibra_connector-1.0.19 → collibra_connector-1.1.0}/collibra_connector/api/Asset.py +301 -3
- collibra_connector-1.1.0/collibra_connector/api/Attribute.py +204 -0
- {collibra_connector-1.0.19 → collibra_connector-1.1.0}/collibra_connector/api/Base.py +2 -2
- {collibra_connector-1.0.19 → collibra_connector-1.1.0}/collibra_connector/api/Relation.py +216 -0
- {collibra_connector-1.0.19 → collibra_connector-1.1.0}/collibra_connector/api/Responsibility.py +5 -5
- collibra_connector-1.1.0/collibra_connector/api/Search.py +102 -0
- {collibra_connector-1.0.19 → collibra_connector-1.1.0}/collibra_connector/api/__init__.py +23 -13
- collibra_connector-1.1.0/collibra_connector/async_connector.py +930 -0
- collibra_connector-1.1.0/collibra_connector/cli.py +597 -0
- collibra_connector-1.1.0/collibra_connector/connector.py +311 -0
- collibra_connector-1.1.0/collibra_connector/helpers.py +845 -0
- collibra_connector-1.1.0/collibra_connector/lineage.py +716 -0
- collibra_connector-1.1.0/collibra_connector/models.py +897 -0
- collibra_connector-1.1.0/collibra_connector/py.typed +0 -0
- collibra_connector-1.1.0/collibra_connector/telemetry.py +576 -0
- collibra_connector-1.1.0/collibra_connector/testing.py +806 -0
- collibra_connector-1.1.0/collibra_connector.egg-info/PKG-INFO +540 -0
- {collibra_connector-1.0.19 → collibra_connector-1.1.0}/collibra_connector.egg-info/SOURCES.txt +20 -1
- collibra_connector-1.1.0/collibra_connector.egg-info/entry_points.txt +2 -0
- collibra_connector-1.1.0/collibra_connector.egg-info/requires.txt +36 -0
- collibra_connector-1.1.0/pyproject.toml +133 -0
- collibra_connector-1.1.0/tests/test_asset.py +268 -0
- collibra_connector-1.1.0/tests/test_connector.py +292 -0
- collibra_connector-1.1.0/tests/test_exceptions.py +96 -0
- collibra_connector-1.1.0/tests/test_helpers.py +418 -0
- collibra_connector-1.1.0/tests/test_lineage.py +312 -0
- collibra_connector-1.1.0/tests/test_models.py +407 -0
- collibra_connector-1.1.0/tests/test_search.py +51 -0
- collibra_connector-1.1.0/tests/test_testing.py +217 -0
- collibra_connector-1.0.19/PKG-INFO +0 -157
- collibra_connector-1.0.19/README.md +0 -139
- collibra_connector-1.0.19/collibra_connector/__init__.py +0 -39
- collibra_connector-1.0.19/collibra_connector/connector.py +0 -89
- collibra_connector-1.0.19/collibra_connector.egg-info/PKG-INFO +0 -157
- collibra_connector-1.0.19/collibra_connector.egg-info/requires.txt +0 -1
- collibra_connector-1.0.19/pyproject.toml +0 -31
- {collibra_connector-1.0.19 → collibra_connector-1.1.0}/LICENSE +0 -0
- {collibra_connector-1.0.19 → collibra_connector-1.1.0}/collibra_connector/api/Comment.py +0 -0
- {collibra_connector-1.0.19 → collibra_connector-1.1.0}/collibra_connector/api/Community.py +0 -0
- {collibra_connector-1.0.19 → collibra_connector-1.1.0}/collibra_connector/api/Domain.py +0 -0
- {collibra_connector-1.0.19 → collibra_connector-1.1.0}/collibra_connector/api/Exceptions.py +0 -0
- {collibra_connector-1.0.19 → collibra_connector-1.1.0}/collibra_connector/api/Metadata.py +0 -0
- {collibra_connector-1.0.19 → collibra_connector-1.1.0}/collibra_connector/api/OutputModule.py +0 -0
- {collibra_connector-1.0.19 → collibra_connector-1.1.0}/collibra_connector/api/User.py +0 -0
- {collibra_connector-1.0.19 → collibra_connector-1.1.0}/collibra_connector/api/Utils.py +0 -0
- {collibra_connector-1.0.19 → collibra_connector-1.1.0}/collibra_connector/api/Workflow.py +0 -0
- {collibra_connector-1.0.19 → collibra_connector-1.1.0}/collibra_connector.egg-info/dependency_links.txt +0 -0
- {collibra_connector-1.0.19 → collibra_connector-1.1.0}/collibra_connector.egg-info/top_level.txt +0 -0
- {collibra_connector-1.0.19 → collibra_connector-1.1.0}/setup.cfg +0 -0
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: collibra-connector
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: An UNOFFICIAL standard Python connector for the Collibra Data Governance Center API with full type safety, async support, and enterprise features.
|
|
5
|
+
Author-email: Raul Dalgamonni <rauldalgamonnialonso@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/rauldaal/collibra-python-connector
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/rauldaal/collibra-python-connector/issues
|
|
8
|
+
Project-URL: Documentation, https://github.com/rauldaal/collibra-python-connector#readme
|
|
9
|
+
Project-URL: Changelog, https://github.com/rauldaal/collibra-python-connector/blob/main/CHANGELOG.md
|
|
10
|
+
Keywords: collibra,data-governance,data-catalog,api-client,data-lineage,metadata-management
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Classifier: Intended Audience :: Developers
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Classifier: Framework :: Pydantic :: 2
|
|
24
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
25
|
+
Requires-Python: >=3.8
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: requests>=2.20.0
|
|
29
|
+
Requires-Dist: pydantic>=2.0.0
|
|
30
|
+
Provides-Extra: async
|
|
31
|
+
Requires-Dist: httpx>=0.25.0; extra == "async"
|
|
32
|
+
Provides-Extra: cli
|
|
33
|
+
Requires-Dist: click>=8.0.0; extra == "cli"
|
|
34
|
+
Requires-Dist: pandas>=1.3.0; extra == "cli"
|
|
35
|
+
Provides-Extra: telemetry
|
|
36
|
+
Requires-Dist: opentelemetry-api>=1.20.0; extra == "telemetry"
|
|
37
|
+
Requires-Dist: opentelemetry-sdk>=1.20.0; extra == "telemetry"
|
|
38
|
+
Requires-Dist: opentelemetry-exporter-otlp>=1.20.0; extra == "telemetry"
|
|
39
|
+
Provides-Extra: pandas
|
|
40
|
+
Requires-Dist: pandas>=1.3.0; extra == "pandas"
|
|
41
|
+
Provides-Extra: all
|
|
42
|
+
Requires-Dist: httpx>=0.25.0; extra == "all"
|
|
43
|
+
Requires-Dist: click>=8.0.0; extra == "all"
|
|
44
|
+
Requires-Dist: pandas>=1.3.0; extra == "all"
|
|
45
|
+
Requires-Dist: opentelemetry-api>=1.20.0; extra == "all"
|
|
46
|
+
Requires-Dist: opentelemetry-sdk>=1.20.0; extra == "all"
|
|
47
|
+
Requires-Dist: opentelemetry-exporter-otlp>=1.20.0; extra == "all"
|
|
48
|
+
Provides-Extra: dev
|
|
49
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
50
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
51
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
52
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
53
|
+
Requires-Dist: types-requests>=2.28.0; extra == "dev"
|
|
54
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
55
|
+
Requires-Dist: httpx>=0.25.0; extra == "dev"
|
|
56
|
+
Requires-Dist: click>=8.0.0; extra == "dev"
|
|
57
|
+
Requires-Dist: pandas>=1.3.0; extra == "dev"
|
|
58
|
+
Dynamic: license-file
|
|
59
|
+
|
|
60
|
+
# Collibra Python Connector
|
|
61
|
+
|
|
62
|
+
[](https://badge.fury.io/py/collibra-connector)
|
|
63
|
+
[](https://www.python.org/downloads/)
|
|
64
|
+
[](https://opensource.org/licenses/MIT)
|
|
65
|
+
[](https://www.python.org/dev/peps/pep-0561/)
|
|
66
|
+
|
|
67
|
+
An **UNOFFICIAL** comprehensive Python connector for the Collibra Data Governance Center API.
|
|
68
|
+
|
|
69
|
+
## Features
|
|
70
|
+
|
|
71
|
+
- **Complete API Coverage**: Asset, Community, Domain, User, Responsibility, Workflow, Metadata, Comment, Relation, and Output Module management
|
|
72
|
+
- **Automatic Retry Logic**: Built-in retry mechanism with exponential backoff for transient errors
|
|
73
|
+
- **Context Manager Support**: Use `with` statement for automatic session management and connection pooling
|
|
74
|
+
- **Pagination Helpers**: Easy iteration over large datasets without memory issues
|
|
75
|
+
- **Batch Processing**: Process bulk operations efficiently with rate limiting
|
|
76
|
+
- **Metadata Caching**: Thread-safe cache for frequently accessed metadata (UUIDs, types, statuses)
|
|
77
|
+
- **Input Validation**: Comprehensive parameter validation with clear error messages
|
|
78
|
+
- **Type Hints**: Full type annotations for better IDE support and static analysis
|
|
79
|
+
- **Custom Exceptions**: Structured exception hierarchy for precise error handling
|
|
80
|
+
|
|
81
|
+
## Installation
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pip install collibra-connector
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
For development with testing tools:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
pip install collibra-connector[dev]
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Quick Start
|
|
94
|
+
|
|
95
|
+
### Basic Usage
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
from collibra_connector import CollibraConnector
|
|
99
|
+
|
|
100
|
+
# Initialize the connector
|
|
101
|
+
connector = CollibraConnector(
|
|
102
|
+
api="https://your-collibra-instance.com",
|
|
103
|
+
username="your-username",
|
|
104
|
+
password="your-password",
|
|
105
|
+
timeout=30, # Request timeout in seconds
|
|
106
|
+
max_retries=3, # Number of retry attempts
|
|
107
|
+
retry_delay=1.0 # Base delay between retries
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
# Test connection
|
|
111
|
+
if connector.test_connection():
|
|
112
|
+
print("Connected successfully!")
|
|
113
|
+
|
|
114
|
+
# Find communities
|
|
115
|
+
communities = connector.community.find_communities(limit=10)
|
|
116
|
+
for community in communities.get("results", []):
|
|
117
|
+
print(f"Community: {community['name']}")
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Using Context Manager (Recommended)
|
|
121
|
+
|
|
122
|
+
The context manager provides automatic session management and connection pooling:
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
from collibra_connector import CollibraConnector
|
|
126
|
+
|
|
127
|
+
with CollibraConnector(
|
|
128
|
+
api="https://your-collibra-instance.com",
|
|
129
|
+
username="your-username",
|
|
130
|
+
password="your-password"
|
|
131
|
+
) as connector:
|
|
132
|
+
# Session is automatically managed
|
|
133
|
+
communities = connector.community.find_communities()
|
|
134
|
+
assets = connector.asset.find_assets(limit=100)
|
|
135
|
+
|
|
136
|
+
# Session is automatically closed
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Environment Variables Pattern
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
import os
|
|
143
|
+
from collibra_connector import CollibraConnector
|
|
144
|
+
|
|
145
|
+
connector = CollibraConnector(
|
|
146
|
+
api=os.environ["COLLIBRA_URL"],
|
|
147
|
+
username=os.environ["COLLIBRA_USERNAME"],
|
|
148
|
+
password=os.environ["COLLIBRA_PASSWORD"]
|
|
149
|
+
)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## API Reference
|
|
153
|
+
|
|
154
|
+
### Assets
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
# Get an asset by ID
|
|
158
|
+
asset = connector.asset.get_asset("asset-uuid")
|
|
159
|
+
|
|
160
|
+
# Create an asset
|
|
161
|
+
new_asset = connector.asset.add_asset(
|
|
162
|
+
name="My New Asset",
|
|
163
|
+
domain_id="domain-uuid",
|
|
164
|
+
display_name="My Asset Display Name",
|
|
165
|
+
type_id="asset-type-uuid",
|
|
166
|
+
status_id="status-uuid" # Optional
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
# Update an asset
|
|
170
|
+
updated = connector.asset.change_asset(
|
|
171
|
+
asset_id="asset-uuid",
|
|
172
|
+
name="Updated Name",
|
|
173
|
+
display_name="Updated Display Name"
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
# Find assets with filters
|
|
177
|
+
assets = connector.asset.find_assets(
|
|
178
|
+
community_id="community-uuid",
|
|
179
|
+
domain_id="domain-uuid",
|
|
180
|
+
asset_type_ids=["type-uuid-1", "type-uuid-2"],
|
|
181
|
+
limit=1000
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
# Set asset attributes
|
|
185
|
+
connector.asset.set_asset_attributes(
|
|
186
|
+
asset_id="asset-uuid",
|
|
187
|
+
type_id="attribute-type-uuid",
|
|
188
|
+
values=["value1", "value2"]
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
# Set asset relations
|
|
192
|
+
connector.asset.set_asset_relations(
|
|
193
|
+
asset_id="asset-uuid",
|
|
194
|
+
related_asset_ids=["related-uuid-1", "related-uuid-2"],
|
|
195
|
+
relation_direction="TO_TARGET",
|
|
196
|
+
type_id="relation-type-uuid"
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
# Remove an asset
|
|
200
|
+
connector.asset.remove_asset("asset-uuid")
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Communities
|
|
204
|
+
|
|
205
|
+
```python
|
|
206
|
+
# Get a community
|
|
207
|
+
community = connector.community.get_community("community-uuid")
|
|
208
|
+
|
|
209
|
+
# Find communities with filters
|
|
210
|
+
communities = connector.community.find_communities(
|
|
211
|
+
name="Search Term",
|
|
212
|
+
name_match_mode="ANYWHERE", # START, END, ANYWHERE, EXACT
|
|
213
|
+
parent_id="parent-community-uuid",
|
|
214
|
+
sort_field="NAME",
|
|
215
|
+
sort_order="ASC",
|
|
216
|
+
limit=100
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
# Create a community
|
|
220
|
+
new_community = connector.community.add_community(
|
|
221
|
+
name="My New Community",
|
|
222
|
+
description="Community description",
|
|
223
|
+
parent_id="parent-community-uuid" # Optional
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
# Update a community
|
|
227
|
+
connector.community.change_community(
|
|
228
|
+
community_id="community-uuid",
|
|
229
|
+
name="Updated Name",
|
|
230
|
+
description="Updated description"
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
# Remove a community
|
|
234
|
+
connector.community.remove_community("community-uuid")
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Domains
|
|
238
|
+
|
|
239
|
+
```python
|
|
240
|
+
# Get a domain
|
|
241
|
+
domain = connector.domain.get_domain("domain-uuid")
|
|
242
|
+
|
|
243
|
+
# Find domains
|
|
244
|
+
domains = connector.domain.find_domains(
|
|
245
|
+
community_id="community-uuid",
|
|
246
|
+
name="Search Term",
|
|
247
|
+
type_id="domain-type-uuid",
|
|
248
|
+
include_sub_communities=True,
|
|
249
|
+
limit=100
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
# Create a domain
|
|
253
|
+
new_domain = connector.domain.add_domain(
|
|
254
|
+
name="My New Domain",
|
|
255
|
+
community_id="community-uuid",
|
|
256
|
+
type_id="domain-type-uuid",
|
|
257
|
+
description="Domain description"
|
|
258
|
+
)
|
|
259
|
+
|
|
260
|
+
# Update a domain
|
|
261
|
+
connector.domain.change_domain(
|
|
262
|
+
domain_id="domain-uuid",
|
|
263
|
+
name="Updated Name"
|
|
264
|
+
)
|
|
265
|
+
|
|
266
|
+
# Remove a domain
|
|
267
|
+
connector.domain.remove_domain("domain-uuid")
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Users
|
|
271
|
+
|
|
272
|
+
```python
|
|
273
|
+
# Get user by ID
|
|
274
|
+
user = connector.user.get_user("user-uuid")
|
|
275
|
+
|
|
276
|
+
# Get user by username (convenience method)
|
|
277
|
+
user_id = connector.user.get_user_by_username("john.doe")
|
|
278
|
+
|
|
279
|
+
# Find users
|
|
280
|
+
users = connector.user.find_users(
|
|
281
|
+
name="John",
|
|
282
|
+
name_search_fields=["USERNAME", "FIRSTNAME", "LASTNAME"],
|
|
283
|
+
include_disabled=False,
|
|
284
|
+
sort_field="USERNAME",
|
|
285
|
+
limit=50
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
# Create a user
|
|
289
|
+
new_user = connector.user.create_user(
|
|
290
|
+
username="newuser",
|
|
291
|
+
email_address="newuser@example.com"
|
|
292
|
+
)
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Workflows
|
|
296
|
+
|
|
297
|
+
```python
|
|
298
|
+
# Start a workflow
|
|
299
|
+
workflow = connector.workflow.start_workflow(
|
|
300
|
+
workflow_definition_id="workflow-def-uuid",
|
|
301
|
+
asset_ids=["asset-uuid-1", "asset-uuid-2"]
|
|
302
|
+
)
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## Helper Utilities
|
|
306
|
+
|
|
307
|
+
### Pagination
|
|
308
|
+
|
|
309
|
+
Efficiently iterate over large datasets:
|
|
310
|
+
|
|
311
|
+
```python
|
|
312
|
+
from collibra_connector import CollibraConnector, Paginator
|
|
313
|
+
|
|
314
|
+
connector = CollibraConnector(...)
|
|
315
|
+
|
|
316
|
+
# Iterate over all assets (memory-efficient)
|
|
317
|
+
paginator = Paginator(
|
|
318
|
+
connector.asset.find_assets,
|
|
319
|
+
limit=100, # Items per page
|
|
320
|
+
max_items=10000 # Optional: stop after N items
|
|
321
|
+
)
|
|
322
|
+
|
|
323
|
+
# Iterate item by item
|
|
324
|
+
for asset in paginator.items():
|
|
325
|
+
print(asset['name'])
|
|
326
|
+
|
|
327
|
+
# Or iterate page by page
|
|
328
|
+
for page in paginator.pages():
|
|
329
|
+
print(f"Processing {len(page)} assets")
|
|
330
|
+
for asset in page:
|
|
331
|
+
process(asset)
|
|
332
|
+
|
|
333
|
+
# Collect all items (loads into memory)
|
|
334
|
+
all_assets = paginator.collect()
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### Batch Processing
|
|
338
|
+
|
|
339
|
+
Process bulk operations with rate limiting:
|
|
340
|
+
|
|
341
|
+
```python
|
|
342
|
+
from collibra_connector import CollibraConnector, BatchProcessor
|
|
343
|
+
|
|
344
|
+
connector = CollibraConnector(...)
|
|
345
|
+
|
|
346
|
+
# Prepare data
|
|
347
|
+
assets_to_create = [
|
|
348
|
+
{"name": "Asset 1", "domain_id": "domain-uuid"},
|
|
349
|
+
{"name": "Asset 2", "domain_id": "domain-uuid"},
|
|
350
|
+
# ... more assets
|
|
351
|
+
]
|
|
352
|
+
|
|
353
|
+
# Process in batches
|
|
354
|
+
processor = BatchProcessor(
|
|
355
|
+
batch_size=50, # Items per batch
|
|
356
|
+
delay=0.1, # Delay between batches (seconds)
|
|
357
|
+
on_error="continue" # "continue", "stop", or "collect"
|
|
358
|
+
)
|
|
359
|
+
|
|
360
|
+
result = processor.process(
|
|
361
|
+
items=assets_to_create,
|
|
362
|
+
operation=connector.asset.add_asset,
|
|
363
|
+
item_mapper=lambda a: {"name": a["name"], "domain_id": a["domain_id"]},
|
|
364
|
+
progress_callback=lambda done, total: print(f"Progress: {done}/{total}")
|
|
365
|
+
)
|
|
366
|
+
|
|
367
|
+
print(f"Success: {result.success_count}, Errors: {result.error_count}")
|
|
368
|
+
print(f"Success rate: {result.success_rate:.1f}%")
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### Metadata Caching
|
|
372
|
+
|
|
373
|
+
Cache frequently accessed metadata to reduce API calls:
|
|
374
|
+
|
|
375
|
+
```python
|
|
376
|
+
from collibra_connector import CollibraConnector, CachedMetadata
|
|
377
|
+
|
|
378
|
+
connector = CollibraConnector(...)
|
|
379
|
+
|
|
380
|
+
# Create cache with 1-hour TTL
|
|
381
|
+
cache = CachedMetadata(connector, ttl=3600)
|
|
382
|
+
|
|
383
|
+
# Get UUIDs by name (cached after first call)
|
|
384
|
+
asset_type_id = cache.get_asset_type_id("Business Term")
|
|
385
|
+
status_id = cache.get_status_id("Approved")
|
|
386
|
+
attribute_type_id = cache.get_attribute_type_id("Description")
|
|
387
|
+
domain_type_id = cache.get_domain_type_id("Physical Data Dictionary")
|
|
388
|
+
role_id = cache.get_role_id("Owner")
|
|
389
|
+
|
|
390
|
+
# Force refresh if needed
|
|
391
|
+
cache.refresh_all()
|
|
392
|
+
|
|
393
|
+
# Clear cache
|
|
394
|
+
cache.clear()
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
### Data Transformation
|
|
398
|
+
|
|
399
|
+
Utilities for transforming API responses:
|
|
400
|
+
|
|
401
|
+
```python
|
|
402
|
+
from collibra_connector import DataTransformer
|
|
403
|
+
|
|
404
|
+
# Extract IDs from results
|
|
405
|
+
assets = connector.asset.find_assets()
|
|
406
|
+
asset_ids = DataTransformer.extract_ids(assets["results"])
|
|
407
|
+
|
|
408
|
+
# Create name->ID mapping
|
|
409
|
+
communities = connector.community.find_communities()
|
|
410
|
+
name_to_id = DataTransformer.to_name_id_map(communities["results"])
|
|
411
|
+
community_id = name_to_id.get("My Community")
|
|
412
|
+
|
|
413
|
+
# Group items by a field
|
|
414
|
+
grouped = DataTransformer.group_by(assets["results"], "type.name")
|
|
415
|
+
for type_name, items in grouped.items():
|
|
416
|
+
print(f"{type_name}: {len(items)} assets")
|
|
417
|
+
|
|
418
|
+
# Flatten nested asset structure
|
|
419
|
+
flat_asset = DataTransformer.flatten_asset(asset)
|
|
420
|
+
print(flat_asset["type.name"]) # Access nested values with dot notation
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
## Error Handling
|
|
424
|
+
|
|
425
|
+
The library provides a custom exception hierarchy:
|
|
426
|
+
|
|
427
|
+
```python
|
|
428
|
+
from collibra_connector import (
|
|
429
|
+
CollibraConnector,
|
|
430
|
+
CollibraAPIError,
|
|
431
|
+
UnauthorizedError,
|
|
432
|
+
ForbiddenError,
|
|
433
|
+
NotFoundError,
|
|
434
|
+
ServerError
|
|
435
|
+
)
|
|
436
|
+
|
|
437
|
+
connector = CollibraConnector(...)
|
|
438
|
+
|
|
439
|
+
try:
|
|
440
|
+
asset = connector.asset.get_asset("invalid-uuid")
|
|
441
|
+
except UnauthorizedError:
|
|
442
|
+
print("Invalid credentials")
|
|
443
|
+
except ForbiddenError:
|
|
444
|
+
print("Insufficient permissions")
|
|
445
|
+
except NotFoundError:
|
|
446
|
+
print("Asset not found")
|
|
447
|
+
except ServerError:
|
|
448
|
+
print("Server error - try again later")
|
|
449
|
+
except CollibraAPIError as e:
|
|
450
|
+
print(f"API error: {e}")
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
## Retry Logic
|
|
454
|
+
|
|
455
|
+
The connector automatically retries on transient failures:
|
|
456
|
+
|
|
457
|
+
- **Connection errors**: Network issues, DNS failures
|
|
458
|
+
- **Timeouts**: Request timeouts
|
|
459
|
+
- **Server errors**: 500, 502, 503, 504 status codes
|
|
460
|
+
- **Rate limiting**: 429 status code
|
|
461
|
+
|
|
462
|
+
Configure retry behavior:
|
|
463
|
+
|
|
464
|
+
```python
|
|
465
|
+
connector = CollibraConnector(
|
|
466
|
+
api="https://your-instance.com",
|
|
467
|
+
username="user",
|
|
468
|
+
password="pass",
|
|
469
|
+
max_retries=5, # Number of retry attempts
|
|
470
|
+
retry_delay=2.0 # Base delay (uses exponential backoff)
|
|
471
|
+
)
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
## Configuration
|
|
475
|
+
|
|
476
|
+
### Timeouts
|
|
477
|
+
|
|
478
|
+
```python
|
|
479
|
+
# Set custom timeout (seconds)
|
|
480
|
+
connector = CollibraConnector(
|
|
481
|
+
api="...",
|
|
482
|
+
username="...",
|
|
483
|
+
password="...",
|
|
484
|
+
timeout=60 # 60 seconds
|
|
485
|
+
)
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
### Auto-load UUIDs
|
|
489
|
+
|
|
490
|
+
Load all metadata UUIDs on initialization:
|
|
491
|
+
|
|
492
|
+
```python
|
|
493
|
+
connector = CollibraConnector(
|
|
494
|
+
api="...",
|
|
495
|
+
username="...",
|
|
496
|
+
password="...",
|
|
497
|
+
uuids=True # Fetch all UUIDs on init
|
|
498
|
+
)
|
|
499
|
+
|
|
500
|
+
# Access cached UUIDs
|
|
501
|
+
asset_type_id = connector.uuids["AssetType"]["Business Term"]
|
|
502
|
+
status_id = connector.uuids["Status"]["Approved"]
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
## Requirements
|
|
506
|
+
|
|
507
|
+
- Python 3.8+
|
|
508
|
+
- requests >= 2.20.0
|
|
509
|
+
|
|
510
|
+
## Development
|
|
511
|
+
|
|
512
|
+
Install development dependencies:
|
|
513
|
+
|
|
514
|
+
```bash
|
|
515
|
+
pip install -e ".[dev]"
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
Run tests:
|
|
519
|
+
|
|
520
|
+
```bash
|
|
521
|
+
pytest tests/ -v
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
Run type checking:
|
|
525
|
+
|
|
526
|
+
```bash
|
|
527
|
+
mypy collibra_connector/
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
## License
|
|
531
|
+
|
|
532
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
533
|
+
|
|
534
|
+
## Disclaimer
|
|
535
|
+
|
|
536
|
+
This is an **UNOFFICIAL** connector and is not affiliated with, endorsed by, or supported by Collibra. Use at your own risk.
|
|
537
|
+
|
|
538
|
+
## Contributing
|
|
539
|
+
|
|
540
|
+
Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|