Skip to content

Commit

Permalink
Merge pull request #117 from AssemblyAI/fern-bot/07-25-2024-0338AM
Browse files Browse the repository at this point in the history
🌿 Fern Regeneration -- July 25, 2024
  • Loading branch information
Swimburger authored Jul 26, 2024
2 parents 3bf02ae + 64689c0 commit ad9b2e9
Show file tree
Hide file tree
Showing 84 changed files with 1,256 additions and 435 deletions.
2 changes: 2 additions & 0 deletions .fernignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ src/main/java/com/assemblyai/api/PollingTranscriptsClient.java
src/main/java/com/assemblyai/api/Transcriber.java
src/main/java/com/assemblyai/api/RealtimeTranscriber.java
src/main/java/com/assemblyai/api/core/Constants.java
src/main/java/com/assemblyai/api/core/ApiError.java
src/main/java/com/assemblyai/api/core/AssemblyAIApiException.java

# Temporarily update deserialization logic
src/main/java/com/assemblyai/api/core/ObjectMappers.java
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
2 changes: 2 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down
30 changes: 30 additions & 0 deletions sample-app/src/main/java/sample/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import com.assemblyai.api.AssemblyAI;
import com.assemblyai.api.RealtimeTranscriber;
import com.assemblyai.api.core.ApiError;
import com.assemblyai.api.core.AssemblyAIApiException;
import com.assemblyai.api.core.AssemblyAIException;
import com.assemblyai.api.resources.files.types.UploadedFile;
import com.assemblyai.api.resources.lemur.requests.LemurQuestionAnswerParams;
import com.assemblyai.api.resources.lemur.requests.LemurTaskParams;
Expand Down Expand Up @@ -94,6 +97,33 @@ public static void main(String... args) throws IOException, InterruptedException
LemurQuestionAnswer qa2 = lemurQuestionAnswerResponse2.getResponse().get(0);
System.out.println("Q&A: " + qa2.getQuestion() + ": " + qa2.getAnswer());

try {
client.lemur().task(LemurTaskParams.builder().prompt("test").build());
} catch (AssemblyAIException e) {
System.out.println("Caught expected AssemblyAIException");
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
System.err.println("This error should've been AssemblyAIException, but is not.");
}

try {
client.lemur().task(LemurTaskParams.builder().prompt("test").build());
} catch (AssemblyAIApiException e) {
System.out.println("Caught expected AssemblyAIApiException");
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
System.err.println("This error should've been AssemblyAIApiException, but is not.");
}

try {
client.lemur().task(LemurTaskParams.builder().prompt("test").build());
} catch (ApiError e) {
System.out.println("Caught expected ApiError");
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
System.err.println("This error should've been ApiError, but is not.");
}

transcript = client.transcripts().delete(transcript.getId());
System.out.println("Delete transcript. " + transcript);

Expand Down
28 changes: 22 additions & 6 deletions src/main/java/com/assemblyai/api/core/ApiError.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,44 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.assemblyai.api.core;

