gmt-python-sdk 0.10.0__tar.gz → 0.11.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. gmt_python_sdk-0.11.0/.release-please-manifest.json +3 -0
  2. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/CHANGELOG.md +13 -0
  3. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/LICENSE +1 -1
  4. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/PKG-INFO +1 -1
  5. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/pyproject.toml +1 -1
  6. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/_base_client.py +134 -11
  7. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/_models.py +16 -1
  8. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/_types.py +9 -0
  9. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/_version.py +1 -1
  10. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/tests/test_client.py +185 -2
  11. gmt_python_sdk-0.10.0/.release-please-manifest.json +0 -3
  12. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/.gitignore +0 -0
  13. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/CONTRIBUTING.md +0 -0
  14. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/README.md +0 -0
  15. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/SECURITY.md +0 -0
  16. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/api.md +0 -0
  17. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/bin/check-release-environment +0 -0
  18. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/bin/publish-pypi +0 -0
  19. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/examples/.keep +0 -0
  20. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/release-please-config.json +0 -0
  21. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/requirements-dev.lock +0 -0
  22. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/__init__.py +0 -0
  23. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/_client.py +0 -0
  24. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/_compat.py +0 -0
  25. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/_constants.py +0 -0
  26. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/_exceptions.py +0 -0
  27. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/_files.py +0 -0
  28. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/_qs.py +0 -0
  29. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/_resource.py +0 -0
  30. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/_response.py +0 -0
  31. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/_streaming.py +0 -0
  32. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/_utils/__init__.py +0 -0
  33. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/_utils/_compat.py +0 -0
  34. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/_utils/_datetime_parse.py +0 -0
  35. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/_utils/_logs.py +0 -0
  36. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/_utils/_proxy.py +0 -0
  37. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/_utils/_reflection.py +0 -0
  38. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/_utils/_resources_proxy.py +0 -0
  39. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/_utils/_streams.py +0 -0
  40. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/_utils/_sync.py +0 -0
  41. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/_utils/_transform.py +0 -0
  42. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/_utils/_typing.py +0 -0
  43. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/_utils/_utils.py +0 -0
  44. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/lib/.keep +0 -0
  45. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/pagination.py +0 -0
  46. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/py.typed +0 -0
  47. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/resources/__init__.py +0 -0
  48. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/resources/accounts.py +0 -0
  49. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/resources/profile.py +0 -0
  50. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/resources/purchases.py +0 -0
  51. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/resources/service.py +0 -0
  52. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/resources/webhooks.py +0 -0
  53. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/types/__init__.py +0 -0
  54. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/types/account_list_countries_params.py +0 -0
  55. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/types/account_list_countries_response.py +0 -0
  56. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/types/account_list_params.py +0 -0
  57. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/types/account_list_response.py +0 -0
  58. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/types/account_retrieve_response.py +0 -0
  59. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/types/profile_retrieve_response.py +0 -0
  60. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/types/purchase_create_params.py +0 -0
  61. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/types/purchase_create_response.py +0 -0
  62. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/types/purchase_list_params.py +0 -0
  63. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/types/purchase_list_response.py +0 -0
  64. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/types/purchase_refund_response.py +0 -0
  65. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/types/purchase_request_verification_code_params.py +0 -0
  66. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/types/purchase_request_verification_code_response.py +0 -0
  67. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/types/purchase_retrieve_response.py +0 -0
  68. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/types/service_get_server_time_response.py +0 -0
  69. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/types/service_health_check_response.py +0 -0
  70. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/types/webhook_test_params.py +0 -0
  71. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/src/gmt/types/webhook_test_response.py +0 -0
  72. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/tests/__init__.py +0 -0
  73. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/tests/api_resources/__init__.py +0 -0
  74. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/tests/api_resources/test_accounts.py +0 -0
  75. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/tests/api_resources/test_profile.py +0 -0
  76. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/tests/api_resources/test_purchases.py +0 -0
  77. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/tests/api_resources/test_service.py +0 -0
  78. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/tests/api_resources/test_webhooks.py +0 -0
  79. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/tests/conftest.py +0 -0
  80. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/tests/sample_file.txt +0 -0
  81. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/tests/test_deepcopy.py +0 -0
  82. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/tests/test_extract_files.py +0 -0
  83. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/tests/test_files.py +0 -0
  84. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/tests/test_models.py +0 -0
  85. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/tests/test_qs.py +0 -0
  86. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/tests/test_required_args.py +0 -0
  87. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/tests/test_response.py +0 -0
  88. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/tests/test_streaming.py +0 -0
  89. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/tests/test_transform.py +0 -0
  90. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/tests/test_utils/test_datetime_parse.py +0 -0
  91. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/tests/test_utils/test_proxy.py +0 -0
  92. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/tests/test_utils/test_typing.py +0 -0
  93. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/tests/utils.py +0 -0
  94. {gmt_python_sdk-0.10.0 → gmt_python_sdk-0.11.0}/uv.lock +0 -0
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "0.11.0"
3
+ }
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.0 (2026-01-14)
4
+
5
+ Full Changelog: [v0.10.0...v0.11.0](https://github.com/cameo6/gmt-python-sdk/compare/v0.10.0...v0.11.0)
6
+
7
+ ### Features
8
+
9
+ * **client:** add support for binary request streaming ([4630e55](https://github.com/cameo6/gmt-python-sdk/commit/4630e558cea821aaf9f4997ff14fdcf524951b29))
10
+
11
+
12
+ ### Chores
13
+
14
+ * **internal:** codegen related update ([3c1fe79](https://github.com/cameo6/gmt-python-sdk/commit/3c1fe79d3b6ff994d9b238c9155095dc33668f62))
15
+
3
16
  ## 0.10.0 (2025-12-19)
4
17
 
5
18
  Full Changelog: [v0.9.1...v0.10.0](https://github.com/cameo6/gmt-python-sdk/compare/v0.9.1...v0.10.0)
@@ -186,7 +186,7 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright 2025 Gmt
189
+ Copyright 2026 Gmt
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: gmt-python-sdk
3
- Version: 0.10.0
3
+ Version: 0.11.0
4
4
  Summary: The official Python library for the gmt API
5
5
  Project-URL: Homepage, https://github.com/cameo6/gmt-python-sdk
6
6
  Project-URL: Repository, https://github.com/cameo6/gmt-python-sdk
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "gmt-python-sdk"
3
- version = "0.10.0"
3
+ version = "0.11.0"
4
4
  description = "The official Python library for the gmt API"
5
5
  dynamic = ["readme"]
6
6
  license = "Apache-2.0"
@@ -9,6 +9,7 @@ import asyncio
9
9
  import inspect
10
10
  import logging
11
11
  import platform
12
+ import warnings
12
13
  import email.utils
13
14
  from types import TracebackType
14
15
  from random import random
@@ -51,9 +52,11 @@ from ._types import (
51
52
  ResponseT,
52
53
  AnyMapping,
53
54
  PostParser,
55
+ BinaryTypes,
54
56
  RequestFiles,
55
57
  HttpxSendArgs,
56
58
  RequestOptions,
59
+ AsyncBinaryTypes,
57
60
  HttpxRequestFiles,
58
61
  ModelBuilderProtocol,
59
62
  not_given,
@@ -477,8 +480,19 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
477
480
  retries_taken: int = 0,
478
481
  ) -> httpx.Request:
479
482
  if log.isEnabledFor(logging.DEBUG):
480
- log.debug("Request options: %s", model_dump(options, exclude_unset=True))
481
-
483
+ log.debug(
484
+ "Request options: %s",
485
+ model_dump(
486
+ options,
487
+ exclude_unset=True,
488
+ # Pydantic v1 can't dump every type we support in content, so we exclude it for now.
489
+ exclude={
490
+ "content",
491
+ }
492
+ if PYDANTIC_V1
493
+ else {},
494
+ ),
495
+ )
482
496
  kwargs: dict[str, Any] = {}
483
497
 
484
498
  json_data = options.json_data
@@ -532,7 +546,13 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
532
546
  is_body_allowed = options.method.lower() != "get"
533
547
 
534
548
  if is_body_allowed:
535
- if isinstance(json_data, bytes):
549
+ if options.content is not None and json_data is not None:
550
+ raise TypeError("Passing both `content` and `json_data` is not supported")
551
+ if options.content is not None and files is not None:
552
+ raise TypeError("Passing both `content` and `files` is not supported")
553
+ if options.content is not None:
554
+ kwargs["content"] = options.content
555
+ elif isinstance(json_data, bytes):
536
556
  kwargs["content"] = json_data
537
557
  else:
538
558
  kwargs["json"] = json_data if is_given(json_data) else None
@@ -1194,6 +1214,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
1194
1214
  *,
1195
1215
  cast_to: Type[ResponseT],
1196
1216
  body: Body | None = None,
1217
+ content: BinaryTypes | None = None,
1197
1218
  options: RequestOptions = {},
1198
1219
  files: RequestFiles | None = None,
1199
1220
  stream: Literal[False] = False,
@@ -1206,6 +1227,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
1206
1227
  *,
1207
1228
  cast_to: Type[ResponseT],
1208
1229
  body: Body | None = None,
1230
+ content: BinaryTypes | None = None,
1209
1231
  options: RequestOptions = {},
1210
1232
  files: RequestFiles | None = None,
1211
1233
  stream: Literal[True],
@@ -1219,6 +1241,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
1219
1241
  *,
1220
1242
  cast_to: Type[ResponseT],
1221
1243
  body: Body | None = None,
1244
+ content: BinaryTypes | None = None,
1222
1245
  options: RequestOptions = {},
1223
1246
  files: RequestFiles | None = None,
1224
1247
  stream: bool,
@@ -1231,13 +1254,25 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
1231
1254
  *,
1232
1255
  cast_to: Type[ResponseT],
1233
1256
  body: Body | None = None,
1257
+ content: BinaryTypes | None = None,
1234
1258
  options: RequestOptions = {},
1235
1259
  files: RequestFiles | None = None,
1236
1260
  stream: bool = False,
1237
1261
  stream_cls: type[_StreamT] | None = None,
1238
1262
  ) -> ResponseT | _StreamT:
1263
+ if body is not None and content is not None:
1264
+ raise TypeError("Passing both `body` and `content` is not supported")
1265
+ if files is not None and content is not None:
1266
+ raise TypeError("Passing both `files` and `content` is not supported")
1267
+ if isinstance(body, bytes):
1268
+ warnings.warn(
1269
+ "Passing raw bytes as `body` is deprecated and will be removed in a future version. "
1270
+ "Please pass raw bytes via the `content` parameter instead.",
1271
+ DeprecationWarning,
1272
+ stacklevel=2,
1273
+ )
1239
1274
  opts = FinalRequestOptions.construct(
1240
- method="post", url=path, json_data=body, files=to_httpx_files(files), **options
1275
+ method="post", url=path, json_data=body, content=content, files=to_httpx_files(files), **options
1241
1276
  )
1242
1277
  return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
1243
1278
 
@@ -1247,11 +1282,23 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
1247
1282
  *,
1248
1283
  cast_to: Type[ResponseT],
1249
1284
  body: Body | None = None,
1285
+ content: BinaryTypes | None = None,
1250
1286
  files: RequestFiles | None = None,
1251
1287
  options: RequestOptions = {},
1252
1288
  ) -> ResponseT:
1289
+ if body is not None and content is not None:
1290
+ raise TypeError("Passing both `body` and `content` is not supported")
1291
+ if files is not None and content is not None:
1292
+ raise TypeError("Passing both `files` and `content` is not supported")
1293
+ if isinstance(body, bytes):
1294
+ warnings.warn(
1295
+ "Passing raw bytes as `body` is deprecated and will be removed in a future version. "
1296
+ "Please pass raw bytes via the `content` parameter instead.",
1297
+ DeprecationWarning,
1298
+ stacklevel=2,
1299
+ )
1253
1300
  opts = FinalRequestOptions.construct(
1254
- method="patch", url=path, json_data=body, files=to_httpx_files(files), **options
1301
+ method="patch", url=path, json_data=body, content=content, files=to_httpx_files(files), **options
1255
1302
  )
1256
1303
  return self.request(cast_to, opts)
1257
1304
 
@@ -1261,11 +1308,23 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
1261
1308
  *,
1262
1309
  cast_to: Type[ResponseT],
1263
1310
  body: Body | None = None,
1311
+ content: BinaryTypes | None = None,
1264
1312
  files: RequestFiles | None = None,
1265
1313
  options: RequestOptions = {},
1266
1314
  ) -> ResponseT:
1315
+ if body is not None and content is not None:
1316
+ raise TypeError("Passing both `body` and `content` is not supported")
1317
+ if files is not None and content is not None:
1318
+ raise TypeError("Passing both `files` and `content` is not supported")
1319
+ if isinstance(body, bytes):
1320
+ warnings.warn(
1321
+ "Passing raw bytes as `body` is deprecated and will be removed in a future version. "
1322
+ "Please pass raw bytes via the `content` parameter instead.",
1323
+ DeprecationWarning,
1324
+ stacklevel=2,
1325
+ )
1267
1326
  opts = FinalRequestOptions.construct(
1268
- method="put", url=path, json_data=body, files=to_httpx_files(files), **options
1327
+ method="put", url=path, json_data=body, content=content, files=to_httpx_files(files), **options
1269
1328
  )
1270
1329
  return self.request(cast_to, opts)
1271
1330
 
@@ -1275,9 +1334,19 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
1275
1334
  *,
1276
1335
  cast_to: Type[ResponseT],
1277
1336
  body: Body | None = None,
1337
+ content: BinaryTypes | None = None,
1278
1338
  options: RequestOptions = {},
1279
1339
  ) -> ResponseT:
1280
- opts = FinalRequestOptions.construct(method="delete", url=path, json_data=body, **options)
1340
+ if body is not None and content is not None:
1341
+ raise TypeError("Passing both `body` and `content` is not supported")
1342
+ if isinstance(body, bytes):
1343
+ warnings.warn(
1344
+ "Passing raw bytes as `body` is deprecated and will be removed in a future version. "
1345
+ "Please pass raw bytes via the `content` parameter instead.",
1346
+ DeprecationWarning,
1347
+ stacklevel=2,
1348
+ )
1349
+ opts = FinalRequestOptions.construct(method="delete", url=path, json_data=body, content=content, **options)
1281
1350
  return self.request(cast_to, opts)
1282
1351
 
1283
1352
  def get_api_list(
@@ -1717,6 +1786,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1717
1786
  *,
1718
1787
  cast_to: Type[ResponseT],
1719
1788
  body: Body | None = None,
1789
+ content: AsyncBinaryTypes | None = None,
1720
1790
  files: RequestFiles | None = None,
1721
1791
  options: RequestOptions = {},
1722
1792
  stream: Literal[False] = False,
@@ -1729,6 +1799,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1729
1799
  *,
1730
1800
  cast_to: Type[ResponseT],
1731
1801
  body: Body | None = None,
1802
+ content: AsyncBinaryTypes | None = None,
1732
1803
  files: RequestFiles | None = None,
1733
1804
  options: RequestOptions = {},
1734
1805
  stream: Literal[True],
@@ -1742,6 +1813,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1742
1813
  *,
1743
1814
  cast_to: Type[ResponseT],
1744
1815
  body: Body | None = None,
1816
+ content: AsyncBinaryTypes | None = None,
1745
1817
  files: RequestFiles | None = None,
1746
1818
  options: RequestOptions = {},
1747
1819
  stream: bool,
@@ -1754,13 +1826,25 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1754
1826
  *,
1755
1827
  cast_to: Type[ResponseT],
1756
1828
  body: Body | None = None,
1829
+ content: AsyncBinaryTypes | None = None,
1757
1830
  files: RequestFiles | None = None,
1758
1831
  options: RequestOptions = {},
1759
1832
  stream: bool = False,
1760
1833
  stream_cls: type[_AsyncStreamT] | None = None,
1761
1834
  ) -> ResponseT | _AsyncStreamT:
1835
+ if body is not None and content is not None:
1836
+ raise TypeError("Passing both `body` and `content` is not supported")
1837
+ if files is not None and content is not None:
1838
+ raise TypeError("Passing both `files` and `content` is not supported")
1839
+ if isinstance(body, bytes):
1840
+ warnings.warn(
1841
+ "Passing raw bytes as `body` is deprecated and will be removed in a future version. "
1842
+ "Please pass raw bytes via the `content` parameter instead.",
1843
+ DeprecationWarning,
1844
+ stacklevel=2,
1845
+ )
1762
1846
  opts = FinalRequestOptions.construct(
1763
- method="post", url=path, json_data=body, files=await async_to_httpx_files(files), **options
1847
+ method="post", url=path, json_data=body, content=content, files=await async_to_httpx_files(files), **options
1764
1848
  )
1765
1849
  return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
1766
1850
 
@@ -1770,11 +1854,28 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1770
1854
  *,
1771
1855
  cast_to: Type[ResponseT],
1772
1856
  body: Body | None = None,
1857
+ content: AsyncBinaryTypes | None = None,
1773
1858
  files: RequestFiles | None = None,
1774
1859
  options: RequestOptions = {},
1775
1860
  ) -> ResponseT:
1861
+ if body is not None and content is not None:
1862
+ raise TypeError("Passing both `body` and `content` is not supported")
1863
+ if files is not None and content is not None:
1864
+ raise TypeError("Passing both `files` and `content` is not supported")
1865
+ if isinstance(body, bytes):
1866
+ warnings.warn(
1867
+ "Passing raw bytes as `body` is deprecated and will be removed in a future version. "
1868
+ "Please pass raw bytes via the `content` parameter instead.",
1869
+ DeprecationWarning,
1870
+ stacklevel=2,
1871
+ )
1776
1872
  opts = FinalRequestOptions.construct(
1777
- method="patch", url=path, json_data=body, files=await async_to_httpx_files(files), **options
1873
+ method="patch",
1874
+ url=path,
1875
+ json_data=body,
1876
+ content=content,
1877
+ files=await async_to_httpx_files(files),
1878
+ **options,
1778
1879
  )
1779
1880
  return await self.request(cast_to, opts)
1780
1881
 
@@ -1784,11 +1885,23 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1784
1885
  *,
1785
1886
  cast_to: Type[ResponseT],
1786
1887
  body: Body | None = None,
1888
+ content: AsyncBinaryTypes | None = None,
1787
1889
  files: RequestFiles | None = None,
1788
1890
  options: RequestOptions = {},
1789
1891
  ) -> ResponseT:
