collibra-connector 1.0.10rc0__py3-none-any.whl → 1.0.12__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.
@@ -221,7 +221,7 @@ class Asset(BaseAPI):
221
221
  data = {
222
222
  "values": values
223
223
  }
224
-
224
+
225
225
  # Add type_id or type_public_id to the data
226
226
  if type_id:
227
227
  data["typeId"] = type_id
@@ -38,7 +38,7 @@ class BaseAPI:
38
38
  timeout=self.__connector.timeout
39
39
  )
40
40
 
41
- def _post(self, url: str, data: dict, headers: dict = None):
41
+ def _post(self, url: str, data: dict, headers: dict = None, params: dict = None):
42
42
  """
43
43
  Makes a POST request to the specified URL with the given data.
44
44
  :param url: The URL to send the POST request to.
@@ -56,6 +56,7 @@ class BaseAPI:
56
56
  auth=self.__connector.auth,
57
57
  json=data,
58
58
  headers=headers,
59
+ params=params,
59
60
  timeout=self.__connector.timeout
60
61
  )
61
62
 
@@ -112,7 +112,7 @@ class Domain(BaseAPI):
112
112
  if type_public_id is not None:
113
113
  params["typePublicId"] = type_public_id
114
114
 
115
- response = self._get(params=params)
115
+ response = self._get(url=self.__base_api, params=params)
116
116
  return self._handle_response(response)
117
117
 
118
118
  def add_domain(
@@ -72,8 +72,8 @@ class Metadata(BaseAPI):
72
72
  for domain in domains_data.get("results", []):
73
73
  metadata["Domain"][domain["name"]] = domain["id"]
74
74
  if (
75
- domains_data.get("offset", 0) + domains_data.get("limit", 0) >=
76
- domains_data.get("total", 0)
75
+ domains_data.get("offset", 0) + domains_data.get("limit", 0)
76
+ >= domains_data.get("total", 0)
77
77
  ):
78
78
  break
79
79
  domains_params["offset"] += domains_params["limit"]
@@ -0,0 +1,48 @@
1
+ import requests
2
+ from typing import Optional, Dict, Any
3
+ from .Base import BaseAPI
4
+
5
+
6
+ class OutputModule(BaseAPI):
7
+ """
8
+ Output Module API endpoints for Collibra DGC.
9
+ """
10
+ def __init__(self, connector):
11
+ super().__init__(connector)
12
+ self.__base_api = connector.api + "/outputModule"
13
+
14
+ def export_json(
15
+ self,
16
+ body: str,
17
+ validation_enabled: bool = False
18
+ ) -> Dict[Any, Any]:
19
+ """
20
+ Exports results in JSON format, returns the results immediately.
21
+
22
+ Performs an Output Module query and exports the returns results immediately in JSON format.
23
+
24
+ Please note that the ViewConfig/TableViewConfig's syntax validation is not executed by default.
25
+ DGC admin console settings may impact the execution of the query (especially in terms of timeout
26
+ and a limit on the number of results).
27
+
28
+ Args:
29
+ view_config (str): The JSON/YAML representation of ViewConfig/TableViewConfig
30
+ that describes the query to be performed.
31
+ validation_enabled (bool): Determines if the ViewConfig's syntax should be validated
32
+ (True) or not (False). Default value is False for backward
33
+ compatibility reasons but it is strongly advised to always
34
+ enable this validation.
35
+
36
+ Returns:
37
+ Dict[Any, Any]: The exported results in JSON format.
38
+
39
+ Raises:
40
+ requests.exceptions.RequestException: If the API request fails.
41
+ """
42
+ endpoint = f"{self.__base_api}/export/json"
43
+
44
+ headers = {
45
+ 'Content-Type': 'application/json'
46
+ }
47
+
48
+ return self._post(url=endpoint, data=body, headers=headers).json()
@@ -0,0 +1,103 @@
1
+ import re
2
+ import logging
3
+ from .Base import BaseAPI
4
+
5
+ logger = logging.getLogger(__name__)
6
+
7
+
8
+ class Utils(BaseAPI):
9
+ def __init__(self, connector):
10
+ super().__init__(connector)
11
+ self.__base_api = connector.api
12
+
13
+ def get_uuids(self):
14
+ """
15
+ Retrieves UUIDs of asset types, relation types, responsibilities, statuses, and attributes from Collibra,
16
+ returning a dictionary with names as keys and UUIDs as values. Relation type names are used.
17
+
18
+ Returns:
19
+ A dictionary containing dictionaries of named UUIDs for asset types, relation types,
20
+ responsibilities, statuses, and attributes.
21
+ """
22
+ metadata = {
23
+ "AssetType": {},
24
+ "Relation": {},
25
+ "Responsability": {},
26
+ "Status": {},
27
+ "Attribute": {},
28
+ "Community": {},
29
+ "Domain": {},
30
+ "DomainType": {},
31
+ }
32
+ try:
33
+ # Get Asset Type UUIDs
34
+ asset_types_url = f"{self.__base_api}/assetTypes"
35
+ asset_types_response = self._get(url=asset_types_url)
36
+ asset_types_data = self._handle_response(asset_types_response)
37
+ for asset_type in asset_types_data["results"]:
38
+ metadata["AssetType"][asset_type["name"]] = asset_type["id"]
39
+
40
+ # Get Relation Type UUIDs
41
+ relation_types_url = f"{self.__base_api}/relationTypes"
42
+ relation_types_response = self._get(url=relation_types_url)
43
+ relation_types_data = self._handle_response(relation_types_response)
44
+ for relation_type in relation_types_data["results"]:
45
+ source_name = re.sub(" ", "", relation_type["sourceType"]["name"])
46
+ target_name = re.sub(" ", "", relation_type["targetType"]["name"])
47
+ metadata["Relation"][f"{source_name}_{target_name}"] = relation_type["id"]
48
+
49
+ # Get Roles
50
+ resource_roles_url = f"{self.__base_api}/roles"
51
+ resource_roles_response = self._get(url=resource_roles_url)
52
+ resource_roles_data = self._handle_response(resource_roles_response)
53
+ for resource_role in resource_roles_data["results"]:
54
+ metadata["Responsability"][resource_role["name"]] = resource_role["id"]
55
+
56
+ # Get Status UUIDs
57
+ statuses_url = f"{self.__base_api}/statuses"
58
+ statuses_response = self._get(url=statuses_url)
59
+ statuses_data = self._handle_response(statuses_response)
60
+ for status in statuses_data["results"]:
61
+ metadata["Status"][status["name"]] = status["id"]
62
+
63
+ # Get Attribute UUIDs
64
+ attributes_url = f"{self.__base_api}/attributeTypes"
65
+ attributes_response = self._get(url=attributes_url)
66
+ attributes_data = self._handle_response(attributes_response)
67
+ for attribute in attributes_data["results"]:
68
+ metadata["Attribute"][attribute["name"]] = attribute["id"]
69
+
70
+ # Get Community UUIDs
71
+ communities_url = f"{self.__base_api}/communities"
72
+ communities_response = self._get(url=communities_url)
73
+ communities_data = self._handle_response(communities_response)
74
+ for community in communities_data["results"]:
75
+ metadata["Community"][community["name"]] = community["id"]
76
+
77
+ # Get Domain UUIDs
78
+ domains_url = f"{self.__base_api}/domains"
79
+ domains_params = {"limit": 1000, "offset": 0}
80
+ while True:
81
+ domains_response = self._get(url=domains_url, params=domains_params)
82
+ domains_data = self._handle_response(domains_response)
83
+ for domain in domains_data["results"]:
84
+ metadata["Domain"][domain["name"]] = domain["id"]
85
+ if domains_data.get("offset") + domains_data.get(
86
+ "limit"
87
+ ) >= domains_data.get("total"):
88
+ break
89
+ domains_params["offset"] += domains_params["limit"]
90
+
91
+ # Get Domain Type UUIDs
92
+ domain_types_url = f"{self.__base_api}/domainTypes"
93
+ domain_types_response = self._get(url=domain_types_url)
94
+ domain_types_data = self._handle_response(domain_types_response)
95
+ for domain_type in domain_types_data["results"]:
96
+ metadata["DomainType"][domain_type["name"]] = domain_type["id"]
97
+
98
+ logger.info("Collibra UUIDS fetched successfully")
99
+ return metadata
100
+
101
+ except (KeyError, ValueError, AttributeError) as e:
102
+ logger.error("Error fetching Collibra UUIDs: %s", e)
103
+ return None
@@ -1,13 +1,8 @@
1
1
  from .Asset import Asset
2
2
  from .Base import BaseAPI
3
3
  from .Community import Community
4
- from .Domain import Domain
5
- from .User import User
6
- from .Responsibility import Responsibility
7
- from .Workflow import Workflow
8
- from .Metadata import Metadata
9
4
  from .Comment import Comment
10
- from .Relation import Relation
5
+ from .Domain import Domain
11
6
  from .Exceptions import (
12
7
  CollibraAPIError,
13
8
  UnauthorizedError,
@@ -15,3 +10,10 @@ from .Exceptions import (
15
10
  NotFoundError,
16
11
  ServerError
17
12
  )
13
+ from .Metadata import Metadata
14
+ from .OutputModule import OutputModule
15
+ from .Relation import Relation
16
+ from .Responsibility import Responsibility
17
+ from .User import User
18
+ from .Utils import Utils
19
+ from .Workflow import Workflow
@@ -11,7 +11,9 @@ from .api import (
11
11
  Workflow,
12
12
  Metadata,
13
13
  Comment,
14
- Relation
14
+ Relation,
15
+ OutputModule,
16
+ Utils
15
17
  )
16
18
 
17
19
 
@@ -22,7 +24,7 @@ class CollibraConnector():
22
24
  The authentication is done using HTTP Basic Auth.
23
25
  """
