Skip to content

Commit 2270fd4

Browse files
feat(api): manual updates
1 parent 7a0c7b2 commit 2270fd4

File tree

5 files changed

+69
-21
lines changed

5 files changed

+69
-21
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 42
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-dd864816d7f4316ae89f57394da2fd1926166d4704db5a0bb5d23461d2d75e49.yml
3-
openapi_spec_hash: 7f7c416563a15bbaea98804ecdc1a8f9
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml
3+
openapi_spec_hash: 1d382866fce3284f26d341f112988d9d
44
config_hash: 54c05a157f2cc730fac9e1df5dc3ca29

src/imagekit/resources/files/files.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def update(
172172
self,
173173
file_id: str,
174174
*,
175-
body: object,
175+
publish: file_update_params.ChangePublicationStatusPublish | Omit = omit,
176176
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
177177
# The extra values given here take precedence over values defined on the client or passed to this method.
178178
extra_headers: Headers | None = None,
@@ -186,6 +186,8 @@ def update(
186186
status, remove existing `AITags` and apply extensions using this API.
187187
188188
Args:
189+
publish: Configure the publication status of a file and its versions.
190+
189191
extra_headers: Send extra headers
190192
191193
extra_query: Add additional query parameters to the request
@@ -207,7 +209,7 @@ def update(
207209
remove_ai_tags: Union[SequenceNotStr[str], Literal["all"]] | Omit = omit,
208210
tags: Optional[SequenceNotStr[str]] | Omit = omit,
209211
webhook_url: str | Omit = omit,
210-
body: object | Omit = omit,
212+
publish: file_update_params.ChangePublicationStatusPublish | Omit = omit,
211213
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
212214
# The extra values given here take precedence over values defined on the client or passed to this method.
213215
extra_headers: Headers | None = None,
@@ -228,7 +230,7 @@ def update(
228230
"remove_ai_tags": remove_ai_tags,
229231
"tags": tags,
230232
"webhook_url": webhook_url,
231-
"body": body,
233+
"publish": publish,
232234
},
233235
file_update_params.FileUpdateParams,
234236
),
@@ -841,7 +843,7 @@ async def update(
841843
self,
842844
file_id: str,
843845
*,
844-
body: object,
846+
publish: file_update_params.ChangePublicationStatusPublish | Omit = omit,
845847
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
846848
# The extra values given here take precedence over values defined on the client or passed to this method.
847849
extra_headers: Headers | None = None,
@@ -855,6 +857,8 @@ async def update(
855857
status, remove existing `AITags` and apply extensions using this API.
856858
857859
Args:
860+
publish: Configure the publication status of a file and its versions.
861+
858862
extra_headers: Send extra headers
859863
860864
extra_query: Add additional query parameters to the request
@@ -876,7 +880,7 @@ async def update(
876880
remove_ai_tags: Union[SequenceNotStr[str], Literal["all"]] | Omit = omit,
877881
tags: Optional[SequenceNotStr[str]] | Omit = omit,
878882
webhook_url: str | Omit = omit,
879-
body: object | Omit = omit,
883+
publish: file_update_params.ChangePublicationStatusPublish | Omit = omit,
880884
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
881885
# The extra values given here take precedence over values defined on the client or passed to this method.
882886
extra_headers: Headers | None = None,
@@ -897,7 +901,7 @@ async def update(
897901
"remove_ai_tags": remove_ai_tags,
898902
"tags": tags,
899903
"webhook_url": webhook_url,
900-
"body": body,
904+
"publish": publish,
901905
},
902906
file_update_params.FileUpdateParams,
903907
),

src/imagekit/types/file_update_params.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from .._utils import PropertyInfo
1010
from .shared_params.extensions import Extensions
1111

12-
__all__ = ["FileUpdateParams", "UpdateFileDetails", "ChangePublicationStatus"]
12+
__all__ = ["FileUpdateParams", "UpdateFileDetails", "ChangePublicationStatus", "ChangePublicationStatusPublish"]
1313

1414

1515
class UpdateFileDetails(TypedDict, total=False):
@@ -65,7 +65,19 @@ class UpdateFileDetails(TypedDict, total=False):
6565

6666

6767
class ChangePublicationStatus(TypedDict, total=False):
68-
body: Required[object]
68+
publish: ChangePublicationStatusPublish
69+
"""Configure the publication status of a file and its versions."""
70+
71+
72+
class ChangePublicationStatusPublish(TypedDict, total=False):
73+
is_published: Required[Annotated[bool, PropertyInfo(alias="isPublished")]]
74+
"""Set to `true` to publish the file. Set to `false` to unpublish the file."""
75+
76+
include_file_versions: Annotated[bool, PropertyInfo(alias="includeFileVersions")]
77+
"""Set to `true` to publish/unpublish all versions of the file.
78+
79+
Set to `false` to publish/unpublish only the current version of the file.
80+
"""
6981

7082

7183
FileUpdateParams: TypeAlias = Union[UpdateFileDetails, ChangePublicationStatus]

src/imagekit/types/update_file_request_param.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
from __future__ import annotations
44

55
from typing import Dict, Union, Optional
6-
from typing_extensions import Literal, Annotated, TypeAlias, TypedDict
6+
from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict
77

88
from .._types import SequenceNotStr
99
from .._utils import PropertyInfo
1010
from .shared_params.extensions import Extensions
1111

12-
__all__ = ["UpdateFileRequestParam", "UpdateFileDetails"]
12+
__all__ = ["UpdateFileRequestParam", "UpdateFileDetails", "ChangePublicationStatus", "ChangePublicationStatusPublish"]
1313

1414

1515
class UpdateFileDetails(TypedDict, total=False):
@@ -64,4 +64,20 @@ class UpdateFileDetails(TypedDict, total=False):
6464
"""
6565

6666

67-
UpdateFileRequestParam: TypeAlias = Union[UpdateFileDetails, object]
67+
class ChangePublicationStatusPublish(TypedDict, total=False):
68+
is_published: Required[Annotated[bool, PropertyInfo(alias="isPublished")]]
69+
"""Set to `true` to publish the file. Set to `false` to unpublish the file."""
70+
71+
include_file_versions: Annotated[bool, PropertyInfo(alias="includeFileVersions")]
72+
"""Set to `true` to publish/unpublish all versions of the file.
73+
74+
Set to `false` to publish/unpublish only the current version of the file.
75+
"""
76+
77+
78+
class ChangePublicationStatus(TypedDict, total=False):
79+
publish: ChangePublicationStatusPublish
80+
"""Configure the publication status of a file and its versions."""
81+
82+
83+
UpdateFileRequestParam: TypeAlias = Union[UpdateFileDetails, ChangePublicationStatus]

tests/api_resources/test_files.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,18 @@ def test_path_params_update_overload_1(self, client: ImageKit) -> None:
102102
def test_method_update_overload_2(self, client: ImageKit) -> None:
103103
file = client.files.update(
104104
file_id="fileId",
105-
body={},
105+
)
106+
assert_matches_type(FileUpdateResponse, file, path=["response"])
107+
108+
@pytest.mark.skip(reason="Prism tests are disabled")
109+
@parametrize
110+
def test_method_update_with_all_params_overload_2(self, client: ImageKit) -> None:
111+
file = client.files.update(
112+
file_id="fileId",
113+
publish={
114+
"is_published": True,
115+
"include_file_versions": True,
116+
},
106117
)
107118
assert_matches_type(FileUpdateResponse, file, path=["response"])
108119

@@ -111,7 +122,6 @@ def test_method_update_overload_2(self, client: ImageKit) -> None:
111122
def test_raw_response_update_overload_2(self, client: ImageKit) -> None:
112123
response = client.files.with_raw_response.update(
113124
file_id="fileId",
114-
body={},
115125
)
116126

117127
assert response.is_closed is True
@@ -124,7 +134,6 @@ def test_raw_response_update_overload_2(self, client: ImageKit) -> None:
124134
def test_streaming_response_update_overload_2(self, client: ImageKit) -> None:
125135
with client.files.with_streaming_response.update(
126136
file_id="fileId",
127-
body={},
128137
) as response:
129138
assert not response.is_closed
130139
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -140,7 +149,6 @@ def test_path_params_update_overload_2(self, client: ImageKit) -> None:
140149
with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"):
141150
client.files.with_raw_response.update(
142151
file_id="",
143-
body={},
144152
)
145153

146154
@pytest.mark.skip(reason="Prism tests are disabled")
@@ -541,7 +549,18 @@ async def test_path_params_update_overload_1(self, async_client: AsyncImageKit)
541549
async def test_method_update_overload_2(self, async_client: AsyncImageKit) -> None:
542550
file = await async_client.files.update(
543551
file_id="fileId",
544-
body={},
552+
)
553+
assert_matches_type(FileUpdateResponse, file, path=["response"])
554+
555+
@pytest.mark.skip(reason="Prism tests are disabled")
556+
@parametrize
557+
async def test_method_update_with_all_params_overload_2(self, async_client: AsyncImageKit) -> None:
558+
file = await async_client.files.update(
559+
file_id="fileId",
560+
publish={
561+
"is_published": True,
562+
"include_file_versions": True,
563+
},
545564
)
546565
assert_matches_type(FileUpdateResponse, file, path=["response"])
547566

@@ -550,7 +569,6 @@ async def test_method_update_overload_2(self, async_client: AsyncImageKit) -> No
550569
async def test_raw_response_update_overload_2(self, async_client: AsyncImageKit) -> None:
551570
response = await async_client.files.with_raw_response.update(
552571
file_id="fileId",
553-
body={},
554572
)
555573

556574
assert response.is_closed is True
@@ -563,7 +581,6 @@ async def test_raw_response_update_overload_2(self, async_client: AsyncImageKit)
563581
async def test_streaming_response_update_overload_2(self, async_client: AsyncImageKit) -> None:
564582
async with async_client.files.with_streaming_response.update(
565583
file_id="fileId",
566-
body={},
567584
) as response:
568585
assert not response.is_closed
569586
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -579,7 +596,6 @@ async def test_path_params_update_overload_2(self, async_client: AsyncImageKit)
579596
with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"):
580597
await async_client.files.with_raw_response.update(
581598
file_id="",
582-
body={},
583599
)
584600

585601
@pytest.mark.skip(reason="Prism tests are disabled")

0 commit comments

Comments
 (0)