use of com.arm.mbed.cloud.sdk.annotations.API in project mbed-cloud-sdk-java by ARMmbed.
the class AccountManagement method listGroupUsers.
/**
* Lists users of a group.
* <p>
* Example:
*
* <pre>
* {@code
* try {
* String groupId = "015f4ac587f500000000000100109294";
* ListOptions options = new ListOptions();
* options.setLimit(10);
*
* ListResponse<User> users = accountManagementApi.listGroupUsers(groupId, options);
* for (User user : users) {
* System.out.println("User ID: " + user.getId());
* System.out.println("User name: " + user.getFullName());
* }
* } catch (MbedCloudException e) {
* e.printStackTrace();
* }
* }
* </pre>
*
* @param groupId
* The group ID.
* @param options
* filter options.
* @return The list of users corresponding to groupId and filter options (One page).
* @throws MbedCloudException
* if a problem occurred during request processing.
*/
@API
@Nullable
public ListResponse<User> listGroupUsers(@NonNull String groupId, @Nullable ListOptions options) throws MbedCloudException {
checkNotNull(groupId, TAG_GROUP_ID);
final ListOptions finalOptions = (options == null) ? new ListOptions() : options;
final String finalGroupId = groupId;
return CloudCaller.call(this, "listGroupUsers()", UserAdapter.getListMapper(), new CloudCall<UserInfoRespList>() {
@Override
public Call<UserInfoRespList> call() {
return endpoint.getAdmin().getUsersOfGroup(finalGroupId, finalOptions.getLimit(), finalOptions.getAfter(), finalOptions.getOrder().toString(), finalOptions.encodeInclude());
}
});
}
use of com.arm.mbed.cloud.sdk.annotations.API in project mbed-cloud-sdk-java by ARMmbed.
the class AccountManagement method updateAccount.
/**
* Updates details of account associated with current API key.
* <p>
* Example:
*
* <pre>
* {@code Account account = accountManagementApi.getAccount()
* account.setCity("Austin");
* accoujnt.setState("Texas");
* account.setCountry("US");
*
* accountManagementApi.updateAccount(account);
* }
* </pre>
*
* @param account
* The account object to update.
* @return updated account.
* @throws MbedCloudException
* if a problem occurred during request processing.
*/
@API
@Nullable
public Account updateAccount(@NonNull Account account) throws MbedCloudException {
checkNotNull(account, TAG_ACCOUNT);
checkModelValidity(account, TAG_ACCOUNT);
final Account finalAccount = account;
return CloudCaller.call(this, "updateAccount()", AccountAdapter.getMapper(), new CloudCall<AccountInfo>() {
@Override
public Call<AccountInfo> call() {
return endpoint.getAdmin().updateMyAccount(AccountAdapter.reverseMap(finalAccount));
}
});
}
use of com.arm.mbed.cloud.sdk.annotations.API 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);
}
});
}
use of com.arm.mbed.cloud.sdk.annotations.API in project mbed-cloud-sdk-java by ARMmbed.
the class Connect method getResource.
/**
* Gets device's resource.
* <p>
* Example:
*
* <pre>
* {@code
* try {
* Device device = new Device();
* device.setId("015f4ac587f500000000000100100249");
*
* String resourcePath = "/3201/0/5853";
*
* Resource resource = connectApi.getResource(device, resourcePath);
* System.out.println("Confirmed resource path: " + resource.getPath());
* assert resourcePath == resource.getPath();
* } catch (MbedCloudException e) {
* e.printStackTrace();
* }
* }
* </pre>
*
* @param device
* Device.
* @param resourcePath
* Path of the resource to get
* @return resource present on the device.
* @throws MbedCloudException
* if a problem occurred during request processing.
*/
@API
@Nullable
public Resource getResource(@NonNull Device device, @NonNull String resourcePath) throws MbedCloudException {
checkNotNull(device, TAG_DEVICE);
checkNotNull(device.getId(), TAG_DEVICE_ID);
checkNotNull(resourcePath, TAG_RESOURCE_PATH);
final List<Resource> resources = listResources(device);
if (resources == null || resources.isEmpty()) {
return null;
}
for (final Resource resource : resources) {
if (ApiUtils.comparePaths(resourcePath, resource.getPath())) {
return resource;
}
}
return null;
}
use of com.arm.mbed.cloud.sdk.annotations.API in project mbed-cloud-sdk-java by ARMmbed.
the class Update method addFirmwareManifest.
/**
* Adds a firmware manifest.
* <p>
* Example:
*
* <pre>
* {@code
* try {
* String fileName = "C:\\Users\\mbedUser\\quickstart.manifest";
* FirmwareManifest manifest = new FirmwareManifest();
* manifest.setDatafile(fileName);
* manifest.setDescription("Quick start manifest");
* manifest.setName(manifest.getDatafile().getName());
*
* FirmwareManifest newManifest = updateApi.addFirmwareManifest(manifest);
* System.out.println("FirmwareManifest URL: " + newManifest.getUrl());
*
* } catch (MbedCloudException e) {
* e.printStackTrace();
* }
* }
* </pre>
*
* @param manifest
* The manifest to add.
* @return added manifest.
* @throws MbedCloudException
* if a problem occurred during request processing.
*/
@API
@Nullable
public FirmwareManifest addFirmwareManifest(@NonNull FirmwareManifest manifest) throws MbedCloudException {
checkNotNull(manifest, TAG_FIRMWARE_MANIFEST);
checkModelValidity(manifest, TAG_FIRMWARE_MANIFEST);
final FirmwareManifest finalManifest = manifest;
return CloudCaller.call(this, "addFirmwareManifest()", FirmwareManifestAdapter.getMapper(), new CloudCall<com.arm.mbed.cloud.sdk.internal.updateservice.model.FirmwareManifest>() {
@Override
public Call<com.arm.mbed.cloud.sdk.internal.updateservice.model.FirmwareManifest> call() {
return endpoint.getUpdate().firmwareManifestCreate(DataFileAdapter.reverseMap(finalManifest.getDataFile()), finalManifest.getName(), finalManifest.getDescription(), DataFileAdapter.reverseMap(finalManifest.getDecryptionKeysFile()));
}
});
}
Aggregations