use of com.arm.mbed.cloud.sdk.annotations.NonNull in project mbed-cloud-sdk-java by ARMmbed.
the class AccountManagement method addApiKey.
/**
* Adds an API key.
* <p>
* Example:
*
* <pre>
* {@code
* try {
* ApiKey apiKey = new ApiKey();
* apiKey.setName("QuickstartKey");
*
* ApiKey newApiKey = accountManagementApi.addApiKey(apiKey);
* System.out.println("Api Key: " + newApiKey.getKey());
*
* } catch (MbedCloudException e) {
* e.printStackTrace();
* }
* }
* </pre>
*
* @param apiKey
* The API key to add.
* @return added API Key.
* @throws MbedCloudException
* if a problem occurred during request processing.
*/
@API
@NonNull
public ApiKey addApiKey(@NonNull ApiKey apiKey) throws MbedCloudException {
checkNotNull(apiKey, TAG_API_KEY);
checkModelValidity(apiKey, TAG_API_KEY);
final ApiKey finalApiKey = apiKey;
return CloudCaller.call(this, "addApiKey()", ApiKeyAdapter.getMapper(), new CloudCall<ApiKeyInfoResp>() {
@Override
public Call<ApiKeyInfoResp> call() {
return endpoint.getDeveloper().createApiKey(ApiKeyAdapter.reverseMapAdd(finalApiKey));
}
});
}
use of com.arm.mbed.cloud.sdk.annotations.NonNull in project mbed-cloud-sdk-java by ARMmbed.
the class AccountManagement method addUser.
/**
* Adds a user.
* <p>
* Example:
*
* <pre>
* {@code
* try {
* User user = new User();
* user.setEmail("javaSDK@arm.com");
* user.setUsername("javaSDK");
* user.setFullName("Java SDK");
*
* User newUser = accountManagementApi.addUser(user);
* System.out.println("User ID: " + newUser.getId());
* } catch (MbedCloudException e) {
* e.printStackTrace();
* }
* }
* </pre>
*
* @param user
* User to add.
* @return added user.
* @throws MbedCloudException
* if a problem occurred during request processing.
*/
@API
@NonNull
public User addUser(@NonNull User user) throws MbedCloudException {
checkNotNull(user, TAG_USER);
checkModelValidity(user, TAG_USER);
final User finalUser = user;
return CloudCaller.call(this, "addUser()", UserAdapter.getMapper(), new CloudCall<UserInfoResp>() {
@Override
public Call<UserInfoResp> call() {
return endpoint.getAdmin().createUser(UserAdapter.reverseMapAdd(finalUser), "create");
}
});
}
Aggregations