Skip to content

Commit 2ac6bce

Browse files
chore(cloud)!: use new PATCH files shares endpoint
1 parent e906ee6 commit 2ac6bce

3 files changed

Lines changed: 201 additions & 130 deletions

File tree

api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ from gcore.types.cloud import FileShare
725725
Methods:
726726

727727
- <code title="post /cloud/v1/file_shares/{project_id}/{region_id}">client.cloud.file_shares.<a href="./src/gcore/resources/cloud/file_shares/file_shares.py">create</a>(\*, project_id, region_id, \*\*<a href="src/gcore/types/cloud/file_share_create_params.py">params</a>) -> <a href="./src/gcore/types/cloud/task_id_list.py">TaskIDList</a></code>
728-
- <code title="patch /cloud/v1/file_shares/{project_id}/{region_id}/{file_share_id}">client.cloud.file_shares.<a href="./src/gcore/resources/cloud/file_shares/file_shares.py">update</a>(file_share_id, \*, project_id, region_id, \*\*<a href="src/gcore/types/cloud/file_share_update_params.py">params</a>) -> <a href="./src/gcore/types/cloud/file_share.py">FileShare</a></code>
728+
- <code title="patch /cloud/v3/file_shares/{project_id}/{region_id}/{file_share_id}">client.cloud.file_shares.<a href="./src/gcore/resources/cloud/file_shares/file_shares.py">update</a>(file_share_id, \*, project_id, region_id, \*\*<a href="src/gcore/types/cloud/file_share_update_params.py">params</a>) -> <a href="./src/gcore/types/cloud/task_id_list.py">TaskIDList</a></code>
729729
- <code title="get /cloud/v1/file_shares/{project_id}/{region_id}">client.cloud.file_shares.<a href="./src/gcore/resources/cloud/file_shares/file_shares.py">list</a>(\*, project_id, region_id, \*\*<a href="src/gcore/types/cloud/file_share_list_params.py">params</a>) -> <a href="./src/gcore/types/cloud/file_share.py">SyncOffsetPage[FileShare]</a></code>
730730
- <code title="delete /cloud/v1/file_shares/{project_id}/{region_id}/{file_share_id}">client.cloud.file_shares.<a href="./src/gcore/resources/cloud/file_shares/file_shares.py">delete</a>(file_share_id, \*, project_id, region_id) -> <a href="./src/gcore/types/cloud/task_id_list.py">TaskIDList</a></code>
731731
- <code title="get /cloud/v1/file_shares/{project_id}/{region_id}/{file_share_id}">client.cloud.file_shares.<a href="./src/gcore/resources/cloud/file_shares/file_shares.py">get</a>(file_share_id, \*, project_id, region_id) -> <a href="./src/gcore/types/cloud/file_share.py">FileShare</a></code>

src/gcore/resources/cloud/file_shares/file_shares.py

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

33
from __future__ import annotations
44

5-
import typing_extensions
65
from typing import Dict, Iterable, Optional
76
from typing_extensions import Literal, overload
87

@@ -228,7 +227,6 @@ def create(
228227
cast_to=TaskIDList,
229228
)
230229

