Search in sources :

Example 1 with NonNull

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));
        }
    });
}
Also used : CloudCall(com.arm.mbed.cloud.sdk.common.CloudCaller.CloudCall) Call(retrofit2.Call) ApiKey(com.arm.mbed.cloud.sdk.accountmanagement.model.ApiKey) ApiKeyInfoResp(com.arm.mbed.cloud.sdk.internal.iam.model.ApiKeyInfoResp) NonNull(com.arm.mbed.cloud.sdk.annotations.NonNull) API(com.arm.mbed.cloud.sdk.annotations.API)

Example 2 with NonNull

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");
        }
    });
}
Also used : CloudCall(com.arm.mbed.cloud.sdk.common.CloudCaller.CloudCall) Call(retrofit2.Call) User(com.arm.mbed.cloud.sdk.accountmanagement.model.User) UserInfoResp(com.arm.mbed.cloud.sdk.internal.iam.model.UserInfoResp) NonNull(com.arm.mbed.cloud.sdk.annotations.NonNull) API(com.arm.mbed.cloud.sdk.annotations.API)

Aggregations

API (com.arm.mbed.cloud.sdk.annotations.API)2 NonNull (com.arm.mbed.cloud.sdk.annotations.NonNull)2 CloudCall (com.arm.mbed.cloud.sdk.common.CloudCaller.CloudCall)2 Call (retrofit2.Call)2 ApiKey (com.arm.mbed.cloud.sdk.accountmanagement.model.ApiKey)1 User (com.arm.mbed.cloud.sdk.accountmanagement.model.User)1 ApiKeyInfoResp (com.arm.mbed.cloud.sdk.internal.iam.model.ApiKeyInfoResp)1 UserInfoResp (com.arm.mbed.cloud.sdk.internal.iam.model.UserInfoResp)1