Files
ngrok-api-java/src/main/java/com/ngrok/services/Vaults.java
T
2026-01-23 21:37:44 +00:00

649 lines
23 KiB
Java

/* Code generated for API Clients. DO NOT EDIT. */
package com.ngrok.services;
import com.ngrok.NgrokApiClient;
import com.ngrok.definitions.*;
import java.util.AbstractMap;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
import java.util.function.Function;
import java.util.stream.Stream;
/**
* Vaults is an api service for securely storing and managing sensitive data such
* as secrets, credentials, and tokens.
*
* See also <a href="https://ngrok.com/docs/api#api-vaults">https://ngrok.com/docs/api#api-vaults</a>.
*/
public class Vaults {
private final NgrokApiClient apiClient;
/**
* Creates a new sub-client for Vaults.
*
* @param apiClient an instance of {@link com.ngrok.NgrokApiClient}
*/
public Vaults(final NgrokApiClient apiClient) {
this.apiClient = Objects.requireNonNull(apiClient, "apiClient is required");
}
/**
* A builder object encapsulating state for an unsent Create API call.
*/
public class CreateCallBuilder {
private Optional<String> name = Optional.empty();
private Optional<String> metadata = Optional.empty();
private Optional<String> description = Optional.empty();
private CreateCallBuilder(
) {
}
/**
* Name of vault
*
* @param name the value of the name parameter as a {@link String}
* @return the call builder instance
*/
public CreateCallBuilder name(final String name) {
this.name = Optional.of(Objects.requireNonNull(name, "name is required"));
return this;
}
/**
* Name of vault
*
* @param name the value of the name parameter as an {@link Optional} of {@link String}
* @return the call builder instance
*/
public CreateCallBuilder name(final Optional<String> name) {
this.name = Objects.requireNonNull(name, "name is required");
return this;
}
/**
* Arbitrary user-defined metadata for this Vault
*
* @param metadata the value of the metadata parameter as a {@link String}
* @return the call builder instance
*/
public CreateCallBuilder metadata(final String metadata) {
this.metadata = Optional.of(Objects.requireNonNull(metadata, "metadata is required"));
return this;
}
/**
* Arbitrary user-defined metadata for this Vault
*
* @param metadata the value of the metadata parameter as an {@link Optional} of {@link String}
* @return the call builder instance
*/
public CreateCallBuilder metadata(final Optional<String> metadata) {
this.metadata = Objects.requireNonNull(metadata, "metadata is required");
return this;
}
/**
* description of Vault
*
* @param description the value of the description parameter as a {@link String}
* @return the call builder instance
*/
public CreateCallBuilder description(final String description) {
this.description = Optional.of(Objects.requireNonNull(description, "description is required"));
return this;
}
/**
* description of Vault
*
* @param description the value of the description parameter as an {@link Optional} of {@link String}
* @return the call builder instance
*/
public CreateCallBuilder description(final Optional<String> description) {
this.description = Objects.requireNonNull(description, "description is required");
return this;
}
/**
* Initiates the API call asynchronously.
*
* @return a {@link CompletionStage} of {@link Vault}
*/
public CompletionStage<Vault> call() {
return apiClient.sendRequest(
NgrokApiClient.HttpMethod.POST,
"/vaults",
Stream.empty(),
Stream.of(
new AbstractMap.SimpleEntry<>("name", this.name.map(Function.identity())),
new AbstractMap.SimpleEntry<>("metadata", this.metadata.map(Function.identity())),
new AbstractMap.SimpleEntry<>("description", this.description.map(Function.identity()))
),
Optional.of(Vault.class)
);
}
/**
* Initiates the API call and blocks until it returns.
*
* @return {@link Vault}
* @throws InterruptedException if the thread was interrupted during the call
*/
public Vault 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());
}
}
}
/**
* Create a new Vault
*
* See also <a href="https://ngrok.com/docs/api#api-vaults-create">https://ngrok.com/docs/api#api-vaults-create</a>.
*
* @return a call builder for this API call
*/
public CreateCallBuilder create(
) {
return new CreateCallBuilder(
);
}
/**
* A builder object encapsulating state for an unsent Update API call.
*/
public class UpdateCallBuilder {
private final String id;
private Optional<String> name = Optional.empty();
private Optional<String> metadata = Optional.empty();
private Optional<String> description = Optional.empty();
private UpdateCallBuilder(
final String id
) {
this.id = Objects.requireNonNull(id, "id is required");
}
/**
* Name of vault
*
* @param name the value of the name parameter as a {@link String}
* @return the call builder instance
*/
public UpdateCallBuilder name(final String name) {
this.name = Optional.of(Objects.requireNonNull(name, "name is required"));
return this;
}
/**
* Name of vault
*
* @param name the value of the name parameter as an {@link Optional} of {@link String}
* @return the call builder instance
*/
public UpdateCallBuilder name(final Optional<String> name) {
this.name = Objects.requireNonNull(name, "name is required");
return this;
}
/**
* Arbitrary user-defined metadata for this Vault
*
* @param metadata the value of the metadata parameter as a {@link String}
* @return the call builder instance
*/
public UpdateCallBuilder metadata(final String metadata) {
this.metadata = Optional.of(Objects.requireNonNull(metadata, "metadata is required"));
return this;
}
/**
* Arbitrary user-defined metadata for this Vault
*
* @param metadata the value of the metadata parameter as an {@link Optional} of {@link String}
* @return the call builder instance
*/
public UpdateCallBuilder metadata(final Optional<String> metadata) {
this.metadata = Objects.requireNonNull(metadata, "metadata is required");
return this;
}
/**
* description of Vault
*
* @param description the value of the description parameter as a {@link String}
* @return the call builder instance
*/
public UpdateCallBuilder description(final String description) {
this.description = Optional.of(Objects.requireNonNull(description, "description is required"));
return this;
}
/**
* description of Vault
*
* @param description the value of the description parameter as an {@link Optional} of {@link String}
* @return the call builder instance
*/
public UpdateCallBuilder description(final Optional<String> description) {
this.description = Objects.requireNonNull(description, "description is required");
return this;
}
/**
* Initiates the API call asynchronously.
*
* @return a {@link CompletionStage} of {@link Vault}
*/
public CompletionStage<Vault> call() {
return apiClient.sendRequest(
NgrokApiClient.HttpMethod.PATCH,
"/vaults/" + this.id,
Stream.empty(),
Stream.of(
new AbstractMap.SimpleEntry<>("name", this.name.map(Function.identity())),
new AbstractMap.SimpleEntry<>("metadata", this.metadata.map(Function.identity())),
new AbstractMap.SimpleEntry<>("description", this.description.map(Function.identity()))
),
Optional.of(Vault.class)
);
}
/**
* Initiates the API call and blocks until it returns.
*
* @return {@link Vault}
* @throws InterruptedException if the thread was interrupted during the call
*/
public Vault 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());
}
}
}
/**
* Update an existing Vault by ID
*
* See also <a href="https://ngrok.com/docs/api#api-vaults-update">https://ngrok.com/docs/api#api-vaults-update</a>.
*
* @param id identifier for Vault
* @return a call builder for this API call
*/
public UpdateCallBuilder update(
final String id
) {
return new UpdateCallBuilder(
id
);
}
/**
* A builder object encapsulating state for an unsent Delete API call.
*/
public class DeleteCallBuilder {
private final String id;
private DeleteCallBuilder(
final String id
) {
this.id = Objects.requireNonNull(id, "id is required");
}
/**
* Initiates the API call asynchronously.
*
* @return a {@link CompletionStage} of {@link Void}
*/
public CompletionStage<Void> call() {
return apiClient.sendRequest(
NgrokApiClient.HttpMethod.DELETE,
"/vaults/" + this.id,
Stream.empty(),
Stream.empty(),
Optional.empty()
);
}
/**
* Initiates the API call and blocks until it returns.
*
* @throws InterruptedException if the thread was interrupted during the call
*/
public void blockingCall() throws InterruptedException {
try {
call().toCompletableFuture().get();
} catch (final ExecutionException e) {
throw e.getCause() instanceof RuntimeException ? (RuntimeException) e.getCause() : new RuntimeException(e.getCause().getMessage(), e.getCause());
}
}
}
/**
* Delete a Vault
*
* See also <a href="https://ngrok.com/docs/api#api-vaults-delete">https://ngrok.com/docs/api#api-vaults-delete</a>.
*
* @param id a resource identifier
* @return a call builder for this API call
*/
public DeleteCallBuilder delete(
final String id
) {
return new DeleteCallBuilder(
id
);
}
/**
* A builder object encapsulating state for an unsent Get API call.
*/
public class GetCallBuilder {
private final String id;
private GetCallBuilder(
final String id
) {
this.id = Objects.requireNonNull(id, "id is required");
}
/**
* Initiates the API call asynchronously.
*
* @return a {@link CompletionStage} of {@link Vault}
*/
public CompletionStage<Vault> call() {
return apiClient.sendRequest(
NgrokApiClient.HttpMethod.GET,
"/vaults/" + this.id,
Stream.empty(),
Stream.empty(),
Optional.of(Vault.class)
);
}
/**
* Initiates the API call and blocks until it returns.
*
* @return {@link Vault}
* @throws InterruptedException if the thread was interrupted during the call
*/
public Vault 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 a Vault by ID
*
* See also <a href="https://ngrok.com/docs/api#api-vaults-get">https://ngrok.com/docs/api#api-vaults-get</a>.
*
* @param id a resource identifier
* @return a call builder for this API call
*/
public GetCallBuilder get(
final String id
) {
return new GetCallBuilder(
id
);
}
/**
* A builder object encapsulating state for an unsent GetSecretsByVault API call.
*/
public class GetSecretsByVaultCallBuilder {
private final String id;
private Optional<String> beforeId = Optional.empty();
private Optional<String> limit = Optional.empty();
private GetSecretsByVaultCallBuilder(
final String id
) {
this.id = Objects.requireNonNull(id, "id is required");
}
/**
* Sets the <code>before_id</code> 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 <code>before_id</code> 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<String> beforeId) {
this.beforeId = Objects.requireNonNull(beforeId, "beforeId is required");
return this;
}
/**
* Sets the <code>limit</code> 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 <code>limit</code> 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<String> 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<Page<SecretList>> 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<SecretList> 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 <a href="https://ngrok.com/docs/api#api-vaults-get-secrets-by-vault">https://ngrok.com/docs/api#api-vaults-get-secrets-by-vault</a>.
*
* @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.
*/
public class ListCallBuilder {
private Optional<String> beforeId = Optional.empty();
private Optional<String> limit = Optional.empty();
private Optional<String> filter = Optional.empty();
private ListCallBuilder(
) {
}
/**
* Expects a resource ID as its input. Returns earlier entries in the result set,
* sorted by ID.
*
* @param beforeId the value of the before_id parameter as a {@link String}
* @return the call builder instance
*/
public ListCallBuilder beforeId(final String beforeId) {
this.beforeId = Optional.of(Objects.requireNonNull(beforeId, "beforeId is required"));
return this;
}
/**
* Expects a resource ID as its input. Returns earlier entries in the result set,
* sorted by ID.
*
* @param beforeId the value of the before_id parameter as an {@link Optional} of {@link String}
* @return the call builder instance
*/
public ListCallBuilder beforeId(final Optional<String> beforeId) {
this.beforeId = Objects.requireNonNull(beforeId, "beforeId is required");
return this;
}
/**
* Constrains the number of results in the dataset. See the <a
* href="https://ngrok.com/docs/api/index#pagination">API Overview</a> for details.
*
* @param limit the value of the limit parameter as a {@link String}
* @return the call builder instance
*/
public ListCallBuilder limit(final String limit) {
this.limit = Optional.of(Objects.requireNonNull(limit, "limit is required"));
return this;
}
/**
* Constrains the number of results in the dataset. See the <a
* href="https://ngrok.com/docs/api/index#pagination">API Overview</a> for details.
*
* @param limit the value of the limit parameter as an {@link Optional} of {@link String}
* @return the call builder instance
*/
public ListCallBuilder limit(final Optional<String> limit) {
this.limit = Objects.requireNonNull(limit, "limit is required");
return this;
}
/**
* A CEL expression to filter the list results. Supports logical and comparison
* operators to match on fields such as <code>id</code>, <code>metadata</code>,
* <code>created_at</code>, and more. See ngrok API Filtering for syntax and field
* details: <a
* href="https://ngrok.com/docs/api/api-filtering">https://ngrok.com/docs/api/api-filtering</a>.
*
* @param filter the value of the filter parameter as a {@link String}
* @return the call builder instance
*/
public ListCallBuilder filter(final String filter) {
this.filter = Optional.of(Objects.requireNonNull(filter, "filter is required"));
return this;
}
/**
* A CEL expression to filter the list results. Supports logical and comparison
* operators to match on fields such as <code>id</code>, <code>metadata</code>,
* <code>created_at</code>, and more. See ngrok API Filtering for syntax and field
* details: <a
* href="https://ngrok.com/docs/api/api-filtering">https://ngrok.com/docs/api/api-filtering</a>.
*
* @param filter the value of the filter parameter as an {@link Optional} of {@link String}
* @return the call builder instance
*/
public ListCallBuilder filter(final Optional<String> filter) {
this.filter = Objects.requireNonNull(filter, "filter is required");
return this;
}
/**
* Initiates the API call asynchronously.
*
* @return a {@link CompletionStage} of a {@link Page} of {@link VaultList}
*/
public CompletionStage<Page<VaultList>> call() {
return apiClient.sendRequest(
NgrokApiClient.HttpMethod.GET,
"/vaults",
Stream.of(
new AbstractMap.SimpleEntry<>("before_id", this.beforeId.map(Function.identity())),
new AbstractMap.SimpleEntry<>("limit", this.limit.map(Function.identity())),
new AbstractMap.SimpleEntry<>("filter", this.filter.map(Function.identity()))
),
Stream.empty(),
Optional.of(VaultList.class)
).thenApply(list -> new Page<>(apiClient, list));
}
/**
* Initiates the API call and blocks until it returns.
*
* @return a {@link Page} of {@link VaultList}
* @throws InterruptedException if the thread was interrupted during the call
*/
public Page<VaultList> 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());
}
}
}
/**
* List all Vaults owned by account
*
* See also <a href="https://ngrok.com/docs/api#api-vaults-list">https://ngrok.com/docs/api#api-vaults-list</a>.
*
* @return a call builder for this API call
*/
public ListCallBuilder list(
) {
return new ListCallBuilder(
);
}
}