Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
311 changes: 311 additions & 0 deletions src/main/java/AsyncCambApiClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,311 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import core.CambApiApiException;
import core.CambApiException;
import core.ClientOptions;
import core.ObjectMappers;
import core.RequestOptions;
import core.Suppliers;
import java.io.IOException;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.util.concurrent.CompletableFuture;
import java.util.function.Supplier;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.jetbrains.annotations.NotNull;
import resources.audioseparation.AsyncAudioSeparationClient;
import resources.deprecatedstreaming.AsyncDeprecatedStreamingClient;
import resources.dictionaries.AsyncDictionariesClient;
import resources.dub.AsyncDubClient;
import resources.folders.AsyncFoldersClient;
import resources.languages.AsyncLanguagesClient;
import resources.projectsetup.AsyncProjectSetupClient;
import resources.story.AsyncStoryClient;
import resources.streaming.AsyncStreamingClient;
import resources.texttoaudio.AsyncTextToAudioClient;
import resources.texttospeech.AsyncTextToSpeechClient;
import resources.texttovoice.AsyncTextToVoiceClient;
import resources.transcription.AsyncTranscriptionClient;
import resources.translatedstory.AsyncTranslatedStoryClient;
import resources.translatedtts.AsyncTranslatedTtsClient;
import resources.translation.AsyncTranslationClient;
import resources.voicecloning.AsyncVoiceCloningClient;

public class AsyncCambApiClient {
protected final ClientOptions clientOptions;

protected final Supplier<AsyncAudioSeparationClient> audioSeparationClient;

protected final Supplier<AsyncDubClient> dubClient;

protected final Supplier<AsyncFoldersClient> foldersClient;

protected final Supplier<AsyncLanguagesClient> languagesClient;

protected final Supplier<AsyncStoryClient> storyClient;

protected final Supplier<AsyncTranslatedStoryClient> translatedStoryClient;

protected final Supplier<AsyncTextToAudioClient> textToAudioClient;

protected final Supplier<AsyncTextToVoiceClient> textToVoiceClient;

protected final Supplier<AsyncTextToSpeechClient> textToSpeechClient;

protected final Supplier<AsyncTranslationClient> translationClient;

protected final Supplier<AsyncTranscriptionClient> transcriptionClient;

protected final Supplier<AsyncTranslatedTtsClient> translatedTtsClient;

protected final Supplier<AsyncStreamingClient> streamingClient;

protected final Supplier<AsyncVoiceCloningClient> voiceCloningClient;

protected final Supplier<AsyncDictionariesClient> dictionariesClient;

protected final Supplier<AsyncProjectSetupClient> projectSetupClient;

protected final Supplier<AsyncDeprecatedStreamingClient> deprecatedStreamingClient;

public AsyncCambApiClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.audioSeparationClient = Suppliers.memoize(() -> new AsyncAudioSeparationClient(clientOptions));
this.dubClient = Suppliers.memoize(() -> new AsyncDubClient(clientOptions));
this.foldersClient = Suppliers.memoize(() -> new AsyncFoldersClient(clientOptions));
this.languagesClient = Suppliers.memoize(() -> new AsyncLanguagesClient(clientOptions));
this.storyClient = Suppliers.memoize(() -> new AsyncStoryClient(clientOptions));
this.translatedStoryClient = Suppliers.memoize(() -> new AsyncTranslatedStoryClient(clientOptions));
this.textToAudioClient = Suppliers.memoize(() -> new AsyncTextToAudioClient(clientOptions));
this.textToVoiceClient = Suppliers.memoize(() -> new AsyncTextToVoiceClient(clientOptions));
this.textToSpeechClient = Suppliers.memoize(() -> new AsyncTextToSpeechClient(clientOptions));
this.translationClient = Suppliers.memoize(() -> new AsyncTranslationClient(clientOptions));
this.transcriptionClient = Suppliers.memoize(() -> new AsyncTranscriptionClient(clientOptions));
this.translatedTtsClient = Suppliers.memoize(() -> new AsyncTranslatedTtsClient(clientOptions));
this.streamingClient = Suppliers.memoize(() -> new AsyncStreamingClient(clientOptions));
this.voiceCloningClient = Suppliers.memoize(() -> new AsyncVoiceCloningClient(clientOptions));
this.dictionariesClient = Suppliers.memoize(() -> new AsyncDictionariesClient(clientOptions));
this.projectSetupClient = Suppliers.memoize(() -> new AsyncProjectSetupClient(clientOptions));
this.deprecatedStreamingClient = Suppliers.memoize(() -> new AsyncDeprecatedStreamingClient(clientOptions));
}

public CompletableFuture<Object> getSwaggerDocsDocsGet() {
return getSwaggerDocsDocsGet(null);
}

public CompletableFuture<Object> getSwaggerDocsDocsGet(RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder()

.addPathSegments("docs")
.build();
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("GET", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
CompletableFuture<Object> future = new CompletableFuture<>();
client.newCall(okhttpRequest).enqueue(new Callback() {
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
if (response.isSuccessful()) {
future.complete(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Object.class));
return;
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
future.completeExceptionally(new CambApiApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)));
return;
}
catch (IOException e) {
future.completeExceptionally(new CambApiException("Network error executing HTTP request", e));
}
}

