@@ -363,6 +363,70 @@ async def delete_secret(
363363 self ._throw_on_error (res )
364364 return None
365365
366+ async def protect_secret (
367+ self ,
368+ * ,
369+ secret_id : str ,
370+ region : Optional [Region ] = None ,
371+ ) -> Secret :
372+ """
373+ Protect a secret.
374+ Protect a given secret specified by the `secret_id` parameter. A protected secret can be read and modified but cannot be deleted.
375+ :param region: Region to target. If none is passed will use default region from the config.
376+ :param secret_id: ID of the secret to protect.
377+ :return: :class:`Secret <Secret>`
378+
379+ Usage:
380+ ::
381+
382+ result = await api.protect_secret(secret_id="example")
383+ """
384+
385+ param_region = validate_path_param (
386+ "region" , region or self .client .default_region
387+ )
388+ param_secret_id = validate_path_param ("secret_id" , secret_id )
389+
390+ res = self ._request (
391+ "POST" ,
392+ f"/secret-manager/v1alpha1/regions/{ param_region } /secrets/{ param_secret_id } /protect" ,
393+ )
394+
395+ self ._throw_on_error (res )
396+ return unmarshal_Secret (res .json ())
397+
398+ async def unprotect_secret (
399+ self ,
400+ * ,
401+ secret_id : str ,
402+ region : Optional [Region ] = None ,
403+ ) -> Secret :
404+ """
405+ Unprotect a secret.
406+ Unprotect a given secret specified by the `secret_id` parameter. An unprotected secret can be read, modified and deleted.
407+ :param region: Region to target. If none is passed will use default region from the config.
408+ :param secret_id: ID of the secret to unprotect.
409+ :return: :class:`Secret <Secret>`
410+
411+ Usage:
412+ ::
413+
414+ result = await api.unprotect_secret(secret_id="example")
415+ """
416+
417+ param_region = validate_path_param (
418+ "region" , region or self .client .default_region
419+ )
420+ param_secret_id = validate_path_param ("secret_id" , secret_id )
421+
422+ res = self ._request (
423+ "POST" ,
424+ f"/secret-manager/v1alpha1/regions/{ param_region } /secrets/{ param_secret_id } /unprotect" ,
425+ )
426+
427+ self ._throw_on_error (res )
428+ return unmarshal_Secret (res .json ())
429+
366430 async def add_secret_owner (
367431 self ,
368432 * ,
0 commit comments