Skip to content

Commit a0841a4

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(api): OpenAPI spec update via Stainless API (#101)
1 parent 772cfa1 commit a0841a4

2 files changed

Lines changed: 30 additions & 16 deletions

File tree

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 23
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runloop-ai%2Frunloop-bf3950d5829c4fb7d7692900bd5f18ea4dcd0b14e8a417d66166c91fd747039f.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runloop-ai%2Frunloop-8dd1329492bd6c23ed374d72abfc2ab7928cd398f06f849865dc48cc2ecf6b8a.yml

src/runloop_api_client/resources/devboxes/devboxes.py

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import Dict, List
5+
from typing import Dict, List, Mapping, cast
66

77
import httpx
88

@@ -25,7 +25,9 @@
2525
)
2626
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
2727
from ..._utils import (
28+
extract_files,
2829
maybe_transform,
30+
deepcopy_minimal,
2931
async_maybe_transform,
3032
)
3133
from ..._compat import cached_property
@@ -393,15 +395,21 @@ def upload_file(
393395
"""
394396
if not id:
395397
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
398+
body = deepcopy_minimal(
399+
{
400+
"file": file,
401+
"path": path,
402+
}
403+
)
404+
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
405+
# It should be noted that the actual Content-Type header that will be
406+
# sent to the server will contain a `boundary` parameter, e.g.
407+
# multipart/form-data; boundary=---abc--
408+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
396409
return self._post(
397410
f"/v1/devboxes/{id}/upload_file",
398-
body=maybe_transform(
399-
{
400-
"file": file,
401-
"path": path,
402-
},
403-
devbox_upload_file_params.DevboxUploadFileParams,
404-
),
411+
body=maybe_transform(body, devbox_upload_file_params.DevboxUploadFileParams),
412+
files=files,
405413
options=make_request_options(
406414
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
407415
),
@@ -804,15 +812,21 @@ async def upload_file(
804812
"""
805813
if not id:
806814
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
815+
body = deepcopy_minimal(
816+
{
817+
"file": file,
818+
"path": path,
819+
}
820+
)
821+
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
822+
# It should be noted that the actual Content-Type header that will be
823+
# sent to the server will contain a `boundary` parameter, e.g.
824+
# multipart/form-data; boundary=---abc--
825+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
807826
return await self._post(
808827
f"/v1/devboxes/{id}/upload_file",
809-
body=await async_maybe_transform(
810-
{
811-
"file": file,
812-
"path": path,
813-
},
814-
devbox_upload_file_params.DevboxUploadFileParams,
815-
),
828+
body=await async_maybe_transform(body, devbox_upload_file_params.DevboxUploadFileParams),
829+
files=files,
816830
options=make_request_options(
817831
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
818832
),

0 commit comments

Comments
 (0)