diff --git a/packages/gooddata-sdk/src/gooddata_sdk/catalog/organization/service.py b/packages/gooddata-sdk/src/gooddata_sdk/catalog/organization/service.py index aa9de621b..70825d372 100644 --- a/packages/gooddata-sdk/src/gooddata_sdk/catalog/organization/service.py +++ b/packages/gooddata-sdk/src/gooddata_sdk/catalog/organization/service.py @@ -721,13 +721,17 @@ def get_ip_allowlist_policy(self, policy_id: str) -> CatalogIpAllowlistPolicy: Returns: CatalogIpAllowlistPolicy: Retrieved policy. """ - response = self._entities_api.get_entity_ip_allowlist_policies(policy_id, _check_return_type=False) + response = self._entities_api.get_entity_ip_allowlist_policies( + policy_id, include=["users", "userGroups"], _check_return_type=False + ) return CatalogIpAllowlistPolicy.from_api(response.data) def list_ip_allowlist_policies(self) -> list[CatalogIpAllowlistPolicy]: """Return all IP allowlist policies in the organization.""" get_policies = functools.partial( - self._entities_api.get_all_entities_ip_allowlist_policies, _check_return_type=False + self._entities_api.get_all_entities_ip_allowlist_policies, + include=["users", "userGroups"], + _check_return_type=False, ) policies = load_all_entities(get_policies) return [CatalogIpAllowlistPolicy.from_api(policy) for policy in policies.data] @@ -735,14 +739,16 @@ def list_ip_allowlist_policies(self) -> list[CatalogIpAllowlistPolicy]: def create_ip_allowlist_policy(self, policy: CatalogIpAllowlistPolicy) -> CatalogIpAllowlistPolicy: """Create a new IP allowlist policy.""" response = self._entities_api.create_entity_ip_allowlist_policies( - json_api_ip_allowlist_policy_in_document=policy.to_api(), _check_return_type=False + json_api_ip_allowlist_policy_in_document=policy.to_api(), + include=["users", "userGroups"], + _check_return_type=False, ) return CatalogIpAllowlistPolicy.from_api(response.data) def update_ip_allowlist_policy(self, policy: CatalogIpAllowlistPolicy) -> CatalogIpAllowlistPolicy: """Replace an existing IP allowlist policy.""" response = self._entities_api.update_entity_ip_allowlist_policies( - policy.id, policy.to_api(), _check_return_type=False + policy.id, policy.to_api(), include=["users", "userGroups"], _check_return_type=False ) return CatalogIpAllowlistPolicy.from_api(response.data) diff --git a/packages/gooddata-sdk/tests/catalog/unit_tests/test_ip_allowlist_policy.py b/packages/gooddata-sdk/tests/catalog/unit_tests/test_ip_allowlist_policy.py index 234476e8c..3e6c4a9a2 100644 --- a/packages/gooddata-sdk/tests/catalog/unit_tests/test_ip_allowlist_policy.py +++ b/packages/gooddata-sdk/tests/catalog/unit_tests/test_ip_allowlist_policy.py @@ -120,11 +120,15 @@ def test_ip_allowlist_policy_crud_methods_call_generated_client() -> None: service.delete_ip_allowlist_policy("corp-vpn-only") assert entities_api.get_entity_ip_allowlist_policies.call_args.args[0] == "corp-vpn-only" + # Relationship data is stripped unless explicitly requested via the JSON:API include param. + assert entities_api.get_entity_ip_allowlist_policies.call_args.kwargs["include"] == ["users", "userGroups"] create_doc = entities_api.create_entity_ip_allowlist_policies.call_args.kwargs[ "json_api_ip_allowlist_policy_in_document" ] assert create_doc.data.id == "corp-vpn-only" + assert entities_api.create_entity_ip_allowlist_policies.call_args.kwargs["include"] == ["users", "userGroups"] assert entities_api.update_entity_ip_allowlist_policies.call_args.args[0] == "corp-vpn-only" + assert entities_api.update_entity_ip_allowlist_policies.call_args.kwargs["include"] == ["users", "userGroups"] assert entities_api.delete_entity_ip_allowlist_policies.call_args.args[0] == "corp-vpn-only" @@ -143,6 +147,7 @@ def test_list_ip_allowlist_policies_loads_all_entities() -> None: assert [policy.id for policy in policies] == ["first", "second"] assert entities_api.get_all_entities_ip_allowlist_policies.called + assert entities_api.get_all_entities_ip_allowlist_policies.call_args.kwargs["include"] == ["users", "userGroups"] def test_ip_allowlist_target_actions_call_generated_client() -> None: