1616from yandex_cloud_ml_sdk ._types .misc import UNDEFINED , UndefinedOr , get_defined_value , is_defined
1717from yandex_cloud_ml_sdk ._types .operation import AsyncOperation , Operation , OperationTypeT
1818from yandex_cloud_ml_sdk ._utils .coerce import ResourceType , coerce_resource_ids
19+ from yandex_cloud_ml_sdk ._utils .doc import doc_from
1920from yandex_cloud_ml_sdk ._utils .sync import run_sync , run_sync_generator
2021
2122from .index_type import BaseSearchIndexType
2223from .search_index import AsyncSearchIndex , SearchIndex , SearchIndexTypeT
2324
2425
2526class BaseSearchIndexes (BaseDomain , Generic [SearchIndexTypeT , OperationTypeT ]):
27+ """
28+ A class for search indexes. It is a part of Assistants API
29+ and it provides the foundation for creating and managing search indexes.
30+ """
2631 _impl : type [SearchIndexTypeT ]
2732 _operation_type : type [OperationTypeT ]
2833
@@ -39,6 +44,22 @@ async def _create_deferred(
3944 expiration_policy : UndefinedOr [ExpirationPolicyAlias ] = UNDEFINED ,
4045 timeout : float = 60 ,
4146 ) -> OperationTypeT :
47+ """
48+ Create a deferred search index.
49+
50+ It returns an operation that can be used to track the creation process.
51+
52+ :param files: the files to be indexed.
53+ :param index_type: the type of the search index.
54+ :param name: the name of the search index.
55+ :param description: a description for the search index.
56+ :param labels: a set of labels for the search index.
57+ :param ttl_days: time-to-live in days for the search index.
58+ :param expiration_policy: expiration policy for the file.
59+ Assepts for passing ``static`` or ``since_last_active`` strings. Should be defined if ``ttl_days`` has been defined, otherwise both parameters should be undefined.
60+ :param timeout: the time to wait for the operation to complete.
61+ Defaults to 60 seconds.
62+ """
4263 if is_defined (ttl_days ) != is_defined (expiration_policy ):
4364 raise ValueError ("ttl_days and expiration policy must be both defined either undefined" )
4465
@@ -83,6 +104,14 @@ async def _get(
83104 * ,
84105 timeout : float = 60 ,
85106 ) -> SearchIndexTypeT :
107+ """Retrieve a search index by its id.
108+
109+ This method fetches an already created search index using its unique identifier.
110+
111+ :param search_index_id: the unique identifier of the search index to retrieve.
112+ :param timeout: the time to wait for the operation to complete.
113+ Defaults to 60 seconds.
114+ """
86115 # TODO: we need a global per-sdk cache on ids to rule out
87116 # possibility we have two SearchIndexs with same ids but different fields
88117 request = GetSearchIndexRequest (search_index_id = search_index_id )
@@ -103,6 +132,15 @@ async def _list(
103132 page_size : UndefinedOr [int ] = UNDEFINED ,
104133 timeout : float = 60
105134 ) -> AsyncIterator [SearchIndexTypeT ]:
135+ """List search indexes in the specified folder.
136+
137+ This method retrieves a list of search indexes. It continues
138+ to fetch search indexes until there are no more available.
139+
140+ :param page_size: the maximum number of search indexes to return per page.
141+ :param timeout: the time to wait for the operation to complete.
142+ Defaults to 60 seconds.
143+ """
106144 page_token_ = ''
107145 page_size_ = get_defined_value (page_size , 0 )
108146
@@ -129,10 +167,12 @@ async def _list(
129167 page_token_ = response .next_page_token
130168
131169
170+ @doc_from (BaseSearchIndexes )
132171class AsyncSearchIndexes (BaseSearchIndexes [AsyncSearchIndex , AsyncOperation [AsyncSearchIndex ]]):
133172 _impl = AsyncSearchIndex
134173 _operation_type = AsyncOperation [AsyncSearchIndex ]
135174
175+ @doc_from (BaseSearchIndexes ._create_deferred )
136176 async def create_deferred (
137177 self ,
138178 files : ResourceType [BaseFile ],
@@ -156,6 +196,7 @@ async def create_deferred(
156196 timeout = timeout
157197 )
158198
199+ @doc_from (BaseSearchIndexes ._get )
159200 async def get (
160201 self ,
161202 search_index_id : str ,
@@ -167,6 +208,7 @@ async def get(
167208 timeout = timeout ,
168209 )
169210
211+ @doc_from (BaseSearchIndexes ._list )
170212 async def list (
171213 self ,
172214 * ,
@@ -180,6 +222,7 @@ async def list(
180222 yield search_index
181223
182224
225+ @doc_from (BaseSearchIndexes )
183226class SearchIndexes (BaseSearchIndexes [SearchIndex , Operation [SearchIndex ]]):
184227 _impl = SearchIndex
185228 _operation_type = Operation [SearchIndex ]
@@ -188,6 +231,7 @@ class SearchIndexes(BaseSearchIndexes[SearchIndex, Operation[SearchIndex]]):
188231 __create_deferred = run_sync (BaseSearchIndexes ._create_deferred )
189232 __list = run_sync_generator (BaseSearchIndexes ._list )
190233
234+ @doc_from (BaseSearchIndexes ._create_deferred )
191235 def create_deferred (
192236 self ,
193237 files : ResourceType [BaseFile ],
@@ -211,6 +255,7 @@ def create_deferred(
211255 timeout = timeout
212256 )
213257
258+ @doc_from (BaseSearchIndexes ._get )
214259 def get (
215260 self ,
216261 search_index_id : str ,
@@ -222,6 +267,7 @@ def get(
222267 timeout = timeout ,
223268 )
224269
270+ @doc_from (BaseSearchIndexes ._list )
225271 def list (
226272 self ,
227273 * ,
0 commit comments