collibra-connector 1.0.9__tar.gz → 1.0.10a0__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.
Files changed (29) hide show
  1. collibra_connector-1.0.10a0/PKG-INFO +157 -0
  2. collibra_connector-1.0.10a0/README.md +139 -0
  3. collibra_connector-1.0.10a0/collibra_connector/api/Asset.py +272 -0
  4. collibra_connector-1.0.10a0/collibra_connector/api/Base.py +153 -0
  5. collibra_connector-1.0.10a0/collibra_connector/api/Comment.py +125 -0
  6. collibra_connector-1.0.10a0/collibra_connector/api/Community.py +112 -0
  7. collibra_connector-1.0.10a0/collibra_connector/api/Domain.py +116 -0
  8. {collibra_connector-1.0.9 → collibra_connector-1.0.10a0}/collibra_connector/api/Exceptions.py +0 -5
  9. collibra_connector-1.0.10a0/collibra_connector/api/Metadata.py +120 -0
  10. collibra_connector-1.0.10a0/collibra_connector/api/Responsibility.py +303 -0
  11. collibra_connector-1.0.10a0/collibra_connector/api/User.py +203 -0
  12. collibra_connector-1.0.10a0/collibra_connector/api/Workflow.py +260 -0
  13. collibra_connector-1.0.10a0/collibra_connector/api/__init__.py +16 -0
  14. {collibra_connector-1.0.9 → collibra_connector-1.0.10a0}/collibra_connector/connector.py +20 -1
  15. collibra_connector-1.0.10a0/collibra_connector.egg-info/PKG-INFO +157 -0
  16. {collibra_connector-1.0.9 → collibra_connector-1.0.10a0}/collibra_connector.egg-info/SOURCES.txt +7 -0
  17. {collibra_connector-1.0.9 → collibra_connector-1.0.10a0}/pyproject.toml +2 -2
  18. collibra_connector-1.0.9/PKG-INFO +0 -27
  19. collibra_connector-1.0.9/README.md +0 -9
  20. collibra_connector-1.0.9/collibra_connector/api/Asset.py +0 -102
  21. collibra_connector-1.0.9/collibra_connector/api/Base.py +0 -83
  22. collibra_connector-1.0.9/collibra_connector/api/__init__.py +0 -2
  23. collibra_connector-1.0.9/collibra_connector.egg-info/PKG-INFO +0 -27
  24. {collibra_connector-1.0.9 → collibra_connector-1.0.10a0}/LICENSE +0 -0
  25. {collibra_connector-1.0.9 → collibra_connector-1.0.10a0}/collibra_connector/__init__.py +0 -0
  26. {collibra_connector-1.0.9 → collibra_connector-1.0.10a0}/collibra_connector.egg-info/dependency_links.txt +0 -0
  27. {collibra_connector-1.0.9 → collibra_connector-1.0.10a0}/collibra_connector.egg-info/requires.txt +0 -0
  28. {collibra_connector-1.0.9 → collibra_connector-1.0.10a0}/collibra_connector.egg-info/top_level.txt +0 -0
  29. {collibra_connector-1.0.9 → collibra_connector-1.0.10a0}/setup.cfg +0 -0
