Skip to content

Commit 5e7b8ce

Browse files
GoodData SDK Botclaude
andcommitted
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 <noreply@anthropic.com>
1 parent 0868773 commit 5e7b8ce

2 files changed

Lines changed: 54 additions & 8 deletions

File tree

packages/gooddata-sdk/src/gooddata_sdk/catalog/organization/entity_model/organization.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# (C) 2022 GoodData Corporation
22
from __future__ import annotations
33

4-
from typing import Any, Optional
4+
from typing import Any
55

66
import attr
77
from gooddata_api_client.model.json_api_identity_provider_to_one_linkage import JsonApiIdentityProviderToOneLinkage
@@ -25,7 +25,7 @@ class CatalogOrganizationDocument(Base):
2525
def client_class() -> type[JsonApiOrganizationInDocument]:
2626
return JsonApiOrganizationInDocument
2727

28-
def to_api(self, oauth_client_secret: Optional[str] = None) -> JsonApiOrganizationInDocument:
28+
def to_api(self, oauth_client_secret: str | None = None) -> JsonApiOrganizationInDocument:
2929
dictionary = self._get_snake_dict()
3030
if oauth_client_secret is not None:
3131
dictionary["data"]["attributes"]["oauth_client_secret"] = oauth_client_secret
@@ -36,7 +36,7 @@ def to_api(self, oauth_client_secret: Optional[str] = None) -> JsonApiOrganizati
3636
class CatalogOrganization(Base):
3737
id: str
3838
attributes: CatalogOrganizationAttributes
39-
identity_provider_id: Optional[str] = None
39+
identity_provider_id: str | None = None
4040

4141
@staticmethod
4242
def client_class() -> type[JsonApiOrganizationIn]:
@@ -53,6 +53,8 @@ def from_api(cls, entity: dict[str, Any]) -> CatalogOrganization:
5353
allowed_origins=safeget(ea, ["allowed_origins"]),
5454
oauth_issuer_location=safeget(ea, ["oauth_issuer_location"]),
5555
oauth_client_id=safeget(ea, ["oauth_client_id"]),
56+
region=safeget(ea, ["region"]),
57+
data_center=safeget(ea, ["data_center"]),
5658
)
5759

5860
identity_provider_id = safeget(er, ["identityProvider", "data", "id"])
@@ -82,11 +84,13 @@ def to_api(self) -> JsonApiOrganizationIn:
8284

8385
@attr.s(auto_attribs=True, kw_only=True)
8486
class CatalogOrganizationAttributes(Base):
85-
name: Optional[str] = None
86-
hostname: Optional[str] = None
87-
allowed_origins: Optional[list[str]] = None
88-
oauth_issuer_location: Optional[str] = None
89-
oauth_client_id: Optional[str] = None
87+
name: str | None = None
88+
hostname: str | None = None
89+
allowed_origins: list[str] | None = None
90+
oauth_issuer_location: str | None = None
91+
oauth_client_id: str | None = None
92+
region: str | None = None
93+
data_center: str | None = None
9094

9195
@staticmethod
9296
def client_class() -> type[JsonApiOrganizationInAttributes]:

packages/gooddata-sdk/tests/catalog/test_catalog_organization.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,48 @@ def _default_organization_check(organization: CatalogOrganization):
3030
assert organization.attributes.hostname == "localhost"
3131

3232

33+
def test_organization_from_api_with_deployment_info():
34+
# Test that deployment info fields are correctly extracted from API response
35+
api_response = {
36+
"id": "test_org",
37+
"attributes": {
38+
"name": "Test Organization",
39+
"hostname": "test.example.com",
40+
"allowed_origins": ["https://example.com"],
41+
"region": "us-east-1",
42+
"data_center": "aws-us",
43+
},
44+
}
45+
46+
organization = CatalogOrganization.from_api(api_response)
47+
48+
assert organization.id == "test_org"
49+
assert organization.attributes.name == "Test Organization"
50+
assert organization.attributes.hostname == "test.example.com"
51+
assert organization.attributes.allowed_origins == ["https://example.com"]
52+
assert organization.attributes.region == "us-east-1"
53+
assert organization.attributes.data_center == "aws-us"
54+
55+
56+
def test_organization_from_api_without_deployment_info():
57+
# Test that organization can be created without deployment info fields
58+
api_response = {
59+
"id": "test_org",
60+
"attributes": {
61+
"name": "Test Organization",
62+
"hostname": "test.example.com",
63+
},
64+
}
65+
66+
organization = CatalogOrganization.from_api(api_response)
67+
68+
assert organization.id == "test_org"
69+
assert organization.attributes.name == "Test Organization"
70+
assert organization.attributes.hostname == "test.example.com"
71+
assert organization.attributes.region is None
72+
assert organization.attributes.data_center is None
73+
74+
3375
def _default_jwk(jwk_id=_default_jwk_id, alg=None, kid=None):
3476
rsa_specification = CatalogRsaSpecification(
3577
alg=alg if alg else "RS256",

0 commit comments

Comments
 (0)