collibra-connector 1.0.7__tar.gz → 1.0.9__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 (17) hide show
  1. {collibra_connector-1.0.7 → collibra_connector-1.0.9}/PKG-INFO +1 -1
  2. collibra_connector-1.0.9/collibra_connector/__init__.py +39 -0
  3. {collibra_connector-1.0.7 → collibra_connector-1.0.9}/collibra_connector/api/Asset.py +40 -11
  4. {collibra_connector-1.0.7 → collibra_connector-1.0.9}/collibra_connector/api/Base.py +19 -8
  5. {collibra_connector-1.0.7 → collibra_connector-1.0.9}/collibra_connector/api/Exceptions.py +5 -0
  6. {collibra_connector-1.0.7 → collibra_connector-1.0.9}/collibra_connector/connector.py +3 -2
  7. {collibra_connector-1.0.7 → collibra_connector-1.0.9}/collibra_connector.egg-info/PKG-INFO +1 -1
  8. {collibra_connector-1.0.7 → collibra_connector-1.0.9}/pyproject.toml +1 -1
  9. collibra_connector-1.0.7/collibra_connector/__init__.py +0 -39
  10. {collibra_connector-1.0.7 → collibra_connector-1.0.9}/LICENSE +0 -0
  11. {collibra_connector-1.0.7 → collibra_connector-1.0.9}/README.md +0 -0
  12. {collibra_connector-1.0.7 → collibra_connector-1.0.9}/collibra_connector/api/__init__.py +0 -0
  13. {collibra_connector-1.0.7 → collibra_connector-1.0.9}/collibra_connector.egg-info/SOURCES.txt +0 -0
  14. {collibra_connector-1.0.7 → collibra_connector-1.0.9}/collibra_connector.egg-info/dependency_links.txt +0 -0
  15. {collibra_connector-1.0.7 → collibra_connector-1.0.9}/collibra_connector.egg-info/requires.txt +0 -0
  16. {collibra_connector-1.0.7 → collibra_connector-1.0.9}/collibra_connector.egg-info/top_level.txt +0 -0
  17. {collibra_connector-1.0.7 → collibra_connector-1.0.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: collibra-connector
3
- Version: 1.0.7
3
+ Version: 1.0.9
4
4
  Summary: An UNOFICIAL 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,39 @@
1
+ #
2
+ #
3
+ # ███
4
+ # ██ ███ ███
5
+ # ████ ███
6
+ # ███ ████ ██ ███ ████
7
+ # ███ ████ ███ ███ ████
8
+ # ███ ███
9
+ # ███ ███
10
+ # ██████████████ ███ ███ ████████
11
+ # ███████████ █ ███ ██████
12
+ #
13
+ # ███ █████████████ ████████████ ███
14
+ # ███ █████████████ ████████████ ███
15
+ #
16
+ # ██████ █ █████████████
17
+ # ███████ ████ ███ ██████████████
18
+ # ████ ███
19
+ # ████ ███
20
+ # ███ ████ ███ ███ ████
21
+ # ██ ████ ██ ███ ██
22
+ # ████ ███
23
+ # ██ ███ ███
24
+ # █
25
+ #
26
+ #
27
+ """
28
+
29
+ Collibra Connector Library
30
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
31
+
32
+ Uses the Collibra API to connect and interact with Collibra's data governance platform.
33
+ This library provides a simple interface to handle connection and URLs
34
+
35
+ """
36
+
37
+ from .connector import CollibraConnector
38
+
39
+ __version__ = "0.1.0"
@@ -1,11 +1,13 @@
1
+ import uuid
1
2
  from .Base import BaseAPI
2
3
 
4
+
3
5
  class Asset(BaseAPI):
4
6
  def __init__(self, connector):
5
7
  super().__init__(connector)
6
8
  self.__base_api = connector.api + "/assets"
7
9
 
8
- def __get(self, url: str = None, params: dict = None, headers: dict = None):
10
+ def _get(self, url: str = None, params: dict = None, headers: dict = None):
9
11
  """
10
12
  Makes a GET request to the asset API.
11
13
  :param url: The URL to send the GET request to.
@@ -13,28 +15,31 @@ class Asset(BaseAPI):
13
15
  :param headers: Optional headers to include in the GET request.
14
16
  :return: The response from the GET request.
15
17
  """
16
- return super().__get(self.__base_api if not url else url, params, headers)
18
+ return super()._get(self.__base_api if not url else url, params, headers)
17
19
 
18
- def __post(self, url: str, data: dict):
20
+ def _post(self, url: str, data: dict):
19
21
  """
20
22
  Makes a POST request to the asset API.
21
23
  :param url: The URL to send the POST request to.
22
24
  :param data: The data to send in the POST request.
23
25
  :return: The response from the POST request.
24
26
  """
25
- return super().__post(url, data)
27
+ return super()._post(url, data)
28
+
29
+ def _handle_response(self, response):
30
+ return super()._handle_response(response)
31
+
32
+ def _uuid_validation(self, id):
33
+ return super()._uuid_validation(id)
26
34
 
27
- def __handle_response(self, response):
28
- return super().__handle_response(response)
29
-
30
35
  def get_asset(self, asset_id):
31
36
  """
32
37
  Retrieves an asset by its ID.
33
38
  :param asset_id: The ID of the asset to retrieve.
34
39
  :return: Asset details.
35
40
  """
36
- response = self.__get(url=f"{self.__base_api}/{asset_id}")
37
- return self.__handle_response(response)
41
+ response = self._get(url=f"{self.__base_api}/{asset_id}")
42
+ return self._handle_response(response)
38
43
 
39
44
  def add_asset(
40
45
  self,
@@ -59,6 +64,30 @@ class Asset(BaseAPI):
59
64
  :param type_public_id: Optional public ID for the asset type.
60
65
  :return: Details of the created asset.
61
66
  """
67
+ # Parameter type validation
68
+ if not name or not domain_id:
69
+ raise ValueError("Name and domain_id are required parameters.")
70
+ if not isinstance(excluded_from_auto_hyperlink, bool):
71
+ raise ValueError("excluded_from_auto_hyperlink must be a boolean value.")
72
+ if type_id and not isinstance(type_id, str):
73
+ raise ValueError("type_id must be a string if provided.")
74
+ if id and not isinstance(id, str):
75
+ raise ValueError("id must be a string if provided.")
76
+ if status_id and not isinstance(status_id, str):
77
+ raise ValueError("status_id must be a string if provided.")
78
+ if type_public_id and not isinstance(type_public_id, str):
79
+ raise ValueError("type_public_id must be a string if provided.")
80
+
81
+ # Check Ids are UUIDS
82
+ if id and self._uuid_validation(id) is False:
83
+ raise ValueError("id must be a valid UUID.")
84
+ if domain_id and self._uuid_validation(domain_id) is False:
85
+ raise ValueError("domain_id must be a valid UUID.")
86
+ if type_id and self._uuid_validation(type_id) is False:
87
+ raise ValueError("type_id must be a valid UUID.")
88
+ if status_id and self._uuid_validation(status_id) is False:
89
+ raise ValueError("status_id must be a valid UUID.")
90
+
62
91
  data = {
63
92
  "name": name,
64
93
  "domainId": domain_id,
@@ -69,5 +98,5 @@ class Asset(BaseAPI):
69
98
  "excludedFromAutoHyperlink": excluded_from_auto_hyperlink,
70
99
  "typePublicId": type_public_id
71
100
  }
72
- response = self.__post(url=self.__base_api, data=data)
73
- return self.__handle_response(response)
101
+ response = self._post(url=self.__base_api, data=data)
102
+ return self._handle_response(response)
@@ -1,3 +1,4 @@
1
+ import re
1
2
  import requests
2
3
  from .Exceptions import (
3
4
  UnauthorizedError,
@@ -6,6 +7,7 @@ from .Exceptions import (
6
7
  ServerError
7
8
  )
8
9
 
10
+
9
11
  class BaseAPI:
10
12
  def __init__(self, connector):
11
13
  self.__connector = connector
@@ -16,7 +18,7 @@ class BaseAPI:
16
18
  }
17
19
  self.__params = None
18
20
 
19
- def __get(self, url: str = None, params: dict = None, headers: dict = None):
21
+ def _get(self, url: str = None, params: dict = None, headers: dict = None):
20
22
  """
21
23
  Makes a GET request to the specified URL.
22
24
  :param url: The URL to send the GET request to.
@@ -34,7 +36,7 @@ class BaseAPI:
34
36
  headers=headers
35
37
  )
36
38
 
37
- def __post(self, url: str, data: dict, headers: dict = None):
39
+ def _post(self, url: str, data: dict, headers: dict = None):
38
40
  """
39
41
  Makes a POST request to the specified URL with the given data.
40
42
  :param url: The URL to send the POST request to.
@@ -51,10 +53,10 @@ class BaseAPI:
51
53
  url,
52
54
  auth=self.__connector.auth,
53
55
  json=data,
54
- headers=self.__header
56
+ headers=headers
55
57
  )
56
58
 
57
- def __handle_response(self, response):
59
+ def _handle_response(self, response):
58
60
  """
59
61
  Handles the response from the API.
60
62
  :param response: The response object from the API request.
@@ -63,10 +65,19 @@ class BaseAPI:
63
65
  if response.status_code == 200 or response.status_code == 201:
64
66
  return response.json()
65
67
  elif response.status_code == 401:
66
- raise UnauthorizedError("Unauthorized access - invalid credentials")
68
+ raise UnauthorizedError("Unauthorized access - invalid credentials" + response.text)
67
69
  elif response.status_code == 403:
68
- raise ForbiddenError("Forbidden access - insufficient permissions")
70
+ raise ForbiddenError("Forbidden access - insufficient permissions" + response.text)
69
71
  elif response.status_code == 404:
70
- raise NotFoundError("The specified resource was not found")
72
+ raise NotFoundError("The specified resource was not found" + response.text)
71
73
  elif response.status_code >= 500:
72
- raise ServerError("Internal server error - something went wrong on the server")
74
+ raise ServerError("Internal server error - something went wrong on the server" + response.text)
75
+
76
+ def _uuid_validation(self, id: str):
77
+ """
78
+ Validates if the provided ID is a valid UUID.
79
+ :param id: The ID to validate.
80
+ :return: True if the ID is a valid UUID, otherwise raises ValueError.
81
+ """
82
+ pattern = re.compile(r"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$")
83
+ return bool(pattern.match(id))
@@ -1,19 +1,24 @@
1
+
1
2
  class CollibraAPIError(Exception):
2
3
  """Base exception for Collibra API errors"""
3
4
  pass
4
5
 
6
+
5
7
  class UnauthorizedError(CollibraAPIError):
6
8
  """Raised when authentication fails"""
7
9
  pass
8
10
 
11
+
9
12
  class ForbiddenError(CollibraAPIError):
10
13
  """Raised when access is forbidden"""
11
14
  pass
12
15
 
16
+
13
17
  class NotFoundError(CollibraAPIError):
14
18
  """Raised when resource is not found"""
15
19
  pass
16
20
 
21
+
17
22
  class ServerError(CollibraAPIError):
18
23
  """Raised when server returns 5xx errors"""
19
24
  pass
@@ -4,6 +4,7 @@ from requests.auth import HTTPBasicAuth
4
4
 
5
5
  from .api import Asset
6
6
 
7
+
7
8
  class CollibraConnector():
8
9
  """
9
10
  This class is used to connect to the Collibra API.
@@ -35,7 +36,7 @@ class CollibraConnector():
35
36
  """Test the connection to Collibra API"""
36
37
  try:
37
38
  response = requests.get(
38
- f"{self.__api}/info",
39
+ f"{self.__api}/auth/sessions/current",
39
40
  auth=self.__auth,
40
41
  timeout=self.__timeout
41
42
  )
@@ -54,4 +55,4 @@ class CollibraConnector():
54
55
 
55
56
  @property
56
57
  def base_url(self):
57
- return self.__base_url
58
+ return self.__base_url
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: collibra-connector
3
- Version: 1.0.7
3
+ Version: 1.0.9
4
4
  Summary: An UNOFICIAL 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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "collibra-connector"
3
- version = "1.0.7"
3
+ version = "1.0.9"
4
4
  authors = [
5
5
  { name="Raül Dalgamonni", email="rauldalgamonnialonso@gmail.com"},
6
6
  ]
@@ -1,39 +0,0 @@
1
- #
2
- #
3
- # ███
4
- # ██ ███ ███
5
- # ████ ███
6
- # ███ ████ ██ ███ ████
7
- # ███ ████ ███ ███ ████
8
- # ███ ███
9
- # ███ ███
10
- # ██████████████ ███ ███ ████████
11
- # ███████████ █ ███ ██████
12
- #
13
- # ███ █████████████ ████████████ ███
14
- # ███ █████████████ ████████████ ███
15
- #
16
- # ██████ █ █████████████
17
- # ███████ ████ ███ ██████████████
18
- # ████ ███
19
- # ████ ███
20
- # ███ ████ ███ ███ ████
21
- # ██ ████ ██ ███ ██
22
- # ████ ███
23
- # ██ ███ ███
24
- # █
25
- #
26
- #
27
- """
28
-
29
- Collibra Connector Library
30
- ~~~~~~~~~~~~~~~~~~~~~~~~~~
31
-
32
- Uses the Collibra API to connect and interact with Collibra's data governance platform.
33
- This library provides a simple interface to handle connection and URLs
34
-
35
- """
36
-
37
- from .connector import CollibraConnector
38
-
39
- __version__ = "0.1.0"