44
55import 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
88from ...._utils import path_template , maybe_transform , async_maybe_transform
99from ...._compat import cached_property
1010from ...._resource import SyncAPIResource , AsyncAPIResource
1616)
1717from ....pagination import SyncOffsetPage , AsyncOffsetPage
1818from ...._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
2020from ....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
131255class 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
237485class 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
249506class 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
261527class 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
273548class 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+ )
0 commit comments