231-
@typing_extensions.deprecated("deprecated")
232230
def update(
233231
self,
234232
file_share_id: str,
@@ -244,12 +242,9 @@ def update(
244242
extra_query: Query | None = None,
245243
extra_body: Body | None = None,
246244
timeout: float | httpx.Timeout | None | NotGiven = not_given,
247-
) -> FileShare:
245+
) -> TaskIDList:
248246
"""
249-
Rename file share or update tags
250-
251-
**Deprecated**: Use PATCH
252-
/v3/`file_shares`/{`project_id`}/{`region_id`}/{`file_share_id`} instead
247+
Rename file share, update tags or set share specific properties
253248
254249
Args:
255250
project_id: Project ID
@@ -299,7 +294,7 @@ def update(
299294
if not file_share_id:
300295
raise ValueError(f"Expected a non-empty value for `file_share_id` but received {file_share_id!r}")
301296
return self._patch(
302-
f"/cloud/v1/file_shares/{project_id}/{region_id}/{file_share_id}",
297+
f"/cloud/v3/file_shares/{project_id}/{region_id}/{file_share_id}",
303298
body=maybe_transform(
304299
{
305300
"name": name,
@@ -311,7 +306,53 @@ def update(
311306
options=make_request_options(
312307
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
313308
),
314-
cast_to=FileShare,
309+
cast_to=TaskIDList,
310+
)
311+
312+
def update_and_poll(
313+
self,
314+
file_share_id: str,
315+
*,
316+
project_id: int | None = None,
317+
region_id: int | None = None,
318+
name: str | Omit = omit,
319+
share_settings: file_share_update_params.ShareSettings | Omit = omit,
320+
tags: Optional[TagUpdateMapParam] | Omit = omit,
321+
polling_interval_seconds: int | Omit = omit,
322+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
323+
# The extra values given here take precedence over values defined on the client or passed to this method.
324+
extra_headers: Headers | None = None,
325+
extra_query: Query | None = None,
326+
extra_body: Body | None = None,
327+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
328+
) -> FileShare:
329+
response = self.update(
330+
file_share_id,
331+
project_id=project_id,
332+
region_id=region_id,
333+
name=name,
334+
share_settings=share_settings,
335+
tags=tags,
336+
extra_headers=extra_headers,
337+
extra_query=extra_query,
338+
extra_body=extra_body,
339+
timeout=timeout,
340+
)
341+
if not response.tasks:
342+
raise ValueError("Expected at least one task to be created")
343+
self._client.cloud.tasks.poll(
344+
task_id=response.tasks[0],
345+
extra_headers=extra_headers,
346+
polling_interval_seconds=polling_interval_seconds,
347+
)
348+
return self.get(
349+
file_share_id,
350+
project_id=project_id,
351+
region_id=region_id,
352+
extra_headers=extra_headers,
353+
extra_query=extra_query,
354+
extra_body=extra_body,
355+
timeout=timeout,
315356
)
316357

317358
def list(
@@ -707,7 +748,6 @@ async def create(
707748
cast_to=TaskIDList,
708749
)
709750

710-
@typing_extensions.deprecated("deprecated")
711751
async def update(
712752
self,
713753
file_share_id: str,
@@ -723,12 +763,9 @@ async def update(
723763
extra_query: Query | None = None,
724764
extra_body: Body | None = None,
725765
timeout: float | httpx.Timeout | None | NotGiven = not_given,
726-
) -> FileShare:
766+
) -> TaskIDList:
727767
"""
728-
Rename file share or update tags
729-
730-
**Deprecated**: Use PATCH
731-
/v3/`file_shares`/{`project_id`}/{`region_id`}/{`file_share_id`} instead
768+
Rename file share, update tags or set share specific properties
732769
733770
Args:
734771
project_id: Project ID
@@ -778,7 +815,7 @@ async def update(
778815
if not file_share_id:
779816
raise ValueError(f"Expected a non-empty value for `file_share_id` but received {file_share_id!r}")
780817
return await self._patch(
781-
f"/cloud/v1/file_shares/{project_id}/{region_id}/{file_share_id}",
818+
f"/cloud/v3/file_shares/{project_id}/{region_id}/{file_share_id}",
782819
body=await async_maybe_transform(
783820
{
784821
"name": name,
@@ -790,7 +827,53 @@ async def update(
790827
options=make_request_options(
791828
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
792829
),
793-
cast_to=FileShare,
830+
cast_to=TaskIDList,
831+
)
832+
833+
async def update_and_poll(
834+
self,
835+
file_share_id: str,
836+
*,
837+
project_id: int | None = None,
838+
region_id: int | None = None,
839+
name: str | Omit = omit,
840+
share_settings: file_share_update_params.ShareSettings | Omit = omit,
841+
tags: Optional[TagUpdateMapParam] | Omit = omit,
842+
polling_interval_seconds: int | Omit = omit,
843+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
844+
# The extra values given here take precedence over values defined on the client or passed to this method.
845+
extra_headers: Headers | None = None,
846+
extra_query: Query | None = None,
847+
extra_body: Body | None = None,
848+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
849+
) -> FileShare:
850+
response = await self.update(
851+
file_share_id,
852+
project_id=project_id,
853+
region_id=region_id,
854+
name=name,
855+
share_settings=share_settings,
856+
tags=tags,
857+
extra_headers=extra_headers,
858+
extra_query=extra_query,
859+
extra_body=extra_body,
860+
timeout=timeout,
861+
)
862+
if not response.tasks:
863+
raise ValueError("Expected at least one task to be created")
864+
await self._client.cloud.tasks.poll(
865+
task_id=response.tasks[0],
866+
extra_headers=extra_headers,
867+
polling_interval_seconds=polling_interval_seconds,
868+
)
869+
return await self.get(
870+
file_share_id,
871+
project_id=project_id,
872+
region_id=region_id,
873+
extra_headers=extra_headers,
874+
extra_query=extra_query,
875+
extra_body=extra_body,
876+
timeout=timeout,
794877
)
795878

796879
def list(
@@ -1006,10 +1089,11 @@ def __init__(self, file_shares: FileSharesResource) -> None:
10061089
self.create = to_raw_response_wrapper(
10071090
file_shares.create,
10081091
)
1009-
self.update = ( # pyright: ignore[reportDeprecated]
1010-
to_raw_response_wrapper(
1011-
file_shares.update, # pyright: ignore[reportDeprecated],
1012-
)
1092+
self.update = to_raw_response_wrapper(
1093+
file_shares.update,
1094+
)
1095+
self.update_and_poll = to_raw_response_wrapper(
1096+
file_shares.update_and_poll,
10131097
)
10141098
self.list = to_raw_response_wrapper(
10151099
file_shares.list,
@@ -1036,10 +1120,11 @@ def __init__(self, file_shares: AsyncFileSharesResource) -> None:
10361120
self.create = async_to_raw_response_wrapper(
10371121
file_shares.create,
10381122
)
1039-
self.update = ( # pyright: ignore[reportDeprecated]
1040-
async_to_raw_response_wrapper(
1041-
file_shares.update, # pyright: ignore[reportDeprecated],
1042-
)
1123+
self.update = async_to_raw_response_wrapper(
1124+
file_shares.update,
1125+
)
1126+
self.update_and_poll = async_to_raw_response_wrapper(
1127+
file_shares.update_and_poll,
10431128
)
10441129
self.list = async_to_raw_response_wrapper(
10451130
file_shares.list,
@@ -1066,10 +1151,11 @@ def __init__(self, file_shares: FileSharesResource) -> None:
10661151
self.create = to_streamed_response_wrapper(
10671152
file_shares.create,
10681153
)
1069-
self.update = ( # pyright: ignore[reportDeprecated]
1070-
to_streamed_response_wrapper(
1071-
file_shares.update, # pyright: ignore[reportDeprecated],
1072-
)
1154+
self.update = to_streamed_response_wrapper(
1155+
file_shares.update,
1156+
)
1157+
self.update_and_poll = to_streamed_response_wrapper(
1158+
file_shares.update_and_poll,
10731159
)
10741160
self.list = to_streamed_response_wrapper(
10751161
file_shares.list,
@@ -1096,10 +1182,11 @@ def __init__(self, file_shares: AsyncFileSharesResource) -> None:
10961182
self.create = async_to_streamed_response_wrapper(
10971183
file_shares.create,
10981184
)
1099-
self.update = ( # pyright: ignore[reportDeprecated]
1100-
async_to_streamed_response_wrapper(
1101-
file_shares.update, # pyright: ignore[reportDeprecated],
1102-
)
1185+
self.update = async_to_streamed_response_wrapper(
1186+
file_shares.update,
1187+
)
1188+
self.update_and_pol = async_to_streamed_response_wrapper(
1189+
file_shares.update_and_poll,
11031190
)
11041191
self.list = async_to_streamed_response_wrapper(
11051192
file_shares.list,

0 commit comments

Comments
 (0)