|
31 | 31 | devbox_enable_tunnel_params, |
32 | 32 | devbox_execute_async_params, |
33 | 33 | devbox_snapshot_disk_params, |
| 34 | + devbox_create_mcp_token_params, |
34 | 35 | devbox_wait_for_command_params, |
35 | 36 | devbox_read_file_contents_params, |
36 | 37 | devbox_list_disk_snapshots_params, |
37 | 38 | devbox_snapshot_disk_async_params, |
38 | 39 | devbox_write_file_contents_params, |
| 40 | + devbox_create_gateway_token_params, |
39 | 41 | ) |
40 | 42 | from ..._files import deepcopy_with_paths |
41 | 43 | from ..._types import Body, Omit, Query, Headers, NotGiven, FileTypes, omit, not_given |
|
90 | 92 | from ...lib.polling_async import async_poll_until |
91 | 93 | from ...types.devbox_view import DevboxView |
92 | 94 | from ...types.tunnel_view import TunnelView |
| 95 | +from ...types.mcp_token_view import McpTokenView |
93 | 96 | from ...lib.wait_for_status import wait_for_status, async_wait_for_status |
94 | 97 | from ...types.pty_tunnel_view import PtyTunnelView |
| 98 | +from ...types.gateway_token_view import GatewayTokenView |
95 | 99 | from ...types.shared_params.mount import Mount |
96 | 100 | from ...types.devbox_snapshot_view import DevboxSnapshotView |
97 | 101 | from ...types.shared.launch_parameters import LaunchParameters as SharedLaunchParameters |
@@ -608,6 +612,126 @@ def list( |
608 | 612 | model=DevboxView, |
609 | 613 | ) |
610 | 614 |
|
| 615 | + def create_gateway_token( |
| 616 | + self, |
| 617 | + id: str, |
| 618 | + *, |
| 619 | + gateway: str, |
| 620 | + secret: str, |
| 621 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 622 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 623 | + extra_headers: Headers | None = None, |
| 624 | + extra_query: Query | None = None, |
| 625 | + extra_body: Body | None = None, |
| 626 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 627 | + idempotency_key: str | None = None, |
| 628 | + ) -> GatewayTokenView: |
| 629 | + """ |
| 630 | + Mint a token that lets a running Devbox call an external API through the Runloop |
| 631 | + agent gateway, using the credential in the supplied secret. The gateway applies |
| 632 | + the credential to proxied requests, so the real API key is never exposed to the |
| 633 | + Devbox. |
| 634 | +
|
| 635 | + The token is bound to this Devbox and is only accepted for requests that |
| 636 | + originate from it. Nothing is stored on the Devbox: the token is returned to the |
| 637 | + caller and is not re-issued when the Devbox is resumed. |
| 638 | +
|
| 639 | + Args: |
| 640 | + gateway: The gateway config to use. Can be a gateway config ID (gwc_xxx) or name. |
| 641 | +
|
| 642 | + secret: The secret containing the credential. Can be a secret ID or name. |
| 643 | +
|
| 644 | + extra_headers: Send extra headers |
| 645 | +
|
| 646 | + extra_query: Add additional query parameters to the request |
| 647 | +
|
| 648 | + extra_body: Add additional JSON properties to the request |
| 649 | +
|
| 650 | + timeout: Override the client-level default timeout for this request, in seconds |
| 651 | +
|
| 652 | + idempotency_key: Specify a custom idempotency key for this request |
| 653 | + """ |
| 654 | + if not id: |
| 655 | + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") |
| 656 | + return self._post( |
| 657 | + path_template("/v1/devboxes/{id}/create_gateway_token", id=id), |
| 658 | + body=maybe_transform( |
| 659 | + { |
| 660 | + "gateway": gateway, |
| 661 | + "secret": secret, |
| 662 | + }, |
| 663 | + devbox_create_gateway_token_params.DevboxCreateGatewayTokenParams, |
| 664 | + ), |
| 665 | + options=make_request_options( |
| 666 | + extra_headers=extra_headers, |
| 667 | + extra_query=extra_query, |
| 668 | + extra_body=extra_body, |
| 669 | + timeout=timeout, |
| 670 | + idempotency_key=idempotency_key, |
| 671 | + ), |
| 672 | + cast_to=GatewayTokenView, |
| 673 | + ) |
| 674 | + |
| 675 | + def create_mcp_token( |
| 676 | + self, |
| 677 | + id: str, |
| 678 | + *, |
| 679 | + mcp_config: str, |
| 680 | + secret: str, |
| 681 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 682 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 683 | + extra_headers: Headers | None = None, |
| 684 | + extra_query: Query | None = None, |
| 685 | + extra_body: Body | None = None, |
| 686 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 687 | + idempotency_key: str | None = None, |
| 688 | + ) -> McpTokenView: |
| 689 | + """ |
| 690 | + [Beta] Mint a token that lets a running Devbox reach an upstream MCP (Model |
| 691 | + Context Protocol) server through the Runloop MCP hub, using the credential in |
| 692 | + the supplied secret. Tool access is limited to the MCP config's allowed_tools, |
| 693 | + and the credential itself is never exposed to the Devbox. |
| 694 | +
|
| 695 | + The token is bound to this Devbox and is only accepted for requests that |
| 696 | + originate from it. Nothing is stored on the Devbox: the token is returned to the |
| 697 | + caller and is not re-issued when the Devbox is resumed. |
| 698 | +
|
| 699 | + Args: |
| 700 | + mcp_config: The MCP config to use. Can be an MCP config ID (mcp_xxx) or name. |
| 701 | +
|
| 702 | + secret: The secret containing the MCP server credential. Can be a secret ID or name. |
| 703 | +
|
| 704 | + extra_headers: Send extra headers |
| 705 | +
|
| 706 | + extra_query: Add additional query parameters to the request |
| 707 | +
|
| 708 | + extra_body: Add additional JSON properties to the request |
| 709 | +
|
| 710 | + timeout: Override the client-level default timeout for this request, in seconds |
| 711 | +
|
| 712 | + idempotency_key: Specify a custom idempotency key for this request |
| 713 | + """ |
| 714 | + if not id: |
| 715 | + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") |
| 716 | + return self._post( |
| 717 | + path_template("/v1/devboxes/{id}/create_mcp_token", id=id), |
| 718 | + body=maybe_transform( |
| 719 | + { |
| 720 | + "mcp_config": mcp_config, |
| 721 | + "secret": secret, |
| 722 | + }, |
| 723 | + devbox_create_mcp_token_params.DevboxCreateMcpTokenParams, |
| 724 | + ), |
| 725 | + options=make_request_options( |
| 726 | + extra_headers=extra_headers, |
| 727 | + extra_query=extra_query, |
| 728 | + extra_body=extra_body, |
| 729 | + timeout=timeout, |
| 730 | + idempotency_key=idempotency_key, |
| 731 | + ), |
| 732 | + cast_to=McpTokenView, |
| 733 | + ) |
| 734 | + |
611 | 735 | def create_pty_tunnel( |
612 | 736 | self, |
613 | 737 | id: str, |
@@ -2324,6 +2448,126 @@ def list( |
2324 | 2448 | model=DevboxView, |
2325 | 2449 | ) |
2326 | 2450 |
|
| 2451 | + async def create_gateway_token( |
| 2452 | + self, |
| 2453 | + id: str, |
| 2454 | + *, |
| 2455 | + gateway: str, |
| 2456 | + secret: str, |
| 2457 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 2458 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 2459 | + extra_headers: Headers | None = None, |
| 2460 | + extra_query: Query | None = None, |
| 2461 | + extra_body: Body | None = None, |
| 2462 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 2463 | + idempotency_key: str | None = None, |
| 2464 | + ) -> GatewayTokenView: |
| 2465 | + """ |
| 2466 | + Mint a token that lets a running Devbox call an external API through the Runloop |
| 2467 | + agent gateway, using the credential in the supplied secret. The gateway applies |
| 2468 | + the credential to proxied requests, so the real API key is never exposed to the |
| 2469 | + Devbox. |
| 2470 | +
|
| 2471 | + The token is bound to this Devbox and is only accepted for requests that |
| 2472 | + originate from it. Nothing is stored on the Devbox: the token is returned to the |
| 2473 | + caller and is not re-issued when the Devbox is resumed. |
| 2474 | +
|
| 2475 | + Args: |
| 2476 | + gateway: The gateway config to use. Can be a gateway config ID (gwc_xxx) or name. |
| 2477 | +
|
| 2478 | + secret: The secret containing the credential. Can be a secret ID or name. |
| 2479 | +
|
| 2480 | + extra_headers: Send extra headers |
| 2481 | +
|
| 2482 | + extra_query: Add additional query parameters to the request |
| 2483 | +
|
| 2484 | + extra_body: Add additional JSON properties to the request |
| 2485 | +
|
| 2486 | + timeout: Override the client-level default timeout for this request, in seconds |
| 2487 | +
|
| 2488 | + idempotency_key: Specify a custom idempotency key for this request |
| 2489 | + """ |
| 2490 | + if not id: |
| 2491 | + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") |
| 2492 | + return await self._post( |
| 2493 | + path_template("/v1/devboxes/{id}/create_gateway_token", id=id), |
| 2494 | + body=await async_maybe_transform( |
| 2495 | + { |
| 2496 | + "gateway": gateway, |
| 2497 | + "secret": secret, |
| 2498 | + }, |
| 2499 | + devbox_create_gateway_token_params.DevboxCreateGatewayTokenParams, |
| 2500 | + ), |
| 2501 | + options=make_request_options( |
| 2502 | + extra_headers=extra_headers, |
| 2503 | + extra_query=extra_query, |
| 2504 | + extra_body=extra_body, |
| 2505 | + timeout=timeout, |
| 2506 | + idempotency_key=idempotency_key, |
| 2507 | + ), |
| 2508 | + cast_to=GatewayTokenView, |
| 2509 | + ) |
| 2510 | + |
| 2511 | + async def create_mcp_token( |
| 2512 | + self, |
| 2513 | + id: str, |
| 2514 | + *, |
| 2515 | + mcp_config: str, |
| 2516 | + secret: str, |
| 2517 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 2518 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 2519 | + extra_headers: Headers | None = None, |
| 2520 | + extra_query: Query | None = None, |
| 2521 | + extra_body: Body | None = None, |
| 2522 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 2523 | + idempotency_key: str | None = None, |
| 2524 | + ) -> McpTokenView: |
| 2525 | + """ |
| 2526 | + [Beta] Mint a token that lets a running Devbox reach an upstream MCP (Model |
| 2527 | + Context Protocol) server through the Runloop MCP hub, using the credential in |
| 2528 | + the supplied secret. Tool access is limited to the MCP config's allowed_tools, |
| 2529 | + and the credential itself is never exposed to the Devbox. |
| 2530 | +
|
| 2531 | + The token is bound to this Devbox and is only accepted for requests that |
| 2532 | + originate from it. Nothing is stored on the Devbox: the token is returned to the |
| 2533 | + caller and is not re-issued when the Devbox is resumed. |
| 2534 | +
|
| 2535 | + Args: |
| 2536 | + mcp_config: The MCP config to use. Can be an MCP config ID (mcp_xxx) or name. |
| 2537 | +
|
| 2538 | + secret: The secret containing the MCP server credential. Can be a secret ID or name. |
| 2539 | +
|
| 2540 | + extra_headers: Send extra headers |
| 2541 | +
|
| 2542 | + extra_query: Add additional query parameters to the request |
| 2543 | +
|
| 2544 | + extra_body: Add additional JSON properties to the request |
| 2545 | +
|
| 2546 | + timeout: Override the client-level default timeout for this request, in seconds |
| 2547 | +
|
| 2548 | + idempotency_key: Specify a custom idempotency key for this request |
| 2549 | + """ |
| 2550 | + if not id: |
| 2551 | + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") |
| 2552 | + return await self._post( |
| 2553 | + path_template("/v1/devboxes/{id}/create_mcp_token", id=id), |
| 2554 | + body=await async_maybe_transform( |
| 2555 | + { |
| 2556 | + "mcp_config": mcp_config, |
| 2557 | + "secret": secret, |
| 2558 | + }, |
| 2559 | + devbox_create_mcp_token_params.DevboxCreateMcpTokenParams, |
| 2560 | + ), |
| 2561 | + options=make_request_options( |
| 2562 | + extra_headers=extra_headers, |
| 2563 | + extra_query=extra_query, |
| 2564 | + extra_body=extra_body, |
| 2565 | + timeout=timeout, |
| 2566 | + idempotency_key=idempotency_key, |
| 2567 | + ), |
| 2568 | + cast_to=McpTokenView, |
| 2569 | + ) |
| 2570 | + |
2327 | 2571 | async def create_pty_tunnel( |
2328 | 2572 | self, |
2329 | 2573 | id: str, |
@@ -3578,6 +3822,12 @@ def __init__(self, devboxes: DevboxesResource) -> None: |
3578 | 3822 | self.list = to_raw_response_wrapper( |
3579 | 3823 | devboxes.list, |
3580 | 3824 | ) |
| 3825 | + self.create_gateway_token = to_raw_response_wrapper( |
| 3826 | + devboxes.create_gateway_token, |
| 3827 | + ) |
| 3828 | + self.create_mcp_token = to_raw_response_wrapper( |
| 3829 | + devboxes.create_mcp_token, |
| 3830 | + ) |
3581 | 3831 | self.create_pty_tunnel = to_raw_response_wrapper( |
3582 | 3832 | devboxes.create_pty_tunnel, |
3583 | 3833 | ) |
@@ -3677,6 +3927,12 @@ def __init__(self, devboxes: AsyncDevboxesResource) -> None: |
3677 | 3927 | self.list = async_to_raw_response_wrapper( |
3678 | 3928 | devboxes.list, |
3679 | 3929 | ) |
| 3930 | + self.create_gateway_token = async_to_raw_response_wrapper( |
| 3931 | + devboxes.create_gateway_token, |
| 3932 | + ) |
| 3933 | + self.create_mcp_token = async_to_raw_response_wrapper( |
| 3934 | + devboxes.create_mcp_token, |
| 3935 | + ) |
3680 | 3936 | self.create_pty_tunnel = async_to_raw_response_wrapper( |
3681 | 3937 | devboxes.create_pty_tunnel, |
3682 | 3938 | ) |
@@ -3776,6 +4032,12 @@ def __init__(self, devboxes: DevboxesResource) -> None: |
3776 | 4032 | self.list = to_streamed_response_wrapper( |
3777 | 4033 | devboxes.list, |
3778 | 4034 | ) |
| 4035 | + self.create_gateway_token = to_streamed_response_wrapper( |
| 4036 | + devboxes.create_gateway_token, |
| 4037 | + ) |
| 4038 | + self.create_mcp_token = to_streamed_response_wrapper( |
| 4039 | + devboxes.create_mcp_token, |
| 4040 | + ) |
3779 | 4041 | self.create_pty_tunnel = to_streamed_response_wrapper( |
3780 | 4042 | devboxes.create_pty_tunnel, |
3781 | 4043 | ) |
@@ -3875,6 +4137,12 @@ def __init__(self, devboxes: AsyncDevboxesResource) -> None: |
3875 | 4137 | self.list = async_to_streamed_response_wrapper( |
3876 | 4138 | devboxes.list, |
3877 | 4139 | ) |
| 4140 | + self.create_gateway_token = async_to_streamed_response_wrapper( |
| 4141 | + devboxes.create_gateway_token, |
| 4142 | + ) |
| 4143 | + self.create_mcp_token = async_to_streamed_response_wrapper( |
| 4144 | + devboxes.create_mcp_token, |
| 4145 | + ) |
3878 | 4146 | self.create_pty_tunnel = async_to_streamed_response_wrapper( |
3879 | 4147 | devboxes.create_pty_tunnel, |
3880 | 4148 | ) |
|
0 commit comments