Search in sources :

Example 1 with DevicePage

use of com.arm.mbed.cloud.sdk.internal.devicedirectory.model.DevicePage in project mbed-cloud-sdk-java by ARMmbed.

the class DeviceDirectory method listDevicesWithExtraFilters.

protected ListResponse<Device> listDevicesWithExtraFilters(String functionName, DeviceListOptions options, Filter additionalFilter) throws MbedCloudException {
    final DeviceListOptions finalOptions = (options == null) ? new DeviceListOptions() : options;
    finalOptions.addFilter(additionalFilter);
    return CloudCaller.call(this, functionName, DeviceAdapter.getListMapper(), new CloudCall<DevicePage>() {

        @Override
        public Call<DevicePage> call() {
            return endpoint.getDirectory().deviceList(finalOptions.getLimit(), finalOptions.getOrder().toString(), finalOptions.getAfter(), DeviceAdapter.FILTERS_MARSHALLER.encode(finalOptions.getFilter()), finalOptions.encodeInclude());
        }
    });
}
Also used : CloudCall(com.arm.mbed.cloud.sdk.common.CloudCaller.CloudCall) Call(retrofit2.Call) DevicePage(com.arm.mbed.cloud.sdk.internal.devicedirectory.model.DevicePage) DeviceListOptions(com.arm.mbed.cloud.sdk.devicedirectory.model.DeviceListOptions)

Example 2 with DevicePage

use of com.arm.mbed.cloud.sdk.internal.devicedirectory.model.DevicePage in project mbed-cloud-sdk-java by ARMmbed.

the class DeviceAdapter method mapList.

/**
 * Maps a list of device data.
 *
 * @param list
 *            device page
 * @return a list of devices
 */
public static ListResponse<Device> mapList(DevicePage list) {
    final DevicePage deviceList = list;
    final RespList<DeviceData> respList = new RespList<DeviceData>() {

        @Override
        public Boolean getHasMore() {
            return (deviceList == null) ? null : deviceList.isHasMore();
        }

        @Override
        public Integer getTotalCount() {
            return (deviceList == null) ? null : deviceList.getTotalCount();
        }

        @Override
        public String getAfter() {
            return (deviceList == null) ? null : deviceList.getAfter();
        }

        @Override
        public Integer getLimit() {
            return (deviceList == null) ? null : deviceList.getLimit();
        }

        @Override
        public String getOrder() {
            return (deviceList == null) ? null : deviceList.getOrder().toString();
        }

        @Override
        public List<DeviceData> getData() {
            return (deviceList == null) ? null : deviceList.getData();
        }
    };
    return GenericAdapter.mapList(respList, getMapper());
}
Also used : DevicePage(com.arm.mbed.cloud.sdk.internal.devicedirectory.model.DevicePage) DeviceData(com.arm.mbed.cloud.sdk.internal.devicedirectory.model.DeviceData) RespList(com.arm.mbed.cloud.sdk.common.GenericAdapter.RespList)

Aggregations

DevicePage (com.arm.mbed.cloud.sdk.internal.devicedirectory.model.DevicePage)2 CloudCall (com.arm.mbed.cloud.sdk.common.CloudCaller.CloudCall)1 RespList (com.arm.mbed.cloud.sdk.common.GenericAdapter.RespList)1 DeviceListOptions (com.arm.mbed.cloud.sdk.devicedirectory.model.DeviceListOptions)1 DeviceData (com.arm.mbed.cloud.sdk.internal.devicedirectory.model.DeviceData)1 Call (retrofit2.Call)1