collibra-connector 1.0.6__py3-none-any.whl → 1.0.7__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.
- collibra_connector/api/Asset.py +73 -0
- collibra_connector/api/Base.py +72 -0
- collibra_connector/api/Exceptions.py +19 -0
- collibra_connector/api/__init__.py +2 -0
- {collibra_connector-1.0.6.dist-info → collibra_connector-1.0.7.dist-info}/METADATA +2 -2
- collibra_connector-1.0.7.dist-info/RECORD +11 -0
- collibra_connector-1.0.6.dist-info/RECORD +0 -7
- {collibra_connector-1.0.6.dist-info → collibra_connector-1.0.7.dist-info}/WHEEL +0 -0
- {collibra_connector-1.0.6.dist-info → collibra_connector-1.0.7.dist-info}/licenses/LICENSE +0 -0
- {collibra_connector-1.0.6.dist-info → collibra_connector-1.0.7.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
from .Base import BaseAPI
|
|
2
|
+
|
|
3
|
+
class Asset(BaseAPI):
|
|
4
|
+
def __init__(self, connector):
|
|
5
|
+
super().__init__(connector)
|
|
6
|
+
self.__base_api = connector.api + "/assets"
|
|
7
|
+
|
|
8
|
+
def __get(self, url: str = None, params: dict = None, headers: dict = None):
|
|
9
|
+
"""
|
|
10
|
+
Makes a GET request to the asset API.
|
|
11
|
+
:param url: The URL to send the GET request to.
|
|
12
|
+
:param params: Optional parameters to include in the GET request.
|
|
13
|
+
:param headers: Optional headers to include in the GET request.
|
|
14
|
+
:return: The response from the GET request.
|
|
15
|
+
"""
|
|
16
|
+
return super().__get(self.__base_api if not url else url, params, headers)
|
|
17
|
+
|
|
18
|
+
def __post(self, url: str, data: dict):
|
|
19
|
+
"""
|
|
20
|
+
Makes a POST request to the asset API.
|
|
21
|
+
:param url: The URL to send the POST request to.
|
|
22
|
+
:param data: The data to send in the POST request.
|
|
23
|
+
:return: The response from the POST request.
|
|
24
|
+
"""
|
|
25
|
+
return super().__post(url, data)
|
|
26
|
+
|
|
27
|
+
def __handle_response(self, response):
|
|
28
|
+
return super().__handle_response(response)
|
|
29
|
+
|
|
30
|
+
def get_asset(self, asset_id):
|
|
31
|
+
"""
|
|
32
|
+
Retrieves an asset by its ID.
|
|
33
|
+
:param asset_id: The ID of the asset to retrieve.
|
|
34
|
+
:return: Asset details.
|
|
35
|
+
"""
|
|
36
|
+
response = self.__get(url=f"{self.__base_api}/{asset_id}")
|
|
37
|
+
return self.__handle_response(response)
|
|
38
|
+
|
|
39
|
+
def add_asset(
|
|
40
|
+
self,
|
|
41
|
+
name: str,
|
|
42
|
+
domain_id: str,
|
|
43
|
+
display_name: str = None,
|
|
44
|
+
type_id: str = None,
|
|
45
|
+
id: str = None,
|
|
46
|
+
status_id: str = None,
|
|
47
|
+
excluded_from_auto_hyperlink: bool = False,
|
|
48
|
+
type_public_id: str = None,
|
|
49
|
+
):
|
|
50
|
+
"""
|
|
51
|
+
Adds a new asset.
|
|
52
|
+
:param name: The name of the asset.
|
|
53
|
+
:param domain_id: The ID of the domain to which the asset belongs.
|
|
54
|
+
:param display_name: Optional display name for the asset.
|
|
55
|
+
:param type_id: Optional type ID for the asset.
|
|
56
|
+
:param id: Optional ID for the asset.
|
|
57
|
+
:param status_id: Optional status ID for the asset.
|
|
58
|
+
:param excluded_from_auto_hyperlink: Whether the asset is excluded from auto hyperlinking.
|
|
59
|
+
:param type_public_id: Optional public ID for the asset type.
|
|
60
|
+
:return: Details of the created asset.
|
|
61
|
+
"""
|
|
62
|
+
data = {
|
|
63
|
+
"name": name,
|
|
64
|
+
"domainId": domain_id,
|
|
65
|
+
"displayName": display_name,
|
|
66
|
+
"typeId": type_id,
|
|
67
|
+
"id": id,
|
|
68
|
+
"statusId": status_id,
|
|
69
|
+
"excludedFromAutoHyperlink": excluded_from_auto_hyperlink,
|
|
70
|
+
"typePublicId": type_public_id
|
|
71
|
+
}
|
|
72
|
+
response = self.__post(url=self.__base_api, data=data)
|
|
73
|
+
return self.__handle_response(response)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
from .Exceptions import (
|
|
3
|
+
UnauthorizedError,
|
|
4
|
+
ForbiddenError,
|
|
5
|
+
NotFoundError,
|
|
6
|
+
ServerError
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
class BaseAPI:
|
|
10
|
+
def __init__(self, connector):
|
|
11
|
+
self.__connector = connector
|
|
12
|
+
self.__base_api = connector.api
|
|
13
|
+
self.__header = {
|
|
14
|
+
"Content-Type": "application/json",
|
|
15
|
+
"Accept": "application/json"
|
|
16
|
+
}
|
|
17
|
+
self.__params = None
|
|
18
|
+
|
|
19
|
+
def __get(self, url: str = None, params: dict = None, headers: dict = None):
|
|
20
|
+
"""
|
|
21
|
+
Makes a GET request to the specified URL.
|
|
22
|
+
:param url: The URL to send the GET request to.
|
|
23
|
+
:param params: Optional parameters to include in the GET request.
|
|
24
|
+
:param headers: Optional headers to include in the GET request.
|
|
25
|
+
:return: The response from the GET request.
|
|
26
|
+
"""
|
|
27
|
+
url = self.__base_api if not url else url
|
|
28
|
+
headers = self.__header if not headers else headers
|
|
29
|
+
params = self.__params if not params else params
|
|
30
|
+
return requests.get(
|
|
31
|
+
url,
|
|
32
|
+
auth=self.__connector.auth,
|
|
33
|
+
params=params,
|
|
34
|
+
headers=headers
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
def __post(self, url: str, data: dict, headers: dict = None):
|
|
38
|
+
"""
|
|
39
|
+
Makes a POST request to the specified URL with the given data.
|
|
40
|
+
:param url: The URL to send the POST request to.
|
|
41
|
+
:param data: The data to send in the POST request.
|
|
42
|
+
:return: The response from the POST request.
|
|
43
|
+
"""
|
|
44
|
+
url = self.__base_api if not url else url
|
|
45
|
+
headers = self.__header if not headers else headers
|
|
46
|
+
if not isinstance(data, dict):
|
|
47
|
+
raise ValueError("Data must be a dictionary")
|
|
48
|
+
if not data:
|
|
49
|
+
raise ValueError("Data cannot be empty")
|
|
50
|
+
return requests.post(
|
|
51
|
+
url,
|
|
52
|
+
auth=self.__connector.auth,
|
|
53
|
+
json=data,
|
|
54
|
+
headers=self.__header
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
def __handle_response(self, response):
|
|
58
|
+
"""
|
|
59
|
+
Handles the response from the API.
|
|
60
|
+
:param response: The response object from the API request.
|
|
61
|
+
:return: The JSON content of the response if successful, otherwise raises an error.
|
|
62
|
+
"""
|
|
63
|
+
if response.status_code == 200 or response.status_code == 201:
|
|
64
|
+
return response.json()
|
|
65
|
+
elif response.status_code == 401:
|
|
66
|
+
raise UnauthorizedError("Unauthorized access - invalid credentials")
|
|
67
|
+
elif response.status_code == 403:
|
|
68
|
+
raise ForbiddenError("Forbidden access - insufficient permissions")
|
|
69
|
+
elif response.status_code == 404:
|
|
70
|
+
raise NotFoundError("The specified resource was not found")
|
|
71
|
+
elif response.status_code >= 500:
|
|
72
|
+
raise ServerError("Internal server error - something went wrong on the server")
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class CollibraAPIError(Exception):
|
|
2
|
+
"""Base exception for Collibra API errors"""
|
|
3
|
+
pass
|
|
4
|
+
|
|
5
|
+
class UnauthorizedError(CollibraAPIError):
|
|
6
|
+
"""Raised when authentication fails"""
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
class ForbiddenError(CollibraAPIError):
|
|
10
|
+
"""Raised when access is forbidden"""
|
|
11
|
+
pass
|
|
12
|
+
|
|
13
|
+
class NotFoundError(CollibraAPIError):
|
|
14
|
+
"""Raised when resource is not found"""
|
|
15
|
+
pass
|
|
16
|
+
|
|
17
|
+
class ServerError(CollibraAPIError):
|
|
18
|
+
"""Raised when server returns 5xx errors"""
|
|
19
|
+
pass
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: collibra-connector
|
|
3
|
-
Version: 1.0.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 1.0.7
|
|
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
|
|
7
7
|
Project-URL: Bug Tracker, https://github.com/rauldaal/collibra-python-connector
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
collibra_connector/__init__.py,sha256=qBiWD8_hxRjggbCZRd-mDJ0rN5jVBF-KTNqEAJHtkEY,1879
|
|
2
|
+
collibra_connector/connector.py,sha256=ejgLrPbbHHFm4PW6DI6DqKjZVr-ZBGBjq4TUPke9vAE,1668
|
|
3
|
+
collibra_connector/api/Asset.py,sha256=fBROJPuQsUn0A_m7SlQ-ImhcIMY_9Kq0QM-IOFBGG6A,2734
|
|
4
|
+
collibra_connector/api/Base.py,sha256=d0SOIZQv95-SSgJHD-gYcGf3pUNqth7U2LlLffEOFFw,2767
|
|
5
|
+
collibra_connector/api/Exceptions.py,sha256=cHmDByGx1UgLsVMbiS_vXVArRAmKUP1y3vgqu2cjCTo,469
|
|
6
|
+
collibra_connector/api/__init__.py,sha256=eXm8RTRE5dWlEcIGwVjFJKy07Ux4wvL1BtgWBj-5vng,51
|
|
7
|
+
collibra_connector-1.0.7.dist-info/licenses/LICENSE,sha256=6KmWWtAu_q58gerPlrnkgsmGM2l8j6Wc_VL0y4S_ip4,1079
|
|
8
|
+
collibra_connector-1.0.7.dist-info/METADATA,sha256=ixBDQs8mzOwBhLg5SgWYlajZUmXg2hpIhueM_ebWYpU,970
|
|
9
|
+
collibra_connector-1.0.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
+
collibra_connector-1.0.7.dist-info/top_level.txt,sha256=Vs-kR64zf__ebL2j3_AEx7rhO6xkwgmHUFRzxlQPgTQ,19
|
|
11
|
+
collibra_connector-1.0.7.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
collibra_connector/__init__.py,sha256=qBiWD8_hxRjggbCZRd-mDJ0rN5jVBF-KTNqEAJHtkEY,1879
|
|
2
|
-
collibra_connector/connector.py,sha256=ejgLrPbbHHFm4PW6DI6DqKjZVr-ZBGBjq4TUPke9vAE,1668
|
|
3
|
-
collibra_connector-1.0.6.dist-info/licenses/LICENSE,sha256=6KmWWtAu_q58gerPlrnkgsmGM2l8j6Wc_VL0y4S_ip4,1079
|
|
4
|
-
collibra_connector-1.0.6.dist-info/METADATA,sha256=CRni0wpuPu2VOIDtwj-XJgi8u6lEjQgXTxzvrUfTQK0,959
|
|
5
|
-
collibra_connector-1.0.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
6
|
-
collibra_connector-1.0.6.dist-info/top_level.txt,sha256=Vs-kR64zf__ebL2j3_AEx7rhO6xkwgmHUFRzxlQPgTQ,19
|
|
7
|
-
collibra_connector-1.0.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|