Skip to content

Commit 3ddbb7e

Browse files
feat(api): container network_policy and skills
1 parent 156d518 commit 3ddbb7e

9 files changed

Lines changed: 121 additions & 18 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 148
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-1595c7e4e1d7bf7eae2e49ad800316e13b69ffb18bff2a2f55236fce792deb53.yml
3-
openapi_spec_hash: c3a3a0d8d4bbf11179149244f017a6dc
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-0db5326a0fb6a30ffad9242c72872c3388ef927e8a4549ddd20aec3420541209.yml
3+
openapi_spec_hash: 9523fe30739802e15c88f4e7aac44e7f
44
config_hash: 948733484caf41e71093c6582dbc319c

src/openai/resources/containers/containers.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
from typing import Iterable
56
from typing_extensions import Literal
67

78
import httpx
@@ -61,6 +62,8 @@ def create(
6162
expires_after: container_create_params.ExpiresAfter | Omit = omit,
6263
file_ids: SequenceNotStr[str] | Omit = omit,
6364
memory_limit: Literal["1g", "4g", "16g", "64g"] | Omit = omit,
65+
network_policy: container_create_params.NetworkPolicy | Omit = omit,
66+
skills: Iterable[container_create_params.Skill] | Omit = omit,
6467
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
6568
# The extra values given here take precedence over values defined on the client or passed to this method.
6669
extra_headers: Headers | None = None,
@@ -80,6 +83,10 @@ def create(
8083
8184
memory_limit: Optional memory limit for the container. Defaults to "1g".
8285
86+
network_policy: Network access policy for the container.
87+
88+
skills: An optional list of skills referenced by id or inline data.
89+
8390
extra_headers: Send extra headers
8491
8592
extra_query: Add additional query parameters to the request
@@ -96,6 +103,8 @@ def create(
96103
"expires_after": expires_after,
97104
"file_ids": file_ids,
98105
"memory_limit": memory_limit,
106+
"network_policy": network_policy,
107+
"skills": skills,
99108
},
100109
container_create_params.ContainerCreateParams,
101110
),
@@ -143,6 +152,7 @@ def list(
143152
*,
144153
after: str | Omit = omit,
145154
limit: int | Omit = omit,
155+
name: str | Omit = omit,
146156
order: Literal["asc", "desc"] | Omit = omit,
147157
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
148158
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -164,6 +174,8 @@ def list(
164174
limit: A limit on the number of objects to be returned. Limit can range between 1 and
165175
100, and the default is 20.
166176
177+
name: Filter results by container name.
178+
167179
order: Sort order by the `created_at` timestamp of the objects. `asc` for ascending
168180
order and `desc` for descending order.
169181
@@ -187,6 +199,7 @@ def list(
187199
{
188200
"after": after,
189201
"limit": limit,
202+
"name": name,
190203
"order": order,
191204
},
192205
container_list_params.ContainerListParams,
@@ -261,6 +274,8 @@ async def create(
261274
expires_after: container_create_params.ExpiresAfter | Omit = omit,
262275
file_ids: SequenceNotStr[str] | Omit = omit,
263276
memory_limit: Literal["1g", "4g", "16g", "64g"] | Omit = omit,
277+
network_policy: container_create_params.NetworkPolicy | Omit = omit,
278+
skills: Iterable[container_create_params.Skill] | Omit = omit,
264279
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
265280
# The extra values given here take precedence over values defined on the client or passed to this method.
266281
extra_headers: Headers | None = None,
@@ -280,6 +295,10 @@ async def create(
280295
281296
memory_limit: Optional memory limit for the container. Defaults to "1g".
282297
298+
network_policy: Network access policy for the container.
299+
300+
skills: An optional list of skills referenced by id or inline data.
301+
283302
extra_headers: Send extra headers
284303
285304
extra_query: Add additional query parameters to the request
@@ -296,6 +315,8 @@ async def create(
296315
"expires_after": expires_after,
297316
"file_ids": file_ids,
298317
"memory_limit": memory_limit,
318+
"network_policy": network_policy,
319+
"skills": skills,
299320
},
300321
container_create_params.ContainerCreateParams,
301322
),
@@ -343,6 +364,7 @@ def list(
343364
*,
344365
after: str | Omit = omit,
345366
limit: int | Omit = omit,
367+
name: str | Omit = omit,
346368
order: Literal["asc", "desc"] | Omit = omit,
347369
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
348370
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -364,6 +386,8 @@ def list(
364386
limit: A limit on the number of objects to be returned. Limit can range between 1 and
365387
100, and the default is 20.
366388
389+
name: Filter results by container name.
390+
367391
order: Sort order by the `created_at` timestamp of the objects. `asc` for ascending
368392
order and `desc` for descending order.
369393
@@ -387,6 +411,7 @@ def list(
387411
{
388412
"after": after,
389413
"limit": limit,
414+
"name": name,
390415
"order": order,
391416
},
392417
container_list_params.ContainerListParams,

src/openai/resources/containers/files/files.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,11 @@ def create(
9696
}
9797
)
9898
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
99-
# It should be noted that the actual Content-Type header that will be
100-
# sent to the server will contain a `boundary` parameter, e.g.
101-
# multipart/form-data; boundary=---abc--
102-
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
99+
if files:
100+
# It should be noted that the actual Content-Type header that will be
101+
# sent to the server will contain a `boundary` parameter, e.g.
102+
# multipart/form-data; boundary=---abc--
103+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
103104
return self._post(
104105
f"/containers/{container_id}/files",
105106
body=maybe_transform(body, file_create_params.FileCreateParams),
@@ -309,10 +310,11 @@ async def create(
309310
}
310311
)
311312
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
312-
# It should be noted that the actual Content-Type header that will be
313-
# sent to the server will contain a `boundary` parameter, e.g.
314-
# multipart/form-data; boundary=---abc--
315-
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
313+
if files:
314+
# It should be noted that the actual Content-Type header that will be
315+
# sent to the server will contain a `boundary` parameter, e.g.
316+
# multipart/form-data; boundary=---abc--
317+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
316318
return await self._post(
317319
f"/containers/{container_id}/files",
318320
body=await async_maybe_transform(body, file_create_params.FileCreateParams),

src/openai/types/container_create_params.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22

33
from __future__ import annotations
44

5-
from typing_extensions import Literal, Required, TypedDict
5+
from typing import Union, Iterable
6+
from typing_extensions import Literal, Required, TypeAlias, TypedDict
67

78
from .._types import SequenceNotStr
9+
from .responses.inline_skill_param import InlineSkillParam
10+
from .responses.skill_reference_param import SkillReferenceParam
11+
from .responses.container_network_policy_disabled_param import ContainerNetworkPolicyDisabledParam
12+
from .responses.container_network_policy_allowlist_param import ContainerNetworkPolicyAllowlistParam
813

9-
__all__ = ["ContainerCreateParams", "ExpiresAfter"]
14+
__all__ = ["ContainerCreateParams", "ExpiresAfter", "NetworkPolicy", "Skill"]
1015

1116

1217
class ContainerCreateParams(TypedDict, total=False):
@@ -22,6 +27,12 @@ class ContainerCreateParams(TypedDict, total=False):
2227
memory_limit: Literal["1g", "4g", "16g", "64g"]
2328
"""Optional memory limit for the container. Defaults to "1g"."""
2429

30+
network_policy: NetworkPolicy
31+
"""Network access policy for the container."""
32+
33+
skills: Iterable[Skill]
34+
"""An optional list of skills referenced by id or inline data."""
35+
2536

2637
class ExpiresAfter(TypedDict, total=False):
2738
"""Container expiration time in seconds relative to the 'anchor' time."""
@@ -33,3 +44,8 @@ class ExpiresAfter(TypedDict, total=False):
3344
"""
3445

3546
minutes: Required[int]
47+
48+
49+
NetworkPolicy: TypeAlias = Union[ContainerNetworkPolicyDisabledParam, ContainerNetworkPolicyAllowlistParam]
50+
51+
Skill: TypeAlias = Union[SkillReferenceParam, InlineSkillParam]

src/openai/types/container_create_response.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import Optional
3+
from typing import List, Optional
44
from typing_extensions import Literal
55

66
from .._models import BaseModel
77

8-
__all__ = ["ContainerCreateResponse", "ExpiresAfter"]
8+
__all__ = ["ContainerCreateResponse", "ExpiresAfter", "NetworkPolicy"]
99

1010

1111
class ExpiresAfter(BaseModel):
@@ -22,6 +22,16 @@ class ExpiresAfter(BaseModel):
2222
"""The number of minutes after the anchor before the container expires."""
2323

2424

25+
class NetworkPolicy(BaseModel):
26+
"""Network access policy for the container."""
27+
28+
type: Literal["allowlist", "disabled"]
29+
"""The network policy mode."""
30+
31+
allowed_domains: Optional[List[str]] = None
32+
"""Allowed outbound domains when `type` is `allowlist`."""
33+
34+
2535
class ContainerCreateResponse(BaseModel):
2636
id: str
2737
"""Unique identifier for the container."""
@@ -50,3 +60,6 @@ class ContainerCreateResponse(BaseModel):
5060

5161
memory_limit: Optional[Literal["1g", "4g", "16g", "64g"]] = None
5262
"""The memory limit configured for the container."""
63+
64+
network_policy: Optional[NetworkPolicy] = None
65+
"""Network access policy for the container."""

src/openai/types/container_list_params.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class ContainerListParams(TypedDict, total=False):
2323
Limit can range between 1 and 100, and the default is 20.
2424
"""
2525

26+
name: str
27+
"""Filter results by container name."""
28+
2629
order: Literal["asc", "desc"]
2730
"""Sort order by the `created_at` timestamp of the objects.
2831

src/openai/types/container_list_response.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import Optional
3+
from typing import List, Optional
44
from typing_extensions import Literal
55

66
from .._models import BaseModel
77

8-
__all__ = ["ContainerListResponse", "ExpiresAfter"]
8+
__all__ = ["ContainerListResponse", "ExpiresAfter", "NetworkPolicy"]
99

1010

1111
class ExpiresAfter(BaseModel):
@@ -22,6 +22,16 @@ class ExpiresAfter(BaseModel):
2222
"""The number of minutes after the anchor before the container expires."""
2323

2424

25+
class NetworkPolicy(BaseModel):
26+
"""Network access policy for the container."""
27+
28+
type: Literal["allowlist", "disabled"]
29+
"""The network policy mode."""
30+
31+
allowed_domains: Optional[List[str]] = None
32+
"""Allowed outbound domains when `type` is `allowlist`."""
33+
34+
2535
class ContainerListResponse(BaseModel):
2636
id: str
2737
"""Unique identifier for the container."""
@@ -50,3 +60,6 @@ class ContainerListResponse(BaseModel):
5060

5161
memory_limit: Optional[Literal["1g", "4g", "16g", "64g"]] = None
5262
"""The memory limit configured for the container."""
63+
64+
network_policy: Optional[NetworkPolicy] = None
65+
"""Network access policy for the container."""

src/openai/types/container_retrieve_response.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import Optional
3+
from typing import List, Optional
44
from typing_extensions import Literal
55

66
from .._models import BaseModel
77

8-
__all__ = ["ContainerRetrieveResponse", "ExpiresAfter"]
8+
__all__ = ["ContainerRetrieveResponse", "ExpiresAfter", "NetworkPolicy"]
99

1010

1111
class ExpiresAfter(BaseModel):
@@ -22,6 +22,16 @@ class ExpiresAfter(BaseModel):
2222
"""The number of minutes after the anchor before the container expires."""
2323

2424

25+
class NetworkPolicy(BaseModel):
26+
"""Network access policy for the container."""
27+
28+
type: Literal["allowlist", "disabled"]
29+
"""The network policy mode."""
30+
31+
allowed_domains: Optional[List[str]] = None
32+
"""Allowed outbound domains when `type` is `allowlist`."""
33+
34+
2535
class ContainerRetrieveResponse(BaseModel):
2636
id: str
2737
"""Unique identifier for the container."""
@@ -50,3 +60,6 @@ class ContainerRetrieveResponse(BaseModel):
5060

5161
memory_limit: Optional[Literal["1g", "4g", "16g", "64g"]] = None
5262
"""The memory limit configured for the container."""
63+
64+
network_policy: Optional[NetworkPolicy] = None
65+
"""Network access policy for the container."""

tests/api_resources/test_containers.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ def test_method_create_with_all_params(self, client: OpenAI) -> None:
3939
},
4040
file_ids=["string"],
4141
memory_limit="1g",
42+
network_policy={"type": "disabled"},
43+
skills=[
44+
{
45+
"skill_id": "x",
46+
"type": "skill_reference",
47+
"version": "version",
48+
}
49+
],
4250
)
4351
assert_matches_type(ContainerCreateResponse, container, path=["response"])
4452

@@ -114,6 +122,7 @@ def test_method_list_with_all_params(self, client: OpenAI) -> None:
114122
container = client.containers.list(
115123
after="after",
116124
limit=0,
125+
name="name",
117126
order="asc",
118127
)
119128
assert_matches_type(SyncCursorPage[ContainerListResponse], container, path=["response"])
@@ -199,6 +208,14 @@ async def test_method_create_with_all_params(self, async_client: AsyncOpenAI) ->
199208
},
200209
file_ids=["string"],
201210
memory_limit="1g",
211+
network_policy={"type": "disabled"},
212+
skills=[
213+
{
214+
"skill_id": "x",
215+
"type": "skill_reference",
216+
"version": "version",
217+
}
218+
],
202219
)
203220
assert_matches_type(ContainerCreateResponse, container, path=["response"])
204221

@@ -274,6 +291,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncOpenAI) -> N
274291
container = await async_client.containers.list(
275292
after="after",
276293
limit=0,
294+
name="name",
277295
order="asc",
278296
)
279297
assert_matches_type(AsyncCursorPage[ContainerListResponse], container, path=["response"])

0 commit comments

Comments
 (0)