Skip to content

Commit fa4acc7

Browse files
google-genai-botcopybara-github
authored andcommitted
feat: Support "allowlist": "disabled" in environment network config.
Adds a short form for `network.allowlist` so terminal egress can be blocked from inside the `network` object. `network: "disabled"` keeps working unchanged. PiperOrigin-RevId: 994980935
1 parent 84bf19c commit fa4acc7

5 files changed

Lines changed: 41 additions & 54 deletions

File tree

‎google/genai/_gaos/resources/environments/__init__.py‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,16 @@
2323
from ...types.environments.getenvironmentfilesresponse import (
2424
GetEnvironmentFilesResponse,
2525
)
26-
from ...types.environments.listenvironmentsresponse import (
27-
ListEnvironmentsResponse as EnvironmentListResponse,
28-
)
26+
from ...types.environments.listenvironmentsresponse import ListEnvironmentsResponse
2927
from ...types.interactions.empty import Empty as EnvironmentDeleteResponse
30-
from . import createenvironmentrequest
31-
from . import environment
3228

29+
EnvironmentListResponse = ListEnvironmentsResponse
3330
__all__ = [
3431
"CreateEnvironmentRequest",
3532
"Environment",
3633
"EnvironmentDeleteResponse",
3734
"EnvironmentFile",
3835
"EnvironmentListResponse",
3936
"GetEnvironmentFilesResponse",
40-
"createenvironmentrequest",
41-
"environment",
37+
"ListEnvironmentsResponse",
4238
]

‎google/genai/_gaos/resources/environments/environment/__init__.py‎

Lines changed: 0 additions & 22 deletions
This file was deleted.

‎google/genai/_gaos/resources/interactions/environment/__init__.py‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,16 @@
1717

1818
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
1919

20-
from ....types.interactions.environmentnetworkegressallowlist import Allowlist
20+
from ....types.interactions.environmentnetworkegressallowlist import (
21+
EnvironmentNetworkEgressAllowlist,
22+
)
2123
from ....types.interactions.envvar import EnvVar
2224
from ....types.interactions.source import Source
25+
from . import environmentnetworkegressallowlist
2326

24-
__all__ = ["Allowlist", "EnvVar", "Source"]
27+
__all__ = [
28+
"EnvVar",
29+
"EnvironmentNetworkEgressAllowlist",
30+
"Source",
31+
"environmentnetworkegressallowlist",
32+
]

google/genai/_gaos/resources/environments/createenvironmentrequest/__init__.py renamed to google/genai/_gaos/resources/interactions/environment/environmentnetworkegressallowlist/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717

1818
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
1919

20-
from ....types.interactions.environmentnetworkegressallowlist import Allowlist
20+
from .....types.interactions.allowlistentry import AllowlistEntry
2121

22-
__all__ = ["Allowlist"]
22+
__all__ = ["AllowlistEntry"]

‎google/genai/_gaos/types/interactions/environmentnetworkegressallowlist.py‎

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,38 @@
2626

2727

2828
Disabled = Literal["disabled",]
29-
r"""Turns all network off."""
3029

3130

32-
class AllowlistParam(TypedDict):
33-
r"""Outbound networking configuration for the sandbox. When specified, restricts which external domains the sandbox can reach. Omit entirely to allow all outbound traffic with no header injection."""
31+
AllowlistParam = TypeAliasType(
32+
"AllowlistParam", Union[List[AllowlistEntryParam], Disabled]
33+
)
34+
r"""List of allowed domains and their configurations. Set to `\"disabled\"`
35+
to block all network egress.
36+
"""
37+
38+
39+
Allowlist = TypeAliasType("Allowlist", Union[List[AllowlistEntry], Disabled])
40+
r"""List of allowed domains and their configurations. Set to `\"disabled\"`
41+
to block all network egress.
42+
"""
3443

35-
allowlist: NotRequired[List[AllowlistEntryParam]]
36-
r"""List of allowed outbound domains. Only requests to listed domains are permitted. Use [{'domain': '*'}] to allow all domains while still injecting headers on specific ones."""
3744

45+
class EnvironmentNetworkEgressAllowlistParam(TypedDict):
46+
r"""Network egress configuration for the environment."""
3847

39-
class Allowlist(BaseModel):
40-
r"""Outbound networking configuration for the sandbox. When specified, restricts which external domains the sandbox can reach. Omit entirely to allow all outbound traffic with no header injection."""
48+
allowlist: NotRequired[AllowlistParam]
49+
r"""List of allowed domains and their configurations. Set to `\"disabled\"`
50+
to block all network egress.
51+
"""
4152

42-
allowlist: Optional[List[AllowlistEntry]] = None
43-
r"""List of allowed outbound domains. Only requests to listed domains are permitted. Use [{'domain': '*'}] to allow all domains while still injecting headers on specific ones."""
53+
54+
class EnvironmentNetworkEgressAllowlist(BaseModel):
55+
r"""Network egress configuration for the environment."""
56+
57+
allowlist: Optional[Allowlist] = None
58+
r"""List of allowed domains and their configurations. Set to `\"disabled\"`
59+
to block all network egress.
60+
"""
4461

4562
@model_serializer(mode="wrap")
4663
def serialize_model(self, handler):
@@ -57,15 +74,3 @@ def serialize_model(self, handler):
5774
m[k] = val
5875

5976
return m
60-
61-
62-
EnvironmentNetworkEgressAllowlistParam = TypeAliasType(
63-
"EnvironmentNetworkEgressAllowlistParam", Union[AllowlistParam, Disabled]
64-
)
65-
r"""Outbound networking configuration for the sandbox. Accepts an object with an 'allowlist' array to restrict traffic, or the string 'disabled' to turn off all network access. Omit entirely to allow all outbound traffic with no header injection."""
66-
67-
68-
EnvironmentNetworkEgressAllowlist = TypeAliasType(
69-
"EnvironmentNetworkEgressAllowlist", Union[Allowlist, Disabled]
70-
)
71-
r"""Outbound networking configuration for the sandbox. Accepts an object with an 'allowlist' array to restrict traffic, or the string 'disabled' to turn off all network access. Omit entirely to allow all outbound traffic with no header injection."""

0 commit comments

Comments
 (0)