Search in sources :

Example 1 with GetMembershipInformationOptions

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

the class Cloudant method getMembershipInformation.

/**
 * Retrieve cluster membership information.
 *
 * Displays the nodes that are part of the cluster as `cluster_nodes`. The field, `all_nodes`, displays all nodes this
 * node knows about, including the ones that are part of the cluster. This endpoint is useful when you set up a
 * cluster.
 *
 * @param getMembershipInformationOptions the {@link GetMembershipInformationOptions} containing the options for the call
 * @return a {@link ServiceCall} with a result of type {@link MembershipInformation}
 */
public ServiceCall<MembershipInformation> getMembershipInformation(GetMembershipInformationOptions getMembershipInformationOptions) {
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_membership"));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getMembershipInformation");
    for (Entry<String, String> header : sdkHeaders.entrySet()) {
        builder.header(header.getKey(), header.getValue());
    }
    builder.header("Accept", "application/json");
    ResponseConverter<MembershipInformation> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<MembershipInformation>() {
    }.getType());
    return createServiceCall(builder.build(), responseConverter);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) MembershipInformation(com.ibm.cloud.cloudant.v1.model.MembershipInformation)

Example 2 with GetMembershipInformationOptions

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

the class GetMembershipInformationOptionsTest method testGetMembershipInformationOptions.

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

Example 3 with GetMembershipInformationOptions

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

the class CloudantTest method testGetMembershipInformationWOptions.

@Test
public void testGetMembershipInformationWOptions() throws Throwable {
    // Schedule some responses.
    String mockResponseBody = "{\"all_nodes\": [\"allNodes\"], \"cluster_nodes\": [\"clusterNodes\"]}";
    String getMembershipInformationPath = "/_membership";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
    constructClientService();
    // Construct an instance of the GetMembershipInformationOptions model
    GetMembershipInformationOptions getMembershipInformationOptionsModel = new GetMembershipInformationOptions();
    // Invoke operation with valid options model (positive test)
    Response<MembershipInformation> response = cloudantService.getMembershipInformation(getMembershipInformationOptionsModel).execute();
    assertNotNull(response);
    MembershipInformation 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, getMembershipInformationPath);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) GetMembershipInformationOptions(com.ibm.cloud.cloudant.v1.model.GetMembershipInformationOptions) MembershipInformation(com.ibm.cloud.cloudant.v1.model.MembershipInformation) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

GetMembershipInformationOptions (com.ibm.cloud.cloudant.v1.model.GetMembershipInformationOptions)2 MembershipInformation (com.ibm.cloud.cloudant.v1.model.MembershipInformation)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