22
33from __future__ import annotations
44
5- from typing import Any , List , Type , Optional , cast
5+ from typing import Any , Dict , List , Type , Optional , cast
66from typing_extensions import Literal , overload
77
88import httpx
2424 secret_get_params ,
2525 secret_delete_params ,
2626 secret_update_params ,
27+ secret_bulk_update_params ,
2728)
2829from ......types .workers_for_platforms .dispatch .namespaces .scripts .secret_get_response import SecretGetResponse
2930from ......types .workers_for_platforms .dispatch .namespaces .scripts .secret_list_response import SecretListResponse
3031from ......types .workers_for_platforms .dispatch .namespaces .scripts .secret_update_response import SecretUpdateResponse
32+ from ......types .workers_for_platforms .dispatch .namespaces .scripts .secret_bulk_update_response import (
33+ SecretBulkUpdateResponse ,
34+ )
3135
3236__all__ = ["SecretsResource" , "AsyncSecretsResource" ]
3337
@@ -339,6 +343,85 @@ def delete(
339343 cast_to = cast (Type [object ], ResultWrapper [object ]),
340344 )
341345
346+ def bulk_update (
347+ self ,
348+ script_name : str ,
349+ * ,
350+ account_id : str ,
351+ dispatch_namespace : str ,
352+ secrets : Dict [str , Optional [secret_bulk_update_params .Secrets ]] | Omit = omit ,
353+ version_tags : Dict [str , object ] | Omit = omit ,
354+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
355+ # The extra values given here take precedence over values defined on the client or passed to this method.
356+ extra_headers : Headers | None = None ,
357+ extra_query : Query | None = None ,
358+ extra_body : Body | None = None ,
359+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
360+ ) -> SecretBulkUpdateResponse :
361+ """
362+ Create, update, or delete multiple secrets on a script in a single operation
363+ using JSON Merge Patch (RFC 7396).
364+
365+ Usage:
366+
367+ - To create or update a secret, set its value to a secret object.
368+ - To delete a secret, set its value to `null`.
369+ - Secrets not included in the request are left unchanged.
370+
371+ Args:
372+ account_id: Identifier.
373+
374+ dispatch_namespace: Name of the Workers for Platforms dispatch namespace.
375+
376+ script_name: Name of the script, used in URLs and route configuration.
377+
378+ secrets:
379+ Map of secret names to secret values:
380+
381+ - Set to a secret object to create or update.
382+ - Set to `null` to delete.
383+ - Omit to leave unchanged.
384+
385+ version_tags: Optional version tags to apply to the new script version.
386+
387+ extra_headers: Send extra headers
388+
389+ extra_query: Add additional query parameters to the request
390+
391+ extra_body: Add additional JSON properties to the request
392+
393+ timeout: Override the client-level default timeout for this request, in seconds
394+ """
395+ if not account_id :
396+ raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
397+ if not dispatch_namespace :
398+ raise ValueError (f"Expected a non-empty value for `dispatch_namespace` but received { dispatch_namespace !r} " )
399+ if not script_name :
400+ raise ValueError (f"Expected a non-empty value for `script_name` but received { script_name !r} " )
401+ return self ._patch (
402+ path_template (
403+ "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/secrets-bulk" ,
404+ account_id = account_id ,
405+ dispatch_namespace = dispatch_namespace ,
406+ script_name = script_name ,
407+ ),
408+ body = maybe_transform (
409+ {
410+ "secrets" : secrets ,
411+ "version_tags" : version_tags ,
412+ },
413+ secret_bulk_update_params .SecretBulkUpdateParams ,
414+ ),
415+ options = make_request_options (
416+ extra_headers = extra_headers ,
417+ extra_query = extra_query ,
418+ extra_body = extra_body ,
419+ timeout = timeout ,
420+ post_parser = ResultWrapper [SecretBulkUpdateResponse ]._unwrapper ,
421+ ),
422+ cast_to = cast (Type [SecretBulkUpdateResponse ], ResultWrapper [SecretBulkUpdateResponse ]),
423+ )
424+
342425 def get (
343426 self ,
344427 secret_name : str ,
@@ -719,6 +802,85 @@ async def delete(
719802 cast_to = cast (Type [object ], ResultWrapper [object ]),
720803 )
721804
805+ async def bulk_update (
806+ self ,
807+ script_name : str ,
808+ * ,
809+ account_id : str ,
810+ dispatch_namespace : str ,
811+ secrets : Dict [str , Optional [secret_bulk_update_params .Secrets ]] | Omit = omit ,
812+ version_tags : Dict [str , object ] | Omit = omit ,
813+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
814+ # The extra values given here take precedence over values defined on the client or passed to this method.
815+ extra_headers : Headers | None = None ,
816+ extra_query : Query | None = None ,
817+ extra_body : Body | None = None ,
818+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
819+ ) -> SecretBulkUpdateResponse :
820+ """
821+ Create, update, or delete multiple secrets on a script in a single operation
822+ using JSON Merge Patch (RFC 7396).
823+
824+ Usage:
825+
826+ - To create or update a secret, set its value to a secret object.
827+ - To delete a secret, set its value to `null`.
828+ - Secrets not included in the request are left unchanged.
829+
830+ Args:
831+ account_id: Identifier.
832+
833+ dispatch_namespace: Name of the Workers for Platforms dispatch namespace.
834+
835+ script_name: Name of the script, used in URLs and route configuration.
836+
837+ secrets:
838+ Map of secret names to secret values:
839+
840+ - Set to a secret object to create or update.
841+ - Set to `null` to delete.
842+ - Omit to leave unchanged.
843+
844+ version_tags: Optional version tags to apply to the new script version.
845+
846+ extra_headers: Send extra headers
847+
848+ extra_query: Add additional query parameters to the request
849+
850+ extra_body: Add additional JSON properties to the request
851+
852+ timeout: Override the client-level default timeout for this request, in seconds
853+ """
854+ if not account_id :
855+ raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
856+ if not dispatch_namespace :
857+ raise ValueError (f"Expected a non-empty value for `dispatch_namespace` but received { dispatch_namespace !r} " )
858+ if not script_name :
859+ raise ValueError (f"Expected a non-empty value for `script_name` but received { script_name !r} " )
860+ return await self ._patch (
861+ path_template (
862+ "/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/secrets-bulk" ,
863+ account_id = account_id ,
864+ dispatch_namespace = dispatch_namespace ,
865+ script_name = script_name ,
866+ ),
867+ body = await async_maybe_transform (
868+ {
869+ "secrets" : secrets ,
870+ "version_tags" : version_tags ,
871+ },
872+ secret_bulk_update_params .SecretBulkUpdateParams ,
873+ ),
874+ options = make_request_options (
875+ extra_headers = extra_headers ,
876+ extra_query = extra_query ,
877+ extra_body = extra_body ,
878+ timeout = timeout ,
879+ post_parser = ResultWrapper [SecretBulkUpdateResponse ]._unwrapper ,
880+ ),
881+ cast_to = cast (Type [SecretBulkUpdateResponse ], ResultWrapper [SecretBulkUpdateResponse ]),
882+ )
883+
722884 async def get (
723885 self ,
724886 secret_name : str ,
@@ -803,6 +965,9 @@ def __init__(self, secrets: SecretsResource) -> None:
803965 self .delete = to_raw_response_wrapper (
804966 secrets .delete ,
805967 )
968+ self .bulk_update = to_raw_response_wrapper (
969+ secrets .bulk_update ,
970+ )
806971 self .get = to_raw_response_wrapper (
807972 secrets .get ,
808973 )
@@ -821,6 +986,9 @@ def __init__(self, secrets: AsyncSecretsResource) -> None:
821986 self .delete = async_to_raw_response_wrapper (
822987 secrets .delete ,
823988 )
989+ self .bulk_update = async_to_raw_response_wrapper (
990+ secrets .bulk_update ,
991+ )
824992 self .get = async_to_raw_response_wrapper (
825993 secrets .get ,
826994 )
@@ -839,6 +1007,9 @@ def __init__(self, secrets: SecretsResource) -> None:
8391007 self .delete = to_streamed_response_wrapper (
8401008 secrets .delete ,
8411009 )
1010+ self .bulk_update = to_streamed_response_wrapper (
1011+ secrets .bulk_update ,
1012+ )
8421013 self .get = to_streamed_response_wrapper (
8431014 secrets .get ,
8441015 )
@@ -857,6 +1028,9 @@ def __init__(self, secrets: AsyncSecretsResource) -> None:
8571028 self .delete = async_to_streamed_response_wrapper (
8581029 secrets .delete ,
8591030 )
1031+ self .bulk_update = async_to_streamed_response_wrapper (
1032+ secrets .bulk_update ,
1033+ )
8601034 self .get = async_to_streamed_response_wrapper (
8611035 secrets .get ,
8621036 )
0 commit comments