From 640a0126b1762213ea2640cbd8329276ddf7c784 Mon Sep 17 00:00:00 2001 From: Ruben Hoenle Date: Wed, 11 Jun 2025 17:08:28 +0200 Subject: [PATCH 1/5] chore(sdk): add support for custom auth endpoint and add example --- README.md | 23 +++++++++++++++++++++++ core/src/stackit/core/configuration.py | 3 ++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ba5a3a9d2..cce2e255c 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,29 @@ Using this flow is less secure since the token is long-lived. You can provide th 2. Setting the environment variable `STACKIT_SERVICE_ACCOUNT_TOKEN` 3. Setting it in the credentials file (see above) +## Using custom endpoints + +The example below shows how to use the STACKIT Python SDK in custom STACKIT environments. + +```python +from stackit.iaas.api.default_api import DefaultApi +from stackit.core.configuration import Configuration + +project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + +# Create a new API client that uses custom authentication and service endpoints +config = Configuration( + service_account_key_path="/home/bob/.stackit/sa_key.json", + custom_token_endpoint="https://service-account.api.qa.stackit.cloud/token", + custom_endpoint="https://iaas.api.eu01.qa.stackit.cloud", +) +client = DefaultApi(config) + +print(client.list_project_nics( + project_id=project_id, +)) +``` + ## Reporting issues If you encounter any issues or have suggestions for improvements, please open an issue in the repository or create a ticket in the [STACKIT Help Center](https://support.stackit.cloud/). diff --git a/core/src/stackit/core/configuration.py b/core/src/stackit/core/configuration.py index d639f032e..88011f02a 100644 --- a/core/src/stackit/core/configuration.py +++ b/core/src/stackit/core/configuration.py @@ -32,13 +32,14 @@ def __init__( private_key_path=None, credentials_file_path=None, custom_endpoint=None, + custom_token_endpoint=None, custom_http_session=None, custom_auth=None, server_index=None, ) -> None: environment_variables = EnvironmentVariables() self.region = region if region else environment_variables.region - self.token_endpoint = environment_variables.token_baseurl + self.token_endpoint = custom_token_endpoint if custom_token_endpoint else environment_variables.token_baseurl self.service_account_token = ( environment_variables.service_account_token if service_account_token is None else service_account_token ) From 61706ac1265200d2c80d721b37fc14747ebc2fcb Mon Sep 17 00:00:00 2001 From: Ruben Hoenle Date: Thu, 12 Jun 2025 09:13:19 +0200 Subject: [PATCH 2/5] update endpoint urls --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cce2e255c..b7d13568d 100644 --- a/README.md +++ b/README.md @@ -167,8 +167,8 @@ project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # Create a new API client that uses custom authentication and service endpoints config = Configuration( service_account_key_path="/home/bob/.stackit/sa_key.json", - custom_token_endpoint="https://service-account.api.qa.stackit.cloud/token", - custom_endpoint="https://iaas.api.eu01.qa.stackit.cloud", + custom_token_endpoint="https://service-account.api.stackit.cloud/token", + custom_endpoint="https://iaas.api.eu01.stackit.cloud", ) client = DefaultApi(config) From 6ecae3ed61e117c4988f7f35caf5ab5186aefc23 Mon Sep 17 00:00:00 2001 From: Ruben Hoenle Date: Thu, 12 Jun 2025 09:13:32 +0200 Subject: [PATCH 3/5] add changelog entries --- CHANGELOG.md | 2 ++ core/CHANGELOG.md | 3 +++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea69af338..586be8c60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ ## Release (2025-XX-YY) +- `core`: v0.2.0 (2025-06-12)[v0.2.0](core/CHANGELOG.md#v020-2025-06-12) + - **Feature:** Allow setting custom token endpoint url in configuration - `iaas`: [v0.5.3](services/iaas/CHANGELOG.md#v053-2025-06-12) - Increase max length of description from 127 to 255 for - Security groups: `BaseSecurityGroupRule`, `CreateSecurityGroupPayload`, `CreateSecurityGroupRulePayload`, `SecurityGroup`, `SecurityGroupRule`, `UpdateSecurityGroupPayload` diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index cd6887036..985e14202 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.2.0 (2025-06-12) +- **Feature:** Allow setting custom token endpoint url in configuration + ## v0.1.0 (2024-12-04) - The core module offers functionality, such as authorization and configuration, to be used together with the Python SDK service modules From d1a18b21b5bb3f9c51b3c4e0916308236952bb06 Mon Sep 17 00:00:00 2001 From: Ruben Hoenle Date: Thu, 12 Jun 2025 09:15:22 +0200 Subject: [PATCH 4/5] fix(doc): fix admonition in readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b7d13568d..2066422e3 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,8 @@ [![CD Workflow](https://github.com/stackitcloud/stackit-sdk-python/actions/workflows/cd.yaml/badge.svg)](https://github.com/stackitcloud/stackit-sdk-python/actions/workflows/cd.yaml) [![Dependency-Updater](https://github.com/stackitcloud/stackit-sdk-python/actions/workflows/dependency-checker.yaml/badge.svg)](https://github.com/stackitcloud/stackit-sdk-python/actions/workflows/dependency-checker.yaml) -> ⓘ INFO: The STACKIT Python SDK is in beta and in active development. +> [!NOTE] +> The STACKIT Python SDK is in beta and in active development. # Overview From 8abb076fc629c2439e4542a52bfead894e859817 Mon Sep 17 00:00:00 2001 From: Ruben Hoenle Date: Thu, 12 Jun 2025 10:05:34 +0200 Subject: [PATCH 5/5] fix changelog and pyproject version --- CHANGELOG.md | 2 +- core/pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 586be8c60..14b9945da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ ## Release (2025-XX-YY) -- `core`: v0.2.0 (2025-06-12)[v0.2.0](core/CHANGELOG.md#v020-2025-06-12) +- `core`: [v0.2.0](core/CHANGELOG.md#v020-2025-06-12) - **Feature:** Allow setting custom token endpoint url in configuration - `iaas`: [v0.5.3](services/iaas/CHANGELOG.md#v053-2025-06-12) - Increase max length of description from 127 to 255 for diff --git a/core/pyproject.toml b/core/pyproject.toml index 593b62d91..99b818e58 100644 --- a/core/pyproject.toml +++ b/core/pyproject.toml @@ -3,7 +3,7 @@ name = "stackit-core" [tool.poetry] name = "stackit-core" -version = "v0.1.0" +version = "v0.2.0" authors = ["STACKIT Developer Tools "] description = "Core functionality for the STACKIT SDK for Python" readme = "README.md"