use of com.ibm.cloud.eventnotifications.event_notifications.v1.model.ListTagsSubscriptionOptions in project event-notifications-java-admin-sdk by IBM.
the class EventNotifications method listTagsSubscription.
/**
* List all Tag Subscriptions.
*
* List all Tag Subscriptions.
*
* @param listTagsSubscriptionOptions the {@link ListTagsSubscriptionOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link TagsSubscriptionList}
*/
public ServiceCall<TagsSubscriptionList> listTagsSubscription(ListTagsSubscriptionOptions listTagsSubscriptionOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(listTagsSubscriptionOptions, "listTagsSubscriptionOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("instance_id", listTagsSubscriptionOptions.instanceId());
pathParamsMap.put("id", listTagsSubscriptionOptions.id());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/instances/{instance_id}/destinations/{id}/tag_subscriptions", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("event_notifications", "v1", "listTagsSubscription");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (listTagsSubscriptionOptions.deviceId() != null) {
builder.query("device_id", String.valueOf(listTagsSubscriptionOptions.deviceId()));
}
if (listTagsSubscriptionOptions.userId() != null) {
builder.query("user_id", String.valueOf(listTagsSubscriptionOptions.userId()));
}
if (listTagsSubscriptionOptions.tagName() != null) {
builder.query("tag_name", String.valueOf(listTagsSubscriptionOptions.tagName()));
}
if (listTagsSubscriptionOptions.limit() != null) {
builder.query("limit", String.valueOf(listTagsSubscriptionOptions.limit()));
}
if (listTagsSubscriptionOptions.offset() != null) {
builder.query("offset", String.valueOf(listTagsSubscriptionOptions.offset()));
}
if (listTagsSubscriptionOptions.search() != null) {
builder.query("search", String.valueOf(listTagsSubscriptionOptions.search()));
}
ResponseConverter<TagsSubscriptionList> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<TagsSubscriptionList>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.eventnotifications.event_notifications.v1.model.ListTagsSubscriptionOptions in project event-notifications-java-admin-sdk by IBM.
the class ListTagsSubscriptionOptionsTest method testListTagsSubscriptionOptions.
@Test
public void testListTagsSubscriptionOptions() throws Throwable {
ListTagsSubscriptionOptions listTagsSubscriptionOptionsModel = new ListTagsSubscriptionOptions.Builder().instanceId("testString").id("testString").deviceId("testString").userId("testString").tagName("testString").limit(Long.valueOf("1")).offset(Long.valueOf("0")).search("testString").build();
assertEquals(listTagsSubscriptionOptionsModel.instanceId(), "testString");
assertEquals(listTagsSubscriptionOptionsModel.id(), "testString");
assertEquals(listTagsSubscriptionOptionsModel.deviceId(), "testString");
assertEquals(listTagsSubscriptionOptionsModel.userId(), "testString");
assertEquals(listTagsSubscriptionOptionsModel.tagName(), "testString");
assertEquals(listTagsSubscriptionOptionsModel.limit(), Long.valueOf("1"));
assertEquals(listTagsSubscriptionOptionsModel.offset(), Long.valueOf("0"));
assertEquals(listTagsSubscriptionOptionsModel.search(), "testString");
}
use of com.ibm.cloud.eventnotifications.event_notifications.v1.model.ListTagsSubscriptionOptions in project event-notifications-java-admin-sdk by IBM.
the class EventNotificationsTest method testListTagsSubscriptionWOptions.
// Test the listTagsSubscription operation with a valid options model parameter
@Test
public void testListTagsSubscriptionWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"total_count\": 10, \"offset\": 6, \"limit\": 5, \"tag_subscriptions\": [{\"id\": \"id\", \"device_id\": \"deviceId\", \"tag_name\": \"tagName\", \"user_id\": \"userId\", \"updated_at\": \"2019-01-01T12:00:00.000Z\"}]}";
String listTagsSubscriptionPath = "/v1/instances/testString/destinations/testString/tag_subscriptions";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the ListTagsSubscriptionOptions model
ListTagsSubscriptionOptions listTagsSubscriptionOptionsModel = new ListTagsSubscriptionOptions.Builder().instanceId("testString").id("testString").deviceId("testString").userId("testString").tagName("testString").limit(Long.valueOf("1")).offset(Long.valueOf("0")).search("testString").build();
// Invoke listTagsSubscription() with a valid options model and verify the result
Response<TagsSubscriptionList> response = eventNotificationsService.listTagsSubscription(listTagsSubscriptionOptionsModel).execute();
assertNotNull(response);
TagsSubscriptionList responseObj = response.getResult();
assertNotNull(responseObj);
// Verify the contents of the request sent to the mock server
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "GET");
// Verify request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, listTagsSubscriptionPath);
// Verify query params
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
assertEquals(query.get("device_id"), "testString");
assertEquals(query.get("user_id"), "testString");
assertEquals(query.get("tag_name"), "testString");
assertEquals(Long.valueOf(query.get("limit")), Long.valueOf("1"));
assertEquals(Long.valueOf(query.get("offset")), Long.valueOf("0"));
assertEquals(query.get("search"), "testString");
}
Aggregations