diff --git a/gradle.properties b/gradle.properties index 844d4f77..a0fd3f89 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,4 +16,4 @@ group=com.nike artifactId=cerberus-lifecycle-cli -version=3.1.0 +version=3.1.1 diff --git a/src/main/java/com/nike/cerberus/client/CerberusAdminClient.java b/src/main/java/com/nike/cerberus/client/CerberusAdminClient.java index 89ba093a..6eb44503 100644 --- a/src/main/java/com/nike/cerberus/client/CerberusAdminClient.java +++ b/src/main/java/com/nike/cerberus/client/CerberusAdminClient.java @@ -32,6 +32,8 @@ import okhttp3.RequestBody; import okhttp3.Response; import okhttp3.ResponseBody; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.net.ssl.SSLException; import java.io.IOException; @@ -46,6 +48,8 @@ */ public class CerberusAdminClient extends VaultAdminClient { + private final Logger log = LoggerFactory.getLogger(getClass()); + protected OkHttpClient httpClient; protected VaultCredentialsProvider credentialsProvider; protected UrlResolver vaultUrlResolver; @@ -84,7 +88,7 @@ public void restoreMetadata(String jsonPayload) { } } - public SdbMetadataResult getSDBMetaData(String offset, String limit) { + public SdbMetadataResult getSDBMetaData(int offset, int limit) { URL baseUrl = null; try { baseUrl = new URL(vaultUrlResolver.resolve()); @@ -96,8 +100,8 @@ public SdbMetadataResult getSDBMetaData(String offset, String limit) { .scheme(baseUrl.getProtocol()) .host(baseUrl.getHost()) .addPathSegments("v1/metadata") - .addQueryParameter("limit", limit) - .addQueryParameter("offset", offset) + .addQueryParameter("limit", String.valueOf(limit)) + .addQueryParameter("offset", String.valueOf(offset)) .build(); Response response = execute(url, HttpMethod.GET, null); @@ -112,11 +116,13 @@ public SdbMetadataResult getSDBMetaData(String offset, String limit) { public List getAllSdbMetadata() { List sdbMetadataList = new LinkedList<>(); SdbMetadataResult currentResult = null; - String offset = "0"; - String limit = "100"; + int offset = 0; + int limit = 100; do { currentResult = getSDBMetaData(offset, limit); sdbMetadataList.addAll(currentResult.getSafeDepositBoxMetadata()); + offset = currentResult.getNextOffset(); + log.info("Retrieved metadata for {} SDBs", currentResult.getSdbCountInResult()); } while (currentResult.hasNext()); return sdbMetadataList;