use of com.ibm.cloud.cloudant.v1.model.PutCapacityThroughputConfigurationOptions in project cloudant-java-sdk by IBM.
the class Cloudant method putCapacityThroughputConfiguration.
/**
* Update the target provisioned throughput capacity.
*
* Sets the target provisioned throughput capacity for an IBM Cloudant instance. When target capacity is changed, the
* current capacity asynchronously changes to meet the target capacity.
*
* @param putCapacityThroughputConfigurationOptions the {@link PutCapacityThroughputConfigurationOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link CapacityThroughputInformation}
*/
public ServiceCall<CapacityThroughputInformation> putCapacityThroughputConfiguration(PutCapacityThroughputConfigurationOptions putCapacityThroughputConfigurationOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(putCapacityThroughputConfigurationOptions, "putCapacityThroughputConfigurationOptions cannot be null");
RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/capacity/throughput"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "putCapacityThroughputConfiguration");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("blocks", putCapacityThroughputConfigurationOptions.blocks());
builder.bodyJson(contentJson);
ResponseConverter<CapacityThroughputInformation> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<CapacityThroughputInformation>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.cloudant.v1.model.PutCapacityThroughputConfigurationOptions in project cloudant-java-sdk by IBM.
the class CloudantTest method testPutCapacityThroughputConfigurationWOptions.
@Test
public void testPutCapacityThroughputConfigurationWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"current\": {\"throughput\": {\"blocks\": 0, \"query\": 0, \"read\": 0, \"write\": 0}}, \"target\": {\"throughput\": {\"blocks\": 0, \"query\": 0, \"read\": 0, \"write\": 0}}}";
String putCapacityThroughputConfigurationPath = "/_api/v2/user/capacity/throughput";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the PutCapacityThroughputConfigurationOptions model
PutCapacityThroughputConfigurationOptions putCapacityThroughputConfigurationOptionsModel = new PutCapacityThroughputConfigurationOptions.Builder().blocks(Long.valueOf("0")).build();
// Invoke operation with valid options model (positive test)
Response<CapacityThroughputInformation> response = cloudantService.putCapacityThroughputConfiguration(putCapacityThroughputConfigurationOptionsModel).execute();
assertNotNull(response);
CapacityThroughputInformation responseObj = response.getResult();
assertNotNull(responseObj);
// Verify the contents of the request
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "PUT");
// Check query
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNull(query);
// Check request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, putCapacityThroughputConfigurationPath);
}
use of com.ibm.cloud.cloudant.v1.model.PutCapacityThroughputConfigurationOptions in project cloudant-java-sdk by IBM.
the class PutCapacityThroughputConfigurationOptionsTest method testPutCapacityThroughputConfigurationOptions.
@Test
public void testPutCapacityThroughputConfigurationOptions() throws Throwable {
PutCapacityThroughputConfigurationOptions putCapacityThroughputConfigurationOptionsModel = new PutCapacityThroughputConfigurationOptions.Builder().blocks(Long.valueOf("0")).build();
assertEquals(putCapacityThroughputConfigurationOptionsModel.blocks(), Long.valueOf("0"));
}
Aggregations