public final class ApiError extends RuntimeException {
/**
* This exception type will be thrown for any non-2XX API responses.
* @deprecated Use {@link AssemblyAIApiException}. ApiError will be removed in a future release.
*/
@Deprecated
public class ApiError extends AssemblyAIException {
/**
* The error code of the response that triggered the exception.
*/
private final int statusCode;

/**
* The body of the response that triggered the exception.
*/
private final Object body;

public ApiError(int statusCode, Object body) {
public ApiError(String message, int statusCode, Object body) {
super(message);
this.statusCode = statusCode;
this.body = body;
}

/**
* @return the statusCode
*/
public int statusCode() {
return this.statusCode;
}

/**
* @return the body
*/
public Object body() {
return this.body;
}

@java.lang.Override
public String toString() {
return "ApiError{" + "statusCode: " + statusCode + ", body: " + body + "}";
return "AssemblyAIApiException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: "
+ body + "}";
}
}
10 changes: 10 additions & 0 deletions src/main/java/com/assemblyai/api/core/AssemblyAIApiException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.assemblyai.api.core;

/**
* This exception type will be thrown for any non-2XX API responses.
*/
public class AssemblyAIApiException extends ApiError {
public AssemblyAIApiException(String message, int statusCode, Object body) {
super(message, statusCode, body);
}
}
17 changes: 17 additions & 0 deletions src/main/java/com/assemblyai/api/core/AssemblyAIException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.assemblyai.api.core;

/**
* This class serves as the base exception for all errors in the SDK.
*/
public class AssemblyAIException extends RuntimeException {
public AssemblyAIException(String message) {
super(message);
}

public AssemblyAIException(String message, Exception e) {
super(message, e);
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/assemblyai/api/core/RequestOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static Builder builder() {
public static final class Builder {
private String apiKey = null;

private Optional<Integer> timeout = null;
private Optional<Integer> timeout = Optional.empty();

private TimeUnit timeoutTimeUnit = TimeUnit.SECONDS;

Expand Down
45 changes: 45 additions & 0 deletions src/main/java/com/assemblyai/api/core/ResponseBodyInputStream.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.assemblyai.api.core;

import java.io.FilterInputStream;
import java.io.IOException;
import okhttp3.Response;

/**
* A custom InputStream that wraps the InputStream from the OkHttp Response and ensures that the
* OkHttp Response object is properly closed when the stream is closed.
*
* This class extends FilterInputStream and takes an OkHttp Response object as a parameter.
* It retrieves the InputStream from the Response and overrides the close method to close
* both the InputStream and the Response object, ensuring proper resource management and preventing
* premature closure of the underlying HTTP connection.
*/
public class ResponseBodyInputStream extends FilterInputStream {
private final Response response;

/**
* Constructs a ResponseBodyInputStream that wraps the InputStream from the given OkHttp
* Response object.
*
* @param response the OkHttp Response object from which the InputStream is retrieved
* @throws IOException if an I/O error occurs while retrieving the InputStream
*/
public ResponseBodyInputStream(Response response) throws IOException {
super(response.body().byteStream());
this.response = response;
}

/**
* Closes the InputStream and the associated OkHttp Response object. This ensures that the
* underlying HTTP connection is properly closed after the stream is no longer needed.
*
* @throws IOException if an I/O error occurs
*/
@Override
public void close() throws IOException {
super.close();
response.close(); // Ensure the response is closed when the stream is closed
}
}
44 changes: 44 additions & 0 deletions src/main/java/com/assemblyai/api/core/ResponseBodyReader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.assemblyai.api.core;

import java.io.FilterReader;
import java.io.IOException;
import okhttp3.Response;

/**
* A custom Reader that wraps the Reader from the OkHttp Response and ensures that the
* OkHttp Response object is properly closed when the reader is closed.
*
* This class extends FilterReader and takes an OkHttp Response object as a parameter.
* It retrieves the Reader from the Response and overrides the close method to close
* both the Reader and the Response object, ensuring proper resource management and preventing
* premature closure of the underlying HTTP connection.
*/
public class ResponseBodyReader extends FilterReader {
private final Response response;

/**
* Constructs a ResponseBodyReader that wraps the Reader from the given OkHttp Response object.
*
* @param response the OkHttp Response object from which the Reader is retrieved
* @throws IOException if an I/O error occurs while retrieving the Reader
*/
public ResponseBodyReader(Response response) throws IOException {
super(response.body().charStream());
this.response = response;
}

/**
* Closes the Reader and the associated OkHttp Response object. This ensures that the
* underlying HTTP connection is properly closed after the reader is no longer needed.
*
* @throws IOException if an I/O error occurs
*/
@Override
public void close() throws IOException {
super.close();
response.close(); // Ensure the response is closed when the reader is closed
}
}
27 changes: 27 additions & 0 deletions src/main/java/com/assemblyai/api/errors/BadRequestError.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.assemblyai.api.errors;

import com.assemblyai.api.core.AssemblyAIApiException;
import com.assemblyai.api.types.Error;

public final class BadRequestError extends AssemblyAIApiException {
/**
* The body of the response that triggered the exception.
*/
private final Error body;

public BadRequestError(Error body) {
super("BadRequestError", 400, body);
this.body = body;
}

/**
* @return the body
*/
@java.lang.Override
public Error body() {
return this.body;
}
}
26 changes: 26 additions & 0 deletions src/main/java/com/assemblyai/api/errors/GatewayTimeoutError.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.assemblyai.api.errors;

import com.assemblyai.api.core.AssemblyAIApiException;

public final class GatewayTimeoutError extends AssemblyAIApiException {
/**
* The body of the response that triggered the exception.
*/
private final Object body;

public GatewayTimeoutError(Object body) {
super("GatewayTimeoutError", 504, body);
this.body = body;
}

/**
* @return the body
*/
@java.lang.Override
public Object body() {
return this.body;
}
}
27 changes: 27 additions & 0 deletions src/main/java/com/assemblyai/api/errors/InternalServerError.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.assemblyai.api.errors;

import com.assemblyai.api.core.AssemblyAIApiException;
import com.assemblyai.api.types.Error;

public final class InternalServerError extends AssemblyAIApiException {
/**
* The body of the response that triggered the exception.
*/
private final Error body;

public InternalServerError(Error body) {
super("InternalServerError", 500, body);
this.body = body;
}

/**
* @return the body
*/
@java.lang.Override
public Error body() {
return this.body;
}
}
27 changes: 27 additions & 0 deletions src/main/java/com/assemblyai/api/errors/NotFoundError.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.assemblyai.api.errors;

import com.assemblyai.api.core.AssemblyAIApiException;
import com.assemblyai.api.types.Error;

public final class NotFoundError extends AssemblyAIApiException {
/**
* The body of the response that triggered the exception.
*/
private final Error body;

public NotFoundError(Error body) {
super("NotFoundError", 404, body);
this.body = body;
}

/**
* @return the body
*/
@java.lang.Override
public Error body() {
return this.body;
}
}
Loading

0 comments on commit ad9b2e9

Please sign in to comment.