@@ -89,6 +89,7 @@ def load(cls, endpoint: pf.Platform, data: types.ApiPayload) -> WebHook:
8989 :param ApiPayload data: The webhook data received from the API
9090 :return: The created WebHook
9191 """
92+ log .debug ("LOading Webhook with %s" , data )
9293 name , project = data ["name" ], data .get ("project" , None )
9394 if (o := WebHook .CACHE .get (name , project , endpoint .local_url )) is None :
9495 o = WebHook (endpoint , name , data ["url" ], data .get ("secret" , None ), project )
@@ -119,7 +120,9 @@ def __hash__(self) -> int:
119120
120121 def refresh (self ) -> None :
121122 """Reads the Webhook data on the SonarQube platform and updates the local object"""
123+ log .debug ("Refreshing %s with proj %s" , str (self ), str (self .project ))
122124 data = json .loads (self .get (WebHook .API [c .LIST ], params = None if not self .project else {"project" : self .project }).text )
125+ log .debug ("Refreshing %s with data %s" , str (self ), str (data ))
123126 wh_data = next ((wh for wh in data ["webhooks" ] if wh ["name" ] == self .name ), None )
124127 if wh_data is None :
125128 wh_name = str (self )
@@ -148,6 +151,7 @@ def update(self, **kwargs: str) -> bool:
148151 :param kwargs: dict - "url", "name", "secret" are the looked up keys
149152 :return: Whether the operation succeeded
150153 """
154+ log .info ("Updating %s with %s" , str (self ), str (self .project ))
151155 params = {"webhook" : self .key , "name" : self .name , "url" : self .webhook_url } | util .remove_nones (kwargs )
152156 ok = self .post (WebHook .API [c .UPDATE ], params = params ).ok
153157 self .refresh ()
@@ -189,10 +193,10 @@ def search(endpoint: pf.Platform, params: types.ApiParams = None) -> dict[str, W
189193def get_list (endpoint : pf .Platform , project_key : Optional [str ] = None ) -> dict [str , WebHook ]:
190194 """Returns the list of web hooks, global ones or for a project if project key is given"""
191195 log .debug ("Getting webhooks for project key %s" , str (project_key ))
192- params = None
193- if project_key is not None :
194- params = { "project" : project_key }
195- return search ( endpoint , params )
196+ wh_list = search ( endpoint , { "project" : project_key } if project_key else None )
197+ for wh in wh_list . values () :
198+ wh . project = project_key
199+ return wh_list
196200
197201
198202def export (endpoint : pf .Platform , project_key : Optional [str ] = None , full : bool = False ) -> types .ObjectJsonRepr :
0 commit comments