use of com.arm.mbed.cloud.sdk.accountmanagement.model.Group in project mbed-cloud-sdk-java by ARMmbed.
the class AccountManagementExamples method listGroups.
/**
* Lists the last 5 groups and their contents.
*/
@SuppressWarnings("boxing")
@Example
public void listGroups() {
ConnectionOptions config = Configuration.get();
AccountManagement api = new AccountManagement(config);
try {
// Defining query options
GroupListOptions options = new GroupListOptions();
options.setLimit(5);
options.setOrder(Order.DESC);
// Listing groups.
ListResponse<Group> groups = api.listGroups(options);
for (Group group : groups.getData()) {
log("Group", group);
Paginator<ApiKey> apiKeyIterator = api.listAllGroupApiKeys(group.getId(), null);
while (apiKeyIterator.hasNext()) {
log("API key of group [" + group.getId() + "]", apiKeyIterator.next());
}
Paginator<User> userIterator = api.listAllGroupUsers(group.getId(), null);
while (userIterator.hasNext()) {
log("User of group [" + group.getId() + "]", userIterator.next());
}
}
} catch (Exception e) {
logError("last API Metadata", api.getLastApiMetadata());
fail(e.getMessage());
}
}
Aggregations