11package com .meilisearch .sdk ;
22
33import com .meilisearch .sdk .exceptions .MeilisearchException ;
4- import com .meilisearch .sdk .http .URLBuilder ;
54import com .meilisearch .sdk .model .IndexesQuery ;
65import com .meilisearch .sdk .model .Results ;
76import com .meilisearch .sdk .model .TaskInfo ;
@@ -60,10 +59,7 @@ TaskInfo createIndex(String uid, String primaryKey) throws MeilisearchException
6059 * @throws MeilisearchException if an error occurs
6160 */
6261 Index getIndex (String uid ) throws MeilisearchException {
63- URLBuilder urlb = new URLBuilder ();
64- urlb .addSubroute ("indexes" ).addSubroute (uid );
65- String urlPath = urlb .getURL ();
66- return httpClient .get (urlPath , Index .class );
62+ return httpClient .get (new IndexesQuery ().toQuery (uid ), Index .class );
6763 }
6864
6965 /**
@@ -84,7 +80,7 @@ Results<Index> getIndexes() throws MeilisearchException {
8480 * @throws MeilisearchException if an error occurs
8581 */
8682 Results <Index > getIndexes (IndexesQuery params ) throws MeilisearchException {
87- return httpClient .get (param .toQuery (params ), Results .class , Index .class );
83+ return httpClient .get (params .toQuery (params ), Results .class , Index .class );
8884 }
8985
9086 /**
@@ -109,10 +105,7 @@ TaskInfo updatePrimaryKey(String uid, String primaryKey) throws MeilisearchExcep
109105 HashMap <String , String > index = new HashMap <String , String >();
110106 index .put ("primaryKey" , primaryKey );
111107
112- URLBuilder urlb = new URLBuilder ();
113- urlb .addSubroute ("indexes" ).addSubroute (uid );
114- String urlPath = urlb .getURL ();
115- return httpClient .patch (urlPath , index , TaskInfo .class );
108+ return httpClient .patch (new IndexesQuery ().toQuery (uid ), index , TaskInfo .class );
116109 }
117110
118111 /**
@@ -123,9 +116,6 @@ TaskInfo updatePrimaryKey(String uid, String primaryKey) throws MeilisearchExcep
123116 * @throws MeilisearchException if an error occurs
124117 */
125118 TaskInfo deleteIndex (String uid ) throws MeilisearchException {
126- URLBuilder urlb = new URLBuilder ();
127- urlb .addSubroute ("indexes" ).addSubroute (uid );
128- String urlPath = urlb .getURL ();
129- return httpClient .delete (urlPath , TaskInfo .class );
119+ return httpClient .delete (new IndexesQuery ().toQuery (uid ), TaskInfo .class );
130120 }
131121}
0 commit comments