use of com.ibm.cloud.cloudant.v1.model.IndexesInformation in project cloudant-java-sdk by IBM.
the class Cloudant method getIndexesInformation.
/**
* Retrieve information about all indexes.
*
* When you make a GET request to `/db/_index`, you get a list of all indexes used by Cloudant Query in the database,
* including the primary index. In addition to the information available through this API, indexes are also stored in
* the `indexes` property of design documents.
*
* @param getIndexesInformationOptions the {@link GetIndexesInformationOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link IndexesInformation}
*/
public ServiceCall<IndexesInformation> getIndexesInformation(GetIndexesInformationOptions getIndexesInformationOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getIndexesInformationOptions, "getIndexesInformationOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", getIndexesInformationOptions.db());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_index", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getIndexesInformation");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<IndexesInformation> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<IndexesInformation>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.cloudant.v1.model.IndexesInformation in project cloudant-java-sdk by IBM.
the class CloudantTest method testGetIndexesInformationWOptions.
@Test
public void testGetIndexesInformationWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"total_rows\": 0, \"indexes\": [{\"ddoc\": \"ddoc\", \"def\": {\"default_analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}, \"default_field\": {\"analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}, \"enabled\": true}, \"fields\": [{\"name\": \"name\", \"type\": \"boolean\"}], \"index_array_lengths\": true, \"partial_filter_selector\": {\"mapKey\": \"anyValue\"}}, \"name\": \"name\", \"type\": \"json\"}]}";
String getIndexesInformationPath = "/testString/_index";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the GetIndexesInformationOptions model
GetIndexesInformationOptions getIndexesInformationOptionsModel = new GetIndexesInformationOptions.Builder().db("testString").build();
// Invoke operation with valid options model (positive test)
Response<IndexesInformation> response = cloudantService.getIndexesInformation(getIndexesInformationOptionsModel).execute();
assertNotNull(response);
IndexesInformation responseObj = response.getResult();
assertNotNull(responseObj);
// Verify the contents of the request
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "GET");
// Check query
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNull(query);
// Check request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, getIndexesInformationPath);
}
use of com.ibm.cloud.cloudant.v1.model.IndexesInformation in project cloudant-java-sdk by IBM.
the class IndexesInformationTest method testIndexesInformation.
@Test
public void testIndexesInformation() throws Throwable {
IndexesInformation indexesInformationModel = new IndexesInformation();
assertNull(indexesInformationModel.getTotalRows());
assertNull(indexesInformationModel.getIndexes());
}
Aggregations