Skip to content
Merged
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
24 changes: 16 additions & 8 deletions src/runloop_api_client/resources/devboxes/devboxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,9 @@ def create_ssh_key(
cast_to=DevboxCreateSSHKeyResponse,
)

@typing_extensions.deprecated("deprecated")
@typing_extensions.deprecated(
"create_tunnel is deprecated; use enable_tunnel or configure a tunnel at devbox creation."
)
def create_tunnel(
self,
id: str,
Expand All @@ -666,7 +668,7 @@ def create_tunnel(
timeout: float | httpx.Timeout | None | NotGiven = not_given,
idempotency_key: str | None = None,
) -> DevboxTunnelView:
"""[Deprecated] Use POST /v1/devboxes/{id}/enable_tunnel instead.
"""[Deprecated] Use enable_tunnel or configure a tunnel at devbox creation instead.

This endpoint
creates a legacy tunnel. The new enable_tunnel endpoint provides improved tunnel
Expand Down Expand Up @@ -1270,7 +1272,9 @@ def read_file_contents(
cast_to=str,
)

@typing_extensions.deprecated("deprecated")
@typing_extensions.deprecated(
"remove_tunnel is deprecated; V2 tunnels cannot be removed and close on devbox shutdown."
)
def remove_tunnel(
self,
id: str,
Expand All @@ -1284,7 +1288,7 @@ def remove_tunnel(
timeout: float | httpx.Timeout | None | NotGiven = not_given,
idempotency_key: str | None = None,
) -> object:
"""[Deprecated] Tunnels remain active until devbox is shutdown.
"""[Deprecated] V2 tunnels cannot be removed and close on devbox shutdown.

This endpoint
removes a legacy tunnel.
Expand Down Expand Up @@ -2261,7 +2265,9 @@ async def create_ssh_key(
cast_to=DevboxCreateSSHKeyResponse,
)

@typing_extensions.deprecated("deprecated")
@typing_extensions.deprecated(
"create_tunnel is deprecated; use enable_tunnel or configure a tunnel at devbox creation."
)
async def create_tunnel(
self,
id: str,
Expand All @@ -2275,7 +2281,7 @@ async def create_tunnel(
timeout: float | httpx.Timeout | None | NotGiven = not_given,
idempotency_key: str | None = None,
) -> DevboxTunnelView:
"""[Deprecated] Use POST /v1/devboxes/{id}/enable_tunnel instead.
"""[Deprecated] Use enable_tunnel or configure a tunnel at devbox creation instead.

This endpoint
creates a legacy tunnel. The new enable_tunnel endpoint provides improved tunnel
Expand Down Expand Up @@ -2882,7 +2888,9 @@ async def read_file_contents(
cast_to=str,
)

@typing_extensions.deprecated("deprecated")
@typing_extensions.deprecated(
"remove_tunnel is deprecated; V2 tunnels cannot be removed and close on devbox shutdown."
)
async def remove_tunnel(
self,
id: str,
Expand All @@ -2896,7 +2904,7 @@ async def remove_tunnel(
timeout: float | httpx.Timeout | None | NotGiven = not_given,
idempotency_key: str | None = None,
) -> object:
"""[Deprecated] Tunnels remain active until devbox is shutdown.
"""[Deprecated] V2 tunnels cannot be removed and close on devbox shutdown.

This endpoint
removes a legacy tunnel.
Expand Down
14 changes: 12 additions & 2 deletions src/runloop_api_client/sdk/async_devbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ async def create_tunnel(
) -> DevboxTunnelView:
"""[Deprecated] Create a legacy tunnel to expose a devbox port publicly.

Use :meth:`enable_tunnel` instead for the V2 tunnel API.
Use :meth:`enable_tunnel` or configure a tunnel during devbox creation instead.

:param params: See :typeddict:`~runloop_api_client.sdk._types.SDKDevboxCreateTunnelParams` for available parameters
:return: Details about the public endpoint
Expand All @@ -789,6 +789,11 @@ async def create_tunnel(
>>> tunnel = await devbox.net.create_tunnel(port=8080)
>>> print(f"Public URL: {tunnel.url}")
"""
warnings.warn(
"create_tunnel is deprecated; use enable_tunnel or configure a tunnel at devbox creation.",
DeprecationWarning,
stacklevel=2,
)
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
return await self._devbox._client.devboxes.create_tunnel( # type: ignore[deprecated]
Expand Down Expand Up @@ -824,7 +829,7 @@ async def remove_tunnel(
self,
**params: Unpack[SDKDevboxRemoveTunnelParams],
) -> object:
"""Remove a network tunnel, disabling public access to the port.
"""[Deprecated] V2 tunnels cannot be removed and close on devbox shutdown.

:param params: See :typeddict:`~runloop_api_client.sdk._types.SDKDevboxRemoveTunnelParams` for available parameters
:return: Response confirming the tunnel removal
Expand All @@ -833,6 +838,11 @@ async def remove_tunnel(
Example:
>>> await devbox.net.remove_tunnel(port=8080)
"""
warnings.warn(
"remove_tunnel is deprecated; V2 tunnels cannot be removed and close on devbox shutdown.",
DeprecationWarning,
stacklevel=2,
)
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
return await self._devbox._client.devboxes.remove_tunnel( # type: ignore[deprecated]
Expand Down
14 changes: 12 additions & 2 deletions src/runloop_api_client/sdk/devbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ def create_tunnel(
) -> DevboxTunnelView:
"""[Deprecated] Create a legacy tunnel to expose a devbox port publicly.

Use :meth:`enable_tunnel` instead for the V2 tunnel API.
Use :meth:`enable_tunnel` or configure a tunnel during devbox creation instead.

:param params: See :typeddict:`~runloop_api_client.sdk._types.SDKDevboxCreateTunnelParams` for available parameters
:return: Details about the public endpoint
Expand All @@ -792,6 +792,11 @@ def create_tunnel(
>>> tunnel = devbox.net.create_tunnel(port=8080)
>>> print(f"Public URL: {tunnel.url}")
"""
warnings.warn(
"create_tunnel is deprecated; use enable_tunnel or configure a tunnel at devbox creation.",
DeprecationWarning,
stacklevel=2,
)
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
return self._devbox._client.devboxes.create_tunnel( # type: ignore[deprecated]
Expand Down Expand Up @@ -827,7 +832,7 @@ def remove_tunnel(
self,
**params: Unpack[SDKDevboxRemoveTunnelParams],
) -> object:
"""Remove a network tunnel, disabling public access to the port.
"""[Deprecated] V2 tunnels cannot be removed and close on devbox shutdown.

:param params: See :typeddict:`~runloop_api_client.sdk._types.SDKDevboxRemoveTunnelParams` for available parameters
:return: Response confirming the tunnel removal
Expand All @@ -836,6 +841,11 @@ def remove_tunnel(
Example:
>>> devbox.net.remove_tunnel(port=8080)
"""
warnings.warn(
"remove_tunnel is deprecated; V2 tunnels cannot be removed and close on devbox shutdown.",
DeprecationWarning,
stacklevel=2,
)
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
return self._devbox._client.devboxes.remove_tunnel( # type: ignore[deprecated]
Expand Down
34 changes: 18 additions & 16 deletions tests/sdk/async_devbox/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,15 @@ async def test_create_tunnel(self, mock_async_client: AsyncMock) -> None:
mock_async_client.devboxes.create_tunnel = AsyncMock(return_value=tunnel_view)

devbox = AsyncDevbox(mock_async_client, "dbx_123")
result = await devbox.net.create_tunnel(
port=8080,
extra_headers={"X-Custom": "value"},
extra_query={"param": "value"},
extra_body={"key": "value"},
timeout=30.0,
idempotency_key="key-123",
)
with pytest.warns(DeprecationWarning, match="create_tunnel is deprecated"):
result = await devbox.net.create_tunnel(
port=8080,
extra_headers={"X-Custom": "value"},
extra_query={"param": "value"},
extra_body={"key": "value"},
timeout=30.0,
idempotency_key="key-123",
)

assert result == tunnel_view
mock_async_client.devboxes.create_tunnel.assert_called_once()
Expand All @@ -203,14 +204,15 @@ async def test_remove_tunnel(self, mock_async_client: AsyncMock) -> None:
mock_async_client.devboxes.remove_tunnel = AsyncMock(return_value=object())

devbox = AsyncDevbox(mock_async_client, "dbx_123")
result = await devbox.net.remove_tunnel(
port=8080,
extra_headers={"X-Custom": "value"},
extra_query={"param": "value"},
extra_body={"key": "value"},
timeout=30.0,
idempotency_key="key-123",
)
with pytest.warns(DeprecationWarning, match="remove_tunnel is deprecated"):
result = await devbox.net.remove_tunnel(
port=8080,
extra_headers={"X-Custom": "value"},
extra_query={"param": "value"},
extra_body={"key": "value"},
timeout=30.0,
idempotency_key="key-123",
)

assert result is not None # Verify return value is propagated
mock_async_client.devboxes.remove_tunnel.assert_called_once()
35 changes: 19 additions & 16 deletions tests/sdk/devbox/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from unittest.mock import Mock

import httpx
import pytest

from tests.sdk.conftest import MockExecutionView
from runloop_api_client.sdk import Devbox
Expand Down Expand Up @@ -285,14 +286,15 @@ def test_create_tunnel(self, mock_client: Mock) -> None:
mock_client.devboxes.create_tunnel.return_value = tunnel_view

devbox = Devbox(mock_client, "dbx_123")
result = devbox.net.create_tunnel(
port=8080,
extra_headers={"X-Custom": "value"},
extra_query={"param": "value"},
extra_body={"key": "value"},
timeout=30.0,
idempotency_key="key-123",
)
with pytest.warns(DeprecationWarning, match="create_tunnel is deprecated"):
result = devbox.net.create_tunnel(
port=8080,
extra_headers={"X-Custom": "value"},
extra_query={"param": "value"},
extra_body={"key": "value"},
timeout=30.0,
idempotency_key="key-123",
)

assert result == tunnel_view
mock_client.devboxes.create_tunnel.assert_called_once_with(
Expand All @@ -310,14 +312,15 @@ def test_remove_tunnel(self, mock_client: Mock) -> None:
mock_client.devboxes.remove_tunnel.return_value = object()

devbox = Devbox(mock_client, "dbx_123")
result = devbox.net.remove_tunnel(
port=8080,
extra_headers={"X-Custom": "value"},
extra_query={"param": "value"},
extra_body={"key": "value"},
timeout=30.0,
idempotency_key="key-123",
)
with pytest.warns(DeprecationWarning, match="remove_tunnel is deprecated"):
result = devbox.net.remove_tunnel(
port=8080,
extra_headers={"X-Custom": "value"},
extra_query={"param": "value"},
extra_body={"key": "value"},
timeout=30.0,
idempotency_key="key-123",
)

assert result is not None # Verify return value is propagated
mock_client.devboxes.remove_tunnel.assert_called_once_with(
Expand Down
6 changes: 4 additions & 2 deletions tests/smoketests/sdk/test_async_devbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,14 +447,16 @@ async def test_create_and_remove_tunnel(self, async_sdk_client: AsyncRunloopSDK)

try:
# Create tunnel
tunnel = await devbox.net.create_tunnel(port=8080)
with pytest.warns(DeprecationWarning, match="create_tunnel is deprecated"):
tunnel = await devbox.net.create_tunnel(port=8080)
assert tunnel is not None
assert tunnel.url is not None
assert tunnel.port == 8080
assert tunnel.devbox_id == devbox.id

# Remove tunnel
await devbox.net.remove_tunnel(port=8080)
with pytest.warns(DeprecationWarning, match="remove_tunnel is deprecated"):
await devbox.net.remove_tunnel(port=8080)
finally:
await devbox.shutdown()

Expand Down
6 changes: 4 additions & 2 deletions tests/smoketests/sdk/test_devbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,14 +444,16 @@ def test_create_and_remove_tunnel(self, sdk_client: RunloopSDK) -> None:

try:
# Create tunnel
tunnel = devbox.net.create_tunnel(port=8080)
with pytest.warns(DeprecationWarning, match="create_tunnel is deprecated"):
tunnel = devbox.net.create_tunnel(port=8080)
assert tunnel is not None
assert tunnel.url is not None
assert tunnel.port == 8080
assert tunnel.devbox_id == devbox.id

# Remove tunnel
devbox.net.remove_tunnel(port=8080)
with pytest.warns(DeprecationWarning, match="remove_tunnel is deprecated"):
devbox.net.remove_tunnel(port=8080)
finally:
devbox.shutdown()

Expand Down