use of com.ibm.cloud.cloudant.v1.model.DocumentShardInfo in project cloudant-java-sdk by IBM.
the class Cloudant method getDocumentShardsInfo.
/**
* Retrieve shard information for a specific document.
*
* Retrieves information about a specific shard where a particular document is stored, along with information about
* the nodes where that shard has a replica.
*
* @param getDocumentShardsInfoOptions the {@link GetDocumentShardsInfoOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link DocumentShardInfo}
*/
public ServiceCall<DocumentShardInfo> getDocumentShardsInfo(GetDocumentShardsInfoOptions getDocumentShardsInfoOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getDocumentShardsInfoOptions, "getDocumentShardsInfoOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", getDocumentShardsInfoOptions.db());
pathParamsMap.put("doc_id", getDocumentShardsInfoOptions.docId());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_shards/{doc_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getDocumentShardsInfo");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<DocumentShardInfo> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<DocumentShardInfo>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.cloudant.v1.model.DocumentShardInfo in project cloudant-java-sdk by IBM.
the class CloudantTest method testGetDocumentShardsInfoWOptions.
@Test
public void testGetDocumentShardsInfoWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"nodes\": [\"nodes\"], \"range\": \"range\"}";
String getDocumentShardsInfoPath = "/testString/_shards/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the GetDocumentShardsInfoOptions model
GetDocumentShardsInfoOptions getDocumentShardsInfoOptionsModel = new GetDocumentShardsInfoOptions.Builder().db("testString").docId("testString").build();
// Invoke operation with valid options model (positive test)
Response<DocumentShardInfo> response = cloudantService.getDocumentShardsInfo(getDocumentShardsInfoOptionsModel).execute();
assertNotNull(response);
DocumentShardInfo 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, getDocumentShardsInfoPath);
}
use of com.ibm.cloud.cloudant.v1.model.DocumentShardInfo in project cloudant-java-sdk by IBM.
the class DocumentShardInfoTest method testDocumentShardInfo.
@Test
public void testDocumentShardInfo() throws Throwable {
DocumentShardInfo documentShardInfoModel = new DocumentShardInfo();
assertNull(documentShardInfoModel.getNodes());
assertNull(documentShardInfoModel.getRange());
}
Aggregations