Search in sources :

Example 1 with PresubscriptionArray

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

the class Connect method updatePresubscriptions.

/**
 * Updates pre-subscription data.
 * <p>
 * Example:
 *
 * <pre>
 * {@code
 * try {
 *     String deviceId = "015f4ac587f500000000000100100249";
 *
 *     Presubscription presub1 = new Presubscription();
 *     presub1.setDeviceType("default");
 *     List<String> resourceList1 = Arrays.asList("/3201/0/5850", "/3201/0/5853");
 *     presub1.setResourcePaths(resourceList1);
 *
 *     Presubscription presub2 = new Presubscription();
 *     presub2.setDeviceId(deviceId);
 *     List<String> resourceList2 = Arrays.asList("/3200/0/5501");
 *     presub2.setResourcePaths(resourceList2);
 *
 *     List<Presubscription> presubscriptions = Arrays.asList(presub1, presub2);
 *     connectApi.updatePresubscriptions(presubscriptions);
 * } catch (MbedCloudException e) {
 *     e.printStackTrace();
 * }
 * }
 * </pre>
 *
 * @param presubscriptions
 *            The pre-subscription list to update.
 *            <p>
 *            If you send an empty/null array, the pre-subscription data will be removed @see
 *            {@link #deletePresubscriptions()} for similar action.
 * @throws MbedCloudException
 *             if a problem occurred during request processing.
 */
@API
public void updatePresubscriptions(@Nullable List<Presubscription> presubscriptions) throws MbedCloudException {
    final List<Presubscription> finalList = presubscriptions;
    final PresubscriptionArray array = PresubscriptionAdapter.reverseMapList(finalList);
    CloudCaller.call(this, "updatePresubscriptions()", null, new CloudCall<Void>() {

        @Override
        public Call<Void> call() {
            return endpoint.getSubscriptions().v2SubscriptionsPut(array);
        }
    });
}
Also used : Call(retrofit2.Call) CloudCall(com.arm.mbed.cloud.sdk.common.CloudCaller.CloudCall) PresubscriptionArray(com.arm.mbed.cloud.sdk.internal.mds.model.PresubscriptionArray) Presubscription(com.arm.mbed.cloud.sdk.connect.model.Presubscription) API(com.arm.mbed.cloud.sdk.annotations.API)

Aggregations

API (com.arm.mbed.cloud.sdk.annotations.API)1 CloudCall (com.arm.mbed.cloud.sdk.common.CloudCaller.CloudCall)1 Presubscription (com.arm.mbed.cloud.sdk.connect.model.Presubscription)1 PresubscriptionArray (com.arm.mbed.cloud.sdk.internal.mds.model.PresubscriptionArray)1 Call (retrofit2.Call)1