1892
+ if body is not None and content is not None:
1893
+ raise TypeError("Passing both `body` and `content` is not supported")
1894
+ if files is not None and content is not None:
1895
+ raise TypeError("Passing both `files` and `content` is not supported")
1896
+ if isinstance(body, bytes):
1897
+ warnings.warn(
1898
+ "Passing raw bytes as `body` is deprecated and will be removed in a future version. "
1899
+ "Please pass raw bytes via the `content` parameter instead.",
1900
+ DeprecationWarning,
1901
+ stacklevel=2,
1902
+ )
1790
1903
  opts = FinalRequestOptions.construct(
1791
- method="put", url=path, json_data=body, files=await async_to_httpx_files(files), **options
1904
+ method="put", url=path, json_data=body, content=content, files=await async_to_httpx_files(files), **options
1792
1905
  )
1793
1906
  return await self.request(cast_to, opts)
1794
1907
 
@@ -1798,9 +1911,19 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1798
1911
  *,
1799
1912
  cast_to: Type[ResponseT],
1800
1913
  body: Body | None = None,
1914
+ content: AsyncBinaryTypes | None = None,
1801
1915
  options: RequestOptions = {},
1802
1916
  ) -> ResponseT:
1803
- opts = FinalRequestOptions.construct(method="delete", url=path, json_data=body, **options)
1917
+ if body is not None and content is not None:
1918
+ raise TypeError("Passing both `body` and `content` is not supported")
1919
+ if isinstance(body, bytes):
1920
+ warnings.warn(
1921
+ "Passing raw bytes as `body` is deprecated and will be removed in a future version. "
1922
+ "Please pass raw bytes via the `content` parameter instead.",
1923
+ DeprecationWarning,
1924
+ stacklevel=2,
1925
+ )
1926
+ opts = FinalRequestOptions.construct(method="delete", url=path, json_data=body, content=content, **options)
1804
1927
  return await self.request(cast_to, opts)
