Search in sources :

Example 1 with PutCapacityThroughputConfigurationOptions

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);
}
Also used : CapacityThroughputInformation(com.ibm.cloud.cloudant.v1.model.CapacityThroughputInformation) RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) JsonObject(com.google.gson.JsonObject)

Example 2 with PutCapacityThroughputConfigurationOptions

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);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) PutCapacityThroughputConfigurationOptions(com.ibm.cloud.cloudant.v1.model.PutCapacityThroughputConfigurationOptions) CapacityThroughputInformation(com.ibm.cloud.cloudant.v1.model.CapacityThroughputInformation) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with PutCapacityThroughputConfigurationOptions

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"));
}
Also used : PutCapacityThroughputConfigurationOptions(com.ibm.cloud.cloudant.v1.model.PutCapacityThroughputConfigurationOptions) Test(org.testng.annotations.Test)

Aggregations

CapacityThroughputInformation (com.ibm.cloud.cloudant.v1.model.CapacityThroughputInformation)2 PutCapacityThroughputConfigurationOptions (com.ibm.cloud.cloudant.v1.model.PutCapacityThroughputConfigurationOptions)2 Test (org.testng.annotations.Test)2 JsonObject (com.google.gson.JsonObject)1 RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)1 MockResponse (okhttp3.mockwebserver.MockResponse)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1