2424
2525
2626class Collection :
27+ """Collection class to interact with the Collection.
28+
29+ Note: Users should not initialize this class directly.
30+ Instead use :meth:`Connection.get_collection() <videodb.client.Connection.get_collection>`
31+ """
32+
2733 def __init__ (
2834 self ,
2935 _connection ,
@@ -57,20 +63,31 @@ def delete(self) -> None:
5763 self ._connection .delete (path = f"{ ApiPath .collection } /{ self .id } " )
5864
5965 def get_videos (self ) -> List [Video ]:
66+ """Get all the videos in the collection.
67+
68+ :return: List of :class:`Video <Video>` objects
69+ :rtype: List[:class:`videodb.video.Video`]
70+ """
6071 videos_data = self ._connection .get (
6172 path = f"{ ApiPath .video } " ,
6273 params = {"collection_id" : self .id },
6374 )
6475 return [Video (self ._connection , ** video ) for video in videos_data .get ("videos" )]
6576
6677 def get_video (self , video_id : str ) -> Video :
78+ """Get a video by its ID.
79+
80+ :param str video_id: ID of the video
81+ :return: :class:`Video <Video>` object
82+ :rtype: :class:`videodb.video.Video`
83+ """
6784 video_data = self ._connection .get (
6885 path = f"{ ApiPath .video } /{ video_id } " , params = {"collection_id" : self .id }
6986 )
7087 return Video (self ._connection , ** video_data )
7188
7289 def delete_video (self , video_id : str ) -> None :
73- """Delete the video
90+ """Delete the video.
7491
7592 :param str video_id: The id of the video to be deleted
7693 :raises InvalidRequestError: If the delete fails
@@ -82,37 +99,73 @@ def delete_video(self, video_id: str) -> None:
8299 )
83100
84101 def get_audios (self ) -> List [Audio ]:
102+ """Get all the audios in the collection.
103+
104+ :return: List of :class:`Audio <Audio>` objects
105+ :rtype: List[:class:`videodb.audio.Audio`]
106+ """
85107 audios_data = self ._connection .get (
86108 path = f"{ ApiPath .audio } " ,
87109 params = {"collection_id" : self .id },
88110 )
89111 return [Audio (self ._connection , ** audio ) for audio in audios_data .get ("audios" )]
90112
91113 def get_audio (self , audio_id : str ) -> Audio :
114+ """Get an audio by its ID.
115+
116+ :param str audio_id: ID of the audio
117+ :return: :class:`Audio <Audio>` object
118+ :rtype: :class:`videodb.audio.Audio`
119+ """
92120 audio_data = self ._connection .get (
93121 path = f"{ ApiPath .audio } /{ audio_id } " , params = {"collection_id" : self .id }
94122 )
95123 return Audio (self ._connection , ** audio_data )
96124
97125 def delete_audio (self , audio_id : str ) -> None :
126+ """Delete the audio.
127+
128+ :param str audio_id: The id of the audio to be deleted
129+ :raises InvalidRequestError: If the delete fails
130+ :return: None if the delete is successful
131+ :rtype: None
132+ """
98133 return self ._connection .delete (
99134 path = f"{ ApiPath .audio } /{ audio_id } " , params = {"collection_id" : self .id }
100135 )
101136
102137 def get_images (self ) -> List [Image ]:
138+ """Get all the images in the collection.
139+
140+ :return: List of :class:`Image <Image>` objects
141+ :rtype: List[:class:`videodb.image.Image`]
142+ """
103143 images_data = self ._connection .get (
104144 path = f"{ ApiPath .image } " ,
105145 params = {"collection_id" : self .id },
106146 )
107147 return [Image (self ._connection , ** image ) for image in images_data .get ("images" )]
108148
109149 def get_image (self , image_id : str ) -> Image :
150+ """Get an image by its ID.
151+
152+ :param str image_id: ID of the image
153+ :return: :class:`Image <Image>` object
154+ :rtype: :class:`videodb.image.Image`
155+ """
110156 image_data = self ._connection .get (
111157 path = f"{ ApiPath .image } /{ image_id } " , params = {"collection_id" : self .id }
112158 )
113159 return Image (self ._connection , ** image_data )
114160
115161 def delete_image (self , image_id : str ) -> None :
162+ """Delete the image.
163+
164+ :param str image_id: The id of the image to be deleted
165+ :raises InvalidRequestError: If the delete fails
166+ :return: None if the delete is successful
167+ :rtype: None
168+ """
116169 return self ._connection .delete (
117170 path = f"{ ApiPath .image } /{ image_id } " , params = {"collection_id" : self .id }
118171 )
@@ -127,6 +180,18 @@ def search(
127180 dynamic_score_percentage : Optional [float ] = None ,
128181 filter : List [Dict [str , Any ]] = [],
129182 ) -> SearchResult :
183+ """Search for a query in the collection.
184+
185+ :param str query: Query to search for
186+ :param SearchType search_type: Type of search to perform (optional)
187+ :param IndexType index_type: Type of index to search (optional)
188+ :param int result_threshold: Number of results to return (optional)
189+ :param float score_threshold: Threshold score for the search (optional)
190+ :param float dynamic_score_percentage: Percentage of dynamic score to consider (optional)
191+ :raise SearchError: If the search fails
192+ :return: :class:`SearchResult <SearchResult>` object
193+ :rtype: :class:`videodb.search.SearchResult`
194+ """
130195 search = SearchFactory (self ._connection ).get_search (search_type )
131196 return search .search_inside_collection (
132197 collection_id = self .id ,
@@ -161,6 +226,17 @@ def upload(
161226 description : Optional [str ] = None ,
162227 callback_url : Optional [str ] = None ,
163228 ) -> Union [Video , Audio , Image , None ]:
229+ """Upload a file to the collection.
230+
231+ :param str file_path: Path to the file to be uploaded
232+ :param str url: URL of the file to be uploaded
233+ :param MediaType media_type: MediaType object (optional)
234+ :param str name: Name of the file (optional)
235+ :param str description: Description of the file (optional)
236+ :param str callback_url: URL to receive the callback (optional)
237+ :return: :class:`Video <Video>`, or :class:`Audio <Audio>`, or :class:`Image <Image>` object
238+ :rtype: Union[ :class:`videodb.video.Video`, :class:`videodb.audio.Audio`, :class:`videodb.image.Image`]
239+ """
164240 upload_data = upload (
165241 self ._connection ,
166242 file_path ,
@@ -179,12 +255,22 @@ def upload(
179255 return Image (self ._connection , ** upload_data )
180256
181257 def make_public (self ):
258+ """Make the collection public.
259+
260+ :return: None
261+ :rtype: None
262+ """
182263 self ._connection .patch (
183264 path = f"{ ApiPath .collection } /{ self .id } " , data = {"is_public" : True }
184265 )
185266 self .is_public = True
186267
187268 def make_private (self ):
269+ """Make the collection private.
270+
271+ :return: None
272+ :rtype: None
273+ """
188274 self ._connection .patch (
189275 path = f"{ ApiPath .collection } /{ self .id } " , data = {"is_public" : False }
190276 )
0 commit comments