@@ -0,0 +1,157 @@
1
+ Metadata-Version: 2.4
2
+ Name: collibra-connector
3
+ Version: 1.0.10a0
4
+ Summary: An UNOFFICIAL standard Python connector for the Collibra Data Governance Center API.
5
+ Author-email: Raül 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
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
12
+ Classifier: Intended Audience :: Developers
13
+ Requires-Python: >=3.8
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: requests>=2.20.0
17
+ Dynamic: license-file
18
+
19
+ # Collibra Python Connector
20
+
21
+ An **UNOFFICIAL** comprehensive Python connector for the Collibra Data Governance Center API.
22
+
23
+ ## Features
24
+
25
+ - 🚀 **Complete API Coverage**: Asset, Community, Domain, User, Responsibility, Workflow, Metadata, and Comment management
26
+ - 🔄 **Automatic Retry Logic**: Built-in retry mechanism for robust API calls
27
+ - ✅ **Input Validation**: Comprehensive parameter validation with clear error messages
28
+ - 🏗️ **Clean Architecture**: Well-structured, extensible codebase with separation of concerns
29
+ - 📝 **Type Hints**: Full type annotations for better IDE support
30
+ - 🛡️ **Error Handling**: Custom exception hierarchy for different error types
31
+ - 🔧 **Utility Functions**: Helper methods for complex operations and bulk operations
32
+
33
+ ## Installation
34
+
35
+ ```bash
36
+ pip install collibra-connector
37
+ ```
38
+
39
+ ## Quick Start
40
+
41
+ ```python
42
+ from collibra_connector import CollibraConnector
43
+
44
+ # Initialize the connector
45
+ connector = CollibraConnector(
46
+ api="https://your-collibra-instance.com",
47
+ username="your-username",
48
+ password="your-password",
49
+ timeout=30
50
+ )
51
+
52
+ # Test connection
53
+ if connector.test_connection():
54
+ print("Connected successfully!")
55
+
56
+ # Get all metadata
57
+ metadata = connector.metadata.get_collibra_metadata()
58
+ print(f"Found {len(metadata['AssetType'])} asset types")
59
+
60
+ # Find communities
61
+ communities = connector.community.find_communities()
62
+ for community in communities.get("results", []):
63
+ print(f"Community: {community['name']}")
64
+ ```
65
+
66
+ ## API Reference
67
+
68
+ ### Assets
69
+
70
+ ```python
71
+ # Get an asset
72
+ asset = connector.asset.get_asset("asset-uuid")
73
+
74
+ # Create an asset
75
+ new_asset = connector.asset.add_asset(
76
+ name="My New Asset",
77
+ domain_id="domain-uuid",
78
+ display_name="My Asset Display Name",
79
+ type_id="asset-type-uuid"
80
+ )
81
+
82
+ # Find assets
83
+ assets = connector.asset.find_assets(
84
+ community_id="community-uuid",
85
+ asset_type_ids=["type-uuid-1", "type-uuid-2"]
86
+ )
87
+ ```
88
+
89
+ ### Communities
90
+
91
+ ```python
92
+ # Get a community
93
+ community = connector.community.get_community("community-uuid")
94
+
95
+ # Find communities
96
+ communities = connector.community.find_communities()
97
+ ```
98
+
99
+ ### Domains
100
+
101
+ ```python
102
+ # Get a domain
103
+ domain = connector.domain.get_domain("domain-uuid")
104
+
105
+ # Create a domain
106
+ new_domain = connector.domain.create_domain(
107
+ name="My New Domain",
108
+ community_id="community-uuid"
109
+ )
110
+ ```
111
+
112
+ ### Users
113
+
114
+ ```python
115
+ # Get user by username
116
+ user_id = connector.user.get_user_by_username("username")
117
+
118
+ # Create a new user
119
+ new_user = connector.user.create_user(
120
+ username="newuser",
121
+ email_address="newuser@example.com"
122
+ )
123
+ ```
124
+
125
+ ### Complete Documentation
126
+
127
+ For comprehensive API documentation and examples, see the full README with all available methods for:
128
+ - Asset management (CRUD operations, attributes, activities)
129
+ - Community and Domain operations
130
+ - User management
131
+ - Responsibility assignments
132
+ - Workflow operations
133
+ - Comment management
134
+ - Metadata retrieval
135
+ - Utility functions for bulk operations
136
+
137
+ ## Error Handling
138
+
139
+ ```python
140
+ from collibra_connector.api.Exceptions import (
141
+ CollibraAPIError,
142
+ UnauthorizedError,
143
+ NotFoundError
144
+ )
145
+
146
+ try:
147
+ asset = connector.asset.get_asset("invalid-uuid")
148
+ except NotFoundError:
149
+ print("Asset not found")
150
+ except CollibraAPIError as e:
151
+ print(f"API error: {e}")
152
+ ```
153
+
154
+ ## Requirements
155
+
156
+ - Python 3.8+
157
+ - requests >= 2.20.0
@@ -0,0 +1,139 @@
1
+ # Collibra Python Connector
2
+
3
+ An **UNOFFICIAL** comprehensive Python connector for the Collibra Data Governance Center API.
4
+
5
+ ## Features
6
+
7
+ - 🚀 **Complete API Coverage**: Asset, Community, Domain, User, Responsibility, Workflow, Metadata, and Comment management
8
+ - 🔄 **Automatic Retry Logic**: Built-in retry mechanism for robust API calls
9
+ - ✅ **Input Validation**: Comprehensive parameter validation with clear error messages
10
+ - 🏗️ **Clean Architecture**: Well-structured, extensible codebase with separation of concerns
11
+ - 📝 **Type Hints**: Full type annotations for better IDE support
12
+ - 🛡️ **Error Handling**: Custom exception hierarchy for different error types
13
+ - 🔧 **Utility Functions**: Helper methods for complex operations and bulk operations
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ pip install collibra-connector
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ```python
24
+ from collibra_connector import CollibraConnector
25
+
26
+ # Initialize the connector
27
+ connector = CollibraConnector(
28
+ api="https://your-collibra-instance.com",
29
+ username="your-username",
30
+ password="your-password",
31
+ timeout=30
32
+ )
33
+
34
+ # Test connection
35
+ if connector.test_connection():
36
+ print("Connected successfully!")
37
+
38
+ # Get all metadata
39
+ metadata = connector.metadata.get_collibra_metadata()
40
+ print(f"Found {len(metadata['AssetType'])} asset types")
41
+
42
+ # Find communities
43
+ communities = connector.community.find_communities()
44
+ for community in communities.get("results", []):
45
+ print(f"Community: {community['name']}")
46
+ ```
47
+
48
+ ## API Reference
49
+
50
+ ### Assets
51
+
52
+ ```python
53
+ # Get an asset
54
+ asset = connector.asset.get_asset("asset-uuid")
55
+
56
+ # Create an asset
57
+ new_asset = connector.asset.add_asset(
58
+ name="My New Asset",
59
+ domain_id="domain-uuid",
60
+ display_name="My Asset Display Name",
61
+ type_id="asset-type-uuid"
62
+ )
63
+
64
+ # Find assets
65
+ assets = connector.asset.find_assets(
66
+ community_id="community-uuid",
67
+ asset_type_ids=["type-uuid-1", "type-uuid-2"]
68
+ )
69
+ ```
70
+
71
+ ### Communities
72
+
73
+ ```python
74
+ # Get a community
75
+ community = connector.community.get_community("community-uuid")
76
+
77
+ # Find communities
78
+ communities = connector.community.find_communities()
79
+ ```
80
+
81
+ ### Domains
82
+
83
+ ```python
84
+ # Get a domain
85
+ domain = connector.domain.get_domain("domain-uuid")
86
+
87
+ # Create a domain
88
+ new_domain = connector.domain.create_domain(
89
+ name="My New Domain",
90
+ community_id="community-uuid"
91
+ )
92
+ ```
93
+
94
+ ### Users
95
+
96
+ ```python
97
+ # Get user by username
98
+ user_id = connector.user.get_user_by_username("username")
99
+
100
+ # Create a new user
101
+ new_user = connector.user.create_user(
102
+ username="newuser",
103
+ email_address="newuser@example.com"
104
+ )
105
+ ```
106
+
107
+ ### Complete Documentation
108
+
109
+ For comprehensive API documentation and examples, see the full README with all available methods for:
110
+ - Asset management (CRUD operations, attributes, activities)
111
+ - Community and Domain operations
112
+ - User management
113
+ - Responsibility assignments
114
+ - Workflow operations
115
+ - Comment management
116
+ - Metadata retrieval
117
+ - Utility functions for bulk operations
118
+
119
+ ## Error Handling
120
+
121
+ ```python
122
+ from collibra_connector.api.Exceptions import (
123
+ CollibraAPIError,
124
+ UnauthorizedError,
125
+ NotFoundError
126
+ )
127
+
128
+ try:
129
+ asset = connector.asset.get_asset("invalid-uuid")
130
+ except NotFoundError:
131
+ print("Asset not found")
132
+ except CollibraAPIError as e:
133
+ print(f"API error: {e}")
134
+ ```
135
+
136
+ ## Requirements
137
+
138
+ - Python 3.8+
139
+ - requests >= 2.20.0
@@ -0,0 +1,272 @@
1
+ import uuid
2
+ from .Base import BaseAPI
3
+
4
+
5
+ class Asset(BaseAPI):
6
+ def __init__(self, connector):
7
+ super().__init__(connector)
8
+ self.__base_api = connector.api + "/assets"
9
+
10
+ def _get(self, url: str = None, params: dict = None, headers: dict = None):
11
+ """
12
+ Makes a GET request to the asset API.
13
+ :param url: The URL to send the GET request to.
14
+ :param params: Optional parameters to include in the GET request.
15
+ :param headers: Optional headers to include in the GET request.
16
+ :return: The response from the GET request.
17
+ """
18
+ return super()._get(self.__base_api if not url else url, params, headers)
19
+
20
+ def get_asset(self, asset_id):
21
+ """
22
+ Retrieves an asset by its ID.
23
+ :param asset_id: The ID of the asset to retrieve.
24
+ :return: Asset details.
25
+ """
26
+ response = self._get(url=f"{self.__base_api}/{asset_id}")
27
+ return self._handle_response(response)
28
+
29
+ def add_asset(
30
+ self,
31
+ name: str,
32
+ domain_id: str,
33
+ display_name: str = None,
34
+ type_id: str = None,
35
+ _id: str = None,
36
+ status_id: str = None,
37
+ excluded_from_auto_hyperlink: bool = False,
38
+ type_public_id: str = None,
39
+ ):
40
+ """
41
+ Adds a new asset.
42
+ :param name: The name of the asset.
43
+ :param domain_id: The ID of the domain to which the asset belongs.
44
+ :param display_name: Optional display name for the asset.
45
+ :param type_id: Optional type ID for the asset.
46
+ :param id: Optional ID for the asset.
47
+ :param status_id: Optional status ID for the asset.
48
+ :param excluded_from_auto_hyperlink: Whether the asset is excluded from auto hyperlinking.
49
+ :param type_public_id: Optional public ID for the asset type.
50
+ :return: Details of the created asset.
51
+ """
52
+ # Parameter type validation
53
+ if not name or not domain_id:
54
+ raise ValueError("Name and domain_id are required parameters.")
55
+ if not isinstance(excluded_from_auto_hyperlink, bool):
56
+ raise ValueError("excluded_from_auto_hyperlink must be a boolean value.")
57
+ if type_id and not isinstance(type_id, str):
58
+ raise ValueError("type_id must be a string if provided.")
59
+ if _id and not isinstance(_id, str):
60
+ raise ValueError("_id must be a string if provided.")
61
+ if status_id and not isinstance(status_id, str):
62
+ raise ValueError("status_id must be a string if provided.")
63
+ if type_public_id and not isinstance(type_public_id, str):
64
+ raise ValueError("type_public_id must be a string if provided.")
65
+
66
+ # Check Ids are UUIDS
67
+ if _id and self._uuid_validation(_id) is False:
68
+ raise ValueError("id must be a valid UUID.")
69
+ if domain_id and self._uuid_validation(domain_id) is False:
70
+ raise ValueError("domain_id must be a valid UUID.")
71
+ if type_id and self._uuid_validation(type_id) is False:
72
+ raise ValueError("type_id must be a valid UUID.")
73
+ if status_id and self._uuid_validation(status_id) is False:
74
+ raise ValueError("status_id must be a valid UUID.")
75
+
76
+ data = {
77
+ "name": name,
78
+ "domainId": domain_id,
79
+ "displayName": display_name,
80
+ "typeId": type_id,
81
+ "id": id,
82
+ "statusId": status_id,
83
+ "excludedFromAutoHyperlink": excluded_from_auto_hyperlink,
84
+ "typePublicId": type_public_id
85
+ }
86
+ response = self._post(url=self.__base_api, data=data)
87
+ return self._handle_response(response)
88
+
89
+ def update_asset_properties(
90
+ self,
91
+ asset_id: str,
92
+ name: str = None,
93
+ display_name: str = None,
94
+ type_id: str = None,
95
+ status_id: str = None,
96
+ domain_id: str = None,
97
+ excluded_from_auto_hyperlinking: bool = None,
98
+ type_public_id: str = None
99
+ ):
100
+ """
101
+ Update asset properties.
102
+ :param asset_id: The ID of the asset to update.
103
+ :param name: Optional new name for the asset.
104
+ :param display_name: Optional new display name.
105
+ :param type_id: Optional new type ID.
106
+ :param status_id: Optional new status ID.
107
+ :param domain_id: Optional new domain ID.
108
+ :param excluded_from_auto_hyperlinking: Optional auto-hyperlinking setting.
109
+ :param type_public_id: Optional new type public ID.
110
+ :return: Updated asset details.
111
+ """
112
+ if not asset_id:
113
+ raise ValueError("asset_id is required")
114
+ if not isinstance(asset_id, str):
115
+ raise ValueError("asset_id must be a string")
116
+
117
+ try:
118
+ uuid.UUID(asset_id)
119
+ except ValueError as exc:
120
+ raise ValueError("asset_id must be a valid UUID") from exc
121
+
122
+ # Validate UUID fields if provided
123
+ uuid_fields = [
124
+ ("type_id", type_id),
125
+ ("status_id", status_id),
126
+ ("domain_id", domain_id)
127
+ ]
128
+
129
+ for field_name, field_value in uuid_fields:
130
+ if field_value:
131
+ if not isinstance(field_value, str):
132
+ raise ValueError(f"{field_name} must be a string")
133
+ try:
134
+ uuid.UUID(field_value)
135
+ except ValueError as exc:
136
+ raise ValueError(f"{field_name} must be a valid UUID") from exc
137
+
138
+ data = {
139
+ "id": asset_id,
140
+ "name": name,
141
+ "displayName": display_name,
142
+ "typeId": type_id,
143
+ "statusId": status_id,
144
+ "domainId": domain_id,
145
+ "excludedFromAutoHyperlinking": excluded_from_auto_hyperlinking,
146
+ "typePublicId": type_public_id,
147
+ }
148
+
149
+ # Use PATCH method through requests directly since BaseAPI doesn't have _patch
150
+ import requests
151
+ response = requests.patch(
152
+ f"{self.__base_api}/{asset_id}",
153
+ auth=self.__connector.auth,
154
+ json=data,
155
+ headers=self.__header,
156
+ timeout=30
157
+ )
158
+
159
+ return self._handle_response(response)
160
+
161
+ def update_asset_attribute(self, asset_id: str, attribute_id: str, value):
162
+ """
163
+ Update an asset attribute.
164
+ :param asset_id: The ID of the asset.
165
+ :param attribute_id: The ID of the attribute type.
166
+ :param value: The new value for the attribute.
167
+ :return: The response from updating the attribute.
168
+ """
169
+ if not all([asset_id, attribute_id]):
170
+ raise ValueError("asset_id and attribute_id are required")
171
+
172
+ for param_name, param_value in [("asset_id", asset_id), ("attribute_id", attribute_id)]:
173
+ if not isinstance(param_value, str):
174
+ raise ValueError(f"{param_name} must be a string")
175
+ try:
176
+ uuid.UUID(param_value)
177
+ except ValueError as exc:
178
+ raise ValueError(f"{param_name} must be a valid UUID") from exc
179
+
180
+ data = {
181
+ "values": [value],
182
+ "typeId": attribute_id
183
+ }
184
+
185
+ # Use PUT method through requests directly since BaseAPI doesn't have _put
186
+ import requests
187
+ response = requests.put(
188
+ f"{self.__base_api}/{asset_id}/attributes",
189
+ auth=self.__connector.auth,
190
+ json=data,
191
+ headers=self.__header,
192
+ timeout=30
193
+ )
194
+
195
+ return self._handle_response(response)
196
+
197
+ def find_assets(
198
+ self,
199
+ community_id: str = None,
200
+ asset_type_ids: list = None,
201
+ domain_id: str = None,
202
+ limit: int = 1000
203
+ ):
204
+ """
205
+ Find assets with optional filters.
206
+ :param community_id: Optional community ID to filter by.
207
+ :param asset_type_ids: Optional list of asset type IDs to filter by.
208
+ :param domain_id: Optional domain ID to filter by.
209
+ :param limit: Maximum number of results per page.
210
+ :return: List of assets matching the criteria.
211
+ """
212
+ params = {"limit": limit}
213
+
214
+ if community_id:
215
+ if not isinstance(community_id, str):
216
+ raise ValueError("community_id must be a string")
217
+ try:
218
+ uuid.UUID(community_id)
219
+ except ValueError as exc:
220
+ raise ValueError("community_id must be a valid UUID") from exc
221
+ params["communityId"] = community_id
222
+
223
+ if asset_type_ids:
224
+ if not isinstance(asset_type_ids, list):
225
+ raise ValueError("asset_type_ids must be a list")
226
+ for type_id in asset_type_ids:
227
+ if not isinstance(type_id, str):
228
+ raise ValueError("All asset_type_ids must be strings")
229
+ try:
230
+ uuid.UUID(type_id)
231
+ except ValueError as exc:
232
+ raise ValueError("All asset_type_ids must be valid UUIDs") from exc
233
+ params["typeIds"] = asset_type_ids
234
+
235
+ if domain_id:
236
+ if not isinstance(domain_id, str):
237
+ raise ValueError("domain_id must be a string")
238
+ try:
239
+ uuid.UUID(domain_id)
240
+ except ValueError as exc:
241
+ raise ValueError("domain_id must be a valid UUID") from exc
242
+ params["domainId"] = domain_id
243
+
244
+ response = self._get(params=params)
245
+ return self._handle_response(response)
246
+
247
+ def get_asset_activities(self, asset_id: str, limit: int = 50):
248
+ """
249
+ Get activities for a specific asset.
250
+ :param asset_id: The ID of the asset.
251
+ :param limit: Maximum number of activities to retrieve.
252
+ :return: List of activities for the asset.
253
+ """
254
+ if not asset_id:
255
+ raise ValueError("asset_id is required")
256
+ if not isinstance(asset_id, str):
257
+ raise ValueError("asset_id must be a string")
258
+
259
+ try:
260
+ uuid.UUID(asset_id)
261
+ except ValueError as exc:
262
+ raise ValueError("asset_id must be a valid UUID") from exc
263
+
264
+ params = {
265
+ "contextId": asset_id,
266
+ "resourceTypes": ["Asset"],
267
+ "limit": limit
268
+ }
269
+
270
+ response = self._get(url=f"{self.__base_api}/activities", params=params)
271
+ result = self._handle_response(response)
272
+ return result.get("results", [])