use of com.ibm.cloud.eventnotifications.event_notifications.v1.model.ListTagsSubscriptionsDeviceOptions in project event-notifications-java-admin-sdk by IBM.
the class EventNotifications method listTagsSubscriptionsDevice.
/**
* List all Tag Subscriptions for a device.
*
* List all Tag Subscriptions for a device.
*
* @param listTagsSubscriptionsDeviceOptions the {@link ListTagsSubscriptionsDeviceOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link TagsSubscriptionList}
*/
public ServiceCall<TagsSubscriptionList> listTagsSubscriptionsDevice(ListTagsSubscriptionsDeviceOptions listTagsSubscriptionsDeviceOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(listTagsSubscriptionsDeviceOptions, "listTagsSubscriptionsDeviceOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("instance_id", listTagsSubscriptionsDeviceOptions.instanceId());
pathParamsMap.put("id", listTagsSubscriptionsDeviceOptions.id());
pathParamsMap.put("device_id", listTagsSubscriptionsDeviceOptions.deviceId());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/instances/{instance_id}/destinations/{id}/tag_subscriptions/devices/{device_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("event_notifications", "v1", "listTagsSubscriptionsDevice");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (listTagsSubscriptionsDeviceOptions.tagName() != null) {
builder.query("tag_name", String.valueOf(listTagsSubscriptionsDeviceOptions.tagName()));
}
if (listTagsSubscriptionsDeviceOptions.limit() != null) {
builder.query("limit", String.valueOf(listTagsSubscriptionsDeviceOptions.limit()));
}
if (listTagsSubscriptionsDeviceOptions.offset() != null) {
builder.query("offset", String.valueOf(listTagsSubscriptionsDeviceOptions.offset()));
}
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.ListTagsSubscriptionsDeviceOptions in project event-notifications-java-admin-sdk by IBM.
the class ListTagsSubscriptionsDeviceOptionsTest method testListTagsSubscriptionsDeviceOptions.
@Test
public void testListTagsSubscriptionsDeviceOptions() throws Throwable {
ListTagsSubscriptionsDeviceOptions listTagsSubscriptionsDeviceOptionsModel = new ListTagsSubscriptionsDeviceOptions.Builder().instanceId("testString").id("testString").deviceId("testString").tagName("testString").limit(Long.valueOf("1")).offset(Long.valueOf("0")).build();
assertEquals(listTagsSubscriptionsDeviceOptionsModel.instanceId(), "testString");
assertEquals(listTagsSubscriptionsDeviceOptionsModel.id(), "testString");
assertEquals(listTagsSubscriptionsDeviceOptionsModel.deviceId(), "testString");
assertEquals(listTagsSubscriptionsDeviceOptionsModel.tagName(), "testString");
assertEquals(listTagsSubscriptionsDeviceOptionsModel.limit(), Long.valueOf("1"));
assertEquals(listTagsSubscriptionsDeviceOptionsModel.offset(), Long.valueOf("0"));
}
use of com.ibm.cloud.eventnotifications.event_notifications.v1.model.ListTagsSubscriptionsDeviceOptions in project event-notifications-java-admin-sdk by IBM.
the class EventNotificationsTest method testListTagsSubscriptionsDeviceWOptions.
// Test the listTagsSubscriptionsDevice operation with a valid options model parameter
@Test
public void testListTagsSubscriptionsDeviceWOptions() 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 listTagsSubscriptionsDevicePath = "/v1/instances/testString/destinations/testString/tag_subscriptions/devices/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the ListTagsSubscriptionsDeviceOptions model
ListTagsSubscriptionsDeviceOptions listTagsSubscriptionsDeviceOptionsModel = new ListTagsSubscriptionsDeviceOptions.Builder().instanceId("testString").id("testString").deviceId("testString").tagName("testString").limit(Long.valueOf("1")).offset(Long.valueOf("0")).build();
// Invoke listTagsSubscriptionsDevice() with a valid options model and verify the result
Response<TagsSubscriptionList> response = eventNotificationsService.listTagsSubscriptionsDevice(listTagsSubscriptionsDeviceOptionsModel).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, listTagsSubscriptionsDevicePath);
// Verify query params
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
assertEquals(query.get("tag_name"), "testString");
assertEquals(Long.valueOf(query.get("limit")), Long.valueOf("1"));
assertEquals(Long.valueOf(query.get("offset")), Long.valueOf("0"));
}
Aggregations