1805
1928
 
1806
1929
  def get_api_list(
@@ -3,7 +3,20 @@ from __future__ import annotations
3
3
  import os
4
4
  import inspect
5
5
  import weakref
6
- from typing import TYPE_CHECKING, Any, Type, Union, Generic, TypeVar, Callable, Optional, cast
6
+ from typing import (
7
+ IO,
8
+ TYPE_CHECKING,
9
+ Any,
10
+ Type,
11
+ Union,
12
+ Generic,
13
+ TypeVar,
14
+ Callable,
15
+ Iterable,
16
+ Optional,
17
+ AsyncIterable,
18
+ cast,
19
+ )
7
20
  from datetime import date, datetime
8
21
  from typing_extensions import (
9
22
  List,
@@ -787,6 +800,7 @@ class FinalRequestOptionsInput(TypedDict, total=False):
787
800
  timeout: float | Timeout | None
788
801
  files: HttpxRequestFiles | None
789
802
  idempotency_key: str
803
+ content: Union[bytes, bytearray, IO[bytes], Iterable[bytes], AsyncIterable[bytes], None]
790
804
  json_data: Body
791
805
  extra_json: AnyMapping
792
806
  follow_redirects: bool
@@ -805,6 +819,7 @@ class FinalRequestOptions(pydantic.BaseModel):
805
819
  post_parser: Union[Callable[[Any], Any], NotGiven] = NotGiven()
806
820
  follow_redirects: Union[bool, None] = None
807
821
 
822
+ content: Union[bytes, bytearray, IO[bytes], Iterable[bytes], AsyncIterable[bytes], None] = None
808
823
  # It should be noted that we cannot use `json` here as that would override
809
824
  # a BaseModel method in an incompatible fashion.
810
825
  json_data: Union[Body, None] = None
@@ -13,9 +13,11 @@ from typing import (
13
13
  Mapping,
14
14
  TypeVar,
15
15
  Callable,
16
+ Iterable,
16
17
  Iterator,
17
18
  Optional,
18
19
  Sequence,
20
+ AsyncIterable,
19
21
  )
20
22
  from typing_extensions import (
21
23
  Set,
@@ -56,6 +58,13 @@ if TYPE_CHECKING:
56
58
  else:
57
59
  Base64FileInput = Union[IO[bytes], PathLike]
58
60
  FileContent = Union[IO[bytes], bytes, PathLike] # PathLike is not subscriptable in Python 3.8.
61
+
62
+
63
+ # Used for sending raw binary data / streaming data in request bodies
64
+ # e.g. for file uploads without multipart encoding
65
+ BinaryTypes = Union[bytes, bytearray, IO[bytes], Iterable[bytes]]
66
+ AsyncBinaryTypes = Union[bytes, bytearray, IO[bytes], AsyncIterable[bytes]]
67
+
59
68
  FileTypes = Union[
60
69
  # file (or bytes)
61
70
  FileContent,
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "gmt"
4
- __version__ = "0.10.0" # x-release-please-version
4
+ __version__ = "0.11.0" # x-release-please-version
@@ -8,10 +8,11 @@ import sys
8
8
  import json
9
9
  import asyncio
10
10
  import inspect
11
+ import dataclasses
11
12
  import tracemalloc
12
- from typing import Any, Union, cast
13
+ from typing import Any, Union, TypeVar, Callable, Iterable, Iterator, Optional, Coroutine, cast
13
14
  from unittest import mock
14
- from typing_extensions import Literal
15
+ from typing_extensions import Literal, AsyncIterator, override
15
16
 
16
17
  import httpx
17
18
  import pytest
@@ -36,6 +37,7 @@ from gmt._base_client import (
36
37
 
37
38
  from .utils import update_env
38
39
 
40
+ T = TypeVar("T")
39
41
  base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
40
42
  api_key = "My API Key"
41
43
 
@@ -50,6 +52,57 @@ def _low_retry_timeout(*_args: Any, **_kwargs: Any) -> float:
50
52
  return 0.1
51
53
 
52
54
 
55
+ def mirror_request_content(request: httpx.Request) -> httpx.Response:
56
+ return httpx.Response(200, content=request.content)
57
+
58
+
59
+ # note: we can't use the httpx.MockTransport class as it consumes the request
60
+ # body itself, which means we can't test that the body is read lazily
61
+ class MockTransport(httpx.BaseTransport, httpx.AsyncBaseTransport):
62
+ def __init__(
63
+ self,
64
+ handler: Callable[[httpx.Request], httpx.Response]
65
+ | Callable[[httpx.Request], Coroutine[Any, Any, httpx.Response]],
66
+ ) -> None:
67
+ self.handler = handler
68
+
69
+ @override
70
+ def handle_request(
71
+ self,
72
+ request: httpx.Request,
73
+ ) -> httpx.Response:
74
+ assert not inspect.iscoroutinefunction(self.handler), "handler must not be a coroutine function"
75
+ assert inspect.isfunction(self.handler), "handler must be a function"
76
+ return self.handler(request)
77
+
78
+ @override
79
+ async def handle_async_request(
80
+ self,
81
+ request: httpx.Request,
82
+ ) -> httpx.Response:
83
+ assert inspect.iscoroutinefunction(self.handler), "handler must be a coroutine function"
84
+ return await self.handler(request)
85
+
86
+
87
+ @dataclasses.dataclass
88
+ class Counter:
89
+ value: int = 0
90
+
91
+
92
+ def _make_sync_iterator(iterable: Iterable[T], counter: Optional[Counter] = None) -> Iterator[T]:
93
+ for item in iterable:
94
+ if counter:
95
+ counter.value += 1
96
+ yield item
97
+
98
+
99
+ async def _make_async_iterator(iterable: Iterable[T], counter: Optional[Counter] = None) -> AsyncIterator[T]:
100
+ for item in iterable:
101
+ if counter:
102
+ counter.value += 1
103
+ yield item
104
+
105
+
53
106
  def _get_open_connections(client: Gmt | AsyncGmt) -> int:
54
107
  transport = client._client._transport
55
108
  assert isinstance(transport, httpx.HTTPTransport) or isinstance(transport, httpx.AsyncHTTPTransport)
@@ -492,6 +545,70 @@ class TestGmt:
492
545
  b"",
493
546
  ]
494
547
 
548
+ @pytest.mark.respx(base_url=base_url)
549
+ def test_binary_content_upload(self, respx_mock: MockRouter, client: Gmt) -> None:
550
+ respx_mock.post("/upload").mock(side_effect=mirror_request_content)
551
+
552
+ file_content = b"Hello, this is a test file."
553
+
554
+ response = client.post(
555
+ "/upload",
556
+ content=file_content,
557
+ cast_to=httpx.Response,
558
+ options={"headers": {"Content-Type": "application/octet-stream"}},
559
+ )
560
+
561
+ assert response.status_code == 200
562
+ assert response.request.headers["Content-Type"] == "application/octet-stream"
563
+ assert response.content == file_content
564
+
565
+ def test_binary_content_upload_with_iterator(self) -> None:
566
+ file_content = b"Hello, this is a test file."
567
+ counter = Counter()
568
+ iterator = _make_sync_iterator([file_content], counter=counter)
569
+
570
+ def mock_handler(request: httpx.Request) -> httpx.Response:
571
+ assert counter.value == 0, "the request body should not have been read"
572
+ return httpx.Response(200, content=request.read())
573
+
574
+ with Gmt(
575
+ base_url=base_url,
576
+ api_key=api_key,
577
+ _strict_response_validation=True,
578
+ http_client=httpx.Client(transport=MockTransport(handler=mock_handler)),
579
+ ) as client:
580
+ response = client.post(
581
+ "/upload",
582
+ content=iterator,
583
+ cast_to=httpx.Response,
584
+ options={"headers": {"Content-Type": "application/octet-stream"}},
585
+ )
586
+
587
+ assert response.status_code == 200
588
+ assert response.request.headers["Content-Type"] == "application/octet-stream"
589
+ assert response.content == file_content
590
+ assert counter.value == 1
591
+
592
+ @pytest.mark.respx(base_url=base_url)
593
+ def test_binary_content_upload_with_body_is_deprecated(self, respx_mock: MockRouter, client: Gmt) -> None:
594
+ respx_mock.post("/upload").mock(side_effect=mirror_request_content)
595
+
596
+ file_content = b"Hello, this is a test file."
597
+
598
+ with pytest.deprecated_call(
599
+ match="Passing raw bytes as `body` is deprecated and will be removed in a future version. Please pass raw bytes via the `content` parameter instead."
600
+ ):
601
+ response = client.post(
602
+ "/upload",
603
+ body=file_content,
604
+ cast_to=httpx.Response,
605
+ options={"headers": {"Content-Type": "application/octet-stream"}},
606
+ )
607
+
608
+ assert response.status_code == 200
609
+ assert response.request.headers["Content-Type"] == "application/octet-stream"
610
+ assert response.content == file_content
611
+
495
612
  @pytest.mark.respx(base_url=base_url)
496
613
  def test_basic_union_response(self, respx_mock: MockRouter, client: Gmt) -> None:
497
614
  class Model1(BaseModel):
@@ -1309,6 +1426,72 @@ class TestAsyncGmt:
1309
1426
  b"",
1310
1427
  ]
1311
1428
 
1429
+ @pytest.mark.respx(base_url=base_url)
1430
+ async def test_binary_content_upload(self, respx_mock: MockRouter, async_client: AsyncGmt) -> None:
1431
+ respx_mock.post("/upload").mock(side_effect=mirror_request_content)
1432
+
1433
+ file_content = b"Hello, this is a test file."
1434
+
1435
+ response = await async_client.post(
1436
+ "/upload",
1437
+ content=file_content,
1438
+ cast_to=httpx.Response,
1439
+ options={"headers": {"Content-Type": "application/octet-stream"}},
1440
+ )
1441
+
1442
+ assert response.status_code == 200
1443
+ assert response.request.headers["Content-Type"] == "application/octet-stream"
1444
+ assert response.content == file_content
1445
+
1446
+ async def test_binary_content_upload_with_asynciterator(self) -> None:
1447
+ file_content = b"Hello, this is a test file."
1448
+ counter = Counter()
1449
+ iterator = _make_async_iterator([file_content], counter=counter)
1450
+
1451
+ async def mock_handler(request: httpx.Request) -> httpx.Response:
1452
+ assert counter.value == 0, "the request body should not have been read"
1453
+ return httpx.Response(200, content=await request.aread())
1454
+
1455
+ async with AsyncGmt(
1456
+ base_url=base_url,
1457
+ api_key=api_key,
1458
+ _strict_response_validation=True,
1459
+ http_client=httpx.AsyncClient(transport=MockTransport(handler=mock_handler)),
1460
+ ) as client:
1461
+ response = await client.post(
1462
+ "/upload",
1463
+ content=iterator,
1464
+ cast_to=httpx.Response,
1465
+ options={"headers": {"Content-Type": "application/octet-stream"}},
1466
+ )
1467
+
1468
+ assert response.status_code == 200
1469
+ assert response.request.headers["Content-Type"] == "application/octet-stream"
1470
+ assert response.content == file_content
1471
+ assert counter.value == 1
1472
+
1473
+ @pytest.mark.respx(base_url=base_url)
1474
+ async def test_binary_content_upload_with_body_is_deprecated(
1475
+ self, respx_mock: MockRouter, async_client: AsyncGmt
1476
+ ) -> None:
1477
+ respx_mock.post("/upload").mock(side_effect=mirror_request_content)
1478
+
1479
+ file_content = b"Hello, this is a test file."
1480
+
1481
+ with pytest.deprecated_call(
1482
+ match="Passing raw bytes as `body` is deprecated and will be removed in a future version. Please pass raw bytes via the `content` parameter instead."
1483
+ ):
1484
+ response = await async_client.post(
1485
+ "/upload",
1486
+ body=file_content,
1487
+ cast_to=httpx.Response,
1488
+ options={"headers": {"Content-Type": "application/octet-stream"}},
1489
+ )
1490
+
1491
+ assert response.status_code == 200
1492
+ assert response.request.headers["Content-Type"] == "application/octet-stream"
1493
+ assert response.content == file_content
1494
+
1312
1495
  @pytest.mark.respx(base_url=base_url)
1313
1496
  async def test_basic_union_response(self, respx_mock: MockRouter, async_client: AsyncGmt) -> None:
1314
1497
  class Model1(BaseModel):
@@ -1,3 +0,0 @@
1
- {
2
- ".": "0.10.0"
3
- }
File without changes
File without changes