@@ -2502,6 +2502,66 @@ async def suggest_user_profiles(
25022502 "POST" , __path , params = __query , headers = __headers , body = __body
25032503 )
25042504
2505+ @_rewrite_parameters (
2506+ body_fields = True ,
2507+ )
2508+ async def update_api_key (
2509+ self ,
2510+ * ,
2511+ id : str ,
2512+ error_trace : t .Optional [bool ] = None ,
2513+ filter_path : t .Optional [
2514+ t .Union [str , t .Union [t .List [str ], t .Tuple [str , ...]]]
2515+ ] = None ,
2516+ human : t .Optional [bool ] = None ,
2517+ metadata : t .Optional [t .Mapping [str , t .Any ]] = None ,
2518+ pretty : t .Optional [bool ] = None ,
2519+ role_descriptors : t .Optional [t .Mapping [str , t .Mapping [str , t .Any ]]] = None ,
2520+ ) -> ObjectApiResponse [t .Any ]:
2521+ """
2522+ Updates attributes of an existing API key.
2523+
2524+ `<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-update-api-key.html>`_
2525+
2526+ :param id: The ID of the API key to update.
2527+ :param metadata: Arbitrary metadata that you want to associate with the API key.
2528+ It supports nested data structure. Within the metadata object, keys beginning
2529+ with _ are reserved for system usage.
2530+ :param role_descriptors: An array of role descriptors for this API key. This
2531+ parameter is optional. When it is not specified or is an empty array, then
2532+ the API key will have a point in time snapshot of permissions of the authenticated
2533+ user. If you supply role descriptors then the resultant permissions would
2534+ be an intersection of API keys permissions and authenticated user’s permissions
2535+ thereby limiting the access scope for API keys. The structure of role descriptor
2536+ is the same as the request for create role API. For more details, see create
2537+ or update roles API.
2538+ """
2539+ if id in SKIP_IN_PATH :
2540+ raise ValueError ("Empty value passed for parameter 'id'" )
2541+ __path = f"/_security/api_key/{ _quote (id )} "
2542+ __query : t .Dict [str , t .Any ] = {}
2543+ __body : t .Dict [str , t .Any ] = {}
2544+ if error_trace is not None :
2545+ __query ["error_trace" ] = error_trace
2546+ if filter_path is not None :
2547+ __query ["filter_path" ] = filter_path
2548+ if human is not None :
2549+ __query ["human" ] = human
2550+ if metadata is not None :
2551+ __body ["metadata" ] = metadata
2552+ if pretty is not None :
2553+ __query ["pretty" ] = pretty
2554+ if role_descriptors is not None :
2555+ __body ["role_descriptors" ] = role_descriptors
2556+ if not __body :
2557+ __body = None # type: ignore[assignment]
2558+ __headers = {"accept" : "application/json" }
2559+ if __body is not None :
2560+ __headers ["content-type" ] = "application/json"
2561+ return await self .perform_request ( # type: ignore[return-value]
2562+ "PUT" , __path , params = __query , headers = __headers , body = __body
2563+ )
2564+
25052565 @_rewrite_parameters (
25062566 body_fields = True ,
25072567 )
0 commit comments