11import logging
22from enum import Enum
3- from typing import Iterable , List
3+ from typing import List , Optional , Union
44
55from labelbox .orm import query
66from labelbox .orm .db_object import DbObject , Updateable
77from labelbox .orm .model import Entity , Field , Relationship
8+ from labelbox import Client , Project
89
910logger = logging .getLogger (__name__ )
1011
@@ -55,7 +56,8 @@ class WebhookTopic(Enum):
5556 project = Relationship .ToOne ("Project" )
5657
5758 @staticmethod
58- def create (client , topics , url , secret , project ):
59+ def create (client : Client , topics : List [WebhookTopic ], url : str ,
60+ secret : str , project : Project ):
5961 """ Creates a Webhook.
6062
6163 Args:
@@ -92,7 +94,7 @@ def create(client, topics, url, secret, project):
9294 return Webhook (client , client .execute (query_str )["createWebhook" ])
9395
9496 @staticmethod
95- def validate_topics (topics : List ["Webhook. WebhookTopic" ]):
97+ def validate_topics (topics : List [WebhookTopic ]):
9698 if not isinstance (topics , list ):
9799 raise TypeError (
98100 f"Topics must be List[Webhook.WebhookTopic]. Found `{ topics } `" )
@@ -101,23 +103,29 @@ def validate_topics(topics: List["Webhook.WebhookTopic"]):
101103 Webhook .validate_value (topic , Webhook .WebhookTopic )
102104
103105 @staticmethod
104- def validate_value (value , enum ):
106+ def validate_value (value : str , enum : Union [ WebhookStatus , WebhookTopic ] ):
105107 supported_values = [x .value for x in enum ]
106108 if value not in supported_values :
107109 raise ValueError (
108110 f"Value `{ value } ` does not exist in supported values. Expected one of { supported_values } "
109111 )
110112
111113 def delete (self ):
114+ """
115+ Deletes the webhook
116+ """
112117 self .update (status = self .WebhookStatus .INACTIVE )
113118
114- def update (self , topics = None , url = None , status = None ):
119+ def update (self ,
120+ topics : Optional [List [WebhookTopic ]] = None ,
121+ url : Optional [str ] = None ,
122+ status : Optional [WebhookStatus ] = None ):
115123 """ Updates the Webhook.
116124
117125 Args:
118- topics (List[str ]): The new topics.
119- url ( str): The new URL value.
120- status (str ): The new status.
126+ topics (Optional[ List[WebhookTopic] ]): The new topics.
127+ url Optional[ str): The new URL value.
128+ status (Optional[WebhookStatus] ): The new status.
121129
122130 If values are set to None then there are no updates made to that field.
123131
0 commit comments