Search in sources :

Example 1 with GetCapacityThroughputInformationOptions

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

the class CloudantTest method testGetCapacityThroughputInformationWOptions.

@Test
public void testGetCapacityThroughputInformationWOptions() 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 getCapacityThroughputInformationPath = "/_api/v2/user/capacity/throughput";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
    constructClientService();
    // Construct an instance of the GetCapacityThroughputInformationOptions model
    GetCapacityThroughputInformationOptions getCapacityThroughputInformationOptionsModel = new GetCapacityThroughputInformationOptions();
    // Invoke operation with valid options model (positive test)
    Response<CapacityThroughputInformation> response = cloudantService.getCapacityThroughputInformation(getCapacityThroughputInformationOptionsModel).execute();
    assertNotNull(response);
    CapacityThroughputInformation 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, getCapacityThroughputInformationPath);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) CapacityThroughputInformation(com.ibm.cloud.cloudant.v1.model.CapacityThroughputInformation) GetCapacityThroughputInformationOptions(com.ibm.cloud.cloudant.v1.model.GetCapacityThroughputInformationOptions) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with GetCapacityThroughputInformationOptions

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

the class GetCapacityThroughputInformationOptionsTest method testGetCapacityThroughputInformationOptions.

@Test
public void testGetCapacityThroughputInformationOptions() throws Throwable {
    GetCapacityThroughputInformationOptions getCapacityThroughputInformationOptionsModel = new GetCapacityThroughputInformationOptions();
    assertNotNull(getCapacityThroughputInformationOptionsModel);
}
Also used : GetCapacityThroughputInformationOptions(com.ibm.cloud.cloudant.v1.model.GetCapacityThroughputInformationOptions) Test(org.testng.annotations.Test)

Example 3 with GetCapacityThroughputInformationOptions

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

the class Cloudant method getCapacityThroughputInformation.

/**
 * Retrieve provisioned throughput capacity information.
 *
 * View the amount of provisioned throughput capacity that is allocated to an IBM Cloudant instance and what is the
 * target provisioned throughput capacity.
 *
 * @param getCapacityThroughputInformationOptions the {@link GetCapacityThroughputInformationOptions} containing the options for the call
 * @return a {@link ServiceCall} with a result of type {@link CapacityThroughputInformation}
 */
public ServiceCall<CapacityThroughputInformation> getCapacityThroughputInformation(GetCapacityThroughputInformationOptions getCapacityThroughputInformationOptions) {
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/capacity/throughput"));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getCapacityThroughputInformation");
    for (Entry<String, String> header : sdkHeaders.entrySet()) {
        builder.header(header.getKey(), header.getValue());
    }
    builder.header("Accept", "application/json");
    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)

Aggregations

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