Search in sources :

Example 1 with ApiKeyListOptions

use of com.arm.mbed.cloud.sdk.accountmanagement.model.ApiKeyListOptions in project mbed-cloud-sdk-java by ARMmbed.

the class AccountManagementExamples method listApiKeys.

/**
 * Lists the first 5 API Keys.
 */
@SuppressWarnings("boxing")
@Example
public void listApiKeys() {
    ConnectionOptions config = Configuration.get();
    AccountManagement api = new AccountManagement(config);
    try {
        // Defining query options
        ApiKeyListOptions options = new ApiKeyListOptions();
        options.setLimit(5);
        // Listing API keys.
        Paginator<ApiKey> apikeys = api.listAllApiKeys(options);
        for (ApiKey apiKey : apikeys) {
            log("API key", apiKey);
        }
    } catch (Exception e) {
        logError("last API Metadata", api.getLastApiMetadata());
        fail(e.getMessage());
    }
}
Also used : ApiKey(com.arm.mbed.cloud.sdk.accountmanagement.model.ApiKey) ApiKeyListOptions(com.arm.mbed.cloud.sdk.accountmanagement.model.ApiKeyListOptions) ConnectionOptions(com.arm.mbed.cloud.sdk.common.ConnectionOptions) AccountManagement(com.arm.mbed.cloud.sdk.AccountManagement) AbstractExample(utils.AbstractExample) Example(utils.Example)

Example 2 with ApiKeyListOptions

use of com.arm.mbed.cloud.sdk.accountmanagement.model.ApiKeyListOptions in project mbed-cloud-sdk-java by ARMmbed.

the class TestAllListOptions method testApiKeyListOptionsClone.

@Test
public void testApiKeyListOptionsClone() {
    ApiKeyListOptions opt1 = new ApiKeyListOptions();
    opt1.addEqualFilter("field1", Integer.valueOf(3));
    opt1.includeTotalCount();
    opt1.setLimit(Integer.valueOf(2));
    ApiKeyListOptions opt2 = new ApiKeyListOptions();
    assertNotEquals(opt2, opt1);
    assertNotSame(opt2, opt1);
    opt2 = opt1.clone();
    assertEquals(opt2, opt1);
    assertNotSame(opt2, opt1);
}
Also used : ApiKeyListOptions(com.arm.mbed.cloud.sdk.accountmanagement.model.ApiKeyListOptions) Test(org.junit.Test)

Aggregations

ApiKeyListOptions (com.arm.mbed.cloud.sdk.accountmanagement.model.ApiKeyListOptions)2 AccountManagement (com.arm.mbed.cloud.sdk.AccountManagement)1 ApiKey (com.arm.mbed.cloud.sdk.accountmanagement.model.ApiKey)1 ConnectionOptions (com.arm.mbed.cloud.sdk.common.ConnectionOptions)1 Test (org.junit.Test)1 AbstractExample (utils.AbstractExample)1 Example (utils.Example)1