Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@

from ....types.interactions.environmentnetworkegressallowlist import Allowlist
from ....types.interactions.source import Source
from . import allowlist

__all__ = ["Allowlist", "Source", "allowlist"]
__all__ = ["Allowlist", "Source"]

This file was deleted.

11 changes: 10 additions & 1 deletion google/genai/_gaos/types/interactions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
if TYPE_CHECKING:
from .agentoption import AgentOption
from .allowedtools import AllowedTools, AllowedToolsParam
from .allowlistentry import AllowlistEntry, AllowlistEntryParam
from .allowlistentry import (
AllowlistEntry,
AllowlistEntryParam,
Transform,
TransformParam,
)
from .annotation import Annotation, AnnotationParam, UnknownAnnotation
from .argumentsdelta import ArgumentsDelta, ArgumentsDeltaTypedDict
from .audiocontent import AudioContent, AudioContentMimeType, AudioContentParam
Expand Down Expand Up @@ -660,6 +665,8 @@
"ToolChoiceParam",
"ToolChoiceType",
"ToolParam",
"Transform",
"TransformParam",
"Turn",
"TurnContent",
"TurnContentParam",
Expand Down Expand Up @@ -719,6 +726,8 @@
"AllowedToolsParam": ".allowedtools",
"AllowlistEntry": ".allowlistentry",
"AllowlistEntryParam": ".allowlistentry",
"Transform": ".allowlistentry",
"TransformParam": ".allowlistentry",
"Annotation": ".annotation",
"AnnotationParam": ".annotation",
"UnknownAnnotation": ".annotation",
Expand Down
22 changes: 16 additions & 6 deletions google/genai/_gaos/types/interactions/allowlistentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,27 @@
from __future__ import annotations
from .. import BaseModel, UNSET_SENTINEL
from pydantic import model_serializer
from typing import Dict, List, Optional
from typing_extensions import NotRequired, TypedDict
from typing import Dict, List, Optional, Union
from typing_extensions import NotRequired, TypeAliasType, TypedDict


TransformParam = TypeAliasType(
"TransformParam", Union[Dict[str, str], List[Dict[str, str]]]
)
r"""Headers to inject on all outbound requests matching this domain. Accepts a single dict or a list of dicts. The egress proxy injects these automatically."""


Transform = TypeAliasType("Transform", Union[Dict[str, str], List[Dict[str, str]]])
r"""Headers to inject on all outbound requests matching this domain. Accepts a single dict or a list of dicts. The egress proxy injects these automatically."""


class AllowlistEntryParam(TypedDict):
r"""A single domain allowlist rule with optional header injection."""

domain: str
r"""Domain to allow outbound requests to. Supports wildcards (e.g. '*.googleapis.com'). Use '*' to allow all domains."""
transform: NotRequired[List[Dict[str, str]]]
r"""Headers to inject on all outbound requests matching this domain. Each entry is a flat {header_name: header_value} object. The egress proxy injects these automatically."""
transform: NotRequired[TransformParam]
r"""Headers to inject on all outbound requests matching this domain. Accepts a single dict or a list of dicts. The egress proxy injects these automatically."""


class AllowlistEntry(BaseModel):
Expand All @@ -38,8 +48,8 @@ class AllowlistEntry(BaseModel):
domain: str
r"""Domain to allow outbound requests to. Supports wildcards (e.g. '*.googleapis.com'). Use '*' to allow all domains."""

transform: Optional[List[Dict[str, str]]] = None
r"""Headers to inject on all outbound requests matching this domain. Each entry is a flat {header_name: header_value} object. The egress proxy injects these automatically."""
transform: Optional[Transform] = None
r"""Headers to inject on all outbound requests matching this domain. Accepts a single dict or a list of dicts. The egress proxy injects these automatically."""

@model_serializer(mode="wrap")
def serialize_model(self, handler):
Expand Down
28 changes: 27 additions & 1 deletion google/genai/tests/interactions/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
pytest_plugins = ("pytest_asyncio",)



def test_client_timeout():
with mock.patch.object(
gaos_google_genai, "GenAI", spec_set=True
Expand Down Expand Up @@ -96,4 +95,31 @@ def test_unrecognized_model_request_serialization():
assert dumped["body"]["model"] == "gemini-3.5-flash"


def test_allowlist_entry_with_dict_transform():
from ..._gaos.types.interactions.allowlistentry import AllowlistEntry

# Should construct successfully with a single dict
entry = AllowlistEntry(
domain="github.com", transform={"Authorization": "Bearer TOKEN"}
)
assert entry.domain == "github.com"
assert entry.transform == {"Authorization": "Bearer TOKEN"}

# Serialization should preserve it as a dict
dumped = entry.model_dump()
assert dumped["transform"] == {"Authorization": "Bearer TOKEN"}


def test_allowlist_entry_with_list_transform():
from ..._gaos.types.interactions.allowlistentry import AllowlistEntry

# Should construct successfully with a list of dicts
entry = AllowlistEntry(
domain="github.com", transform=[{"Authorization": "Bearer TOKEN"}]
)
assert entry.domain == "github.com"
assert entry.transform == [{"Authorization": "Bearer TOKEN"}]

# Serialization should preserve it as a list
dumped = entry.model_dump()
assert dumped["transform"] == [{"Authorization": "Bearer TOKEN"}]
Loading