use of com.ibm.cloud.cloudant.v1.model.PostActivityTrackerEventsOptions in project cloudant-java-sdk by IBM.
the class Cloudant method postActivityTrackerEvents.
/**
* Modify Activity Tracker events configuration.
*
* Configure event types that are being sent to IBM Cloud Activity Tracker for the IBM Cloudant instance.
*
* @param postActivityTrackerEventsOptions the {@link PostActivityTrackerEventsOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link Ok}
*/
public ServiceCall<Ok> postActivityTrackerEvents(PostActivityTrackerEventsOptions postActivityTrackerEventsOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(postActivityTrackerEventsOptions, "postActivityTrackerEventsOptions cannot be null");
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/activity_tracker/events"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postActivityTrackerEvents");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.add("types", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postActivityTrackerEventsOptions.types()));
builder.bodyJson(contentJson);
ResponseConverter<Ok> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Ok>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.cloudant.v1.model.PostActivityTrackerEventsOptions in project cloudant-java-sdk by IBM.
the class CloudantTest method testPostActivityTrackerEventsWOptions.
@Test
public void testPostActivityTrackerEventsWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"ok\": true}";
String postActivityTrackerEventsPath = "/_api/v2/user/activity_tracker/events";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the PostActivityTrackerEventsOptions model
PostActivityTrackerEventsOptions postActivityTrackerEventsOptionsModel = new PostActivityTrackerEventsOptions.Builder().types(new java.util.ArrayList<String>(java.util.Arrays.asList("management"))).build();
// Invoke operation with valid options model (positive test)
Response<Ok> response = cloudantService.postActivityTrackerEvents(postActivityTrackerEventsOptionsModel).execute();
assertNotNull(response);
Ok responseObj = response.getResult();
assertNotNull(responseObj);
// Verify the contents of the request
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "POST");
// Check query
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNull(query);
// Check request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, postActivityTrackerEventsPath);
}
use of com.ibm.cloud.cloudant.v1.model.PostActivityTrackerEventsOptions in project cloudant-java-sdk by IBM.
the class PostActivityTrackerEventsOptionsTest method testPostActivityTrackerEventsOptions.
@Test
public void testPostActivityTrackerEventsOptions() throws Throwable {
PostActivityTrackerEventsOptions postActivityTrackerEventsOptionsModel = new PostActivityTrackerEventsOptions.Builder().types(new java.util.ArrayList<String>(java.util.Arrays.asList("management"))).build();
assertEquals(postActivityTrackerEventsOptionsModel.types(), new java.util.ArrayList<String>(java.util.Arrays.asList("management")));
}
Aggregations