Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/gooddata-sdk/src/gooddata_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@
from gooddata_sdk.catalog.organization.layout.export_template import (
CatalogDeclarativeExportTemplate,
)
from gooddata_sdk.catalog.organization.layout.ip_allowlist_policy import (
CatalogDeclarativeIpAllowlistPolicy,
)
from gooddata_sdk.catalog.organization.layout.notification_channel import (
CatalogDeclarativeNotificationChannel,
CatalogWebhook,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# (C) 2025 GoodData Corporation
from __future__ import annotations

import builtins

from attrs import define, field
from gooddata_api_client.model.declarative_ip_allowlist_policy import DeclarativeIpAllowlistPolicy

from gooddata_sdk.catalog.base import Base
from gooddata_sdk.catalog.identifier import CatalogDeclarativeUserGroupIdentifier, CatalogUserIdentifier


@define(kw_only=True)
class CatalogDeclarativeIpAllowlistPolicy(Base):
id: str
allowed_sources: list[str] = field(factory=list)
user_groups: list[CatalogDeclarativeUserGroupIdentifier] = field(factory=list)
users: list[CatalogUserIdentifier] = field(factory=list)

@staticmethod
def client_class() -> builtins.type[DeclarativeIpAllowlistPolicy]:
return DeclarativeIpAllowlistPolicy
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
)
from gooddata_sdk.catalog.organization.entity_model.setting import CatalogOrganizationSetting
from gooddata_sdk.catalog.organization.layout.identity_provider import CatalogDeclarativeIdentityProvider
from gooddata_sdk.catalog.organization.layout.ip_allowlist_policy import CatalogDeclarativeIpAllowlistPolicy
from gooddata_sdk.catalog.organization.layout.notification_channel import CatalogDeclarativeNotificationChannel
from gooddata_sdk.client import GoodDataApiClient
from gooddata_sdk.utils import load_all_entities, load_all_entities_dict
Expand Down Expand Up @@ -742,3 +743,35 @@ def switch_active_identity_provider(self, identity_provider_id: str) -> None:
)
except Exception as e:
raise ValueError(f"Error switching active identity provider: {str(e)}")

def get_declarative_ip_allowlist_policies(self) -> list[CatalogDeclarativeIpAllowlistPolicy]:
"""Get all declarative IP allowlist policies for the current organization.

IP allowlist policies are returned as part of the full organization layout.

Returns:
list[CatalogDeclarativeIpAllowlistPolicy]:
List of declarative IP allowlist policies.
"""
org_layout = self._layout_api.get_organization_layout(_check_return_type=False)
policies = getattr(org_layout, "ip_allowlist_policies", None) or []
return [CatalogDeclarativeIpAllowlistPolicy.from_api(policy) for policy in policies]

def put_declarative_ip_allowlist_policies(
self, ip_allowlist_policies: list[CatalogDeclarativeIpAllowlistPolicy]
) -> None:
"""Put declarative IP allowlist policies for the current organization.

Reads the full organization layout, replaces the ip_allowlist_policies field,
and writes the full layout back. All other organization settings are preserved.

Args:
ip_allowlist_policies (list[CatalogDeclarativeIpAllowlistPolicy]):
List of declarative IP allowlist policies to set.

Returns:
None
"""
org_layout = self._layout_api.get_organization_layout(_check_return_type=False)
org_layout.ip_allowlist_policies = [policy.to_api() for policy in ip_allowlist_policies]
self._layout_api.set_organization_layout(org_layout, _check_return_type=False)
Loading
Loading