@Override public ApiKeyList getApiKeys(Map<String, Object> queryParams) { ApiKeyList list = getApiKeys(); //safe to get the href: does not execute a query until iteration occurs return getDataStore().getResource(list.getHref(), ApiKeyList.class, queryParams); }
/** @since 1.0.RC */ @Override public ApiKey getApiKey(String id, ApiKeyOptions options) throws ResourceException, IllegalArgumentException { Assert.hasText(id, "The 'id' argument cannot be null or empty to get an api key."); Assert.notNull(options, "options argument cannot be null."); Assert.hasText(getHref(), "The application must have an href to get an api key."); DefaultApiKeyCriteria criteria = new DefaultApiKeyCriteria(); criteria.add(new DefaultEqualsExpressionFactory(ID.getName()).eq(id)); if (!options.isEmpty() && options instanceof Expandable) { Expandable expandable = (Expandable) options; for (Expansion exp : expandable.getExpansions()) { if ("tenant".equals(exp.getName())) { criteria.withTenant(); } if ("account".equals(exp.getName())) { criteria.withAccount(); } } } String href = getHref() + "/apiKeys"; ApiKeyList apiKeys = getDataStore().getResource(href, ApiKeyList.class, (Criteria<ApiKeyCriteria>) criteria); Iterator<ApiKey> iterator = apiKeys.iterator(); // we expect only one api key to be in the collection return iterator.hasNext() ? iterator.next() : null; }
/** @since 1.0.RC */ @Override public ApiKey getApiKey(String id, ApiKeyOptions options) throws ResourceException, IllegalArgumentException { Assert.hasText(id, "The 'id' argument cannot be null or empty to get an api key."); Assert.notNull(options, "options argument cannot be null."); Assert.hasText(getHref(), "The application must have an href to get an api key."); DefaultApiKeyCriteria criteria = new DefaultApiKeyCriteria(); criteria.add(new DefaultEqualsExpressionFactory(ID.getName()).eq(id)); if (!options.isEmpty() && options instanceof Expandable) { Expandable expandable = (Expandable) options; for (Expansion exp : expandable.getExpansions()) { if ("tenant".equals(exp.getName())) { criteria.withTenant(); } if ("account".equals(exp.getName())) { criteria.withAccount(); } } } String href = getHref() + "/apiKeys"; ApiKeyList apiKeys = getDataStore().getResource(href, ApiKeyList.class, (Criteria<ApiKeyCriteria>) criteria); Iterator<ApiKey> iterator = apiKeys.iterator(); // we expect only one api key to be in the collection return iterator.hasNext() ? iterator.next() : null; }
@Override public ApiKeyList getApiKeys(ApiKeyCriteria criteria) { ApiKeyList list = getApiKeys(); //safe to get the href: does not execute a query until iteration occurs return getDataStore().getResource(list.getHref(), ApiKeyList.class, (Criteria<ApiKeyCriteria>) criteria); }
@Override public ApiKeyList getApiKeys(Map<String, Object> queryParams) { ApiKeyList list = getApiKeys(); //safe to get the href: does not execute a query until iteration occurs return getDataStore().getResource(list.getHref(), ApiKeyList.class, queryParams); }
@Override public ApiKeyList getApiKeys(ApiKeyCriteria criteria) { ApiKeyList list = getApiKeys(); //safe to get the href: does not execute a query until iteration occurs return getDataStore().getResource(list.getHref(), ApiKeyList.class, (Criteria<ApiKeyCriteria>) criteria); }
/** * @since 1.0.RC */ @Override public ApiKey createApiKey(ApiKeyOptions options) { Assert.notNull(options, "options argument cannot be null."); String href = getApiKeys().getHref(); return getDataStore().create(href, new DefaultApiKey(getDataStore()), options); }
/** * @since 1.0.RC */ @Override public ApiKey createApiKey(ApiKeyOptions options) { Assert.notNull(options, "options argument cannot be null."); String href = getApiKeys().getHref(); return getDataStore().create(href, new DefaultApiKey(getDataStore()), options); }