@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
future.completeExceptionally(new CambApiException("Network error executing HTTP request", e));
}
});
return future;
}

public CompletableFuture<Object> getRedocDocsRedocsGet() {
return getRedocDocsRedocsGet(null);
}

public CompletableFuture<Object> getRedocDocsRedocsGet(RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder()

.addPathSegments("redocs")
.build();
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("GET", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
CompletableFuture<Object> future = new CompletableFuture<>();
client.newCall(okhttpRequest).enqueue(new Callback() {
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
if (response.isSuccessful()) {
future.complete(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Object.class));
return;
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
future.completeExceptionally(new CambApiApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)));
return;
}
catch (IOException e) {
future.completeExceptionally(new CambApiException("Network error executing HTTP request", e));
}
}

@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
future.completeExceptionally(new CambApiException("Network error executing HTTP request", e));
}
});
return future;
}

public CompletableFuture<Object> getOpenapiSchemaOpenapiJsonGet() {
return getOpenapiSchemaOpenapiJsonGet(null);
}

public CompletableFuture<Object> getOpenapiSchemaOpenapiJsonGet(RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder()

.addPathSegments("openapi.json")
.build();
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("GET", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
CompletableFuture<Object> future = new CompletableFuture<>();
client.newCall(okhttpRequest).enqueue(new Callback() {
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
if (response.isSuccessful()) {
future.complete(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Object.class));
return;
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
future.completeExceptionally(new CambApiApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)));
return;
}
catch (IOException e) {
future.completeExceptionally(new CambApiException("Network error executing HTTP request", e));
}
}

@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
future.completeExceptionally(new CambApiException("Network error executing HTTP request", e));
}
});
return future;
}

public AsyncAudioSeparationClient audioSeparation() {
return this.audioSeparationClient.get();
}

public AsyncDubClient dub() {
return this.dubClient.get();
}

public AsyncFoldersClient folders() {
return this.foldersClient.get();
}

public AsyncLanguagesClient languages() {
return this.languagesClient.get();
}

public AsyncStoryClient story() {
return this.storyClient.get();
}

public AsyncTranslatedStoryClient translatedStory() {
return this.translatedStoryClient.get();
}

public AsyncTextToAudioClient textToAudio() {
return this.textToAudioClient.get();
}

public AsyncTextToVoiceClient textToVoice() {
return this.textToVoiceClient.get();
}

public AsyncTextToSpeechClient textToSpeech() {
return this.textToSpeechClient.get();
}

public AsyncTranslationClient translation() {
return this.translationClient.get();
}

public AsyncTranscriptionClient transcription() {
return this.transcriptionClient.get();
}

public AsyncTranslatedTtsClient translatedTts() {
return this.translatedTtsClient.get();
}

public AsyncStreamingClient streaming() {
return this.streamingClient.get();
}

public AsyncVoiceCloningClient voiceCloning() {
return this.voiceCloningClient.get();
}

public AsyncDictionariesClient dictionaries() {
return this.dictionariesClient.get();
}

public AsyncProjectSetupClient projectSetup() {
return this.projectSetupClient.get();
}

public AsyncDeprecatedStreamingClient deprecatedStreaming() {
return this.deprecatedStreamingClient.get();
}

public static AsyncCambApiClientBuilder builder() {
return new AsyncCambApiClientBuilder();
}
}
59 changes: 59 additions & 0 deletions src/main/java/AsyncCambApiClientBuilder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import core.ClientOptions;
import core.Environment;
import java.lang.String;
import okhttp3.OkHttpClient;

public final class AsyncCambApiClientBuilder {
private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder();

private String apiKey = null;

private Environment environment = Environment.DEFAULT;

/**
* Sets apiKey
*/
public AsyncCambApiClientBuilder apiKey(String apiKey) {
this.apiKey = apiKey;
return this;
}

public AsyncCambApiClientBuilder environment(Environment environment) {
this.environment = environment;
return this;
}

public AsyncCambApiClientBuilder url(String url) {
this.environment = Environment.custom(url);
return this;
}

/**
* Sets the timeout (in seconds) for the client
*/
public AsyncCambApiClientBuilder timeout(int timeout) {
this.clientOptionsBuilder.timeout(timeout);
return this;
}

/**
* Sets the underlying OkHttp client
*/
public AsyncCambApiClientBuilder httpClient(OkHttpClient httpClient) {
this.clientOptionsBuilder.httpClient(httpClient);
return this;
}

public AsyncCambApiClient build() {
if (apiKey == null) {
throw new RuntimeException("Please provide apiKey");
}
this.clientOptionsBuilder.addHeader("x-api-key", this.apiKey);
clientOptionsBuilder.environment(this.environment);
return new AsyncCambApiClient(clientOptionsBuilder.build());
}
}
3 changes: 3 additions & 0 deletions src/main/java/CambApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public Object getSwaggerDocsDocsGet(RequestOptions requestOptions) {
.method("GET", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
Expand Down Expand Up @@ -140,6 +141,7 @@ public Object getRedocDocsRedocsGet(RequestOptions requestOptions) {
.method("GET", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
Expand Down Expand Up @@ -172,6 +174,7 @@ public Object getOpenapiSchemaOpenapiJsonGet(RequestOptions requestOptions) {
.method("GET", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
Expand Down
Loading
Loading