Skip to content

Commit da0a8be

Browse files
authored
Merge pull request #79 from imagekit-developer/release-please--branches--master--changes--next
release: 5.2.0
2 parents ebc2a55 + d70de73 commit da0a8be

File tree

11 files changed

+213
-11
lines changed

11 files changed

+213
-11
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "5.1.2"
2+
".": "5.2.0"
33
}

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 48
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-84f0d75048a9268981a84800b4190e3691997ce57dcfc0876f38a5b3fce6bacd.yml
3-
openapi_spec_hash: 35607d4e850c8a60524223ff632c83bb
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-13fc3d7cafdea492f62eef7c1d63424d6d9d8adbff74b9f6ca6fd3fc12a36840.yml
3+
openapi_spec_hash: a1fe6fa48207791657a1ea2d60a6dfcc
44
config_hash: 47cb702ee2cb52c58d803ae39ade9b44

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Changelog
22

3+
## 5.2.0 (2026-02-02)
4+
5+
Full Changelog: [v5.1.2...v5.2.0](https://github.com/imagekit-developer/imagekit-python/compare/v5.1.2...v5.2.0)
6+
7+
### Features
8+
9+
* **api:** add customMetadata property to folder schema ([9b8597b](https://github.com/imagekit-developer/imagekit-python/commit/9b8597b8d8b4f11eb4c9e93ddbd924169fe9b0ea))
10+
* **client:** add custom JSON encoder for extended type support ([2d7dd40](https://github.com/imagekit-developer/imagekit-python/commit/2d7dd4063992e7c49518ea8bca1bbf9dfec7aa9c))
11+
12+
13+
### Bug Fixes
14+
15+
* **api:** add missing embeddedMetadata and video properties to FileDetails ([b1ffb23](https://github.com/imagekit-developer/imagekit-python/commit/b1ffb235b3f6dae292af80bd99d965db44db47f9))
16+
317
## 5.1.2 (2026-01-29)
418

519
Full Changelog: [v5.1.1...v5.1.2](https://github.com/imagekit-developer/imagekit-python/compare/v5.1.1...v5.1.2)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "imagekitio"
3-
version = "5.1.2"
3+
version = "5.2.0"
44
description = "The official Python library for the ImageKit API"
55
dynamic = ["readme"]
66
license = "Apache-2.0"

src/imagekitio/_base_client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
APIConnectionError,
8787
APIResponseValidationError,
8888
)
89+
from ._utils._json import openapi_dumps
8990

9091
log: logging.Logger = logging.getLogger(__name__)
9192

@@ -554,8 +555,10 @@ def _build_request(
554555
kwargs["content"] = options.content
555556
elif isinstance(json_data, bytes):
556557
kwargs["content"] = json_data
557-
else:
558-
kwargs["json"] = json_data if is_given(json_data) else None
558+
elif not files:
559+
# Don't set content when JSON is sent as multipart/form-data,
560+
# since httpx's content param overrides other body arguments
561+
kwargs["content"] = openapi_dumps(json_data) if is_given(json_data) and json_data is not None else None
559562
kwargs["files"] = files
560563
else:
561564
headers.pop("Content-Type", None)

src/imagekitio/_compat.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ def model_dump(
139139
exclude_defaults: bool = False,
140140
warnings: bool = True,
141141
mode: Literal["json", "python"] = "python",
142+
by_alias: bool | None = None,
142143
) -> dict[str, Any]:
143144
if (not PYDANTIC_V1) or hasattr(model, "model_dump"):
144145
return model.model_dump(
@@ -148,13 +149,12 @@ def model_dump(
148149
exclude_defaults=exclude_defaults,
149150
# warnings are not supported in Pydantic v1
150151
warnings=True if PYDANTIC_V1 else warnings,
152+
by_alias=by_alias,
151153
)
152154
return cast(
153155
"dict[str, Any]",
154156
model.dict( # pyright: ignore[reportDeprecated, reportUnnecessaryCast]
155-
exclude=exclude,
156-
exclude_unset=exclude_unset,
157-
exclude_defaults=exclude_defaults,
157+
exclude=exclude, exclude_unset=exclude_unset, exclude_defaults=exclude_defaults, by_alias=bool(by_alias)
158158
),
159159
)
160160

src/imagekitio/_utils/_json.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import json
2+
from typing import Any
3+
from datetime import datetime
4+
from typing_extensions import override
5+
6+
import pydantic
7+
8+
from .._compat import model_dump
9+
10+
11+
def openapi_dumps(obj: Any) -> bytes:
12+
"""
13+
Serialize an object to UTF-8 encoded JSON bytes.
14+
15+
Extends the standard json.dumps with support for additional types
16+
commonly used in the SDK, such as `datetime`, `pydantic.BaseModel`, etc.
17+
"""
18+
return json.dumps(
19+
obj,
20+
cls=_CustomEncoder,
21+
# Uses the same defaults as httpx's JSON serialization
22+
ensure_ascii=False,
23+
separators=(",", ":"),
24+
allow_nan=False,
25+
).encode()
26+
27+
28+
class _CustomEncoder(json.JSONEncoder):
29+
@override
30+
def default(self, o: Any) -> Any:
31+
if isinstance(o, datetime):
32+
return o.isoformat()
33+
if isinstance(o, pydantic.BaseModel):
34+
return model_dump(o, exclude_unset=True, mode="json", by_alias=True)
35+
return super().default(o)

src/imagekitio/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
__title__ = "imagekitio"
4-
__version__ = "5.1.2" # x-release-please-version
4+
__version__ = "5.2.0" # x-release-please-version

src/imagekitio/types/file.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ class File(BaseModel):
9595
ai_tags: Optional[List[AITag]] = FieldInfo(alias="AITags", default=None)
9696
"""An array of tags assigned to the file by auto tagging."""
9797

98+
audio_codec: Optional[str] = FieldInfo(alias="audioCodec", default=None)
99+
"""The audio codec used in the video (only for video/audio)."""
100+
101+
bit_rate: Optional[int] = FieldInfo(alias="bitRate", default=None)
102+
"""The bit rate of the video in kbps (only for video)."""
103+
98104
created_at: Optional[datetime] = FieldInfo(alias="createdAt", default=None)
99105
"""Date and time when the file was uploaded.
100106
@@ -113,6 +119,15 @@ class File(BaseModel):
113119
Can be set by the user or the ai-auto-description extension.
114120
"""
115121

122+
duration: Optional[int] = None
123+
"""The duration of the video in seconds (only for video)."""
124+
125+
embedded_metadata: Optional[Dict[str, object]] = FieldInfo(alias="embeddedMetadata", default=None)
126+
"""Consolidated embedded metadata associated with the file.
127+
128+
It includes exif, iptc, and xmp data.
129+
"""
130+
116131
file_id: Optional[str] = FieldInfo(alias="fileId", default=None)
117132
"""Unique identifier of the asset."""
118133

@@ -188,5 +203,8 @@ class File(BaseModel):
188203
version_info: Optional[VersionInfo] = FieldInfo(alias="versionInfo", default=None)
189204
"""An object with details of the file version."""
190205

206+
video_codec: Optional[str] = FieldInfo(alias="videoCodec", default=None)
207+
"""The video codec used in the video (only for video)."""
208+
191209
width: Optional[float] = None
192210
"""Width of the file."""

src/imagekitio/types/folder.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import Optional
3+
from typing import Dict, Optional
44
from datetime import datetime
55
from typing_extensions import Literal
66

@@ -18,6 +18,12 @@ class Folder(BaseModel):
1818
The date and time is in ISO8601 format.
1919
"""
2020

21+
custom_metadata: Optional[Dict[str, object]] = FieldInfo(alias="customMetadata", default=None)
22+
"""An object with custom metadata for the folder.
23+
24+
Returns empty object if no custom metadata is set.
25+
"""
26+
2127
folder_id: Optional[str] = FieldInfo(alias="folderId", default=None)
2228
"""Unique identifier of the asset."""
2329

0 commit comments

Comments
 (0)