diff --git a/src/datapilot/clients/altimate/client.py b/src/datapilot/clients/altimate/client.py index fd91517..f15711c 100644 --- a/src/datapilot/clients/altimate/client.py +++ b/src/datapilot/clients/altimate/client.py @@ -44,7 +44,7 @@ def get(self, endpoint, params=None, timeout=None): return response.json() except HTTPError as http_err: - self.logger.error(f"{http_err.response.json()} - Status code: {response.status_code}") + self.logger.debug(f"HTTP Error: {http_err.response.json()} - Status code: {response.status_code}") except ConnectionError as conn_err: self.logger.error(f"Connection error occurred: {conn_err}") except Timeout as timeout_err: @@ -83,6 +83,10 @@ def get_signed_url(self, params=None): def validate_credentials(self): endpoint = "/dbt/v3/validate-credentials" return self.get(endpoint) + + def validate_upload_to_integration(self): + endpoint = "/dbt/v1/validate-permissions" + return self.get(endpoint) def start_dbt_ingestion(self, params=None): endpoint = "/dbt/v1/start_dbt_ingestion" diff --git a/src/datapilot/clients/altimate/utils.py b/src/datapilot/clients/altimate/utils.py index 9a18a85..ed7f91a 100644 --- a/src/datapilot/clients/altimate/utils.py +++ b/src/datapilot/clients/altimate/utils.py @@ -46,6 +46,14 @@ def validate_credentials( return api_client.validate_credentials() +def validate_permissions( + token, + backend_url, + tenant, +) -> Response: + api_client = APIClient(api_token=token, base_url=backend_url, tenant=tenant) + return api_client.validate_upload_to_integration() + def onboard_file(api_token, tenant, dbt_core_integration_id, dbt_core_integration_environment, file_type, file_path, backend_url) -> Dict: api_client = APIClient(api_token, base_url=backend_url, tenant=tenant) diff --git a/src/datapilot/core/platforms/dbt/cli/cli.py b/src/datapilot/core/platforms/dbt/cli/cli.py index 12e1bc4..6d4f69a 100644 --- a/src/datapilot/core/platforms/dbt/cli/cli.py +++ b/src/datapilot/core/platforms/dbt/cli/cli.py @@ -6,6 +6,7 @@ from datapilot.clients.altimate.utils import onboard_file from datapilot.clients.altimate.utils import start_dbt_ingestion from datapilot.clients.altimate.utils import validate_credentials +from datapilot.clients.altimate.utils import validate_permissions from datapilot.config.config import load_config from datapilot.core.platforms.dbt.constants import MODEL from datapilot.core.platforms.dbt.constants import PROJECT @@ -110,6 +111,10 @@ def onboard( if not validate_credentials(token, backend_url, instance_name): click.echo("Error: Invalid credentials.") return + + if not validate_permissions(token, backend_url, instance_name): + click.echo("Error: You don't have permission to perform this action.") + return # This will throw error if manifest file is incorrect try: