Search in sources :

Example 1 with CurrentThroughputInformation

use of com.ibm.cloud.cloudant.v1.model.CurrentThroughputInformation in project cloudant-java-sdk by IBM.

the class Cloudant method getCurrentThroughputInformation.

/**
 * Retrieve the current provisioned throughput capacity consumption.
 *
 * View the current consumption of provisioned throughput capacity for an IBM Cloudant instance. The current
 * consumption shows the quantities of reads, writes, and global queries conducted against the instance for a given
 * second.
 *
 * @param getCurrentThroughputInformationOptions the {@link GetCurrentThroughputInformationOptions} containing the options for the call
 * @return a {@link ServiceCall} with a result of type {@link CurrentThroughputInformation}
 */
public ServiceCall<CurrentThroughputInformation> getCurrentThroughputInformation(GetCurrentThroughputInformationOptions getCurrentThroughputInformationOptions) {
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/current/throughput"));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getCurrentThroughputInformation");
    for (Entry<String, String> header : sdkHeaders.entrySet()) {
        builder.header(header.getKey(), header.getValue());
    }
    builder.header("Accept", "application/json");
    ResponseConverter<CurrentThroughputInformation> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<CurrentThroughputInformation>() {
    }.getType());
    return createServiceCall(builder.build(), responseConverter);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) CurrentThroughputInformation(com.ibm.cloud.cloudant.v1.model.CurrentThroughputInformation)

Example 2 with CurrentThroughputInformation

use of com.ibm.cloud.cloudant.v1.model.CurrentThroughputInformation in project cloudant-java-sdk by IBM.

the class CloudantTest method testGetCurrentThroughputInformationWOptions.

@Test
public void testGetCurrentThroughputInformationWOptions() throws Throwable {
    // Schedule some responses.
    String mockResponseBody = "{\"throughput\": {\"query\": 0, \"read\": 0, \"write\": 0}}";
    String getCurrentThroughputInformationPath = "/_api/v2/user/current/throughput";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
    constructClientService();
    // Construct an instance of the GetCurrentThroughputInformationOptions model
    GetCurrentThroughputInformationOptions getCurrentThroughputInformationOptionsModel = new GetCurrentThroughputInformationOptions();
    // Invoke operation with valid options model (positive test)
    Response<CurrentThroughputInformation> response = cloudantService.getCurrentThroughputInformation(getCurrentThroughputInformationOptionsModel).execute();
    assertNotNull(response);
    CurrentThroughputInformation 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, getCurrentThroughputInformationPath);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) CurrentThroughputInformation(com.ibm.cloud.cloudant.v1.model.CurrentThroughputInformation) GetCurrentThroughputInformationOptions(com.ibm.cloud.cloudant.v1.model.GetCurrentThroughputInformationOptions) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with CurrentThroughputInformation

use of com.ibm.cloud.cloudant.v1.model.CurrentThroughputInformation in project cloudant-java-sdk by IBM.

the class CurrentThroughputInformationTest method testCurrentThroughputInformation.

@Test
public void testCurrentThroughputInformation() throws Throwable {
    CurrentThroughputInformation currentThroughputInformationModel = new CurrentThroughputInformation();
    assertNull(currentThroughputInformationModel.getThroughput());
}
Also used : CurrentThroughputInformation(com.ibm.cloud.cloudant.v1.model.CurrentThroughputInformation) Test(org.testng.annotations.Test)

Aggregations

CurrentThroughputInformation (com.ibm.cloud.cloudant.v1.model.CurrentThroughputInformation)3 Test (org.testng.annotations.Test)2 GetCurrentThroughputInformationOptions (com.ibm.cloud.cloudant.v1.model.GetCurrentThroughputInformationOptions)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