@@ -2715,6 +2715,25 @@ async def remove_secret(self, secret_name, revision=-1):
27152715 if result_error .error is not None :
27162716 raise JujuAPIError (result_error .error )
27172717
2718+ async def grant_secret (self , secret_name , application , * applications ):
2719+ """Grants access to a secret to the specified applications.
2720+
2721+ :param secret_name str: ID|name of the secret.
2722+ :param application str: name of an application for which the access is granted
2723+ :param applications []str: names of more applications to associate the secret with
2724+ """
2725+ if client .SecretsFacade .best_facade_version (self .connection ()) < 2 :
2726+ raise JujuNotSupportedError ("user secrets" )
2727+ secretsFacade = client .SecretsFacade .from_connection (self .connection ())
2728+ results = await secretsFacade .GrantSecret (
2729+ applications = [application ] + list (applications ),
2730+ label = secret_name )
2731+ if len (results .results ) != 1 :
2732+ raise JujuAPIError (f"expected 1 result, got { len (results .results )} " )
2733+ result_error = results .results [0 ]
2734+ if result_error .error is not None :
2735+ raise JujuAPIError (result_error .error )
2736+
27182737 async def _get_source_api (self , url , controller_name = None ):
27192738 controller = Controller ()
27202739 if url .has_empty_source ():
0 commit comments