2424
2525
2626class Collection :
27+ """Collection class to interact with the Collection"""
28+
2729 def __init__ (
2830 self ,
2931 _connection ,
@@ -57,20 +59,31 @@ def delete(self) -> None:
5759 self ._connection .delete (path = f"{ ApiPath .collection } /{ self .id } " )
5860
5961 def get_videos (self ) -> List [Video ]:
62+ """Get all the videos in the collection.
63+
64+ :return: List of :class:`Video <Video>` objects
65+ :rtype: List[:class:`videodb.video.Video`]
66+ """
6067 videos_data = self ._connection .get (
6168 path = f"{ ApiPath .video } " ,
6269 params = {"collection_id" : self .id },
6370 )
6471 return [Video (self ._connection , ** video ) for video in videos_data .get ("videos" )]
6572
6673 def get_video (self , video_id : str ) -> Video :
74+ """Get a video by its ID.
75+
76+ :param str video_id: ID of the video
77+ :return: :class:`Video <Video>` object
78+ :rtype: :class:`videodb.video.Video`
79+ """
6780 video_data = self ._connection .get (
6881 path = f"{ ApiPath .video } /{ video_id } " , params = {"collection_id" : self .id }
6982 )
7083 return Video (self ._connection , ** video_data )
7184
7285 def delete_video (self , video_id : str ) -> None :
73- """Delete the video
86+ """Delete the video.
7487
7588 :param str video_id: The id of the video to be deleted
7689 :raises InvalidRequestError: If the delete fails
@@ -82,37 +95,73 @@ def delete_video(self, video_id: str) -> None:
8295 )
8396
8497 def get_audios (self ) -> List [Audio ]:
98+ """Get all the audios in the collection.
99+
100+ :return: List of :class:`Audio <Audio>` objects
101+ :rtype: List[:class:`videodb.audio.Audio`]
102+ """
85103 audios_data = self ._connection .get (
86104 path = f"{ ApiPath .audio } " ,
87105 params = {"collection_id" : self .id },
88106 )
89107 return [Audio (self ._connection , ** audio ) for audio in audios_data .get ("audios" )]
90108
91109 def get_audio (self , audio_id : str ) -> Audio :
110+ """Get an audio by its ID.
111+
112+ :param str audio_id: ID of the audio
113+ :return: :class:`Audio <Audio>` object
114+ :rtype: :class:`videodb.audio.Audio`
115+ """
92116 audio_data = self ._connection .get (
93117 path = f"{ ApiPath .audio } /{ audio_id } " , params = {"collection_id" : self .id }
94118 )
95119 return Audio (self ._connection , ** audio_data )
96120
97121 def delete_audio (self , audio_id : str ) -> None :
122+ """Delete the audio.
123+
124+ :param str audio_id: The id of the audio to be deleted
125+ :raises InvalidRequestError: If the delete fails
126+ :return: None if the delete is successful
127+ :rtype: None
128+ """
98129 return self ._connection .delete (
99130 path = f"{ ApiPath .audio } /{ audio_id } " , params = {"collection_id" : self .id }
100131 )
101132
102133 def get_images (self ) -> List [Image ]:
134+ """Get all the images in the collection.
135+
136+ :return: List of :class:`Image <Image>` objects
137+ :rtype: List[:class:`videodb.image.Image`]
138+ """
103139 images_data = self ._connection .get (
104140 path = f"{ ApiPath .image } " ,
105141 params = {"collection_id" : self .id },
106142 )
107143 return [Image (self ._connection , ** image ) for image in images_data .get ("images" )]
108144
109145 def get_image (self , image_id : str ) -> Image :
146+ """Get an image by its ID.
147+
148+ :param str image_id: ID of the image
149+ :return: :class:`Image <Image>` object
150+ :rtype: :class:`videodb.image.Image`
151+ """
110152 image_data = self ._connection .get (
111153 path = f"{ ApiPath .image } /{ image_id } " , params = {"collection_id" : self .id }
112154 )
113155 return Image (self ._connection , ** image_data )
114156
115157 def delete_image (self , image_id : str ) -> None :
158+ """Delete the image.
159+
160+ :param str image_id: The id of the image to be deleted
161+ :raises InvalidRequestError: If the delete fails
162+ :return: None if the delete is successful
163+ :rtype: None
164+ """
116165 return self ._connection .delete (
117166 path = f"{ ApiPath .image } /{ image_id } " , params = {"collection_id" : self .id }
118167 )
@@ -127,6 +176,18 @@ def search(
127176 dynamic_score_percentage : Optional [float ] = None ,
128177 filter : List [Dict [str , Any ]] = [],
129178 ) -> SearchResult :
179+ """Search for a query in the collection.
180+
181+ :param str query: Query to search for
182+ :param search_type:(optional) Type of search to perform :class:`SearchType <SearchType>` object
183+ :param index_type:(optional) Type of index to search :class:`IndexType <IndexType>` object
184+ :param int result_threshold:(optional) Number of results to return
185+ :param float score_threshold:(optional) Threshold score for the search
186+ :param float dynamic_score_percentage:(optional) Percentage of dynamic score to consider
187+ :raise SearchError: If the search fails
188+ :return: :class:`SearchResult <SearchResult>` object
189+ :rtype: :class:`videodb.search.SearchResult`
190+ """
130191 search = SearchFactory (self ._connection ).get_search (search_type )
131192 return search .search_inside_collection (
132193 collection_id = self .id ,
@@ -161,6 +222,17 @@ def upload(
161222 description : Optional [str ] = None ,
162223 callback_url : Optional [str ] = None ,
163224 ) -> Union [Video , Audio , Image , None ]:
225+ """Upload a file to the collection.
226+
227+ :param str file_path: Path to the file to be uploaded
228+ :param str url: URL of the file to be uploaded
229+ :param MediaType media_type:(optional):class:`MediaType <MediaType>` object
230+ :param name:(optional) Name of the file
231+ :param description:(optional) Description of the file
232+ :param callback_url:(optional) URL to receive the callback
233+ :return: :class:`Video <Video>`, or :class:`Audio <Audio>`, or :class:`Image <Image>` object
234+ Union[ :class:`videodb.video.Video`, :class:`videodb.audio.Audio`, :class:`videodb.image.Image`]
235+ """
164236 upload_data = upload (
165237 self ._connection ,
166238 file_path ,
0 commit comments