diff --git a/src/main/java/com/ngrok/services/Endpoints.java b/src/main/java/com/ngrok/services/Endpoints.java index ea21b33..ccb3276 100644 --- a/src/main/java/com/ngrok/services/Endpoints.java +++ b/src/main/java/com/ngrok/services/Endpoints.java @@ -208,8 +208,8 @@ public class Endpoints { public class ListCallBuilder { private Optional beforeId = Optional.empty(); private Optional limit = Optional.empty(); - private Optional> ids = Optional.empty(); - private Optional> urls = Optional.empty(); + private Optional> id = Optional.empty(); + private Optional> url = Optional.empty(); private ListCallBuilder( ) { @@ -260,46 +260,46 @@ public class Endpoints { } /** - * Sets the ids parameter. + * Sets the id parameter. * - * @param ids the value of the ids parameter as a {@link java.util.List} of {@link String} + * @param id the value of the id parameter as a {@link java.util.List} of {@link String} * @return the call builder instance */ - public ListCallBuilder ids(final java.util.List ids) { - this.ids = Optional.of(Objects.requireNonNull(ids, "ids is required")); + public ListCallBuilder id(final java.util.List id) { + this.id = Optional.of(Objects.requireNonNull(id, "id is required")); return this; } /** - * Sets (or unsets) the ids parameter. + * Sets (or unsets) the id parameter. * - * @param ids the value of the ids parameter as an {@link Optional} of {@link java.util.List} of {@link String} + * @param id the value of the id parameter as an {@link Optional} of {@link java.util.List} of {@link String} * @return the call builder instance */ - public ListCallBuilder ids(final Optional> ids) { - this.ids = Objects.requireNonNull(ids, "ids is required"); + public ListCallBuilder id(final Optional> id) { + this.id = Objects.requireNonNull(id, "id is required"); return this; } /** - * Sets the urls parameter. + * Sets the url parameter. * - * @param urls the value of the urls parameter as a {@link java.util.List} of {@link String} + * @param url the value of the url parameter as a {@link java.util.List} of {@link String} * @return the call builder instance */ - public ListCallBuilder urls(final java.util.List urls) { - this.urls = Optional.of(Objects.requireNonNull(urls, "urls is required")); + public ListCallBuilder url(final java.util.List url) { + this.url = Optional.of(Objects.requireNonNull(url, "url is required")); return this; } /** - * Sets (or unsets) the urls parameter. + * Sets (or unsets) the url parameter. * - * @param urls the value of the urls parameter as an {@link Optional} of {@link java.util.List} of {@link String} + * @param url the value of the url parameter as an {@link Optional} of {@link java.util.List} of {@link String} * @return the call builder instance */ - public ListCallBuilder urls(final Optional> urls) { - this.urls = Objects.requireNonNull(urls, "urls is required"); + public ListCallBuilder url(final Optional> url) { + this.url = Objects.requireNonNull(url, "url is required"); return this; } @@ -315,8 +315,8 @@ public class Endpoints { Stream.of( new AbstractMap.SimpleEntry<>("before_id", this.beforeId.map(Function.identity())), new AbstractMap.SimpleEntry<>("limit", this.limit.map(Function.identity())), - new AbstractMap.SimpleEntry<>("ids", Optional.of(this.ids).filter(ids -> !ids.isEmpty()).map(Function.identity())), - new AbstractMap.SimpleEntry<>("urls", Optional.of(this.urls).filter(urls -> !urls.isEmpty()).map(Function.identity())) + new AbstractMap.SimpleEntry<>("id", Optional.of(this.id).filter(id -> !id.isEmpty()).map(Function.identity())), + new AbstractMap.SimpleEntry<>("url", Optional.of(this.url).filter(url -> !url.isEmpty()).map(Function.identity())) ), Stream.empty(), Optional.of(EndpointList.class) diff --git a/src/main/java/com/ngrok/services/Vaults.java b/src/main/java/com/ngrok/services/Vaults.java index 9a3f7f0..4925d6c 100644 --- a/src/main/java/com/ngrok/services/Vaults.java +++ b/src/main/java/com/ngrok/services/Vaults.java @@ -402,6 +402,113 @@ public class Vaults { ); } + /** + * A builder object encapsulating state for an unsent GetSecretsByVault API call. + */ + public class GetSecretsByVaultCallBuilder { + private final String id; + private Optional beforeId = Optional.empty(); + private Optional limit = Optional.empty(); + + private GetSecretsByVaultCallBuilder( + final String id + ) { + this.id = Objects.requireNonNull(id, "id is required"); + } + + /** + * Sets the before_id parameter. + * + * @param beforeId the value of the before_id parameter as a {@link String} + * @return the call builder instance + */ + public GetSecretsByVaultCallBuilder beforeId(final String beforeId) { + this.beforeId = Optional.of(Objects.requireNonNull(beforeId, "beforeId is required")); + return this; + } + + /** + * Sets (or unsets) the before_id parameter. + * + * @param beforeId the value of the before_id parameter as an {@link Optional} of {@link String} + * @return the call builder instance + */ + public GetSecretsByVaultCallBuilder beforeId(final Optional beforeId) { + this.beforeId = Objects.requireNonNull(beforeId, "beforeId is required"); + return this; + } + + /** + * Sets the limit parameter. + * + * @param limit the value of the limit parameter as a {@link String} + * @return the call builder instance + */ + public GetSecretsByVaultCallBuilder limit(final String limit) { + this.limit = Optional.of(Objects.requireNonNull(limit, "limit is required")); + return this; + } + + /** + * Sets (or unsets) the limit parameter. + * + * @param limit the value of the limit parameter as an {@link Optional} of {@link String} + * @return the call builder instance + */ + public GetSecretsByVaultCallBuilder limit(final Optional limit) { + this.limit = Objects.requireNonNull(limit, "limit is required"); + return this; + } + + /** + * Initiates the API call asynchronously. + * + * @return a {@link CompletionStage} of a {@link Page} of {@link SecretList} + */ + public CompletionStage> call() { + return apiClient.sendRequest( + NgrokApiClient.HttpMethod.GET, + "/vaults/" + this.id + "/secrets", + Stream.of( + new AbstractMap.SimpleEntry<>("before_id", this.beforeId.map(Function.identity())), + new AbstractMap.SimpleEntry<>("limit", this.limit.map(Function.identity())) + ), + Stream.empty(), + Optional.of(SecretList.class) + ).thenApply(list -> new Page<>(apiClient, list)); + } + + /** + * Initiates the API call and blocks until it returns. + * + * @return a {@link Page} of {@link SecretList} + * @throws InterruptedException if the thread was interrupted during the call + */ + public Page blockingCall() throws InterruptedException { + try { + return call().toCompletableFuture().get(); + } catch (final ExecutionException e) { + throw e.getCause() instanceof RuntimeException ? (RuntimeException) e.getCause() : new RuntimeException(e.getCause().getMessage(), e.getCause()); + } + } + } + + /** + * Get Secrets by Vault ID + * + * See also https://ngrok.com/docs/api#api-vaults-get-secrets-by-vault. + * + * @param id a resource identifier + * @return a call builder for this API call + */ + public GetSecretsByVaultCallBuilder getSecretsByVault( + final String id + ) { + return new GetSecretsByVaultCallBuilder( + id + ); + } + /** * A builder object encapsulating state for an unsent List API call. */