24
26
 
25
- def __init__(self, api: str, username: str, password: str, timeout: int = 30):
27
+ def __init__(self, api: str, username: str, password: str, timeout: int = 30, **kwargs):
26
28
  """
27
29
  Initializes the CollibraConnector with API URL and authentication credentials.
28
30
  :param api: The API URL for Collibra.
@@ -44,6 +46,12 @@ class CollibraConnector():
44
46
  self.metadata = Metadata(self)
45
47
  self.comment = Comment(self)
46
48
  self.relation = Relation(self)
49
+ self.output_module = OutputModule(self)
50
+ self.utils = Utils(self)
51
+
52
+ self.uuids = {}
53
+ if kwargs.get('uuids'):
54
+ self.uuids = self.utils.get_uuids()
47
55
 
48
56
  logging.basicConfig(level=logging.INFO)
49
57
  self.logger = logging.getLogger(__name__)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: collibra-connector
3
- Version: 1.0.10rc0
3
+ Version: 1.0.12
4
4
  Summary: An UNOFFICIAL standard Python connector for the Collibra Data Governance Center API.
5
5
  Author-email: Raül Dalgamonni <rauldalgamonnialonso@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/rauldaal/collibra-python-connector
@@ -0,0 +1,21 @@
1
+ collibra_connector/__init__.py,sha256=vzF9epFfmdnFjOcr_qZhvfiN9Z0cIBB48xldnvIiKjo,1694
2
+ collibra_connector/connector.py,sha256=uBOFEAVIE-v6Zkb9-SwFCFcaeJESStOOFZdI2iy20gw,2449
3
+ collibra_connector/api/Asset.py,sha256=aPhnsRxzdGGFtaytpLueDgMrELMpIs4cuOJoc2DR-p4,17927
4
+ collibra_connector/api/Base.py,sha256=2gHpieP8N_PK-R63zUv38Wpdfqdw9tHcH59hlXUZOWM,5929
5
+ collibra_connector/api/Comment.py,sha256=4ZzXiKj3pDOw_JRhfrUj-gcF8nZVdW_z7X2jJnq7LcU,4994
6
+ collibra_connector/api/Community.py,sha256=kM4j0LGYCXQygOZ4zHuu10JzJzvXtbUDz9litzKeKUI,12132
7
+ collibra_connector/api/Domain.py,sha256=U0i103g1WceCn9qAFUWDLgeXrtOvfBqX3vMCn4sQqRE,13012
8
+ collibra_connector/api/Exceptions.py,sha256=lX8yU3BnlOiWWifIBKlZdXVZaTI5pvtbrffyDtEUtoc,429
9
+ collibra_connector/api/Metadata.py,sha256=4uzb4vnZuMOg_ISCEnCfmAEVbsIcuD4FvupDlcxrfT4,5213
10
+ collibra_connector/api/OutputModule.py,sha256=97TzIbeoC5V63x5fi5fEcGfviUydwKwJC3NobLuNF5w,1791
11
+ collibra_connector/api/Relation.py,sha256=Hw0PlAQrU2Zv-RAbvHZhZpZb2_m6uDWngx2ySwo_mv0,8079
12
+ collibra_connector/api/Responsibility.py,sha256=PJu1Pe1u8mKzgpGGjzHtZNfRTfpgWWbaQn5bSifZOMo,14123
13
+ collibra_connector/api/User.py,sha256=nPl8q6l-H8hq2sR7gLelXq09jl3QRWFzI_WU3OUIHhQ,7755
14
+ collibra_connector/api/Utils.py,sha256=F8ZWrW8urzDX8QfiL16kWRnBYGRiLqeKUbYXlQpXNiM,4674
15
+ collibra_connector/api/Workflow.py,sha256=rsD9mPut69eEy35TNGf2mUKTrgWUmoakgnsXa85XzNY,10417
16
+ collibra_connector/api/__init__.py,sha256=yBJcKzcRraE-UYbBviisbdvQ1asFBnud5Vo1oJcCv_w,491
17
+ collibra_connector-1.0.12.dist-info/licenses/LICENSE,sha256=6KmWWtAu_q58gerPlrnkgsmGM2l8j6Wc_VL0y4S_ip4,1079
18
+ collibra_connector-1.0.12.dist-info/METADATA,sha256=blUOj_pN5Pm-6kJw3YLTWegVLRldgHbj4AAGMp_TNhk,4081
19
+ collibra_connector-1.0.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
+ collibra_connector-1.0.12.dist-info/top_level.txt,sha256=Vs-kR64zf__ebL2j3_AEx7rhO6xkwgmHUFRzxlQPgTQ,19
21
+ collibra_connector-1.0.12.dist-info/RECORD,,
@@ -1,19 +0,0 @@
1
- collibra_connector/__init__.py,sha256=vzF9epFfmdnFjOcr_qZhvfiN9Z0cIBB48xldnvIiKjo,1694
2
- collibra_connector/connector.py,sha256=oNN8WCI1TI6ffSEfl6_SX7SdrznwA5UeN7U13m-O_hU,2224
3
- collibra_connector/api/Asset.py,sha256=uGv5S0jPJ8gTeZCh4AcmttLKW0gXk8yeROM3MdeCD6w,17935
4
- collibra_connector/api/Base.py,sha256=8sYTPrIlHZP8smfYKl2rWSL63aKqHrtFca_M6gEOVns,5881
5
- collibra_connector/api/Comment.py,sha256=4ZzXiKj3pDOw_JRhfrUj-gcF8nZVdW_z7X2jJnq7LcU,4994
6
- collibra_connector/api/Community.py,sha256=kM4j0LGYCXQygOZ4zHuu10JzJzvXtbUDz9litzKeKUI,12132
7
- collibra_connector/api/Domain.py,sha256=tNqqNiATjiAiPe_lfWebO_8vxtmr3fFds8sd-hy_eD4,12991
8
- collibra_connector/api/Exceptions.py,sha256=lX8yU3BnlOiWWifIBKlZdXVZaTI5pvtbrffyDtEUtoc,429
9
- collibra_connector/api/Metadata.py,sha256=lOVXu0pcHSZNhInb4nR4q7lBB1MwtRuoL4Qb-2sr8aI,5213
10
- collibra_connector/api/Relation.py,sha256=Hw0PlAQrU2Zv-RAbvHZhZpZb2_m6uDWngx2ySwo_mv0,8079
11
- collibra_connector/api/Responsibility.py,sha256=PJu1Pe1u8mKzgpGGjzHtZNfRTfpgWWbaQn5bSifZOMo,14123
12
- collibra_connector/api/User.py,sha256=nPl8q6l-H8hq2sR7gLelXq09jl3QRWFzI_WU3OUIHhQ,7755
13
- collibra_connector/api/Workflow.py,sha256=rsD9mPut69eEy35TNGf2mUKTrgWUmoakgnsXa85XzNY,10417
14
- collibra_connector/api/__init__.py,sha256=WTeTeK4LS2fQXcNyAg3yKjlf2jTbLnaOusNRZItQPWM,427
15
- collibra_connector-1.0.10rc0.dist-info/licenses/LICENSE,sha256=6KmWWtAu_q58gerPlrnkgsmGM2l8j6Wc_VL0y4S_ip4,1079
16
- collibra_connector-1.0.10rc0.dist-info/METADATA,sha256=NU4lLlGO1ao73yx8YiJZYbeaJ1Cy3aZyL4omFpy7kzI,4084
17
- collibra_connector-1.0.10rc0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
18
- collibra_connector-1.0.10rc0.dist-info/top_level.txt,sha256=Vs-kR64zf__ebL2j3_AEx7rhO6xkwgmHUFRzxlQPgTQ,19
19
- collibra_connector-1.0.10rc0.dist-info/RECORD,,