Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 55be27f

Browse files
committed
SDK regeneration
1 parent 2b44044 commit 55be27f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+467
-262
lines changed

gradle/wrapper/gradle-wrapper.jar

79 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* This file was auto-generated by Fern from our API Definition.
3+
*/
4+
package com.assemblyai.api.core;
5+
6+
import java.io.InputStream;
7+
import java.util.Objects;
8+
import okhttp3.MediaType;
9+
import okhttp3.RequestBody;
10+
import org.jetbrains.annotations.Nullable;
11+
12+
/**
13+
* Represents a file stream with associated metadata for file uploads.
14+
*/
15+
public class FileStream {
16+
private final InputStream inputStream;
17+
private final String fileName;
18+
private final MediaType contentType;
19+
20+
/**
21+
* Constructs a FileStream with the given input stream and optional metadata.
22+
*
23+
* @param inputStream The input stream of the file content. Must not be null.
24+
* @param fileName The name of the file, or null if unknown.
25+
* @param contentType The MIME type of the file content, or null if unknown.
26+
* @throws NullPointerException if inputStream is null
27+
*/
28+
public FileStream(InputStream inputStream, @Nullable String fileName, @Nullable MediaType contentType) {
29+
this.inputStream = Objects.requireNonNull(inputStream, "Input stream cannot be null");
30+
this.fileName = fileName;
31+
this.contentType = contentType;
32+
}
33+
34+
public FileStream(InputStream inputStream) {
35+
this(inputStream, null, null);
36+
}
37+
38+
public InputStream getInputStream() {
39+
return inputStream;
40+
}
41+
42+
@Nullable
43+
public String getFileName() {
44+
return fileName;
45+
}
46+
47+
@Nullable
48+
public MediaType getContentType() {
49+
return contentType;
50+
}
51+
52+
/**
53+
* Creates a RequestBody suitable for use with OkHttp client.
54+
*
55+
* @return A RequestBody instance representing this file stream.
56+
*/
57+
public RequestBody toRequestBody() {
58+
return new InputStreamRequestBody(contentType, inputStream);
59+
}
60+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/**
2+
* This file was auto-generated by Fern from our API Definition.
3+
*/
4+
package com.assemblyai.api.core;
5+
6+
import java.io.IOException;
7+
import java.io.InputStream;
8+
import java.util.Objects;
9+
import okhttp3.MediaType;
10+
import okhttp3.RequestBody;
11+
import okhttp3.internal.Util;
12+
import okio.BufferedSink;
13+
import okio.Okio;
14+
import okio.Source;
15+
import org.jetbrains.annotations.Nullable;
16+
17+
/**
18+
* A custom implementation of OkHttp's RequestBody that wraps an InputStream.
19+
* This class allows streaming of data from an InputStream directly to an HTTP request body,
20+
* which is useful for file uploads or sending large amounts of data without loading it all into memory.
21+
*/
22+
public class InputStreamRequestBody extends RequestBody {
23+
private final InputStream inputStream;
24+
private final MediaType contentType;
25+
26+
/**
27+
* Constructs an InputStreamRequestBody with the specified content type and input stream.
28+
*
29+
* @param contentType the MediaType of the content, or null if not known
30+
* @param inputStream the InputStream containing the data to be sent
31+
* @throws NullPointerException if inputStream is null
32+
*/
33+
public InputStreamRequestBody(@Nullable MediaType contentType, InputStream inputStream) {
34+
this.contentType = contentType;
35+
this.inputStream = Objects.requireNonNull(inputStream, "inputStream == null");
36+
}
37+
38+
/**
39+
* Returns the content type of this request body.
40+
*
41+
* @return the MediaType of the content, or null if not specified
42+
*/
43+
@Nullable
44+
@Override
45+
public MediaType contentType() {
46+
return contentType;
47+
}
48+
49+
/**
50+
* Returns the content length of this request body, if known.
51+
* This method attempts to determine the length using the InputStream's available() method,
52+
* which may not always accurately reflect the total length of the stream.
53+
*
54+
* @return the content length, or -1 if the length is unknown
55+
* @throws IOException if an I/O error occurs
56+
*/
57+
@Override
58+
public long contentLength() throws IOException {
59+
return inputStream.available() == 0 ? -1 : inputStream.available();
60+
}
61+
62+
/**
63+
* Writes the content of the InputStream to the given BufferedSink.
64+
* This method is responsible for transferring the data from the InputStream to the network request.
65+
*
66+
* @param sink the BufferedSink to write the content to
67+
* @throws IOException if an I/O error occurs during writing
68+
*/
69+
@Override
70+
public void writeTo(BufferedSink sink) throws IOException {
71+
Source source = null;
72+
try {
73+
source = Okio.source(inputStream);
74+
sink.writeAll(source);
75+
} finally {
76+
Util.closeQuietly(Objects.requireNonNull(source));
77+
}
78+
}
79+
}

src/main/java/com/assemblyai/api/resources/files/FilesClient.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.assemblyai.api.core.AssemblyAIApiException;
77
import com.assemblyai.api.core.AssemblyAIException;
88
import com.assemblyai.api.core.ClientOptions;
9+
import com.assemblyai.api.core.InputStreamRequestBody;
910
import com.assemblyai.api.core.ObjectMappers;
1011
import com.assemblyai.api.core.RequestOptions;
1112
import com.assemblyai.api.errors.BadRequestError;
@@ -18,9 +19,12 @@
1819
import com.assemblyai.api.resources.files.types.UploadedFile;
1920
import com.assemblyai.api.types.Error;
2021
import com.fasterxml.jackson.core.JsonProcessingException;
22+
import java.io.ByteArrayInputStream;
2123
import java.io.IOException;
24+
import java.io.InputStream;
2225
import okhttp3.Headers;
2326
import okhttp3.HttpUrl;
27+
import okhttp3.MediaType;
2428
import okhttp3.OkHttpClient;
2529
import okhttp3.Request;
2630
import okhttp3.RequestBody;
@@ -37,24 +41,23 @@ public FilesClient(ClientOptions clientOptions) {
3741
/**
3842
* Upload a media file to AssemblyAI's servers.
3943
*/
40-
public UploadedFile upload(byte[] request) {
44+
public UploadedFile upload(InputStream request) {
4145
return upload(request, null);
4246
}
4347

4448
/**
4549
* Upload a media file to AssemblyAI's servers.
4650
*/
47-
public UploadedFile upload(byte[] request, RequestOptions requestOptions) {
51+
public UploadedFile upload(InputStream request, RequestOptions requestOptions) {
4852
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
4953
.newBuilder()
5054
.addPathSegments("v2/upload")
5155
.build();
52-
RequestBody body = RequestBody.create(request);
56+
RequestBody body = new InputStreamRequestBody(MediaType.parse("application/octet-stream"), request);
5357
Request okhttpRequest = new Request.Builder()
5458
.url(httpUrl)
5559
.method("POST", body)
5660
.headers(Headers.of(clientOptions.headers(requestOptions)))
57-
.addHeader("Content-Type", "application/octet-stream")
5861
.build();
5962
OkHttpClient client = clientOptions.httpClient();
6063
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
@@ -99,4 +102,18 @@ public UploadedFile upload(byte[] request, RequestOptions requestOptions) {
99102
throw new AssemblyAIException("Network error executing HTTP request", e);
100103
}
101104
}
105+
106+
/**
107+
* Upload a media file to AssemblyAI's servers.
108+
*/
109+
public UploadedFile upload(byte[] request) {
110+
return upload(new ByteArrayInputStream(request));
111+
}
112+
113+
/**
114+
* Upload a media file to AssemblyAI's servers.
115+
*/
116+
public UploadedFile upload(byte[] request, RequestOptions requestOptions) {
117+
return upload(new ByteArrayInputStream(request), requestOptions);
118+
}
102119
}

src/main/java/com/assemblyai/api/resources/files/types/UploadedFile.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.util.HashMap;
1515
import java.util.Map;
1616
import java.util.Objects;
17+
import org.jetbrains.annotations.NotNull;
1718

1819
@JsonInclude(JsonInclude.Include.NON_ABSENT)
1920
@JsonDeserialize(builder = UploadedFile.Builder.class)
@@ -65,7 +66,7 @@ public static UploadUrlStage builder() {
6566
}
6667

6768
public interface UploadUrlStage {
68-
_FinalStage uploadUrl(String uploadUrl);
69+
_FinalStage uploadUrl(@NotNull String uploadUrl);
6970

7071
Builder from(UploadedFile other);
7172
}
@@ -95,8 +96,8 @@ public Builder from(UploadedFile other) {
9596
*/
9697
@java.lang.Override
9798
@JsonSetter("upload_url")
98-
public _FinalStage uploadUrl(String uploadUrl) {
99-
this.uploadUrl = uploadUrl;
99+
public _FinalStage uploadUrl(@NotNull String uploadUrl) {
100+
this.uploadUrl = Objects.requireNonNull(uploadUrl, "uploadUrl must not be null");
100101
return this;
101102
}
102103

src/main/java/com/assemblyai/api/resources/lemur/requests/LemurTaskParams.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.Map;
2121
import java.util.Objects;
2222
import java.util.Optional;
23+
import org.jetbrains.annotations.NotNull;
2324

2425
@JsonInclude(JsonInclude.Include.NON_ABSENT)
2526
@JsonDeserialize(builder = LemurTaskParams.Builder.class)
@@ -168,7 +169,7 @@ public static PromptStage builder() {
168169
}
169170

170171
public interface PromptStage {
171-
_FinalStage prompt(String prompt);
172+
_FinalStage prompt(@NotNull String prompt);
172173

173174
Builder from(LemurTaskParams other);
174175
}
@@ -240,8 +241,8 @@ public Builder from(LemurTaskParams other) {
240241
*/
241242
@java.lang.Override
242243
@JsonSetter("prompt")
243-
public _FinalStage prompt(String prompt) {
244-
this.prompt = prompt;
244+
public _FinalStage prompt(@NotNull String prompt) {
245+
this.prompt = Objects.requireNonNull(prompt, "prompt must not be null");
245246
return this;
246247
}
247248

src/main/java/com/assemblyai/api/resources/lemur/types/LemurActionItemsResponse.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.util.HashMap;
1515
import java.util.Map;
1616
import java.util.Objects;
17+
import org.jetbrains.annotations.NotNull;
1718

1819
@JsonInclude(JsonInclude.Include.NON_ABSENT)
1920
@JsonDeserialize(builder = LemurActionItemsResponse.Builder.class)
@@ -91,17 +92,17 @@ public static ResponseStage builder() {
9192
}
9293

9394
public interface ResponseStage {
94-
RequestIdStage response(String response);
95+
RequestIdStage response(@NotNull String response);
9596

9697
Builder from(LemurActionItemsResponse other);
9798
}
9899

99100
public interface RequestIdStage {
100-
UsageStage requestId(String requestId);
101+
UsageStage requestId(@NotNull String requestId);
101102
}
102103

103104
public interface UsageStage {
104-
_FinalStage usage(LemurUsage usage);
105+
_FinalStage usage(@NotNull LemurUsage usage);
105106
}
106107

107108
public interface _FinalStage {
@@ -135,8 +136,8 @@ public Builder from(LemurActionItemsResponse other) {
135136
*/
136137
@java.lang.Override
137138
@JsonSetter("response")
138-
public RequestIdStage response(String response) {
139-
this.response = response;
139+
public RequestIdStage response(@NotNull String response) {
140+
this.response = Objects.requireNonNull(response, "response must not be null");
140141
return this;
141142
}
142143

@@ -146,8 +147,8 @@ public RequestIdStage response(String response) {
146147
*/
147148
@java.lang.Override
148149
@JsonSetter("request_id")
149-
public UsageStage requestId(String requestId) {
150-
this.requestId = requestId;
150+
public UsageStage requestId(@NotNull String requestId) {
151+
this.requestId = Objects.requireNonNull(requestId, "requestId must not be null");
151152
return this;
152153
}
153154

@@ -157,8 +158,8 @@ public UsageStage requestId(String requestId) {
157158
*/
158159
@java.lang.Override
159160
@JsonSetter("usage")
160-
public _FinalStage usage(LemurUsage usage) {
161-
this.usage = usage;
161+
public _FinalStage usage(@NotNull LemurUsage usage) {
162+
this.usage = Objects.requireNonNull(usage, "usage must not be null");
162163
return this;
163164
}
164165

src/main/java/com/assemblyai/api/resources/lemur/types/LemurBaseResponse.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.util.HashMap;
1515
import java.util.Map;
1616
import java.util.Objects;
17+
import org.jetbrains.annotations.NotNull;
1718

1819
@JsonInclude(JsonInclude.Include.NON_ABSENT)
1920
@JsonDeserialize(builder = LemurBaseResponse.Builder.class)
@@ -78,13 +79,13 @@ public static RequestIdStage builder() {
7879
}
7980

8081
public interface RequestIdStage {
81-
UsageStage requestId(String requestId);
82+
UsageStage requestId(@NotNull String requestId);
8283

8384
Builder from(LemurBaseResponse other);
8485
}
8586

8687
public interface UsageStage {
87-
_FinalStage usage(LemurUsage usage);
88+
_FinalStage usage(@NotNull LemurUsage usage);
8889
}
8990

9091
public interface _FinalStage {
@@ -115,8 +116,8 @@ public Builder from(LemurBaseResponse other) {
115116
*/
116117
@java.lang.Override
117118
@JsonSetter("request_id")
118-
public UsageStage requestId(String requestId) {
119-
this.requestId = requestId;
119+
public UsageStage requestId(@NotNull String requestId) {
120+
this.requestId = Objects.requireNonNull(requestId, "requestId must not be null");
120121
return this;
121122
}
122123

@@ -126,8 +127,8 @@ public UsageStage requestId(String requestId) {
126127
*/
127128
@java.lang.Override
128129
@JsonSetter("usage")
129-
public _FinalStage usage(LemurUsage usage) {
130-
this.usage = usage;
130+
public _FinalStage usage(@NotNull LemurUsage usage) {
131+
this.usage = Objects.requireNonNull(usage, "usage must not be null");
131132
return this;
132133
}
133134

0 commit comments

Comments
 (0)