Skip to content

Commit 3fbc8f1

Browse files
feat(api): aggregated API specs update
1 parent 3537e8c commit 3fbc8f1

4 files changed

Lines changed: 89 additions & 58 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 523
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gcore%2Fgcore-eca22164d9482d49887776d39a5e74fb55cc36d40d3f524336aa26433514386e.yml
3-
openapi_spec_hash: f6aa7b95639f6eb639e408ad321f2861
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gcore%2Fgcore-5b7d4df0da50df13bda0d0112b026c0b40e26462f8d7e0013ac3286c27a458bd.yml
3+
openapi_spec_hash: 2ad55753d983df577077b3ce156ac4ca
44
config_hash: 53f1995f46a0e2f7e747e65bafa3d6e0

src/gcore/resources/storage/storage.py

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
import typing_extensions
56
from typing_extensions import Literal
67

78
import httpx
@@ -155,6 +156,7 @@ def create(
155156
cast_to=Storage,
156157
)
157158

159+
@typing_extensions.deprecated("deprecated")
158160
def update(
159161
self,
160162
storage_id: int,
@@ -168,12 +170,15 @@ def update(
168170
extra_body: Body | None = None,
169171
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
170172
) -> Storage:
171-
"""
172-
Updates storage configuration such as expiration date and server alias.
173+
"""Updates storage configuration such as expiration date and server alias.
174+
175+
Note:
176+
Prefer PATCH /provisioning/v2/storage/{`storage_id`} that uses correct HTTP
177+
method for updating the storage.
173178
174179
Args:
175-
expires: ISO 8601 timestamp when the storage should expire. Leave empty to remove
176-
expiration.
180+
expires: Duration when the storage should expire in format like "2 years 6 months 2 weeks
181+
3 days 5 hours 10 minutes 15 seconds". Leave empty to remove expiration.
177182
178183
server_alias: Custom domain alias for accessing the storage. Leave empty to remove alias.
179184
@@ -555,6 +560,7 @@ async def create(
555560
cast_to=Storage,
556561
)
557562

563+
@typing_extensions.deprecated("deprecated")
558564
async def update(
559565
self,
560566
storage_id: int,
@@ -568,12 +574,15 @@ async def update(
568574
extra_body: Body | None = None,
569575
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
570576
) -> Storage:
571-
"""
572-
Updates storage configuration such as expiration date and server alias.
577+
"""Updates storage configuration such as expiration date and server alias.
578+
579+
Note:
580+
Prefer PATCH /provisioning/v2/storage/{`storage_id`} that uses correct HTTP
581+
method for updating the storage.
573582
574583
Args:
575-
expires: ISO 8601 timestamp when the storage should expire. Leave empty to remove
576-
expiration.
584+
expires: Duration when the storage should expire in format like "2 years 6 months 2 weeks
585+
3 days 5 hours 10 minutes 15 seconds". Leave empty to remove expiration.
577586
578587
server_alias: Custom domain alias for accessing the storage. Leave empty to remove alias.
579588
@@ -865,8 +874,10 @@ def __init__(self, storage: StorageResource) -> None:
865874
self.create = to_raw_response_wrapper(
866875
storage.create,
867876
)
868-
self.update = to_raw_response_wrapper(
869-
storage.update,
877+
self.update = ( # pyright: ignore[reportDeprecated]
878+
to_raw_response_wrapper(
879+
storage.update, # pyright: ignore[reportDeprecated],
880+
)
870881
)
871882
self.list = to_raw_response_wrapper(
872883
storage.list,
@@ -911,8 +922,10 @@ def __init__(self, storage: AsyncStorageResource) -> None:
911922
self.create = async_to_raw_response_wrapper(
912923
storage.create,
913924
)
914-
self.update = async_to_raw_response_wrapper(
915-
storage.update,
925+
self.update = ( # pyright: ignore[reportDeprecated]
926+
async_to_raw_response_wrapper(
927+
storage.update, # pyright: ignore[reportDeprecated],
928+
)
916929
)
917930
self.list = async_to_raw_response_wrapper(
918931
storage.list,
@@ -957,8 +970,10 @@ def __init__(self, storage: StorageResource) -> None:
957970
self.create = to_streamed_response_wrapper(
958971
storage.create,
959972
)
960-
self.update = to_streamed_response_wrapper(
961-
storage.update,
973+
self.update = ( # pyright: ignore[reportDeprecated]
974+
to_streamed_response_wrapper(
975+
storage.update, # pyright: ignore[reportDeprecated],
976+
)
962977
)
963978
self.list = to_streamed_response_wrapper(
964979
storage.list,
@@ -1003,8 +1018,10 @@ def __init__(self, storage: AsyncStorageResource) -> None:
10031018
self.create = async_to_streamed_response_wrapper(
10041019
storage.create,
10051020
)
1006-
self.update = async_to_streamed_response_wrapper(
1007-
storage.update,
1021+
self.update = ( # pyright: ignore[reportDeprecated]
1022+
async_to_streamed_response_wrapper(
1023+
storage.update, # pyright: ignore[reportDeprecated],
1024+
)
10081025
)
10091026
self.list = async_to_streamed_response_wrapper(
10101027
storage.list,

src/gcore/types/storage/storage_update_params.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
class StorageUpdateParams(TypedDict, total=False):
1111
expires: str
12-
"""ISO 8601 timestamp when the storage should expire.
13-
14-
Leave empty to remove expiration.
12+
"""
13+
Duration when the storage should expire in format like "2 years 6 months 2 weeks
14+
3 days 5 hours 10 minutes 15 seconds". Leave empty to remove expiration.
1515
"""
1616

1717
server_alias: str

tests/api_resources/test_storage.py

Lines changed: 51 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
Storage,
1515
)
1616

17+
# pyright: reportDeprecated=false
18+
1719
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
1820

1921

@@ -70,25 +72,30 @@ def test_streaming_response_create(self, client: Gcore) -> None:
7072

7173
@parametrize
7274
def test_method_update(self, client: Gcore) -> None:
73-
storage = client.storage.update(
74-
storage_id=0,
75-
)
75+
with pytest.warns(DeprecationWarning):
76+
storage = client.storage.update(
77+
storage_id=0,
78+
)
79+
7680
assert_matches_type(Storage, storage, path=["response"])
7781

7882
@parametrize
7983
def test_method_update_with_all_params(self, client: Gcore) -> None:
80-
storage = client.storage.update(
81-
storage_id=0,
82-
expires="2026-12-31 23:59:59+00:00",
83-
server_alias="my-storage.company.com",
84-
)
84+
with pytest.warns(DeprecationWarning):
85+
storage = client.storage.update(
86+
storage_id=0,
87+
expires="2 years 6 months 2 weeks 3 days 5 hours 10 minutes 15 seconds",
88+
server_alias="my-storage.company.com",
89+
)
90+
8591
assert_matches_type(Storage, storage, path=["response"])
8692

8793
@parametrize
8894
def test_raw_response_update(self, client: Gcore) -> None:
89-
response = client.storage.with_raw_response.update(
90-
storage_id=0,
91-
)
95+
with pytest.warns(DeprecationWarning):
96+
response = client.storage.with_raw_response.update(
97+
storage_id=0,
98+
)
9299

93100
assert response.is_closed is True
94101
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -97,14 +104,15 @@ def test_raw_response_update(self, client: Gcore) -> None:
97104

98105
@parametrize
99106
def test_streaming_response_update(self, client: Gcore) -> None:
100-
with client.storage.with_streaming_response.update(
101-
storage_id=0,
102-
) as response:
103-
assert not response.is_closed
104-
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
107+
with pytest.warns(DeprecationWarning):
108+
with client.storage.with_streaming_response.update(
109+
storage_id=0,
110+
) as response:
111+
assert not response.is_closed
112+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
105113

106-
storage = response.parse()
107-
assert_matches_type(Storage, storage, path=["response"])
114+
storage = response.parse()
115+
assert_matches_type(Storage, storage, path=["response"])
108116

109117
assert cast(Any, response.is_closed) is True
110118

@@ -374,25 +382,30 @@ async def test_streaming_response_create(self, async_client: AsyncGcore) -> None
374382

375383
@parametrize
376384
async def test_method_update(self, async_client: AsyncGcore) -> None:
377-
storage = await async_client.storage.update(
378-
storage_id=0,
379-
)
385+
with pytest.warns(DeprecationWarning):
386+
storage = await async_client.storage.update(
387+
storage_id=0,
388+
)
389+
380390
assert_matches_type(Storage, storage, path=["response"])
381391

382392
@parametrize
383393
async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> None:
384-
storage = await async_client.storage.update(
385-
storage_id=0,
386-
expires="2026-12-31 23:59:59+00:00",
387-
server_alias="my-storage.company.com",
388-
)
394+
with pytest.warns(DeprecationWarning):
395+
storage = await async_client.storage.update(
396+
storage_id=0,
397+
expires="2 years 6 months 2 weeks 3 days 5 hours 10 minutes 15 seconds",
398+
server_alias="my-storage.company.com",
399+
)
400+
389401
assert_matches_type(Storage, storage, path=["response"])
390402

391403
@parametrize
392404
async def test_raw_response_update(self, async_client: AsyncGcore) -> None:
393-
response = await async_client.storage.with_raw_response.update(
394-
storage_id=0,
395-
)
405+
with pytest.warns(DeprecationWarning):
406+
response = await async_client.storage.with_raw_response.update(
407+
storage_id=0,
408+
)
396409

397410
assert response.is_closed is True
398411
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -401,14 +414,15 @@ async def test_raw_response_update(self, async_client: AsyncGcore) -> None:
401414

402415
@parametrize
403416
async def test_streaming_response_update(self, async_client: AsyncGcore) -> None:
404-
async with async_client.storage.with_streaming_response.update(
405-
storage_id=0,
406-
) as response:
407-
assert not response.is_closed
408-
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
409-
410-
storage = await response.parse()
411-
assert_matches_type(Storage, storage, path=["response"])
417+
with pytest.warns(DeprecationWarning):
418+
async with async_client.storage.with_streaming_response.update(
419+
storage_id=0,
420+
) as response:
421+
assert not response.is_closed
422+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
423+
424+
storage = await response.parse()
425+
assert_matches_type(Storage, storage, path=["response"])
412426

413427
assert cast(Any, response.is_closed) is True
414428

0 commit comments

Comments
 (0)