@@ -510,6 +510,45 @@ def register_webhook(self, url: str, auth_token: str, webhook_name: str) -> dict
510510 prepared = req .prepare ()
511511 s = requests .Session ()
512512 response = s .send (prepared , timeout = self .api_timeout )
513+ if response .status_code != 201 :
514+ err = json .loads (response .text )
515+ err ["status_code" ] = response .status_code
516+ raise LLMWhispererClientException (err )
517+ return json .loads (response .text )
518+
519+ def update_webhook_details (self , webhook_name : str , url : str , auth_token : str ) -> dict :
520+ """Updates the details of a webhook from the LLMWhisperer API.
521+
522+ This method sends a PUT request to the '/whisper-manage-callback' endpoint of the LLMWhisperer API.
523+ The response is a JSON object containing the status of the webhook update.
524+
525+ Refer to https://docs.unstract.com/llm_whisperer/apis/
526+
527+ Args:
528+ webhook_name (str): The name of the webhook.
529+ url (str): The URL of the webhook.
530+ auth_token (str): The authentication token for the webhook.
531+
532+ Returns:
533+ dict: A dictionary containing the status code and the response from the API.
534+
535+ Raises:
536+ LLMWhispererClientException: If the API request fails, it raises an exception with
537+ the error message and status code returned by the API.
538+ """
539+
540+ data = {
541+ "url" : url ,
542+ "auth_token" : auth_token ,
543+ "webhook_name" : webhook_name ,
544+ }
545+ url = f"{ self .base_url } /whisper-manage-callback"
546+ headersx = copy .deepcopy (self .headers )
547+ headersx ["Content-Type" ] = "application/json"
548+ req = requests .Request ("PUT" , url , headers = headersx , json = data )
549+ prepared = req .prepare ()
550+ s = requests .Session ()
551+ response = s .send (prepared , timeout = self .api_timeout )
513552 if response .status_code != 200 :
514553 err = json .loads (response .text )
515554 err ["status_code" ] = response .status_code
@@ -547,6 +586,37 @@ def get_webhook_details(self, webhook_name: str) -> dict:
547586 raise LLMWhispererClientException (err )
548587 return json .loads (response .text )
549588
589+ def delete_webhook (self , webhook_name : str ) -> dict :
590+ """Deletes a webhook from the LLMWhisperer API.
591+
592+ This method sends a DELETE request to the '/whisper-manage-callback' endpoint of the LLMWhisperer API.
593+ The response is a JSON object containing the status of the webhook deletion.
594+
595+ Refer to https://docs.unstract.com/llm_whisperer/apis/
596+
597+ Args:
598+ webhook_name (str): The name of the webhook.
599+
600+ Returns:
601+ dict: A dictionary containing the status code and the response from the API.
602+
603+ Raises:
604+ LLMWhispererClientException: If the API request fails, it raises an exception with
605+ the error message and status code returned by the API.
606+ """
607+
608+ url = f"{ self .base_url } /whisper-manage-callback"
609+ params = {"webhook_name" : webhook_name }
610+ req = requests .Request ("DELETE" , url , headers = self .headers , params = params )
611+ prepared = req .prepare ()
612+ s = requests .Session ()
613+ response = s .send (prepared , timeout = self .api_timeout )
614+ if response .status_code != 200 :
615+ err = json .loads (response .text )
616+ err ["status_code" ] = response .status_code
617+ raise LLMWhispererClientException (err )
618+ return json .loads (response .text )
619+
550620 def get_highlight_rect (
551621 self ,
552622 line_metadata : list [int ],
0 commit comments