Skip to content

Commit 836f18d

Browse files
chore: Add archive method to stainless (#7537)
1 parent 273fb5e commit 836f18d

File tree

9 files changed

+225
-8
lines changed

9 files changed

+225
-8
lines changed

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 117
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runloop-ai%2Frunloop-1ee005e7d8f97067abb96c6a38af53b69d362f2511ca775a9b78580a9643c253.yml
3-
openapi_spec_hash: 9c54d19abf7993fd55714759f3265f9c
4-
config_hash: eb28692edd68a6ae95cf92af931c9976
1+
configured_endpoints: 118
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runloop-ai%2Frunloop-1a92de99959f20ab5850a7f89db21cb66269b2e0002ffc5e5afbe660d05b0768.yml
3+
openapi_spec_hash: 41e4660f26e27e6ab94d223da4ec1253
4+
config_hash: cbda3692cb48ab8582a0df1674b9e5c8

api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ Methods:
277277
- <code title="get /v1/scenarios/{id}">client.scenarios.<a href="./src/runloop_api_client/resources/scenarios/scenarios.py">retrieve</a>(id) -> <a href="./src/runloop_api_client/types/scenario_view.py">ScenarioView</a></code>
278278
- <code title="post /v1/scenarios/{id}">client.scenarios.<a href="./src/runloop_api_client/resources/scenarios/scenarios.py">update</a>(id, \*\*<a href="src/runloop_api_client/types/scenario_update_params.py">params</a>) -> <a href="./src/runloop_api_client/types/scenario_view.py">ScenarioView</a></code>
279279
- <code title="get /v1/scenarios">client.scenarios.<a href="./src/runloop_api_client/resources/scenarios/scenarios.py">list</a>(\*\*<a href="src/runloop_api_client/types/scenario_list_params.py">params</a>) -> <a href="./src/runloop_api_client/types/scenario_view.py">SyncScenariosCursorIDPage[ScenarioView]</a></code>
280+
- <code title="post /v1/scenarios/{id}/archive">client.scenarios.<a href="./src/runloop_api_client/resources/scenarios/scenarios.py">archive</a>(id) -> <a href="./src/runloop_api_client/types/scenario_view.py">ScenarioView</a></code>
280281
- <code title="get /v1/scenarios/list_public">client.scenarios.<a href="./src/runloop_api_client/resources/scenarios/scenarios.py">list_public</a>(\*\*<a href="src/runloop_api_client/types/scenario_list_public_params.py">params</a>) -> <a href="./src/runloop_api_client/types/scenario_view.py">SyncScenariosCursorIDPage[ScenarioView]</a></code>
281282
- <code title="post /v1/scenarios/start_run">client.scenarios.<a href="./src/runloop_api_client/resources/scenarios/scenarios.py">start_run</a>(\*\*<a href="src/runloop_api_client/types/scenario_start_run_params.py">params</a>) -> <a href="./src/runloop_api_client/types/scenario_run_view.py">ScenarioRunView</a></code>
282283

src/runloop_api_client/resources/devboxes/devboxes.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,7 @@ def enable_tunnel(
807807
id: str,
808808
*,
809809
auth_mode: Optional[Literal["open", "authenticated"]] | Omit = omit,
810+
http_keep_alive: Optional[bool] | Omit = omit,
810811
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
811812
# The extra values given here take precedence over values defined on the client or passed to this method.
812813
extra_headers: Headers | None = None,
@@ -826,6 +827,9 @@ def enable_tunnel(
826827
Args:
827828
auth_mode: Authentication mode for the tunnel. Defaults to 'public' if not specified.
828829
830+
http_keep_alive: When true, HTTP traffic through the tunnel counts as activity for idle lifecycle
831+
policies, resetting the idle timer. Defaults to true if not specified.
832+
829833
extra_headers: Send extra headers
830834
831835
extra_query: Add additional query parameters to the request
@@ -840,7 +844,13 @@ def enable_tunnel(
840844
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
841845
return self._post(
842846
f"/v1/devboxes/{id}/enable_tunnel",
843-
body=maybe_transform({"auth_mode": auth_mode}, devbox_enable_tunnel_params.DevboxEnableTunnelParams),
847+
body=maybe_transform(
848+
{
849+
"auth_mode": auth_mode,
850+
"http_keep_alive": http_keep_alive,
851+
},
852+
devbox_enable_tunnel_params.DevboxEnableTunnelParams,
853+
),
844854
options=make_request_options(
845855
extra_headers=extra_headers,
846856
extra_query=extra_query,
@@ -2472,6 +2482,7 @@ async def enable_tunnel(
24722482
id: str,
24732483
*,
24742484
auth_mode: Optional[Literal["open", "authenticated"]] | Omit = omit,
2485+
http_keep_alive: Optional[bool] | Omit = omit,
24752486
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
24762487
# The extra values given here take precedence over values defined on the client or passed to this method.
24772488
extra_headers: Headers | None = None,
@@ -2491,6 +2502,9 @@ async def enable_tunnel(
24912502
Args:
24922503
auth_mode: Authentication mode for the tunnel. Defaults to 'public' if not specified.
24932504
2505+
http_keep_alive: When true, HTTP traffic through the tunnel counts as activity for idle lifecycle
2506+
policies, resetting the idle timer. Defaults to true if not specified.
2507+
24942508
extra_headers: Send extra headers
24952509
24962510
extra_query: Add additional query parameters to the request
@@ -2506,7 +2520,11 @@ async def enable_tunnel(
25062520
return await self._post(
25072521
f"/v1/devboxes/{id}/enable_tunnel",
25082522
body=await async_maybe_transform(
2509-
{"auth_mode": auth_mode}, devbox_enable_tunnel_params.DevboxEnableTunnelParams
2523+
{
2524+
"auth_mode": auth_mode,
2525+
"http_keep_alive": http_keep_alive,
2526+
},
2527+
devbox_enable_tunnel_params.DevboxEnableTunnelParams,
25102528
),
25112529
options=make_request_options(
25122530
extra_headers=extra_headers,

src/runloop_api_client/resources/scenarios/scenarios.py

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,48 @@ def list(
353353
model=ScenarioView,
354354
)
355355

356+
def archive(
357+
self,
358+
id: str,
359+
*,
360+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
361+
# The extra values given here take precedence over values defined on the client or passed to this method.
362+
extra_headers: Headers | None = None,
363+
extra_query: Query | None = None,
364+
extra_body: Body | None = None,
365+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
366+
idempotency_key: str | None = None,
367+
) -> ScenarioView:
368+
"""Archive a previously created Scenario.
369+
370+
The scenario will no longer appear in
371+
list endpoints but can still be retrieved by ID.
372+
373+
Args:
374+
extra_headers: Send extra headers
375+
376+
extra_query: Add additional query parameters to the request
377+
378+
extra_body: Add additional JSON properties to the request
379+
380+
timeout: Override the client-level default timeout for this request, in seconds
381+
382+
idempotency_key: Specify a custom idempotency key for this request
383+
"""
384+
if not id:
385+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
386+
return self._post(
387+
f"/v1/scenarios/{id}/archive",
388+
options=make_request_options(
389+
extra_headers=extra_headers,
390+
extra_query=extra_query,
391+
extra_body=extra_body,
392+
timeout=timeout,
393+
idempotency_key=idempotency_key,
394+
),
395+
cast_to=ScenarioView,
396+
)
397+
356398
def list_public(
357399
self,
358400
*,
@@ -823,6 +865,48 @@ def list(
823865
model=ScenarioView,
824866
)
825867

868+
async def archive(
869+
self,
870+
id: str,
871+
*,
872+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
873+
# The extra values given here take precedence over values defined on the client or passed to this method.
874+
extra_headers: Headers | None = None,
875+
extra_query: Query | None = None,
876+
extra_body: Body | None = None,
877+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
878+
idempotency_key: str | None = None,
879+
) -> ScenarioView:
880+
"""Archive a previously created Scenario.
881+
882+
The scenario will no longer appear in
883+
list endpoints but can still be retrieved by ID.
884+
885+
Args:
886+
extra_headers: Send extra headers
887+
888+
extra_query: Add additional query parameters to the request
889+
890+
extra_body: Add additional JSON properties to the request
891+
892+
timeout: Override the client-level default timeout for this request, in seconds
893+
894+
idempotency_key: Specify a custom idempotency key for this request
895+
"""
896+
if not id:
897+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
898+
return await self._post(
899+
f"/v1/scenarios/{id}/archive",
900+
options=make_request_options(
901+
extra_headers=extra_headers,
902+
extra_query=extra_query,
903+
extra_body=extra_body,
904+
timeout=timeout,
905+
idempotency_key=idempotency_key,
906+
),
907+
cast_to=ScenarioView,
908+
)
909+
826910
def list_public(
827911
self,
828912
*,
@@ -1005,6 +1089,9 @@ def __init__(self, scenarios: ScenariosResource) -> None:
10051089
self.list = to_raw_response_wrapper(
10061090
scenarios.list,
10071091
)
1092+
self.archive = to_raw_response_wrapper(
1093+
scenarios.archive,
1094+
)
10081095
self.list_public = to_raw_response_wrapper(
10091096
scenarios.list_public,
10101097
)
@@ -1037,6 +1124,9 @@ def __init__(self, scenarios: AsyncScenariosResource) -> None:
10371124
self.list = async_to_raw_response_wrapper(
10381125
scenarios.list,
10391126
)
1127+
self.archive = async_to_raw_response_wrapper(
1128+
scenarios.archive,
1129+
)
10401130
self.list_public = async_to_raw_response_wrapper(
10411131
scenarios.list_public,
10421132
)
@@ -1069,6 +1159,9 @@ def __init__(self, scenarios: ScenariosResource) -> None:
10691159
self.list = to_streamed_response_wrapper(
10701160
scenarios.list,
10711161
)
1162+
self.archive = to_streamed_response_wrapper(
1163+
scenarios.archive,
1164+
)
10721165
self.list_public = to_streamed_response_wrapper(
10731166
scenarios.list_public,
10741167
)
@@ -1101,6 +1194,9 @@ def __init__(self, scenarios: AsyncScenariosResource) -> None:
11011194
self.list = async_to_streamed_response_wrapper(
11021195
scenarios.list,
11031196
)
1197+
self.archive = async_to_streamed_response_wrapper(
1198+
scenarios.archive,
1199+
)
11041200
self.list_public = async_to_streamed_response_wrapper(
11051201
scenarios.list_public,
11061202
)

src/runloop_api_client/types/devbox_create_params.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,9 @@ class Tunnel(TypedDict, total=False):
142142

143143
auth_mode: Optional[Literal["open", "authenticated"]]
144144
"""Authentication mode for the tunnel. Defaults to 'public' if not specified."""
145+
146+
http_keep_alive: Optional[bool]
147+
"""
148+
When true, HTTP traffic through the tunnel counts as activity for idle lifecycle
149+
policies, resetting the idle timer. Defaults to true if not specified.
150+
"""

src/runloop_api_client/types/devbox_enable_tunnel_params.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@
1111
class DevboxEnableTunnelParams(TypedDict, total=False):
1212
auth_mode: Optional[Literal["open", "authenticated"]]
1313
"""Authentication mode for the tunnel. Defaults to 'public' if not specified."""
14+
15+
http_keep_alive: Optional[bool]
16+
"""
17+
When true, HTTP traffic through the tunnel counts as activity for idle lifecycle
18+
policies, resetting the idle timer. Defaults to true if not specified.
19+
"""

src/runloop_api_client/types/tunnel_view.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ class TunnelView(BaseModel):
2121
create_time_ms: int
2222
"""Creation time of the tunnel (Unix timestamp milliseconds)."""
2323

24+
http_keep_alive: bool
25+
"""
26+
When true, HTTP traffic through the tunnel counts as activity for idle lifecycle
27+
policies, resetting the idle timer.
28+
"""
29+
2430
tunnel_key: str
2531
"""The encrypted tunnel key used to construct the tunnel URL.
2632

tests/api_resources/test_devboxes.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ def test_method_create_with_all_params(self, client: Runloop) -> None:
111111
repo_connection_id="repo_connection_id",
112112
secrets={"foo": "string"},
113113
snapshot_id="snapshot_id",
114-
tunnel={"auth_mode": "open"},
114+
tunnel={
115+
"auth_mode": "open",
116+
"http_keep_alive": True,
117+
},
115118
)
116119
assert_matches_type(DevboxView, devbox, path=["response"])
117120

@@ -447,6 +450,7 @@ def test_method_enable_tunnel_with_all_params(self, client: Runloop) -> None:
447450
devbox = client.devboxes.enable_tunnel(
448451
id="id",
449452
auth_mode="open",
453+
http_keep_alive=True,
450454
)
451455
assert_matches_type(TunnelView, devbox, path=["response"])
452456

@@ -1775,7 +1779,10 @@ async def test_method_create_with_all_params(self, async_client: AsyncRunloop) -
17751779
repo_connection_id="repo_connection_id",
17761780
secrets={"foo": "string"},
17771781
snapshot_id="snapshot_id",
1778-
tunnel={"auth_mode": "open"},
1782+
tunnel={
1783+
"auth_mode": "open",
1784+
"http_keep_alive": True,
1785+
},
17791786
)
17801787
assert_matches_type(DevboxView, devbox, path=["response"])
17811788

@@ -2111,6 +2118,7 @@ async def test_method_enable_tunnel_with_all_params(self, async_client: AsyncRun
21112118
devbox = await async_client.devboxes.enable_tunnel(
21122119
id="id",
21132120
auth_mode="open",
2121+
http_keep_alive=True,
21142122
)
21152123
assert_matches_type(TunnelView, devbox, path=["response"])
21162124

tests/api_resources/test_scenarios.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,44 @@ def test_streaming_response_list(self, client: Runloop) -> None:
319319

320320
assert cast(Any, response.is_closed) is True
321321

322+
@parametrize
323+
def test_method_archive(self, client: Runloop) -> None:
324+
scenario = client.scenarios.archive(
325+
"id",
326+
)
327+
assert_matches_type(ScenarioView, scenario, path=["response"])
328+
329+
@parametrize
330+
def test_raw_response_archive(self, client: Runloop) -> None:
331+
response = client.scenarios.with_raw_response.archive(
332+
"id",
333+
)
334+
335+
assert response.is_closed is True
336+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
337+
scenario = response.parse()
338+
assert_matches_type(ScenarioView, scenario, path=["response"])
339+
340+
@parametrize
341+
def test_streaming_response_archive(self, client: Runloop) -> None:
342+
with client.scenarios.with_streaming_response.archive(
343+
"id",
344+
) as response:
345+
assert not response.is_closed
346+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
347+
348+
scenario = response.parse()
349+
assert_matches_type(ScenarioView, scenario, path=["response"])
350+
351+
assert cast(Any, response.is_closed) is True
352+
353+
@parametrize
354+
def test_path_params_archive(self, client: Runloop) -> None:
355+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
356+
client.scenarios.with_raw_response.archive(
357+
"",
358+
)
359+
322360
@parametrize
323361
def test_method_list_public(self, client: Runloop) -> None:
324362
scenario = client.scenarios.list_public()
@@ -730,6 +768,44 @@ async def test_streaming_response_list(self, async_client: AsyncRunloop) -> None
730768

731769
assert cast(Any, response.is_closed) is True
732770

771+
@parametrize
772+
async def test_method_archive(self, async_client: AsyncRunloop) -> None:
773+
scenario = await async_client.scenarios.archive(
774+
"id",
775+
)
776+
assert_matches_type(ScenarioView, scenario, path=["response"])
777+
778+
@parametrize
779+
async def test_raw_response_archive(self, async_client: AsyncRunloop) -> None:
780+
response = await async_client.scenarios.with_raw_response.archive(
781+
"id",
782+
)
783+
784+
assert response.is_closed is True
785+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
786+
scenario = await response.parse()
787+
assert_matches_type(ScenarioView, scenario, path=["response"])
788+
789+
@parametrize
790+
async def test_streaming_response_archive(self, async_client: AsyncRunloop) -> None:
791+
async with async_client.scenarios.with_streaming_response.archive(
792+
"id",
793+
) as response:
794+
assert not response.is_closed
795+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
796+
797+
scenario = await response.parse()
798+
assert_matches_type(ScenarioView, scenario, path=["response"])
799+
800+
assert cast(Any, response.is_closed) is True
801+
802+
@parametrize
803+
async def test_path_params_archive(self, async_client: AsyncRunloop) -> None:
804+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
805+
await async_client.scenarios.with_raw_response.archive(
806+
"",
807+
)
808+
733809
@parametrize
734810
async def test_method_list_public(self, async_client: AsyncRunloop) -> None:
735811
scenario = await async_client.scenarios.list_public()

0 commit comments

Comments
 (0)