Skip to content

Commit 65ef255

Browse files
fix(storage): rename bucket path param {bucket_name} -> {name}
1 parent a202a7e commit 65ef255

6 files changed

Lines changed: 610 additions & 5 deletions

File tree

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 655
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gcore/gcore-907989a8b978ffafa751f99e61a55cde68bec53bf16b011c221e3b7a70c444a3.yml
1+
configured_endpoints: 658
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gcore/gcore-b3b1edc1075e6806e861cbcbd8f5a21f5aa1d520d1762d3005ad1ed6d2b378ec.yml
33
openapi_spec_hash: c1afaa5644fd940d6fe865733ae90a22
4-
config_hash: 24d55cb26d543a2d65d129ebe46f7775
4+
config_hash: 0ecd0c790249a8eaac3965931f0f239e

src/gcore/resources/storage/api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ from gcore.types.storage.object_storages import Bucket
5454
Methods:
5555

5656
- <code title="post /storage/v4/object_storages/{storage_id}/buckets">client.storage.object_storages.buckets.<a href="./src/gcore/resources/storage/object_storages/buckets.py">create</a>(storage_id, \*\*<a href="src/gcore/types/storage/object_storages/bucket_create_params.py">params</a>) -> <a href="./src/gcore/types/storage/object_storages/bucket.py">Bucket</a></code>
57+
- <code title="patch /storage/v4/object_storages/{storage_id}/buckets/{name}">client.storage.object_storages.buckets.<a href="./src/gcore/resources/storage/object_storages/buckets.py">update</a>(name, \*, storage_id, \*\*<a href="src/gcore/types/storage/object_storages/bucket_update_params.py">params</a>) -> <a href="./src/gcore/types/storage/object_storages/bucket.py">Bucket</a></code>
5758
- <code title="get /storage/v4/object_storages/{storage_id}/buckets">client.storage.object_storages.buckets.<a href="./src/gcore/resources/storage/object_storages/buckets.py">list</a>(storage_id, \*\*<a href="src/gcore/types/storage/object_storages/bucket_list_params.py">params</a>) -> <a href="./src/gcore/types/storage/object_storages/bucket.py">SyncOffsetPage[Bucket]</a></code>
59+
- <code title="delete /storage/v4/object_storages/{storage_id}/buckets/{name}">client.storage.object_storages.buckets.<a href="./src/gcore/resources/storage/object_storages/buckets.py">delete</a>(name, \*, storage_id) -> None</code>
60+
- <code title="get /storage/v4/object_storages/{storage_id}/buckets/{name}">client.storage.object_storages.buckets.<a href="./src/gcore/resources/storage/object_storages/buckets.py">get</a>(name, \*, storage_id) -> <a href="./src/gcore/types/storage/object_storages/bucket.py">Bucket</a></code>
5861

5962
## SftpStorages
6063

src/gcore/resources/storage/object_storages/buckets.py

Lines changed: 286 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import httpx
66

7-
from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
7+
from ...._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given
88
from ...._utils import path_template, maybe_transform, async_maybe_transform
99
from ...._compat import cached_property
1010
from ...._resource import SyncAPIResource, AsyncAPIResource
@@ -16,7 +16,7 @@
1616
)
1717
from ....pagination import SyncOffsetPage, AsyncOffsetPage
1818
from ...._base_client import AsyncPaginator, make_request_options
19-
from ....types.storage.object_storages import bucket_list_params, bucket_create_params
19+
from ....types.storage.object_storages import bucket_list_params, bucket_create_params, bucket_update_params
2020
from ....types.storage.object_storages.bucket import Bucket
2121

2222
__all__ = ["BucketsResource", "AsyncBucketsResource"]
@@ -77,6 +77,58 @@ def create(
7777
cast_to=Bucket,
7878
)
7979

