2222
2323
2424class Collection :
25+ """Collection class to interact with the Collection"""
26+
2527 def __init__ (self , _connection , id : str , name : str = None , description : str = None ):
2628 self ._connection = _connection
2729 self .id = id
@@ -37,20 +39,31 @@ def __repr__(self) -> str:
3739 )
3840
3941 def get_videos (self ) -> List [Video ]:
42+ """Get all the videos in the collection.
43+
44+ :return: List of :class:`Video <Video>` objects
45+ :rtype: List[:class:`videodb.video.Video`]
46+ """
4047 videos_data = self ._connection .get (
4148 path = f"{ ApiPath .video } " ,
4249 params = {"collection_id" : self .id },
4350 )
4451 return [Video (self ._connection , ** video ) for video in videos_data .get ("videos" )]
4552
4653 def get_video (self , video_id : str ) -> Video :
54+ """Get a video by its ID.
55+
56+ :param str video_id: ID of the video
57+ :return: :class:`Video <Video>` object
58+ :rtype: :class:`videodb.video.Video`
59+ """
4760 video_data = self ._connection .get (
4861 path = f"{ ApiPath .video } /{ video_id } " , params = {"collection_id" : self .id }
4962 )
5063 return Video (self ._connection , ** video_data )
5164
5265 def delete_video (self , video_id : str ) -> None :
53- """Delete the video
66+ """Delete the video.
5467
5568 :param str video_id: The id of the video to be deleted
5669 :raises InvalidRequestError: If the delete fails
@@ -62,37 +75,73 @@ def delete_video(self, video_id: str) -> None:
6275 )
6376
6477 def get_audios (self ) -> List [Audio ]:
78+ """Get all the audios in the collection.
79+
80+ :return: List of :class:`Audio <Audio>` objects
81+ :rtype: List[:class:`videodb.audio.Audio`]
82+ """
6583 audios_data = self ._connection .get (
6684 path = f"{ ApiPath .audio } " ,
6785 params = {"collection_id" : self .id },
6886 )
6987 return [Audio (self ._connection , ** audio ) for audio in audios_data .get ("audios" )]
7088
7189 def get_audio (self , audio_id : str ) -> Audio :
90+ """Get an audio by its ID.
91+
92+ :param str audio_id: ID of the audio
93+ :return: :class:`Audio <Audio>` object
94+ :rtype: :class:`videodb.audio.Audio`
95+ """
7296 audio_data = self ._connection .get (
7397 path = f"{ ApiPath .audio } /{ audio_id } " , params = {"collection_id" : self .id }
7498 )
7599 return Audio (self ._connection , ** audio_data )
76100
77101 def delete_audio (self , audio_id : str ) -> None :
102+ """Delete the audio.
103+
104+ :param str audio_id: The id of the audio to be deleted
105+ :raises InvalidRequestError: If the delete fails
106+ :return: None if the delete is successful
107+ :rtype: None
108+ """
78109 return self ._connection .delete (
79110 path = f"{ ApiPath .audio } /{ audio_id } " , params = {"collection_id" : self .id }
80111 )
81112
82113 def get_images (self ) -> List [Image ]:
114+ """Get all the images in the collection.
115+
116+ :return: List of :class:`Image <Image>` objects
117+ :rtype: List[:class:`videodb.image.Image`]
118+ """
83119 images_data = self ._connection .get (
84120 path = f"{ ApiPath .image } " ,
85121 params = {"collection_id" : self .id },
86122 )
87123 return [Image (self ._connection , ** image ) for image in images_data .get ("images" )]
88124
89125 def get_image (self , image_id : str ) -> Image :
126+ """Get an image by its ID.
127+
128+ :param str image_id: ID of the image
129+ :return: :class:`Image <Image>` object
130+ :rtype: :class:`videodb.image.Image`
131+ """
90132 image_data = self ._connection .get (
91133 path = f"{ ApiPath .image } /{ image_id } " , params = {"collection_id" : self .id }
92134 )
93135 return Image (self ._connection , ** image_data )
94136
95137 def delete_image (self , image_id : str ) -> None :
138+ """Delete the image.
139+
140+ :param str image_id: The id of the image to be deleted
141+ :raises InvalidRequestError: If the delete fails
142+ :return: None if the delete is successful
143+ :rtype: None
144+ """
96145 return self ._connection .delete (
97146 path = f"{ ApiPath .image } /{ image_id } " , params = {"collection_id" : self .id }
98147 )
@@ -106,6 +155,18 @@ def search(
106155 score_threshold : Optional [float ] = None ,
107156 dynamic_score_percentage : Optional [float ] = None ,
108157 ) -> SearchResult :
158+ """Search for a query in the collection.
159+
160+ :param str query: Query to search for
161+ :param search_type:(optional) Type of search to perform :class:`SearchType <SearchType>` object
162+ :param index_type:(optional) Type of index to search :class:`IndexType <IndexType>` object
163+ :param int result_threshold:(optional) Number of results to return
164+ :param float score_threshold:(optional) Threshold score for the search
165+ :param float dynamic_score_percentage:(optional) Percentage of dynamic score to consider
166+ :raise SearchError: If the search fails
167+ :return: :class:`SearchResult <SearchResult>` object
168+ :rtype: :class:`videodb.search.SearchResult`
169+ """
109170 search = SearchFactory (self ._connection ).get_search (search_type )
110171 return search .search_inside_collection (
111172 collection_id = self .id ,
@@ -126,6 +187,17 @@ def upload(
126187 description : Optional [str ] = None ,
127188 callback_url : Optional [str ] = None ,
128189 ) -> Union [Video , Audio , Image , None ]:
190+ """Upload a file to the collection.
191+
192+ :param str file_path: Path to the file to be uploaded
193+ :param str url: URL of the file to be uploaded
194+ :param MediaType media_type:(optional):class:`MediaType <MediaType>` object
195+ :param name:(optional) Name of the file
196+ :param description:(optional) Description of the file
197+ :param callback_url:(optional) URL to receive the callback
198+ :return: :class:`Video <Video>`, or :class:`Audio <Audio>`, or :class:`Image <Image>` object
199+ Union[ :class:`videodb.video.Video`, :class:`videodb.audio.Audio`, :class:`videodb.image.Image`]
200+ """
129201 upload_data = upload (
130202 self ._connection ,
131203 file_path ,
0 commit comments