use of com.arm.mbed.cloud.sdk.annotations.Nullable in project mbed-cloud-sdk-java by ARMmbed.
the class DeviceDirectory method updateQuery.
/**
* Updates a query.
* <p>
* Example:
*
* <pre>
* {@code
* try {
* Query query = new Query();
* query.setName("NEW Quickstart query");
* String queryId = "015f4ac587f500000000000100100249";
* query.setId(queryId);
*
* Filters deviceFilter = new Filters();
* deviceFilter.add(new Filter("state", FilterOperator.EQUAL, "registered"));
* deviceFilter.add(new Filter("deviceClass", FilterOperator.EQUAL, getClassId()));
* query.setFilters(deviceFilter);
*
* Calendar date = GregorianCalendar(2017,10,30,10,20,56);
* query.addCreatedAtFilter(date.getTime(),FilterOperator.GREATER_THAN);
*
* Query newQuery = deviceDirectoryApi.updateQuery(query);
* System.out.println("Update query name: " + newQuery.getName());
* assert query.getId() == newQuery.getId();
*
* } catch (MbedCloudException e) {
* e.printStackTrace();
* }
* }
* </pre>
*
* @param query
* The query to update.
* @return updated query.
* @throws MbedCloudException
* if a problem occurred during request processing.
*/
@API
@Nullable
public Query updateQuery(@NonNull Query query) throws MbedCloudException {
checkNotNull(query, TAG_QUERY);
checkNotNull(query.getId(), TAG_QUERY_ID);
checkModelValidity(query, TAG_QUERY);
final Query finalQuery = query;
return CloudCaller.call(this, "updateQuery()", QueryAdapter.getMapper(), new CloudCall<DeviceQuery>() {
@Override
public Call<DeviceQuery> call() {
return endpoint.getDirectory().deviceQueryUpdate(finalQuery.getId(), QueryAdapter.reverseMapUpdate(finalQuery));
}
});
}
use of com.arm.mbed.cloud.sdk.annotations.Nullable in project mbed-cloud-sdk-java by ARMmbed.
the class DeviceDirectory method updateDevice.
/**
* Updates a device.
* <p>
* Example:
*
* <pre>
* {@code
* try {
* Device device = new Device();
* String deviceId = "015f4ac587f500000000000100100249";
* device.setId(deviceId);
* device.setName("QuickstartDevice");
* device.setDescription("Updated quick start device");
* device.setDeviceType("quickstart");
*
* Device newDevice = deviceDirectoryApi.updateDevice(device);
* System.out.println("Updated device description: " + newDevice.getDescription());
* } catch (MbedCloudException e) {
* e.printStackTrace();
* }
* }
* </pre>
*
* @param device
* Device details.
* @return updated device.
* @throws MbedCloudException
* if a problem occurred during request processing.
*/
@API
@Nullable
public Device updateDevice(@NonNull Device device) throws MbedCloudException {
checkNotNull(device, TAG_DEVICE);
checkNotNull(device.getId(), TAG_DEVICE_ID);
checkModelValidity(device, TAG_DEVICE);
final Device finalDevice = device;
return CloudCaller.call(this, "updateDevice()", DeviceAdapter.getMapper(), new CloudCall<DeviceData>() {
@Override
public Call<DeviceData> call() {
return endpoint.getDirectory().deviceUpdate(finalDevice.getId(), DeviceAdapter.reverseMapUpdate(finalDevice));
}
});
}
use of com.arm.mbed.cloud.sdk.annotations.Nullable in project mbed-cloud-sdk-java by ARMmbed.
the class DeviceDirectory method addQuery.
/**
* Adds a query.
* <p>
* Example:
*
* <pre>
* {@code
* try {
* Query query = new Query();
* query.setName("Quickstart query");
*
* Filters deviceFilter = new Filters();
* deviceFilter.add(new Filter("state", FilterOperator.EQUAL, "registered"));
* deviceFilter.add(new Filter("deviceClass", FilterOperator.EQUAL, getClassId()));
* query.setFilters(deviceFilter);
*
* Calendar date = GregorianCalendar(2017,10,30,10,20,56);
* query.addCreatedAtFilter(date.getTime(),FilterOperator.GREATER_THAN);
*
* Query newQuery = deviceDirectoryApi.addQuery(query);
* System.out.println("Query ID: " + newQuery.getId());
* } catch (MbedCloudException e) {
* e.printStackTrace();
* }
* }
* </pre>
*
* @param query
* the query to add.
* @return added query.
* @throws MbedCloudException
* if a problem occurred during request processing.
*/
@API
@Nullable
public Query addQuery(@NonNull Query query) throws MbedCloudException {
checkNotNull(query, TAG_QUERY);
checkModelValidity(query, TAG_QUERY);
final Query finalQuery = query;
return CloudCaller.call(this, "addQuery()", QueryAdapter.getMapper(), new CloudCall<DeviceQuery>() {
@Override
public Call<DeviceQuery> call() {
return endpoint.getDirectory().deviceQueryCreate(QueryAdapter.reverseMapAdd(finalQuery));
}
});
}
use of com.arm.mbed.cloud.sdk.annotations.Nullable in project mbed-cloud-sdk-java by ARMmbed.
the class Update method addFirmwareImage.
/**
* Adds a firmware image.
* <p>
* Example:
*
* <pre>
* {@code
* try {
* String fileName = "C:\\Users\\mbedUser\\mbed-cloud-client-example.bin";
* FirmwareImage image = new FirmwareImage();
* image.setDatafile(fileName);
* image.setDescription("Quick start image");
* image.setName(fileName.substring(0,fileName.indexOf(".")));
*
* FirmwareImage newImage = updateApi.addFirmwareImage(image);
* System.out.println("FirmwareImage URL: " + newImage.getUrl());
*
* } catch (MbedCloudException e) {
* e.printStackTrace();
* }
* }
* </pre>
*
* @param image
* The image to add.
* @return added image.
* @throws MbedCloudException
* if a problem occurred during request processing.
*/
@API
@Nullable
public FirmwareImage addFirmwareImage(@NonNull FirmwareImage image) throws MbedCloudException {
checkNotNull(image, TAG_FIRMWARE_IMAGE);
checkModelValidity(image, TAG_FIRMWARE_IMAGE);
final FirmwareImage finalImage = image;
return CloudCaller.call(this, "addFirmwareImage()", FirmwareImageAdapter.getMapper(), new CloudCall<com.arm.mbed.cloud.sdk.internal.updateservice.model.FirmwareImage>() {
@Override
public Call<com.arm.mbed.cloud.sdk.internal.updateservice.model.FirmwareImage> call() {
return endpoint.getUpdate().firmwareImageCreate(DataFileAdapter.reverseMap(finalImage.getDataFile()), finalImage.getName(), finalImage.getDescription());
}
});
}
use of com.arm.mbed.cloud.sdk.annotations.Nullable in project mbed-cloud-sdk-java by ARMmbed.
the class AccountManagement method updateApiKey.
/**
* Updates an API key.
* <p>
* Example:
*
* <pre>
* {@code
* try {
* ApiKey apiKey = new ApiKey();
* String apiKeyId = "015f4ac587f500000000000100100249";
* apiKey.setId(apiKeyId);
* apiKey.setName("NewKeyName");
*
* ApiKey newApiKey = accountManagementApi.updateApiKey(apiKey);
* System.out.println("New Api Key name: " + newApiKey.getName());
* assert apiKeyId == newApiKey.getId();
*
* } catch (MbedCloudException e) {
* e.printStackTrace();
* }
* }
* </pre>
*
* @param apiKey
* The API key to update.
* @return updated API key.
* @throws MbedCloudException
* if a problem occurred during request processing.
*/
@API
@Nullable
public ApiKey updateApiKey(@NonNull ApiKey apiKey) throws MbedCloudException {
checkNotNull(apiKey, TAG_API_KEY);
checkNotNull(apiKey.getId(), TAG_API_KEY_UUID);
checkModelValidity(apiKey, TAG_API_KEY);
ApiKey updatedApiKey = null;
if (apiKey.hasStatusBeenUpdated()) {
updatedApiKey = apiKey;
} else {
updatedApiKey = apiKey.clone();
updatedApiKey.setStatus(null);
}
final ApiKey finalApiKey = updatedApiKey;
return CloudCaller.call(this, "updateApiKey()", ApiKeyAdapter.getMapper(), new CloudCall<ApiKeyInfoResp>() {
@Override
public Call<ApiKeyInfoResp> call() {
return endpoint.getDeveloper().updateApiKey(finalApiKey.getId(), ApiKeyAdapter.reverseMapUpdate(finalApiKey));
}
});
}
Aggregations