80+
def update(
81+
self,
82+
name: str,
83+
*,
84+
storage_id: int,
85+
cors: bucket_update_params.Cors | Omit = omit,
86+
lifecycle: bucket_update_params.Lifecycle | Omit = omit,
87+
policy: bucket_update_params.Policy | Omit = omit,
88+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
89+
# The extra values given here take precedence over values defined on the client or passed to this method.
90+
extra_headers: Headers | None = None,
91+
extra_query: Query | None = None,
92+
extra_body: Body | None = None,
93+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
94+
) -> Bucket:
95+
"""Updates bucket CORS, Lifecycle, and/or Policy settings.
96+
97+
Supports partial
98+
updates - only specified fields will be modified.
99+
100+
Lifecycle: set `expiration_days` to a positive integer to enable, null or 0 to
101+
remove. Negative values return 400. CORS: set `allowed_origins` to a non-empty
102+
array to configure, empty array to remove. Policy: set `is_public` to true/false
103+
to update.
104+
105+
Args:
106+
extra_headers: Send extra headers
107+
108+
extra_query: Add additional query parameters to the request
109+
110+
extra_body: Add additional JSON properties to the request
111+
112+
timeout: Override the client-level default timeout for this request, in seconds
113+
"""
114+
if not name:
115+
raise ValueError(f"Expected a non-empty value for `name` but received {name!r}")
116+
return self._patch(
117+
path_template("/storage/v4/object_storages/{storage_id}/buckets/{name}", storage_id=storage_id, name=name),
118+
body=maybe_transform(
119+
{
120+
"cors": cors,
121+
"lifecycle": lifecycle,
122+
"policy": policy,
123+
},
124+
bucket_update_params.BucketUpdateParams,
125+
),
126+
options=make_request_options(
127+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
128+
),
129+
cast_to=Bucket,
130+
)
131+
80132
def list(
81133
self,
82134
storage_id: int,
@@ -127,6 +179,78 @@ def list(
127179
model=Bucket,
128180
)
129181

182+
def delete(
183+
self,
184+
name: str,
185+
*,
186+
storage_id: int,
187+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
188+
# The extra values given here take precedence over values defined on the client or passed to this method.
189+
extra_headers: Headers | None = None,
190+
extra_query: Query | None = None,
191+
extra_body: Body | None = None,
192+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
193+
) -> None:
194+
"""Removes a bucket from an S3-compatible storage.
195+
196+
All objects in the bucket will
197+
be deleted.
198+
199+
Args:
200+
extra_headers: Send extra headers
201+
202+
extra_query: Add additional query parameters to the request
203+
204+
extra_body: Add additional JSON properties to the request
205+
206+
timeout: Override the client-level default timeout for this request, in seconds
207+
"""
208+
if not name:
209+
raise ValueError(f"Expected a non-empty value for `name` but received {name!r}")
210+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
211+
return self._delete(
212+
path_template("/storage/v4/object_storages/{storage_id}/buckets/{name}", storage_id=storage_id, name=name),
213+
options=make_request_options(
214+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
215+
),
216+
cast_to=NoneType,
217+
)
218+
219+
def get(
220+
self,
221+
name: str,
222+
*,
223+
storage_id: int,
224+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
225+
# The extra values given here take precedence over values defined on the client or passed to this method.
226+
extra_headers: Headers | None = None,
227+
extra_query: Query | None = None,
228+
extra_body: Body | None = None,
229+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
230+
) -> Bucket:
231+
"""
232+
Returns bucket configuration including CORS, Lifecycle, and Policy settings in a
233+
consolidated response.
234+
235+
Args:
236+
extra_headers: Send extra headers
237+
238+
extra_query: Add additional query parameters to the request
239+
240+
extra_body: Add additional JSON properties to the request
241+
242+
timeout: Override the client-level default timeout for this request, in seconds
243+
"""
244+
if not name:
245+
raise ValueError(f"Expected a non-empty value for `name` but received {name!r}")
246+
return self._get(
247+
path_template("/storage/v4/object_storages/{storage_id}/buckets/{name}", storage_id=storage_id, name=name),
248+
options=make_request_options(
249+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
250+
),
251+
cast_to=Bucket,
252+
)
253+
130254

131255
class AsyncBucketsResource(AsyncAPIResource):
132256
@cached_property
@@ -183,6 +307,58 @@ async def create(
183307
cast_to=Bucket,
184308
)
185309

310+
async def update(
311+
self,
312+
name: str,
313+
*,
314+
storage_id: int,
315+
cors: bucket_update_params.Cors | Omit = omit,
316+
lifecycle: bucket_update_params.Lifecycle | Omit = omit,
317+
policy: bucket_update_params.Policy | Omit = omit,
318+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
319+
# The extra values given here take precedence over values defined on the client or passed to this method.
320+
extra_headers: Headers | None = None,
321+
extra_query: Query | None = None,
322+
extra_body: Body | None = None,
323+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
324+
) -> Bucket:
325+
"""Updates bucket CORS, Lifecycle, and/or Policy settings.
326+
327+
Supports partial
328+
updates - only specified fields will be modified.
329+
330+
Lifecycle: set `expiration_days` to a positive integer to enable, null or 0 to
331+
remove. Negative values return 400. CORS: set `allowed_origins` to a non-empty
332+
array to configure, empty array to remove. Policy: set `is_public` to true/false
333+
to update.
334+
335+
Args:
336+
extra_headers: Send extra headers
337+
338+
extra_query: Add additional query parameters to the request
339+
340+
extra_body: Add additional JSON properties to the request
341+
342+
timeout: Override the client-level default timeout for this request, in seconds
343+
"""
344+
if not name:
345+
raise ValueError(f"Expected a non-empty value for `name` but received {name!r}")
346+
return await self._patch(
347+
path_template("/storage/v4/object_storages/{storage_id}/buckets/{name}", storage_id=storage_id, name=name),
348+
body=await async_maybe_transform(
349+
{
350+
"cors": cors,
351+
"lifecycle": lifecycle,
352+
"policy": policy,
353+
},
354+
bucket_update_params.BucketUpdateParams,
355+
),
356+
options=make_request_options(
357+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
358+
),
359+
cast_to=Bucket,
360+
)
361+
186362
def list(
187363
self,
188364
storage_id: int,
@@ -233,6 +409,78 @@ def list(
233409
model=Bucket,
234410
)
235411

412+
async def delete(
413+
self,
414+
name: str,
415+
*,
416+
storage_id: int,
417+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
418+
# The extra values given here take precedence over values defined on the client or passed to this method.
419+
extra_headers: Headers | None = None,
420+
extra_query: Query | None = None,
421+
extra_body: Body | None = None,
422+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
423+
) -> None:
424+
"""Removes a bucket from an S3-compatible storage.
425+
426+
All objects in the bucket will
427+
be deleted.
428+
429+
Args:
430+
extra_headers: Send extra headers
431+
432+
extra_query: Add additional query parameters to the request
433+
434+
extra_body: Add additional JSON properties to the request
435+
436+
timeout: Override the client-level default timeout for this request, in seconds
437+
"""
438+
if not name:
439+
raise ValueError(f"Expected a non-empty value for `name` but received {name!r}")
440+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
441+
return await self._delete(
442+
path_template("/storage/v4/object_storages/{storage_id}/buckets/{name}", storage_id=storage_id, name=name),
443+
options=make_request_options(
444+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
445+
),
446+
cast_to=NoneType,
447+
)
448+
449+
async def get(
450+
self,
451+
name: str,
452+
*,
453+
storage_id: int,
454+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
455+
# The extra values given here take precedence over values defined on the client or passed to this method.
456+
extra_headers: Headers | None = None,
457+
extra_query: Query | None = None,
458+
extra_body: Body | None = None,
459+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
460+
) -> Bucket:
461+
"""
462+
Returns bucket configuration including CORS, Lifecycle, and Policy settings in a
463+
consolidated response.
464+
465+
Args:
466+
extra_headers: Send extra headers
467+
468+
extra_query: Add additional query parameters to the request
469+
470+
extra_body: Add additional JSON properties to the request
471+
472+
timeout: Override the client-level default timeout for this request, in seconds
473+
"""
474+
if not name:
475+
raise ValueError(f"Expected a non-empty value for `name` but received {name!r}")
476+
return await self._get(
477+
path_template("/storage/v4/object_storages/{storage_id}/buckets/{name}", storage_id=storage_id, name=name),
478+
options=make_request_options(
479+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
480+
),
481+
cast_to=Bucket,
482+
)
483+
236484

237485
class BucketsResourceWithRawResponse:
238486
def __init__(self, buckets: BucketsResource) -> None:
@@ -241,9 +489,18 @@ def __init__(self, buckets: BucketsResource) -> None:
241489
self.create = to_raw_response_wrapper(
242490
buckets.create,
243491
)
492+
self.update = to_raw_response_wrapper(
493+
buckets.update,
494+
)
244495
self.list = to_raw_response_wrapper(
245496
buckets.list,
246497
)
498+
self.delete = to_raw_response_wrapper(
499+
buckets.delete,
500+
)
501+
self.get = to_raw_response_wrapper(
502+
buckets.get,
503+
)
247504

248505

249506
class AsyncBucketsResourceWithRawResponse:
@@ -253,9 +510,18 @@ def __init__(self, buckets: AsyncBucketsResource) -> None:
253510
self.create = async_to_raw_response_wrapper(
254511
buckets.create,
255512
)
513+
self.update = async_to_raw_response_wrapper(
514+
buckets.update,
515+
)
256516
self.list = async_to_raw_response_wrapper(
257517
buckets.list,
258518
)
519+
self.delete = async_to_raw_response_wrapper(
520+
buckets.delete,
521+
)
522+
self.get = async_to_raw_response_wrapper(
523+
buckets.get,
524+
)
259525

260526

261527
class BucketsResourceWithStreamingResponse:
@@ -265,9 +531,18 @@ def __init__(self, buckets: BucketsResource) -> None:
265531
self.create = to_streamed_response_wrapper(
266532
buckets.create,
267533
)
534+
self.update = to_streamed_response_wrapper(
535+
buckets.update,
536+
)
268537
self.list = to_streamed_response_wrapper(
269538
buckets.list,
270539
)
540+
self.delete = to_streamed_response_wrapper(
541+
buckets.delete,
542+
)
543+
self.get = to_streamed_response_wrapper(
544+
buckets.get,
545+
)
271546

272547

273548
class AsyncBucketsResourceWithStreamingResponse:
@@ -277,6 +552,15 @@ def __init__(self, buckets: AsyncBucketsResource) -> None:
277552
self.create = async_to_streamed_response_wrapper(
278553
buckets.create,
279554
)
555+
self.update = async_to_streamed_response_wrapper(
556+
buckets.update,
557+
)
280558
self.list = async_to_streamed_response_wrapper(
281559
buckets.list,
282560
)
561+
self.delete = async_to_streamed_response_wrapper(
562+
buckets.delete,
563+
)
564+
self.get = async_to_streamed_response_wrapper(
565+
buckets.get,
566+
)

src/gcore/types/storage/object_storages/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
from .access_key_created import AccessKeyCreated as AccessKeyCreated
88
from .bucket_list_params import BucketListParams as BucketListParams
99
from .bucket_create_params import BucketCreateParams as BucketCreateParams
10+
from .bucket_update_params import BucketUpdateParams as BucketUpdateParams
1011
from .access_key_list_params import AccessKeyListParams as AccessKeyListParams

0 commit comments

Comments
 (0)