77import com .auth0 .jwt .algorithms .Algorithm ;
88import com .meilisearch .sdk .exceptions .MeilisearchException ;
99import com .meilisearch .sdk .json .JsonHandler ;
10+ import com .meilisearch .sdk .model .IndexesQuery ;
1011import com .meilisearch .sdk .model .Key ;
1112import com .meilisearch .sdk .model .Results ;
1213import com .meilisearch .sdk .model .Stats ;
@@ -63,33 +64,46 @@ public TaskInfo createIndex(String uid) throws MeilisearchException {
6364 * @throws MeilisearchException if an error occurs
6465 */
6566 public TaskInfo createIndex (String uid , String primaryKey ) throws MeilisearchException {
66- return this .indexesHandler .create (uid , primaryKey );
67+ return this .indexesHandler .createIndex (uid , primaryKey );
6768 }
6869
6970 /**
70- * Gets all indexes in the current Meilisearch instance
71- * https://docs.meilisearch.com/reference/api/indexes.html#list-all-indexes
71+ * Gets indexes https://docs.meilisearch.com/reference/api/indexes.html#list-all-indexes
7272 *
73- * @return Array of indexes in the Meilisearch client
73+ * @return Results containing a list of indexes from the Meilisearch API
7474 * @throws MeilisearchException if an error occurs
7575 */
76- public Index [] getIndexes () throws MeilisearchException {
77- Index [] indexes = jsonHandler . decode ( getRawIndexes (), Index []. class );
78- for (Index index : indexes ) {
76+ public Results < Index > getIndexes () throws MeilisearchException {
77+ Results < Index > indexes = this . indexesHandler . getIndexes ( );
78+ for (Index index : indexes . getResults () ) {
7979 index .setConfig (this .config );
8080 }
8181 return indexes ;
8282 }
8383
8484 /**
85- * Gets all indexes in the current Meilisearch instance
86- * https://docs.meilisearch.com/reference/api/indexes.html#list-all-indexes
85+ * Gets indexes https://docs.meilisearch.com/reference/api/indexes.html#list-all-indexes
8786 *
88- * @return Meilisearch API response as String
87+ * @param params query parameters accepted by the get indexes route
88+ * @return Results containing a list of indexes from the Meilisearch API
89+ * @throws MeilisearchException if an error occurs
90+ */
91+ public Results <Index > getIndexes (IndexesQuery params ) throws MeilisearchException {
92+ Results <Index > indexes = this .indexesHandler .getIndexes (params );
93+ for (Index index : indexes .getResults ()) {
94+ index .setConfig (this .config );
95+ }
96+ return indexes ;
97+ }
98+
99+ /**
100+ * Gets all indexes https://docs.meilisearch.com/reference/api/indexes.html#list-all-indexes
101+ *
102+ * @return List of indexes from the Meilisearch API as String
89103 * @throws MeilisearchException if an error occurs
90104 */
91105 public String getRawIndexes () throws MeilisearchException {
92- return this .indexesHandler .getAll ();
106+ return this .indexesHandler .getRawIndexes ();
93107 }
94108
95109 /**
@@ -98,7 +112,7 @@ public String getRawIndexes() throws MeilisearchException {
98112 * methods in the Index class.
99113 *
100114 * @param uid Unique identifier of the index
101- * @return Index instance
115+ * @return Meilisearch API response as Index instance
102116 * @throws MeilisearchException if an error occurs
103117 */
104118 public Index index (String uid ) throws MeilisearchException {
@@ -113,29 +127,17 @@ public Index index(String uid) throws MeilisearchException {
113127 * https://docs.meilisearch.com/reference/api/indexes.html#get-one-index
114128 *
115129 * @param uid Unique identifier of the index to get
116- * @return Meilisearch API response
130+ * @return Meilisearch API response as Index instance
117131 * @throws MeilisearchException if an error occurs
118132 */
119133 public Index getIndex (String uid ) throws MeilisearchException {
120- Index index = jsonHandler . decode ( getRawIndex ( uid ), Index . class );
134+ Index index = this . indexesHandler . getIndex ( uid );
121135 index .setConfig (this .config );
122136 return index ;
123137 }
124138
125139 /**
126- * Gets single index by its unique identifier
127- * https://docs.meilisearch.com/reference/api/indexes.html#get-one-index
128- *
129- * @param uid Unique identifier of the index to get
130- * @return Meilisearch API response as String
131- * @throws MeilisearchException if an error occurs
132- */
133- public String getRawIndex (String uid ) throws MeilisearchException {
134- return this .indexesHandler .get (uid );
135- }
136-
137- /**
138- * Updates the primary key of an index in the Meilisearch instance
140+ * Updates the primary key of an index
139141 * https://docs.meilisearch.com/reference/api/indexes.html#update-an-index
140142 *
141143 * @param uid Unique identifier of the index to update
@@ -156,7 +158,7 @@ public TaskInfo updateIndex(String uid, String primaryKey) throws MeilisearchExc
156158 * @throws MeilisearchException if an error occurs
157159 */
158160 public TaskInfo deleteIndex (String uid ) throws MeilisearchException {
159- return this .indexesHandler .delete (uid );
161+ return this .indexesHandler .deleteIndex (uid );
160162 }
161163
162164 /**
@@ -220,7 +222,7 @@ public String getVersion() throws MeilisearchException {
220222 * https://docs.meilisearch.com/reference/api/tasks.html#get-one-task
221223 *
222224 * @param uid Identifier of the requested Task
223- * @return Task Instance
225+ * @return Meilisearch API response as Task Instance
224226 * @throws MeilisearchException if an error occurs
225227 */
226228 public Task getTask (int uid ) throws MeilisearchException {
@@ -230,7 +232,7 @@ public Task getTask(int uid) throws MeilisearchException {
230232 /**
231233 * Retrieves list of tasks https://docs.meilisearch.com/reference/api/tasks.html#get-tasks
232234 *
233- * @return List of tasks in the Meilisearch client
235+ * @return TasksResults containing a list of tasks from the Meilisearch API
234236 * @throws MeilisearchException if an error occurs
235237 */
236238 public TasksResults getTasks () throws MeilisearchException {
@@ -241,7 +243,7 @@ public TasksResults getTasks() throws MeilisearchException {
241243 * Retrieves list of tasks https://docs.meilisearch.com/reference/api/tasks.html#get-tasks
242244 *
243245 * @param param accept by the tasks route
244- * @return List of tasks in the Meilisearch client
246+ * @return TasksResults containing a list of tasks from the Meilisearch API
245247 * @throws MeilisearchException if an error occurs
246248 */
247249 public TasksResults getTasks (TasksQuery param ) throws MeilisearchException {
0 commit comments