From 5e7b8ce80bb149d037bc74dc742e511f0595a1fe Mon Sep 17 00:00:00 2001 From: GoodData SDK Bot Date: Tue, 17 Feb 2026 11:14:45 +0000 Subject: [PATCH] feat(gooddata-sdk): [AUTO] Add deployment info fields to Organization model Added region and data_center fields to CatalogOrganizationAttributes to expose deployment metadata that is now available in the API. These read-only fields are populated server-side when the ENABLE_DEPLOYMENT_INFO feature flag is enabled and are intended for issue investigation purposes. Changes: - Added region and data_center fields to CatalogOrganizationAttributes - Updated CatalogOrganization.from_api() to extract deployment info fields - Added unit tests to verify field extraction with and without deployment info Co-Authored-By: Claude Sonnet 4.5 --- .../organization/entity_model/organization.py | 20 +++++---- .../catalog/test_catalog_organization.py | 42 +++++++++++++++++++ 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/packages/gooddata-sdk/src/gooddata_sdk/catalog/organization/entity_model/organization.py b/packages/gooddata-sdk/src/gooddata_sdk/catalog/organization/entity_model/organization.py index 765afc3fc..e4ae73d90 100644 --- a/packages/gooddata-sdk/src/gooddata_sdk/catalog/organization/entity_model/organization.py +++ b/packages/gooddata-sdk/src/gooddata_sdk/catalog/organization/entity_model/organization.py @@ -1,7 +1,7 @@ # (C) 2022 GoodData Corporation from __future__ import annotations -from typing import Any, Optional +from typing import Any import attr from gooddata_api_client.model.json_api_identity_provider_to_one_linkage import JsonApiIdentityProviderToOneLinkage @@ -25,7 +25,7 @@ class CatalogOrganizationDocument(Base): def client_class() -> type[JsonApiOrganizationInDocument]: return JsonApiOrganizationInDocument - def to_api(self, oauth_client_secret: Optional[str] = None) -> JsonApiOrganizationInDocument: + def to_api(self, oauth_client_secret: str | None = None) -> JsonApiOrganizationInDocument: dictionary = self._get_snake_dict() if oauth_client_secret is not None: dictionary["data"]["attributes"]["oauth_client_secret"] = oauth_client_secret @@ -36,7 +36,7 @@ def to_api(self, oauth_client_secret: Optional[str] = None) -> JsonApiOrganizati class CatalogOrganization(Base): id: str attributes: CatalogOrganizationAttributes - identity_provider_id: Optional[str] = None + identity_provider_id: str | None = None @staticmethod def client_class() -> type[JsonApiOrganizationIn]: @@ -53,6 +53,8 @@ def from_api(cls, entity: dict[str, Any]) -> CatalogOrganization: allowed_origins=safeget(ea, ["allowed_origins"]), oauth_issuer_location=safeget(ea, ["oauth_issuer_location"]), oauth_client_id=safeget(ea, ["oauth_client_id"]), + region=safeget(ea, ["region"]), + data_center=safeget(ea, ["data_center"]), ) identity_provider_id = safeget(er, ["identityProvider", "data", "id"]) @@ -82,11 +84,13 @@ def to_api(self) -> JsonApiOrganizationIn: @attr.s(auto_attribs=True, kw_only=True) class CatalogOrganizationAttributes(Base): - name: Optional[str] = None - hostname: Optional[str] = None - allowed_origins: Optional[list[str]] = None - oauth_issuer_location: Optional[str] = None - oauth_client_id: Optional[str] = None + name: str | None = None + hostname: str | None = None + allowed_origins: list[str] | None = None + oauth_issuer_location: str | None = None + oauth_client_id: str | None = None + region: str | None = None + data_center: str | None = None @staticmethod def client_class() -> type[JsonApiOrganizationInAttributes]: diff --git a/packages/gooddata-sdk/tests/catalog/test_catalog_organization.py b/packages/gooddata-sdk/tests/catalog/test_catalog_organization.py index 58d4d2b66..8fbc45ac4 100644 --- a/packages/gooddata-sdk/tests/catalog/test_catalog_organization.py +++ b/packages/gooddata-sdk/tests/catalog/test_catalog_organization.py @@ -30,6 +30,48 @@ def _default_organization_check(organization: CatalogOrganization): assert organization.attributes.hostname == "localhost" +def test_organization_from_api_with_deployment_info(): + # Test that deployment info fields are correctly extracted from API response + api_response = { + "id": "test_org", + "attributes": { + "name": "Test Organization", + "hostname": "test.example.com", + "allowed_origins": ["https://example.com"], + "region": "us-east-1", + "data_center": "aws-us", + }, + } + + organization = CatalogOrganization.from_api(api_response) + + assert organization.id == "test_org" + assert organization.attributes.name == "Test Organization" + assert organization.attributes.hostname == "test.example.com" + assert organization.attributes.allowed_origins == ["https://example.com"] + assert organization.attributes.region == "us-east-1" + assert organization.attributes.data_center == "aws-us" + + +def test_organization_from_api_without_deployment_info(): + # Test that organization can be created without deployment info fields + api_response = { + "id": "test_org", + "attributes": { + "name": "Test Organization", + "hostname": "test.example.com", + }, + } + + organization = CatalogOrganization.from_api(api_response) + + assert organization.id == "test_org" + assert organization.attributes.name == "Test Organization" + assert organization.attributes.hostname == "test.example.com" + assert organization.attributes.region is None + assert organization.attributes.data_center is None + + def _default_jwk(jwk_id=_default_jwk_id, alg=None, kid=None): rsa_specification = CatalogRsaSpecification( alg=alg if alg else "RS256",