From 20fd6a99c62f5b8185d0522aecddd3686a67f611 Mon Sep 17 00:00:00 2001 From: Jan Kadlec Date: Wed, 8 Oct 2025 13:28:59 +0200 Subject: [PATCH] feat: add certificate support Add certificate support to GoodDataSdk initialization. JIRA: PSDK-222 risk: low --- gooddata-sdk/gooddata_sdk/client.py | 11 ++++++++++- gooddata-sdk/gooddata_sdk/sdk.py | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gooddata-sdk/gooddata_sdk/client.py b/gooddata-sdk/gooddata_sdk/client.py index cfa0ed848..71af1133d 100644 --- a/gooddata-sdk/gooddata_sdk/client.py +++ b/gooddata-sdk/gooddata_sdk/client.py @@ -3,6 +3,7 @@ from __future__ import annotations +from pathlib import Path from typing import Optional import gooddata_api_client as api_client @@ -25,6 +26,7 @@ def __init__( custom_headers: Optional[dict[str, str]] = None, extra_user_agent: Optional[str] = None, executions_cancellable: bool = False, + ssl_ca_cert: Optional[str] = None, ) -> None: """Take url, token for connecting to GoodData.CN. @@ -45,7 +47,14 @@ def __init__( user_agent = f"{USER_AGENT} {extra_user_agent}" if extra_user_agent is not None else USER_AGENT - self._api_config = api_client.Configuration(host=host) + if ssl_ca_cert is not None: + ssl_ca_cert_path = Path(ssl_ca_cert) + if not ssl_ca_cert_path.exists(): + raise ValueError( + f"ssl_ca_cert file path specified but the file does not exist. Path: {ssl_ca_cert_path}." + ) + + self._api_config = api_client.Configuration(host=host, ssl_ca_cert=ssl_ca_cert) self._api_client = api_client.ApiClient( configuration=self._api_config, header_name="Authorization", diff --git a/gooddata-sdk/gooddata_sdk/sdk.py b/gooddata-sdk/gooddata_sdk/sdk.py index 9320f865f..5e7587464 100644 --- a/gooddata-sdk/gooddata_sdk/sdk.py +++ b/gooddata-sdk/gooddata_sdk/sdk.py @@ -47,6 +47,7 @@ def create( token_: str, extra_user_agent_: Optional[str] = None, *, + ssl_ca_cert: Optional[str] = None, executions_cancellable: bool = False, **custom_headers_: Optional[str], ) -> GoodDataSdk: @@ -64,6 +65,7 @@ def create( custom_headers=filtered_headers, extra_user_agent=extra_user_agent_, executions_cancellable=executions_cancellable, + ssl_ca_cert=ssl_ca_cert, ) return cls(client)