index
int64 | repo_id
string | file_path
string | content
string |
|---|---|---|---|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/TokenType.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.expert.nlapi.v2.model;
import com.fasterxml.jackson.annotation.JsonProperty;
public enum TokenType {
@JsonProperty("ADJ")
ADJ("Adjective"),
@JsonProperty("ADV")
ADV("Adverb"),
@JsonProperty("ART")
ART("Article"),
@JsonProperty("AUX")
AUX("Auxiliary verb"),
@JsonProperty("CON")
CON("Conjunction"),
@JsonProperty("NOU")
NOU("Noun"),
@JsonProperty("NOU.ADR")
NOU_ADR("Street address"),
@JsonProperty("NOU.DAT")
NOU_DAT("Date"),
@JsonProperty("NOU.HOU")
NOU_HOU("Hour"),
@JsonProperty("NOU.MAI")
NOU_MAI("Email address"),
@JsonProperty("NOU.MEA")
NOU_MEA("Measure"),
@JsonProperty("NOU.MON")
NOU_MON("Money"),
@JsonProperty("NOU.PCT")
NOU_PCT("Percentage"),
@JsonProperty("NOU.PHO")
NOU_PHO("Phone number"),
@JsonProperty("NOU.WEB")
NOU_WEB("Web address"),
@JsonProperty("NPR")
NPR("Proper noun"),
@JsonProperty("NPR.ANM")
NPR_ANM("Proper noun of an animal"),
@JsonProperty("NPR.BLD")
NPR_BLD("Proper noun of a building"),
@JsonProperty("NPR.COM")
NPR_COM("Proper noun of a business/company"),
@JsonProperty("NPR.DEV")
NPR_DEV("Proper noun of a device"),
@JsonProperty("NPR.DOC")
NPR_DOC("Proper noun of a document"),
@JsonProperty("NPR.EVN")
NPR_EVN("Proper noun of an event"),
@JsonProperty("NPR.FDD")
NPR_FDD("Proper noun of a food/beverage"),
@JsonProperty("NPR.GEA")
NPR_GEA("Proper noun of a physical geographic feature"),
@JsonProperty("NPR.GEO")
NPR_GEO("Proper noun of an administrative geographic area"),
@JsonProperty("NPR.GEX")
NPR_GEX("Proper noun of an extra-terrestrial or imaginary place"),
@JsonProperty("NPR.LEN")
NPR_LEN("Proper noun of a legal/fiscal entity"),
@JsonProperty("NPR.MMD")
NPR_MMD("Proper noun of a mass media"),
@JsonProperty("NPR.NPH")
NPR_NPH("Proper noun of a human being"),
@JsonProperty("NPR.ORG")
NPR_ORG("Proper noun of an organization/society/institution"),
@JsonProperty("NPR.PPH")
NPR_PPH("Proper noun of a physical phenomena"),
@JsonProperty("NPR.PRD")
NPR_PRD("Proper noun of a product"),
@JsonProperty("NPR.VCL")
NPR_VCL("Proper noun of a vehicle"),
@JsonProperty("NPR.WRK")
NPR_WRK("Proper noun of a work of human intelligence"),
@JsonProperty("PNT")
PNT("Punctuation mark"),
@JsonProperty("PRE")
PRE("Preposition"),
@JsonProperty("PRO")
PRO("Pronoun"),
@JsonProperty("PRT")
PRT("Particle"),
@JsonProperty("VER")
VER("Verb"),
@JsonProperty("...")
ANY("Any entity type");
private final String description;
TokenType(String description) {
this.description = description;
}
public static TokenType fromDescription(String description) {
for(TokenType b : TokenType.values()) {
if(String.valueOf(b.description).equals(description)) {
return b;
}
}
return null;
}
public String getDescription() {
return description;
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/VSyncon.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.expert.nlapi.v2.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class VSyncon {
private Long id;
private Long parent;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/stats/InstanceStats.java
|
/*
* Copyright (c) 2021 original authors
*
* Licensed under the Apache License, Versions 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.expert.nlapi.v2.model.stats;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class InstanceStats {
private long timestamp;
private long request;
private boolean busy;
private boolean invalid;
private boolean running;
private long memory;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/stats/ResourceStats.java
|
/*
* Copyright (c) 2021 original authors
*
* Licensed under the Apache License, Versions 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.expert.nlapi.v2.model.stats;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResourceStats {
private String resource;
private List<InstanceStats> list;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/stats/StatisticsInfo.java
|
/*
* Copyright (c) 2021 original authors
*
* Licensed under the Apache License, Versions 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.expert.nlapi.v2.model.stats;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class StatisticsInfo {
private int total_core;
private int core;
private int instance;
private int busy;
private int pool;
private int queue;
private List<ResourceStats> reslist;
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/AsyncExtendClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend;
import ai.extend.core.ClientOptions;
import ai.extend.core.RequestOptions;
import ai.extend.core.Suppliers;
import ai.extend.requests.ParseAsyncRequest;
import ai.extend.requests.ParseRequest;
import ai.extend.resources.batchprocessorrun.AsyncBatchProcessorRunClient;
import ai.extend.resources.batchworkflowrun.AsyncBatchWorkflowRunClient;
import ai.extend.resources.evaluationset.AsyncEvaluationSetClient;
import ai.extend.resources.evaluationsetitem.AsyncEvaluationSetItemClient;
import ai.extend.resources.file.AsyncFileClient;
import ai.extend.resources.parserrun.AsyncParserRunClient;
import ai.extend.resources.processor.AsyncProcessorClient;
import ai.extend.resources.processorrun.AsyncProcessorRunClient;
import ai.extend.resources.processorversion.AsyncProcessorVersionClient;
import ai.extend.resources.workflow.AsyncWorkflowClient;
import ai.extend.resources.workflowrun.AsyncWorkflowRunClient;
import ai.extend.resources.workflowrunoutput.AsyncWorkflowRunOutputClient;
import ai.extend.types.ParserRun;
import ai.extend.types.ParserRunStatus;
import java.util.concurrent.CompletableFuture;
import java.util.function.Supplier;
public class AsyncExtendClient {
protected final ClientOptions clientOptions;
private final AsyncRawExtendClient rawClient;
protected final Supplier<AsyncWorkflowRunClient> workflowRunClient;
protected final Supplier<AsyncBatchWorkflowRunClient> batchWorkflowRunClient;
protected final Supplier<AsyncProcessorRunClient> processorRunClient;
protected final Supplier<AsyncProcessorClient> processorClient;
protected final Supplier<AsyncProcessorVersionClient> processorVersionClient;
protected final Supplier<AsyncParserRunClient> parserRunClient;
protected final Supplier<AsyncFileClient> fileClient;
protected final Supplier<AsyncEvaluationSetClient> evaluationSetClient;
protected final Supplier<AsyncEvaluationSetItemClient> evaluationSetItemClient;
protected final Supplier<AsyncWorkflowRunOutputClient> workflowRunOutputClient;
protected final Supplier<AsyncBatchProcessorRunClient> batchProcessorRunClient;
protected final Supplier<AsyncWorkflowClient> workflowClient;
public AsyncExtendClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.rawClient = new AsyncRawExtendClient(clientOptions);
this.workflowRunClient = Suppliers.memoize(() -> new AsyncWorkflowRunClient(clientOptions));
this.batchWorkflowRunClient = Suppliers.memoize(() -> new AsyncBatchWorkflowRunClient(clientOptions));
this.processorRunClient = Suppliers.memoize(() -> new AsyncProcessorRunClient(clientOptions));
this.processorClient = Suppliers.memoize(() -> new AsyncProcessorClient(clientOptions));
this.processorVersionClient = Suppliers.memoize(() -> new AsyncProcessorVersionClient(clientOptions));
this.parserRunClient = Suppliers.memoize(() -> new AsyncParserRunClient(clientOptions));
this.fileClient = Suppliers.memoize(() -> new AsyncFileClient(clientOptions));
this.evaluationSetClient = Suppliers.memoize(() -> new AsyncEvaluationSetClient(clientOptions));
this.evaluationSetItemClient = Suppliers.memoize(() -> new AsyncEvaluationSetItemClient(clientOptions));
this.workflowRunOutputClient = Suppliers.memoize(() -> new AsyncWorkflowRunOutputClient(clientOptions));
this.batchProcessorRunClient = Suppliers.memoize(() -> new AsyncBatchProcessorRunClient(clientOptions));
this.workflowClient = Suppliers.memoize(() -> new AsyncWorkflowClient(clientOptions));
}
/**
* Get responses with HTTP metadata like headers
*/
public AsyncRawExtendClient withRawResponse() {
return this.rawClient;
}
/**
* Parse files to get cleaned, chunked target content (e.g. markdown).
* <p>The Parse endpoint allows you to convert documents into structured, machine-readable formats with fine-grained control over the parsing process. This endpoint is ideal for extracting cleaned document content to be used as context for downstream processing, e.g. RAG pipelines, custom ingestion pipelines, embeddings classification, etc.</p>
* <p>For more details, see the <a href="/product/parsing/parse">Parse File guide</a>.</p>
*/
public CompletableFuture<ParserRun> parse(ParseRequest request) {
return this.rawClient.parse(request).thenApply(response -> response.body());
}
/**
* Parse files to get cleaned, chunked target content (e.g. markdown).
* <p>The Parse endpoint allows you to convert documents into structured, machine-readable formats with fine-grained control over the parsing process. This endpoint is ideal for extracting cleaned document content to be used as context for downstream processing, e.g. RAG pipelines, custom ingestion pipelines, embeddings classification, etc.</p>
* <p>For more details, see the <a href="/product/parsing/parse">Parse File guide</a>.</p>
*/
public CompletableFuture<ParserRun> parse(ParseRequest request, RequestOptions requestOptions) {
return this.rawClient.parse(request, requestOptions).thenApply(response -> response.body());
}
/**
* Parse files <strong>asynchronously</strong> to get cleaned, chunked target content (e.g. markdown).
* <p>The Parse Async endpoint allows you to convert documents into structured, machine-readable formats with fine-grained control over the parsing process. This endpoint is ideal for extracting cleaned document content to be used as context for downstream processing, e.g. RAG pipelines, custom ingestion pipelines, embeddings classification, etc.</p>
* <p>Parse files asynchronously and get a parser run ID that can be used to check status and retrieve results with the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/get-parser-run">Get Parser Run</a> endpoint.</p>
* <p>This is useful for:</p>
* <ul>
* <li>Large files that may take longer to process</li>
* <li>Avoiding timeout issues with synchronous parsing.</li>
* </ul>
* <p>For more details, see the <a href="/product/parsing/parse">Parse File guide</a>.</p>
*/
public CompletableFuture<ParserRunStatus> parseAsync(ParseAsyncRequest request) {
return this.rawClient.parseAsync(request).thenApply(response -> response.body());
}
/**
* Parse files <strong>asynchronously</strong> to get cleaned, chunked target content (e.g. markdown).
* <p>The Parse Async endpoint allows you to convert documents into structured, machine-readable formats with fine-grained control over the parsing process. This endpoint is ideal for extracting cleaned document content to be used as context for downstream processing, e.g. RAG pipelines, custom ingestion pipelines, embeddings classification, etc.</p>
* <p>Parse files asynchronously and get a parser run ID that can be used to check status and retrieve results with the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/get-parser-run">Get Parser Run</a> endpoint.</p>
* <p>This is useful for:</p>
* <ul>
* <li>Large files that may take longer to process</li>
* <li>Avoiding timeout issues with synchronous parsing.</li>
* </ul>
* <p>For more details, see the <a href="/product/parsing/parse">Parse File guide</a>.</p>
*/
public CompletableFuture<ParserRunStatus> parseAsync(ParseAsyncRequest request, RequestOptions requestOptions) {
return this.rawClient.parseAsync(request, requestOptions).thenApply(response -> response.body());
}
public AsyncWorkflowRunClient workflowRun() {
return this.workflowRunClient.get();
}
public AsyncBatchWorkflowRunClient batchWorkflowRun() {
return this.batchWorkflowRunClient.get();
}
public AsyncProcessorRunClient processorRun() {
return this.processorRunClient.get();
}
public AsyncProcessorClient processor() {
return this.processorClient.get();
}
public AsyncProcessorVersionClient processorVersion() {
return this.processorVersionClient.get();
}
public AsyncParserRunClient parserRun() {
return this.parserRunClient.get();
}
public AsyncFileClient file() {
return this.fileClient.get();
}
public AsyncEvaluationSetClient evaluationSet() {
return this.evaluationSetClient.get();
}
public AsyncEvaluationSetItemClient evaluationSetItem() {
return this.evaluationSetItemClient.get();
}
public AsyncWorkflowRunOutputClient workflowRunOutput() {
return this.workflowRunOutputClient.get();
}
public AsyncBatchProcessorRunClient batchProcessorRun() {
return this.batchProcessorRunClient.get();
}
public AsyncWorkflowClient workflow() {
return this.workflowClient.get();
}
public static AsyncExtendClientBuilder builder() {
return new AsyncExtendClientBuilder();
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/AsyncExtendClientBuilder.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend;
import ai.extend.core.ClientOptions;
import ai.extend.core.Environment;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import okhttp3.OkHttpClient;
public class AsyncExtendClientBuilder {
private Optional<Integer> timeout = Optional.empty();
private Optional<Integer> maxRetries = Optional.empty();
private final Map<String, String> customHeaders = new HashMap<>();
private String token = null;
private String extendApiVersion = "2025-04-21";
private Environment environment = Environment.PRODUCTION;
private OkHttpClient httpClient;
/**
* Sets token
*/
public AsyncExtendClientBuilder token(String token) {
this.token = token;
return this;
}
/**
* Sets extendApiVersion
*/
public AsyncExtendClientBuilder extendApiVersion(String extendApiVersion) {
this.extendApiVersion = extendApiVersion;
return this;
}
public AsyncExtendClientBuilder environment(Environment environment) {
this.environment = environment;
return this;
}
public AsyncExtendClientBuilder url(String url) {
this.environment = Environment.custom(url);
return this;
}
/**
* Sets the timeout (in seconds) for the client. Defaults to 60 seconds.
*/
public AsyncExtendClientBuilder timeout(int timeout) {
this.timeout = Optional.of(timeout);
return this;
}
/**
* Sets the maximum number of retries for the client. Defaults to 2 retries.
*/
public AsyncExtendClientBuilder maxRetries(int maxRetries) {
this.maxRetries = Optional.of(maxRetries);
return this;
}
/**
* Sets the underlying OkHttp client
*/
public AsyncExtendClientBuilder httpClient(OkHttpClient httpClient) {
this.httpClient = httpClient;
return this;
}
/**
* Add a custom header to be sent with all requests.
* For headers that need to be computed dynamically or conditionally, use the setAdditional() method override instead.
*
* @param name The header name
* @param value The header value
* @return This builder for method chaining
*/
public AsyncExtendClientBuilder addHeader(String name, String value) {
this.customHeaders.put(name, value);
return this;
}
protected ClientOptions buildClientOptions() {
ClientOptions.Builder builder = ClientOptions.builder();
setEnvironment(builder);
setAuthentication(builder);
setCustomHeaders(builder);
setHttpClient(builder);
setTimeouts(builder);
setRetries(builder);
for (Map.Entry<String, String> header : this.customHeaders.entrySet()) {
builder.addHeader(header.getKey(), header.getValue());
}
setAdditional(builder);
return builder.build();
}
/**
* Sets the environment configuration for the client.
* Override this method to modify URLs or add environment-specific logic.
*
* @param builder The ClientOptions.Builder to configure
*/
protected void setEnvironment(ClientOptions.Builder builder) {
builder.environment(this.environment);
}
/**
* Override this method to customize authentication.
* This method is called during client options construction to set up authentication headers.
*
* @param builder The ClientOptions.Builder to configure
*
* Example:
* <pre>{@code
* @Override
* protected void setAuthentication(ClientOptions.Builder builder) {
* super.setAuthentication(builder); // Keep existing auth
* builder.addHeader("X-API-Key", this.apiKey);
* }
* }</pre>
*/
protected void setAuthentication(ClientOptions.Builder builder) {
if (this.token != null) {
builder.addHeader("Authorization", "Bearer " + this.token);
}
}
/**
* Override this method to add or modify custom headers.
* This method is called during client options construction to set up custom headers defined in the API.
*
* @param builder The ClientOptions.Builder to configure
*
* Example:
* <pre>{@code
* @Override
* protected void setCustomHeaders(ClientOptions.Builder builder) {
* super.setCustomHeaders(builder); // Keep existing headers
* builder.addHeader("X-Trace-ID", generateTraceId());
* }
* }</pre>
*/
protected void setCustomHeaders(ClientOptions.Builder builder) {
builder.addHeader("x-extend-api-version", this.extendApiVersion);
}
/**
* Sets the request timeout configuration.
* Override this method to customize timeout behavior.
*
* @param builder The ClientOptions.Builder to configure
*/
protected void setTimeouts(ClientOptions.Builder builder) {
if (this.timeout.isPresent()) {
builder.timeout(this.timeout.get());
}
}
/**
* Sets the retry configuration for failed requests.
* Override this method to implement custom retry strategies.
*
* @param builder The ClientOptions.Builder to configure
*/
protected void setRetries(ClientOptions.Builder builder) {
if (this.maxRetries.isPresent()) {
builder.maxRetries(this.maxRetries.get());
}
}
/**
* Sets the OkHttp client configuration.
* Override this method to customize HTTP client behavior (interceptors, connection pools, etc).
*
* @param builder The ClientOptions.Builder to configure
*/
protected void setHttpClient(ClientOptions.Builder builder) {
if (this.httpClient != null) {
builder.httpClient(this.httpClient);
}
}
/**
* Override this method to add any additional configuration to the client.
* This method is called at the end of the configuration chain, allowing you to add
* custom headers, modify settings, or perform any other client customization.
*
* @param builder The ClientOptions.Builder to configure
*
* Example:
* <pre>{@code
* @Override
* protected void setAdditional(ClientOptions.Builder builder) {
* builder.addHeader("X-Request-ID", () -> UUID.randomUUID().toString());
* builder.addHeader("X-Client-Version", "1.0.0");
* }
* }</pre>
*/
protected void setAdditional(ClientOptions.Builder builder) {}
/**
* Override this method to add custom validation logic before the client is built.
* This method is called at the beginning of the build() method to ensure the configuration is valid.
* Throw an exception to prevent client creation if validation fails.
*
* Example:
* <pre>{@code
* @Override
* protected void validateConfiguration() {
* super.validateConfiguration(); // Run parent validations
* if (tenantId == null || tenantId.isEmpty()) {
* throw new IllegalStateException("tenantId is required");
* }
* }
* }</pre>
*/
protected void validateConfiguration() {}
public AsyncExtendClient build() {
if (token == null) {
throw new RuntimeException("Please provide token");
}
validateConfiguration();
return new AsyncExtendClient(buildClientOptions());
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/AsyncRawExtendClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend;
import ai.extend.core.ClientOptions;
import ai.extend.core.ExtendClientApiException;
import ai.extend.core.ExtendClientException;
import ai.extend.core.ExtendClientHttpResponse;
import ai.extend.core.MediaTypes;
import ai.extend.core.ObjectMappers;
import ai.extend.core.QueryStringMapper;
import ai.extend.core.RequestOptions;
import ai.extend.errors.BadRequestError;
import ai.extend.errors.InternalServerError;
import ai.extend.errors.NotFoundError;
import ai.extend.errors.PaymentRequiredError;
import ai.extend.errors.UnauthorizedError;
import ai.extend.errors.UnprocessableEntityError;
import ai.extend.requests.ParseAsyncRequest;
import ai.extend.requests.ParseRequest;
import ai.extend.types.Error;
import ai.extend.types.ExtendError;
import ai.extend.types.ParserRun;
import ai.extend.types.ParserRunStatus;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.jetbrains.annotations.NotNull;
public class AsyncRawExtendClient {
protected final ClientOptions clientOptions;
public AsyncRawExtendClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
}
/**
* Parse files to get cleaned, chunked target content (e.g. markdown).
* <p>The Parse endpoint allows you to convert documents into structured, machine-readable formats with fine-grained control over the parsing process. This endpoint is ideal for extracting cleaned document content to be used as context for downstream processing, e.g. RAG pipelines, custom ingestion pipelines, embeddings classification, etc.</p>
* <p>For more details, see the <a href="/product/parsing/parse">Parse File guide</a>.</p>
*/
public CompletableFuture<ExtendClientHttpResponse<ParserRun>> parse(ParseRequest request) {
return parse(request, null);
}
/**
* Parse files to get cleaned, chunked target content (e.g. markdown).
* <p>The Parse endpoint allows you to convert documents into structured, machine-readable formats with fine-grained control over the parsing process. This endpoint is ideal for extracting cleaned document content to be used as context for downstream processing, e.g. RAG pipelines, custom ingestion pipelines, embeddings classification, etc.</p>
* <p>For more details, see the <a href="/product/parsing/parse">Parse File guide</a>.</p>
*/
public CompletableFuture<ExtendClientHttpResponse<ParserRun>> parse(
ParseRequest request, RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("parse");
if (request.getResponseType().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "responseType", request.getResponseType().get(), false);
}
Map<String, Object> properties = new HashMap<>();
properties.put("file", request.getFile());
if (request.getConfig().isPresent()) {
properties.put("config", request.getConfig());
}
RequestBody body;
try {
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON);
} catch (Exception e) {
throw new RuntimeException(e);
}
Request.Builder _requestBuilder = new Request.Builder()
.url(httpUrl.build())
.method("POST", body)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json");
Request okhttpRequest = _requestBuilder.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
CompletableFuture<ExtendClientHttpResponse<ParserRun>> 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(new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ParserRun.class), response));
return;
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
future.completeExceptionally(new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
case 401:
future.completeExceptionally(new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
response));
return;
case 402:
future.completeExceptionally(new PaymentRequiredError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
case 404:
future.completeExceptionally(new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
case 422:
future.completeExceptionally(new UnprocessableEntityError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ExtendError.class),
response));
return;
case 500:
future.completeExceptionally(new InternalServerError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ExtendError.class),
response));
return;
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
future.completeExceptionally(new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
});
return future;
}
/**
* Parse files <strong>asynchronously</strong> to get cleaned, chunked target content (e.g. markdown).
* <p>The Parse Async endpoint allows you to convert documents into structured, machine-readable formats with fine-grained control over the parsing process. This endpoint is ideal for extracting cleaned document content to be used as context for downstream processing, e.g. RAG pipelines, custom ingestion pipelines, embeddings classification, etc.</p>
* <p>Parse files asynchronously and get a parser run ID that can be used to check status and retrieve results with the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/get-parser-run">Get Parser Run</a> endpoint.</p>
* <p>This is useful for:</p>
* <ul>
* <li>Large files that may take longer to process</li>
* <li>Avoiding timeout issues with synchronous parsing.</li>
* </ul>
* <p>For more details, see the <a href="/product/parsing/parse">Parse File guide</a>.</p>
*/
public CompletableFuture<ExtendClientHttpResponse<ParserRunStatus>> parseAsync(ParseAsyncRequest request) {
return parseAsync(request, null);
}
/**
* Parse files <strong>asynchronously</strong> to get cleaned, chunked target content (e.g. markdown).
* <p>The Parse Async endpoint allows you to convert documents into structured, machine-readable formats with fine-grained control over the parsing process. This endpoint is ideal for extracting cleaned document content to be used as context for downstream processing, e.g. RAG pipelines, custom ingestion pipelines, embeddings classification, etc.</p>
* <p>Parse files asynchronously and get a parser run ID that can be used to check status and retrieve results with the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/get-parser-run">Get Parser Run</a> endpoint.</p>
* <p>This is useful for:</p>
* <ul>
* <li>Large files that may take longer to process</li>
* <li>Avoiding timeout issues with synchronous parsing.</li>
* </ul>
* <p>For more details, see the <a href="/product/parsing/parse">Parse File guide</a>.</p>
*/
public CompletableFuture<ExtendClientHttpResponse<ParserRunStatus>> parseAsync(
ParseAsyncRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("parse/async")
.build();
RequestBody body;
try {
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (JsonProcessingException e) {
throw new ExtendClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("POST", body)
.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<ExtendClientHttpResponse<ParserRunStatus>> 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(new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ParserRunStatus.class),
response));
return;
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
future.completeExceptionally(new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
case 401:
future.completeExceptionally(new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
response));
return;
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
future.completeExceptionally(new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
});
return future;
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/ExtendClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend;
import ai.extend.core.ClientOptions;
import ai.extend.core.RequestOptions;
import ai.extend.core.Suppliers;
import ai.extend.requests.ParseAsyncRequest;
import ai.extend.requests.ParseRequest;
import ai.extend.resources.batchprocessorrun.BatchProcessorRunClient;
import ai.extend.resources.batchworkflowrun.BatchWorkflowRunClient;
import ai.extend.resources.evaluationset.EvaluationSetClient;
import ai.extend.resources.evaluationsetitem.EvaluationSetItemClient;
import ai.extend.resources.file.FileClient;
import ai.extend.resources.parserrun.ParserRunClient;
import ai.extend.resources.processor.ProcessorClient;
import ai.extend.resources.processorrun.ProcessorRunClient;
import ai.extend.resources.processorversion.ProcessorVersionClient;
import ai.extend.resources.workflow.WorkflowClient;
import ai.extend.resources.workflowrun.WorkflowRunClient;
import ai.extend.resources.workflowrunoutput.WorkflowRunOutputClient;
import ai.extend.types.ParserRun;
import ai.extend.types.ParserRunStatus;
import java.util.function.Supplier;
public class ExtendClient {
protected final ClientOptions clientOptions;
private final RawExtendClient rawClient;
protected final Supplier<WorkflowRunClient> workflowRunClient;
protected final Supplier<BatchWorkflowRunClient> batchWorkflowRunClient;
protected final Supplier<ProcessorRunClient> processorRunClient;
protected final Supplier<ProcessorClient> processorClient;
protected final Supplier<ProcessorVersionClient> processorVersionClient;
protected final Supplier<ParserRunClient> parserRunClient;
protected final Supplier<FileClient> fileClient;
protected final Supplier<EvaluationSetClient> evaluationSetClient;
protected final Supplier<EvaluationSetItemClient> evaluationSetItemClient;
protected final Supplier<WorkflowRunOutputClient> workflowRunOutputClient;
protected final Supplier<BatchProcessorRunClient> batchProcessorRunClient;
protected final Supplier<WorkflowClient> workflowClient;
public ExtendClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.rawClient = new RawExtendClient(clientOptions);
this.workflowRunClient = Suppliers.memoize(() -> new WorkflowRunClient(clientOptions));
this.batchWorkflowRunClient = Suppliers.memoize(() -> new BatchWorkflowRunClient(clientOptions));
this.processorRunClient = Suppliers.memoize(() -> new ProcessorRunClient(clientOptions));
this.processorClient = Suppliers.memoize(() -> new ProcessorClient(clientOptions));
this.processorVersionClient = Suppliers.memoize(() -> new ProcessorVersionClient(clientOptions));
this.parserRunClient = Suppliers.memoize(() -> new ParserRunClient(clientOptions));
this.fileClient = Suppliers.memoize(() -> new FileClient(clientOptions));
this.evaluationSetClient = Suppliers.memoize(() -> new EvaluationSetClient(clientOptions));
this.evaluationSetItemClient = Suppliers.memoize(() -> new EvaluationSetItemClient(clientOptions));
this.workflowRunOutputClient = Suppliers.memoize(() -> new WorkflowRunOutputClient(clientOptions));
this.batchProcessorRunClient = Suppliers.memoize(() -> new BatchProcessorRunClient(clientOptions));
this.workflowClient = Suppliers.memoize(() -> new WorkflowClient(clientOptions));
}
/**
* Get responses with HTTP metadata like headers
*/
public RawExtendClient withRawResponse() {
return this.rawClient;
}
/**
* Parse files to get cleaned, chunked target content (e.g. markdown).
* <p>The Parse endpoint allows you to convert documents into structured, machine-readable formats with fine-grained control over the parsing process. This endpoint is ideal for extracting cleaned document content to be used as context for downstream processing, e.g. RAG pipelines, custom ingestion pipelines, embeddings classification, etc.</p>
* <p>For more details, see the <a href="/product/parsing/parse">Parse File guide</a>.</p>
*/
public ParserRun parse(ParseRequest request) {
return this.rawClient.parse(request).body();
}
/**
* Parse files to get cleaned, chunked target content (e.g. markdown).
* <p>The Parse endpoint allows you to convert documents into structured, machine-readable formats with fine-grained control over the parsing process. This endpoint is ideal for extracting cleaned document content to be used as context for downstream processing, e.g. RAG pipelines, custom ingestion pipelines, embeddings classification, etc.</p>
* <p>For more details, see the <a href="/product/parsing/parse">Parse File guide</a>.</p>
*/
public ParserRun parse(ParseRequest request, RequestOptions requestOptions) {
return this.rawClient.parse(request, requestOptions).body();
}
/**
* Parse files <strong>asynchronously</strong> to get cleaned, chunked target content (e.g. markdown).
* <p>The Parse Async endpoint allows you to convert documents into structured, machine-readable formats with fine-grained control over the parsing process. This endpoint is ideal for extracting cleaned document content to be used as context for downstream processing, e.g. RAG pipelines, custom ingestion pipelines, embeddings classification, etc.</p>
* <p>Parse files asynchronously and get a parser run ID that can be used to check status and retrieve results with the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/get-parser-run">Get Parser Run</a> endpoint.</p>
* <p>This is useful for:</p>
* <ul>
* <li>Large files that may take longer to process</li>
* <li>Avoiding timeout issues with synchronous parsing.</li>
* </ul>
* <p>For more details, see the <a href="/product/parsing/parse">Parse File guide</a>.</p>
*/
public ParserRunStatus parseAsync(ParseAsyncRequest request) {
return this.rawClient.parseAsync(request).body();
}
/**
* Parse files <strong>asynchronously</strong> to get cleaned, chunked target content (e.g. markdown).
* <p>The Parse Async endpoint allows you to convert documents into structured, machine-readable formats with fine-grained control over the parsing process. This endpoint is ideal for extracting cleaned document content to be used as context for downstream processing, e.g. RAG pipelines, custom ingestion pipelines, embeddings classification, etc.</p>
* <p>Parse files asynchronously and get a parser run ID that can be used to check status and retrieve results with the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/get-parser-run">Get Parser Run</a> endpoint.</p>
* <p>This is useful for:</p>
* <ul>
* <li>Large files that may take longer to process</li>
* <li>Avoiding timeout issues with synchronous parsing.</li>
* </ul>
* <p>For more details, see the <a href="/product/parsing/parse">Parse File guide</a>.</p>
*/
public ParserRunStatus parseAsync(ParseAsyncRequest request, RequestOptions requestOptions) {
return this.rawClient.parseAsync(request, requestOptions).body();
}
public WorkflowRunClient workflowRun() {
return this.workflowRunClient.get();
}
public BatchWorkflowRunClient batchWorkflowRun() {
return this.batchWorkflowRunClient.get();
}
public ProcessorRunClient processorRun() {
return this.processorRunClient.get();
}
public ProcessorClient processor() {
return this.processorClient.get();
}
public ProcessorVersionClient processorVersion() {
return this.processorVersionClient.get();
}
public ParserRunClient parserRun() {
return this.parserRunClient.get();
}
public FileClient file() {
return this.fileClient.get();
}
public EvaluationSetClient evaluationSet() {
return this.evaluationSetClient.get();
}
public EvaluationSetItemClient evaluationSetItem() {
return this.evaluationSetItemClient.get();
}
public WorkflowRunOutputClient workflowRunOutput() {
return this.workflowRunOutputClient.get();
}
public BatchProcessorRunClient batchProcessorRun() {
return this.batchProcessorRunClient.get();
}
public WorkflowClient workflow() {
return this.workflowClient.get();
}
public static ExtendClientBuilder builder() {
return new ExtendClientBuilder();
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/ExtendClientBuilder.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend;
import ai.extend.core.ClientOptions;
import ai.extend.core.Environment;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import okhttp3.OkHttpClient;
public class ExtendClientBuilder {
private Optional<Integer> timeout = Optional.empty();
private Optional<Integer> maxRetries = Optional.empty();
private final Map<String, String> customHeaders = new HashMap<>();
private String token = null;
private String extendApiVersion = "2025-04-21";
private Environment environment = Environment.PRODUCTION;
private OkHttpClient httpClient;
/**
* Sets token
*/
public ExtendClientBuilder token(String token) {
this.token = token;
return this;
}
/**
* Sets extendApiVersion
*/
public ExtendClientBuilder extendApiVersion(String extendApiVersion) {
this.extendApiVersion = extendApiVersion;
return this;
}
public ExtendClientBuilder environment(Environment environment) {
this.environment = environment;
return this;
}
public ExtendClientBuilder url(String url) {
this.environment = Environment.custom(url);
return this;
}
/**
* Sets the timeout (in seconds) for the client. Defaults to 60 seconds.
*/
public ExtendClientBuilder timeout(int timeout) {
this.timeout = Optional.of(timeout);
return this;
}
/**
* Sets the maximum number of retries for the client. Defaults to 2 retries.
*/
public ExtendClientBuilder maxRetries(int maxRetries) {
this.maxRetries = Optional.of(maxRetries);
return this;
}
/**
* Sets the underlying OkHttp client
*/
public ExtendClientBuilder httpClient(OkHttpClient httpClient) {
this.httpClient = httpClient;
return this;
}
/**
* Add a custom header to be sent with all requests.
* For headers that need to be computed dynamically or conditionally, use the setAdditional() method override instead.
*
* @param name The header name
* @param value The header value
* @return This builder for method chaining
*/
public ExtendClientBuilder addHeader(String name, String value) {
this.customHeaders.put(name, value);
return this;
}
protected ClientOptions buildClientOptions() {
ClientOptions.Builder builder = ClientOptions.builder();
setEnvironment(builder);
setAuthentication(builder);
setCustomHeaders(builder);
setHttpClient(builder);
setTimeouts(builder);
setRetries(builder);
for (Map.Entry<String, String> header : this.customHeaders.entrySet()) {
builder.addHeader(header.getKey(), header.getValue());
}
setAdditional(builder);
return builder.build();
}
/**
* Sets the environment configuration for the client.
* Override this method to modify URLs or add environment-specific logic.
*
* @param builder The ClientOptions.Builder to configure
*/
protected void setEnvironment(ClientOptions.Builder builder) {
builder.environment(this.environment);
}
/**
* Override this method to customize authentication.
* This method is called during client options construction to set up authentication headers.
*
* @param builder The ClientOptions.Builder to configure
*
* Example:
* <pre>{@code
* @Override
* protected void setAuthentication(ClientOptions.Builder builder) {
* super.setAuthentication(builder); // Keep existing auth
* builder.addHeader("X-API-Key", this.apiKey);
* }
* }</pre>
*/
protected void setAuthentication(ClientOptions.Builder builder) {
if (this.token != null) {
builder.addHeader("Authorization", "Bearer " + this.token);
}
}
/**
* Override this method to add or modify custom headers.
* This method is called during client options construction to set up custom headers defined in the API.
*
* @param builder The ClientOptions.Builder to configure
*
* Example:
* <pre>{@code
* @Override
* protected void setCustomHeaders(ClientOptions.Builder builder) {
* super.setCustomHeaders(builder); // Keep existing headers
* builder.addHeader("X-Trace-ID", generateTraceId());
* }
* }</pre>
*/
protected void setCustomHeaders(ClientOptions.Builder builder) {
builder.addHeader("x-extend-api-version", this.extendApiVersion);
}
/**
* Sets the request timeout configuration.
* Override this method to customize timeout behavior.
*
* @param builder The ClientOptions.Builder to configure
*/
protected void setTimeouts(ClientOptions.Builder builder) {
if (this.timeout.isPresent()) {
builder.timeout(this.timeout.get());
}
}
/**
* Sets the retry configuration for failed requests.
* Override this method to implement custom retry strategies.
*
* @param builder The ClientOptions.Builder to configure
*/
protected void setRetries(ClientOptions.Builder builder) {
if (this.maxRetries.isPresent()) {
builder.maxRetries(this.maxRetries.get());
}
}
/**
* Sets the OkHttp client configuration.
* Override this method to customize HTTP client behavior (interceptors, connection pools, etc).
*
* @param builder The ClientOptions.Builder to configure
*/
protected void setHttpClient(ClientOptions.Builder builder) {
if (this.httpClient != null) {
builder.httpClient(this.httpClient);
}
}
/**
* Override this method to add any additional configuration to the client.
* This method is called at the end of the configuration chain, allowing you to add
* custom headers, modify settings, or perform any other client customization.
*
* @param builder The ClientOptions.Builder to configure
*
* Example:
* <pre>{@code
* @Override
* protected void setAdditional(ClientOptions.Builder builder) {
* builder.addHeader("X-Request-ID", () -> UUID.randomUUID().toString());
* builder.addHeader("X-Client-Version", "1.0.0");
* }
* }</pre>
*/
protected void setAdditional(ClientOptions.Builder builder) {}
/**
* Override this method to add custom validation logic before the client is built.
* This method is called at the beginning of the build() method to ensure the configuration is valid.
* Throw an exception to prevent client creation if validation fails.
*
* Example:
* <pre>{@code
* @Override
* protected void validateConfiguration() {
* super.validateConfiguration(); // Run parent validations
* if (tenantId == null || tenantId.isEmpty()) {
* throw new IllegalStateException("tenantId is required");
* }
* }
* }</pre>
*/
protected void validateConfiguration() {}
public ExtendClient build() {
if (token == null) {
throw new RuntimeException("Please provide token");
}
validateConfiguration();
return new ExtendClient(buildClientOptions());
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/RawExtendClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend;
import ai.extend.core.ClientOptions;
import ai.extend.core.ExtendClientApiException;
import ai.extend.core.ExtendClientException;
import ai.extend.core.ExtendClientHttpResponse;
import ai.extend.core.MediaTypes;
import ai.extend.core.ObjectMappers;
import ai.extend.core.QueryStringMapper;
import ai.extend.core.RequestOptions;
import ai.extend.errors.BadRequestError;
import ai.extend.errors.InternalServerError;
import ai.extend.errors.NotFoundError;
import ai.extend.errors.PaymentRequiredError;
import ai.extend.errors.UnauthorizedError;
import ai.extend.errors.UnprocessableEntityError;
import ai.extend.requests.ParseAsyncRequest;
import ai.extend.requests.ParseRequest;
import ai.extend.types.Error;
import ai.extend.types.ExtendError;
import ai.extend.types.ParserRun;
import ai.extend.types.ParserRunStatus;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;
public class RawExtendClient {
protected final ClientOptions clientOptions;
public RawExtendClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
}
/**
* Parse files to get cleaned, chunked target content (e.g. markdown).
* <p>The Parse endpoint allows you to convert documents into structured, machine-readable formats with fine-grained control over the parsing process. This endpoint is ideal for extracting cleaned document content to be used as context for downstream processing, e.g. RAG pipelines, custom ingestion pipelines, embeddings classification, etc.</p>
* <p>For more details, see the <a href="/product/parsing/parse">Parse File guide</a>.</p>
*/
public ExtendClientHttpResponse<ParserRun> parse(ParseRequest request) {
return parse(request, null);
}
/**
* Parse files to get cleaned, chunked target content (e.g. markdown).
* <p>The Parse endpoint allows you to convert documents into structured, machine-readable formats with fine-grained control over the parsing process. This endpoint is ideal for extracting cleaned document content to be used as context for downstream processing, e.g. RAG pipelines, custom ingestion pipelines, embeddings classification, etc.</p>
* <p>For more details, see the <a href="/product/parsing/parse">Parse File guide</a>.</p>
*/
public ExtendClientHttpResponse<ParserRun> parse(ParseRequest request, RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("parse");
if (request.getResponseType().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "responseType", request.getResponseType().get(), false);
}
Map<String, Object> properties = new HashMap<>();
properties.put("file", request.getFile());
if (request.getConfig().isPresent()) {
properties.put("config", request.getConfig());
}
RequestBody body;
try {
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON);
} catch (Exception e) {
throw new RuntimeException(e);
}
Request.Builder _requestBuilder = new Request.Builder()
.url(httpUrl.build())
.method("POST", body)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json");
Request okhttpRequest = _requestBuilder.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ParserRun.class), response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
throw new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
case 401:
throw new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 402:
throw new PaymentRequiredError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
case 404:
throw new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
case 422:
throw new UnprocessableEntityError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ExtendError.class), response);
case 500:
throw new InternalServerError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ExtendError.class), response);
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
throw new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
throw new ExtendClientException("Network error executing HTTP request", e);
}
}
/**
* Parse files <strong>asynchronously</strong> to get cleaned, chunked target content (e.g. markdown).
* <p>The Parse Async endpoint allows you to convert documents into structured, machine-readable formats with fine-grained control over the parsing process. This endpoint is ideal for extracting cleaned document content to be used as context for downstream processing, e.g. RAG pipelines, custom ingestion pipelines, embeddings classification, etc.</p>
* <p>Parse files asynchronously and get a parser run ID that can be used to check status and retrieve results with the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/get-parser-run">Get Parser Run</a> endpoint.</p>
* <p>This is useful for:</p>
* <ul>
* <li>Large files that may take longer to process</li>
* <li>Avoiding timeout issues with synchronous parsing.</li>
* </ul>
* <p>For more details, see the <a href="/product/parsing/parse">Parse File guide</a>.</p>
*/
public ExtendClientHttpResponse<ParserRunStatus> parseAsync(ParseAsyncRequest request) {
return parseAsync(request, null);
}
/**
* Parse files <strong>asynchronously</strong> to get cleaned, chunked target content (e.g. markdown).
* <p>The Parse Async endpoint allows you to convert documents into structured, machine-readable formats with fine-grained control over the parsing process. This endpoint is ideal for extracting cleaned document content to be used as context for downstream processing, e.g. RAG pipelines, custom ingestion pipelines, embeddings classification, etc.</p>
* <p>Parse files asynchronously and get a parser run ID that can be used to check status and retrieve results with the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/get-parser-run">Get Parser Run</a> endpoint.</p>
* <p>This is useful for:</p>
* <ul>
* <li>Large files that may take longer to process</li>
* <li>Avoiding timeout issues with synchronous parsing.</li>
* </ul>
* <p>For more details, see the <a href="/product/parsing/parse">Parse File guide</a>.</p>
*/
public ExtendClientHttpResponse<ParserRunStatus> parseAsync(
ParseAsyncRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("parse/async")
.build();
RequestBody body;
try {
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (JsonProcessingException e) {
throw new ExtendClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("POST", body)
.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);
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ParserRunStatus.class), response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
throw new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
case 401:
throw new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
throw new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
throw new ExtendClientException("Network error executing HTTP request", e);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/core/ClientOptions.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.core;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
import okhttp3.OkHttpClient;
public final class ClientOptions {
private final Environment environment;
private final Map<String, String> headers;
private final Map<String, Supplier<String>> headerSuppliers;
private final OkHttpClient httpClient;
private final int timeout;
private ClientOptions(
Environment environment,
Map<String, String> headers,
Map<String, Supplier<String>> headerSuppliers,
OkHttpClient httpClient,
int timeout) {
this.environment = environment;
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.headers.putAll(new HashMap<String, String>() {
{
put("User-Agent", "ai.extend:extend-java-sdk/0.0.3-beta");
put("X-Fern-Language", "JAVA");
put("X-Fern-SDK-Name", "com.extendconfig.fern:api-sdk");
put("X-Fern-SDK-Version", "0.0.3-beta");
}
});
this.headerSuppliers = headerSuppliers;
this.httpClient = httpClient;
this.timeout = timeout;
}
public Environment environment() {
return this.environment;
}
public Map<String, String> headers(RequestOptions requestOptions) {
Map<String, String> values = new HashMap<>(this.headers);
headerSuppliers.forEach((key, supplier) -> {
values.put(key, supplier.get());
});
if (requestOptions != null) {
values.putAll(requestOptions.getHeaders());
}
return values;
}
public int timeout(RequestOptions requestOptions) {
if (requestOptions == null) {
return this.timeout;
}
return requestOptions.getTimeout().orElse(this.timeout);
}
public OkHttpClient httpClient() {
return this.httpClient;
}
public OkHttpClient httpClientWithTimeout(RequestOptions requestOptions) {
if (requestOptions == null) {
return this.httpClient;
}
return this.httpClient
.newBuilder()
.callTimeout(requestOptions.getTimeout().get(), requestOptions.getTimeoutTimeUnit())
.connectTimeout(0, TimeUnit.SECONDS)
.writeTimeout(0, TimeUnit.SECONDS)
.readTimeout(0, TimeUnit.SECONDS)
.build();
}
public static Builder builder() {
return new Builder();
}
public static class Builder {
private Environment environment;
private final Map<String, String> headers = new HashMap<>();
private final Map<String, Supplier<String>> headerSuppliers = new HashMap<>();
private int maxRetries = 2;
private Optional<Integer> timeout = Optional.empty();
private OkHttpClient httpClient = null;
public Builder environment(Environment environment) {
this.environment = environment;
return this;
}
public Builder addHeader(String key, String value) {
this.headers.put(key, value);
return this;
}
public Builder addHeader(String key, Supplier<String> value) {
this.headerSuppliers.put(key, value);
return this;
}
/**
* Override the timeout in seconds. Defaults to 60 seconds.
*/
public Builder timeout(int timeout) {
this.timeout = Optional.of(timeout);
return this;
}
/**
* Override the timeout in seconds. Defaults to 60 seconds.
*/
public Builder timeout(Optional<Integer> timeout) {
this.timeout = timeout;
return this;
}
/**
* Override the maximum number of retries. Defaults to 2 retries.
*/
public Builder maxRetries(int maxRetries) {
this.maxRetries = maxRetries;
return this;
}
public Builder httpClient(OkHttpClient httpClient) {
this.httpClient = httpClient;
return this;
}
public ClientOptions build() {
OkHttpClient.Builder httpClientBuilder =
this.httpClient != null ? this.httpClient.newBuilder() : new OkHttpClient.Builder();
if (this.httpClient != null) {
timeout.ifPresent(timeout -> httpClientBuilder
.callTimeout(timeout, TimeUnit.SECONDS)
.connectTimeout(0, TimeUnit.SECONDS)
.writeTimeout(0, TimeUnit.SECONDS)
.readTimeout(0, TimeUnit.SECONDS));
} else {
httpClientBuilder
.callTimeout(this.timeout.orElse(60), TimeUnit.SECONDS)
.connectTimeout(0, TimeUnit.SECONDS)
.writeTimeout(0, TimeUnit.SECONDS)
.readTimeout(0, TimeUnit.SECONDS)
.addInterceptor(new RetryInterceptor(this.maxRetries));
}
this.httpClient = httpClientBuilder.build();
this.timeout = Optional.of(httpClient.callTimeoutMillis() / 1000);
return new ClientOptions(environment, headers, headerSuppliers, httpClient, this.timeout.get());
}
/**
* Create a new Builder initialized with values from an existing ClientOptions
*/
public static Builder from(ClientOptions clientOptions) {
Builder builder = new Builder();
builder.environment = clientOptions.environment();
builder.timeout = Optional.of(clientOptions.timeout(null));
builder.httpClient = clientOptions.httpClient();
return builder;
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/core/DateTimeDeserializer.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.core;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.module.SimpleModule;
import java.io.IOException;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;
import java.time.temporal.TemporalQueries;
/**
* Custom deserializer that handles converting ISO8601 dates into {@link OffsetDateTime} objects.
*/
class DateTimeDeserializer extends JsonDeserializer<OffsetDateTime> {
private static final SimpleModule MODULE;
static {
MODULE = new SimpleModule().addDeserializer(OffsetDateTime.class, new DateTimeDeserializer());
}
/**
* Gets a module wrapping this deserializer as an adapter for the Jackson ObjectMapper.
*
* @return A {@link SimpleModule} to be plugged onto Jackson ObjectMapper.
*/
public static SimpleModule getModule() {
return MODULE;
}
@Override
public OffsetDateTime deserialize(JsonParser parser, DeserializationContext context) throws IOException {
JsonToken token = parser.currentToken();
if (token == JsonToken.VALUE_NUMBER_INT) {
return OffsetDateTime.ofInstant(Instant.ofEpochSecond(parser.getValueAsLong()), ZoneOffset.UTC);
} else {
TemporalAccessor temporal = DateTimeFormatter.ISO_DATE_TIME.parseBest(
parser.getValueAsString(), OffsetDateTime::from, LocalDateTime::from);
if (temporal.query(TemporalQueries.offset()) == null) {
return LocalDateTime.from(temporal).atOffset(ZoneOffset.UTC);
} else {
return OffsetDateTime.from(temporal);
}
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/core/Environment.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.core;
public final class Environment {
public static final Environment PRODUCTION = new Environment("https://api.extend.ai");
private final String url;
private Environment(String url) {
this.url = url;
}
public String getUrl() {
return this.url;
}
public static Environment custom(String url) {
return new Environment(url);
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/core/ExtendClientApiException.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.core;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import okhttp3.Response;
/**
* This exception type will be thrown for any non-2XX API responses.
*/
public class ExtendClientApiException extends ExtendClientException {
/**
* 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;
private final Map<String, List<String>> headers;
public ExtendClientApiException(String message, int statusCode, Object body) {
super(message);
this.statusCode = statusCode;
this.body = body;
this.headers = new HashMap<>();
}
public ExtendClientApiException(String message, int statusCode, Object body, Response rawResponse) {
super(message);
this.statusCode = statusCode;
this.body = body;
this.headers = new HashMap<>();
rawResponse.headers().forEach(header -> {
String key = header.component1();
String value = header.component2();
this.headers.computeIfAbsent(key, _str -> new ArrayList<>()).add(value);
});
}
/**
* @return the statusCode
*/
public int statusCode() {
return this.statusCode;
}
/**
* @return the body
*/
public Object body() {
return this.body;
}
/**
* @return the headers
*/
public Map<String, List<String>> headers() {
return this.headers;
}
@java.lang.Override
public String toString() {
return "ExtendClientApiException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: "
+ body + "}";
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/core/ExtendClientException.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.core;
/**
* This class serves as the base exception for all errors in the SDK.
*/
public class ExtendClientException extends RuntimeException {
public ExtendClientException(String message) {
super(message);
}
public ExtendClientException(String message, Exception e) {
super(message, e);
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/core/ExtendClientHttpResponse.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.core;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import okhttp3.Response;
public final class ExtendClientHttpResponse<T> {
private final T body;
private final Map<String, List<String>> headers;
public ExtendClientHttpResponse(T body, Response rawResponse) {
this.body = body;
Map<String, List<String>> headers = new HashMap<>();
rawResponse.headers().forEach(header -> {
String key = header.component1();
String value = header.component2();
headers.computeIfAbsent(key, _str -> new ArrayList<>()).add(value);
});
this.headers = headers;
}
public T body() {
return this.body;
}
public Map<String, List<String>> headers() {
return headers;
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/core/FileStream.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.core;
import java.io.InputStream;
import java.util.Objects;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import org.jetbrains.annotations.Nullable;
/**
* Represents a file stream with associated metadata for file uploads.
*/
public class FileStream {
private final InputStream inputStream;
private final String fileName;
private final MediaType contentType;
/**
* Constructs a FileStream with the given input stream and optional metadata.
*
* @param inputStream The input stream of the file content. Must not be null.
* @param fileName The name of the file, or null if unknown.
* @param contentType The MIME type of the file content, or null if unknown.
* @throws NullPointerException if inputStream is null
*/
public FileStream(InputStream inputStream, @Nullable String fileName, @Nullable MediaType contentType) {
this.inputStream = Objects.requireNonNull(inputStream, "Input stream cannot be null");
this.fileName = fileName;
this.contentType = contentType;
}
public FileStream(InputStream inputStream) {
this(inputStream, null, null);
}
public InputStream getInputStream() {
return inputStream;
}
@Nullable
public String getFileName() {
return fileName;
}
@Nullable
public MediaType getContentType() {
return contentType;
}
/**
* Creates a RequestBody suitable for use with OkHttp client.
*
* @return A RequestBody instance representing this file stream.
*/
public RequestBody toRequestBody() {
return new InputStreamRequestBody(contentType, inputStream);
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/core/InputStreamRequestBody.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.core;
import java.io.IOException;
import java.io.InputStream;
import java.util.Objects;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okio.BufferedSink;
import okio.Okio;
import okio.Source;
import org.jetbrains.annotations.Nullable;
/**
* A custom implementation of OkHttp's RequestBody that wraps an InputStream.
* This class allows streaming of data from an InputStream directly to an HTTP request body,
* which is useful for file uploads or sending large amounts of data without loading it all into memory.
*/
public class InputStreamRequestBody extends RequestBody {
private final InputStream inputStream;
private final MediaType contentType;
/**
* Constructs an InputStreamRequestBody with the specified content type and input stream.
*
* @param contentType the MediaType of the content, or null if not known
* @param inputStream the InputStream containing the data to be sent
* @throws NullPointerException if inputStream is null
*/
public InputStreamRequestBody(@Nullable MediaType contentType, InputStream inputStream) {
this.contentType = contentType;
this.inputStream = Objects.requireNonNull(inputStream, "inputStream == null");
}
/**
* Returns the content type of this request body.
*
* @return the MediaType of the content, or null if not specified
*/
@Nullable
@Override
public MediaType contentType() {
return contentType;
}
/**
* Returns the content length of this request body, if known.
* This method attempts to determine the length using the InputStream's available() method,
* which may not always accurately reflect the total length of the stream.
*
* @return the content length, or -1 if the length is unknown
* @throws IOException if an I/O error occurs
*/
@Override
public long contentLength() throws IOException {
return inputStream.available() == 0 ? -1 : inputStream.available();
}
/**
* Writes the content of the InputStream to the given BufferedSink.
* This method is responsible for transferring the data from the InputStream to the network request.
*
* @param sink the BufferedSink to write the content to
* @throws IOException if an I/O error occurs during writing
*/
@Override
public void writeTo(BufferedSink sink) throws IOException {
try (Source source = Okio.source(inputStream)) {
sink.writeAll(source);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/core/MediaTypes.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.core;
import okhttp3.MediaType;
public final class MediaTypes {
public static final MediaType APPLICATION_JSON = MediaType.parse("application/json");
private MediaTypes() {}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/core/Nullable.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.core;
import java.util.Optional;
import java.util.function.Function;
public final class Nullable<T> {
private final Either<Optional<T>, Null> value;
private Nullable() {
this.value = Either.left(Optional.empty());
}
private Nullable(T value) {
if (value == null) {
this.value = Either.right(Null.INSTANCE);
} else {
this.value = Either.left(Optional.of(value));
}
}
public static <T> Nullable<T> ofNull() {
return new Nullable<>(null);
}
public static <T> Nullable<T> of(T value) {
return new Nullable<>(value);
}
public static <T> Nullable<T> empty() {
return new Nullable<>();
}
public static <T> Nullable<T> ofOptional(Optional<T> value) {
if (value.isPresent()) {
return of(value.get());
} else {
return empty();
}
}
public boolean isNull() {
return this.value.isRight();
}
public boolean isEmpty() {
return this.value.isLeft() && !this.value.getLeft().isPresent();
}
public T get() {
if (this.isNull()) {
return null;
}
return this.value.getLeft().get();
}
public <U> Nullable<U> map(Function<? super T, ? extends U> mapper) {
if (this.isNull()) {
return Nullable.ofNull();
}
return Nullable.ofOptional(this.value.getLeft().map(mapper));
}
@Override
public boolean equals(Object other) {
if (!(other instanceof Nullable)) {
return false;
}
if (((Nullable<?>) other).isNull() && this.isNull()) {
return true;
}
return this.value.getLeft().equals(((Nullable<?>) other).value.getLeft());
}
private static final class Either<L, R> {
private L left = null;
private R right = null;
private Either(L left, R right) {
if (left != null && right != null) {
throw new IllegalArgumentException("Left and right argument cannot both be non-null.");
}
if (left == null && right == null) {
throw new IllegalArgumentException("Left and right argument cannot both be null.");
}
if (left != null) {
this.left = left;
}
if (right != null) {
this.right = right;
}
}
public static <L, R> Either<L, R> left(L left) {
return new Either<>(left, null);
}
public static <L, R> Either<L, R> right(R right) {
return new Either<>(null, right);
}
public boolean isLeft() {
return this.left != null;
}
public boolean isRight() {
return this.right != null;
}
public L getLeft() {
if (!this.isLeft()) {
throw new IllegalArgumentException("Cannot get left from right Either.");
}
return this.left;
}
public R getRight() {
if (!this.isRight()) {
throw new IllegalArgumentException("Cannot get right from left Either.");
}
return this.right;
}
}
private static final class Null {
private static final Null INSTANCE = new Null();
private Null() {}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/core/NullableNonemptyFilter.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.core;
import java.util.Optional;
public final class NullableNonemptyFilter {
@Override
public boolean equals(Object o) {
boolean isOptionalEmpty = isOptionalEmpty(o);
return isOptionalEmpty;
}
private boolean isOptionalEmpty(Object o) {
return o instanceof Optional && !((Optional<?>) o).isPresent();
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/core/ObjectMappers.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.core;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import java.io.IOException;
public final class ObjectMappers {
public static final ObjectMapper JSON_MAPPER = JsonMapper.builder()
.addModule(new Jdk8Module())
.addModule(new JavaTimeModule())
.addModule(DateTimeDeserializer.getModule())
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.build();
private ObjectMappers() {}
public static String stringify(Object o) {
try {
return JSON_MAPPER
.setSerializationInclusion(JsonInclude.Include.ALWAYS)
.writerWithDefaultPrettyPrinter()
.writeValueAsString(o);
} catch (IOException e) {
return o.getClass().getName() + "@" + Integer.toHexString(o.hashCode());
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/core/QueryStringMapper.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.core;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import okhttp3.HttpUrl;
import okhttp3.MultipartBody;
public class QueryStringMapper {
private static final ObjectMapper MAPPER = ObjectMappers.JSON_MAPPER;
public static void addQueryParameter(HttpUrl.Builder httpUrl, String key, Object value, boolean arraysAsRepeats) {
JsonNode valueNode = MAPPER.valueToTree(value);
List<Map.Entry<String, JsonNode>> flat;
if (valueNode.isObject()) {
flat = flattenObject((ObjectNode) valueNode, arraysAsRepeats);
} else if (valueNode.isArray()) {
flat = flattenArray((ArrayNode) valueNode, "", arraysAsRepeats);
} else {
if (valueNode.isTextual()) {
httpUrl.addQueryParameter(key, valueNode.textValue());
} else {
httpUrl.addQueryParameter(key, valueNode.toString());
}
return;
}
for (Map.Entry<String, JsonNode> field : flat) {
if (field.getValue().isTextual()) {
httpUrl.addQueryParameter(key + field.getKey(), field.getValue().textValue());
} else {
httpUrl.addQueryParameter(key + field.getKey(), field.getValue().toString());
}
}
}
public static void addFormDataPart(
MultipartBody.Builder multipartBody, String key, Object value, boolean arraysAsRepeats) {
JsonNode valueNode = MAPPER.valueToTree(value);
List<Map.Entry<String, JsonNode>> flat;
if (valueNode.isObject()) {
flat = flattenObject((ObjectNode) valueNode, arraysAsRepeats);
} else if (valueNode.isArray()) {
flat = flattenArray((ArrayNode) valueNode, "", arraysAsRepeats);
} else {
if (valueNode.isTextual()) {
multipartBody.addFormDataPart(key, valueNode.textValue());
} else {
multipartBody.addFormDataPart(key, valueNode.toString());
}
return;
}
for (Map.Entry<String, JsonNode> field : flat) {
if (field.getValue().isTextual()) {
multipartBody.addFormDataPart(
key + field.getKey(), field.getValue().textValue());
} else {
multipartBody.addFormDataPart(
key + field.getKey(), field.getValue().toString());
}
}
}
public static List<Map.Entry<String, JsonNode>> flattenObject(ObjectNode object, boolean arraysAsRepeats) {
List<Map.Entry<String, JsonNode>> flat = new ArrayList<>();
Iterator<Map.Entry<String, JsonNode>> fields = object.fields();
while (fields.hasNext()) {
Map.Entry<String, JsonNode> field = fields.next();
String key = "[" + field.getKey() + "]";
if (field.getValue().isObject()) {
List<Map.Entry<String, JsonNode>> flatField =
flattenObject((ObjectNode) field.getValue(), arraysAsRepeats);
addAll(flat, flatField, key);
} else if (field.getValue().isArray()) {
List<Map.Entry<String, JsonNode>> flatField =
flattenArray((ArrayNode) field.getValue(), key, arraysAsRepeats);
addAll(flat, flatField, "");
} else {
flat.add(new AbstractMap.SimpleEntry<>(key, field.getValue()));
}
}
return flat;
}
private static List<Map.Entry<String, JsonNode>> flattenArray(
ArrayNode array, String key, boolean arraysAsRepeats) {
List<Map.Entry<String, JsonNode>> flat = new ArrayList<>();
Iterator<JsonNode> elements = array.elements();
int index = 0;
while (elements.hasNext()) {
JsonNode element = elements.next();
String indexKey = key + "[" + index + "]";
if (arraysAsRepeats) {
indexKey = key;
}
if (element.isObject()) {
List<Map.Entry<String, JsonNode>> flatField = flattenObject((ObjectNode) element, arraysAsRepeats);
addAll(flat, flatField, indexKey);
} else if (element.isArray()) {
List<Map.Entry<String, JsonNode>> flatField = flattenArray((ArrayNode) element, "", arraysAsRepeats);
addAll(flat, flatField, indexKey);
} else {
flat.add(new AbstractMap.SimpleEntry<>(indexKey, element));
}
index++;
}
return flat;
}
private static void addAll(
List<Map.Entry<String, JsonNode>> target, List<Map.Entry<String, JsonNode>> source, String prefix) {
for (Map.Entry<String, JsonNode> entry : source) {
Map.Entry<String, JsonNode> entryToAdd =
new AbstractMap.SimpleEntry<>(prefix + entry.getKey(), entry.getValue());
target.add(entryToAdd);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/core/RequestOptions.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.core;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
public final class RequestOptions {
private final String token;
private final String extendApiVersion;
private final Optional<Integer> timeout;
private final TimeUnit timeoutTimeUnit;
private final Map<String, String> headers;
private final Map<String, Supplier<String>> headerSuppliers;
private RequestOptions(
String token,
String extendApiVersion,
Optional<Integer> timeout,
TimeUnit timeoutTimeUnit,
Map<String, String> headers,
Map<String, Supplier<String>> headerSuppliers) {
this.token = token;
this.extendApiVersion = extendApiVersion;
this.timeout = timeout;
this.timeoutTimeUnit = timeoutTimeUnit;
this.headers = headers;
this.headerSuppliers = headerSuppliers;
}
public Optional<Integer> getTimeout() {
return timeout;
}
public TimeUnit getTimeoutTimeUnit() {
return timeoutTimeUnit;
}
public Map<String, String> getHeaders() {
Map<String, String> headers = new HashMap<>();
if (this.token != null) {
headers.put("Authorization", "Bearer " + this.token);
}
if (this.extendApiVersion != null) {
headers.put("x-extend-api-version", this.extendApiVersion);
}
headers.putAll(this.headers);
this.headerSuppliers.forEach((key, supplier) -> {
headers.put(key, supplier.get());
});
return headers;
}
public static Builder builder() {
return new Builder();
}
public static class Builder {
private String token = null;
private String extendApiVersion = null;
private Optional<Integer> timeout = Optional.empty();
private TimeUnit timeoutTimeUnit = TimeUnit.SECONDS;
private final Map<String, String> headers = new HashMap<>();
private final Map<String, Supplier<String>> headerSuppliers = new HashMap<>();
public Builder token(String token) {
this.token = token;
return this;
}
public Builder extendApiVersion(String extendApiVersion) {
this.extendApiVersion = extendApiVersion;
return this;
}
public Builder timeout(Integer timeout) {
this.timeout = Optional.of(timeout);
return this;
}
public Builder timeout(Integer timeout, TimeUnit timeoutTimeUnit) {
this.timeout = Optional.of(timeout);
this.timeoutTimeUnit = timeoutTimeUnit;
return this;
}
public Builder addHeader(String key, String value) {
this.headers.put(key, value);
return this;
}
public Builder addHeader(String key, Supplier<String> value) {
this.headerSuppliers.put(key, value);
return this;
}
public RequestOptions build() {
return new RequestOptions(token, extendApiVersion, timeout, timeoutTimeUnit, headers, headerSuppliers);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/core/ResponseBodyInputStream.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.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
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/core/ResponseBodyReader.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.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
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/core/RetryInterceptor.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.core;
import java.io.IOException;
import java.time.Duration;
import java.util.Optional;
import java.util.Random;
import okhttp3.Interceptor;
import okhttp3.Response;
public class RetryInterceptor implements Interceptor {
private static final Duration ONE_SECOND = Duration.ofSeconds(1);
private final ExponentialBackoff backoff;
private final Random random = new Random();
public RetryInterceptor(int maxRetries) {
this.backoff = new ExponentialBackoff(maxRetries);
}
@Override
public Response intercept(Chain chain) throws IOException {
Response response = chain.proceed(chain.request());
if (shouldRetry(response.code())) {
return retryChain(response, chain);
}
return response;
}
private Response retryChain(Response response, Chain chain) throws IOException {
Optional<Duration> nextBackoff = this.backoff.nextBackoff();
while (nextBackoff.isPresent()) {
try {
Thread.sleep(nextBackoff.get().toMillis());
} catch (InterruptedException e) {
throw new IOException("Interrupted while trying request", e);
}
response.close();
response = chain.proceed(chain.request());
if (shouldRetry(response.code())) {
nextBackoff = this.backoff.nextBackoff();
} else {
return response;
}
}
return response;
}
private static boolean shouldRetry(int statusCode) {
return statusCode == 408 || statusCode == 429 || statusCode >= 500;
}
private final class ExponentialBackoff {
private final int maxNumRetries;
private int retryNumber = 0;
ExponentialBackoff(int maxNumRetries) {
this.maxNumRetries = maxNumRetries;
}
public Optional<Duration> nextBackoff() {
retryNumber += 1;
if (retryNumber > maxNumRetries) {
return Optional.empty();
}
int upperBound = (int) Math.pow(2, retryNumber);
return Optional.of(ONE_SECOND.multipliedBy(random.nextInt(upperBound)));
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/core/Stream.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.core;
import java.io.Closeable;
import java.io.IOException;
import java.io.Reader;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Scanner;
/**
* The {@code Stream} class implements {@link Iterable} to provide a simple mechanism for reading and parsing
* objects of a given type from data streamed via a {@link Reader} using a specified delimiter.
* <p>
* {@code Stream} assumes that data is being pushed to the provided {@link Reader} asynchronously and utilizes a
* {@code Scanner} to block during iteration if the next object is not available.
* Iterable stream for parsing JSON and Server-Sent Events (SSE) data.
* Supports both newline-delimited JSON and SSE with optional stream termination.
*
* @param <T> The type of objects in the stream.
*/
public final class Stream<T> implements Iterable<T>, Closeable {
private static final String NEWLINE = "\n";
private static final String DATA_PREFIX = "data:";
public enum StreamType {
JSON,
SSE
}
private final Class<T> valueType;
private final Scanner scanner;
private final StreamType streamType;
private final String messageTerminator;
private final String streamTerminator;
private final Reader sseReader;
private boolean isClosed = false;
/**
* Constructs a new {@code Stream} with the specified value type, reader, and delimiter.
*
* @param valueType The class of the objects in the stream.
* @param reader The reader that provides the streamed data.
* @param delimiter The delimiter used to separate elements in the stream.
*/
public Stream(Class<T> valueType, Reader reader, String delimiter) {
this.valueType = valueType;
this.scanner = new Scanner(reader).useDelimiter(delimiter);
this.streamType = StreamType.JSON;
this.messageTerminator = delimiter;
this.streamTerminator = null;
this.sseReader = null;
}
private Stream(Class<T> valueType, StreamType type, Reader reader, String terminator) {
this.valueType = valueType;
this.streamType = type;
if (type == StreamType.JSON) {
this.scanner = new Scanner(reader).useDelimiter(terminator);
this.messageTerminator = terminator;
this.streamTerminator = null;
this.sseReader = null;
} else {
this.scanner = null;
this.messageTerminator = NEWLINE;
this.streamTerminator = terminator;
this.sseReader = reader;
}
}
public static <T> Stream<T> fromJson(Class<T> valueType, Reader reader, String delimiter) {
return new Stream<>(valueType, reader, delimiter);
}
public static <T> Stream<T> fromJson(Class<T> valueType, Reader reader) {
return new Stream<>(valueType, reader, NEWLINE);
}
public static <T> Stream<T> fromSse(Class<T> valueType, Reader sseReader) {
return new Stream<>(valueType, StreamType.SSE, sseReader, null);
}
public static <T> Stream<T> fromSse(Class<T> valueType, Reader sseReader, String streamTerminator) {
return new Stream<>(valueType, StreamType.SSE, sseReader, streamTerminator);
}
@Override
public void close() throws IOException {
if (!isClosed) {
isClosed = true;
if (scanner != null) {
scanner.close();
}
if (sseReader != null) {
sseReader.close();
}
}
}
private boolean isStreamClosed() {
return isClosed;
}
/**
* Returns an iterator over the elements in this stream that blocks during iteration when the next object is
* not yet available.
*
* @return An iterator that can be used to traverse the elements in the stream.
*/
@Override
public Iterator<T> iterator() {
if (streamType == StreamType.SSE) {
return new SSEIterator();
} else {
return new JsonIterator();
}
}
private final class JsonIterator implements Iterator<T> {
/**
* Returns {@code true} if there are more elements in the stream.
* <p>
* Will block and wait for input if the stream has not ended and the next object is not yet available.
*
* @return {@code true} if there are more elements, {@code false} otherwise.
*/
@Override
public boolean hasNext() {
if (isStreamClosed()) {
return false;
}
return scanner.hasNext();
}
/**
* Returns the next element in the stream.
* <p>
* Will block and wait for input if the stream has not ended and the next object is not yet available.
*
* @return The next element in the stream.
* @throws NoSuchElementException If there are no more elements in the stream.
*/
@Override
public T next() {
if (isStreamClosed()) {
throw new NoSuchElementException("Stream is closed");
}
if (!scanner.hasNext()) {
throw new NoSuchElementException();
} else {
try {
T parsedResponse =
ObjectMappers.JSON_MAPPER.readValue(scanner.next().trim(), valueType);
return parsedResponse;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
}
private final class SSEIterator implements Iterator<T> {
private Scanner sseScanner;
private T nextItem;
private boolean hasNextItem = false;
private boolean endOfStream = false;
private StringBuilder buffer = new StringBuilder();
private boolean prefixSeen = false;
private SSEIterator() {
if (sseReader != null && !isStreamClosed()) {
this.sseScanner = new Scanner(sseReader);
} else {
this.endOfStream = true;
}
}
@Override
public boolean hasNext() {
if (isStreamClosed() || endOfStream) {
return false;
}
if (hasNextItem) {
return true;
}
return readNextMessage();
}
@Override
public T next() {
if (!hasNext()) {
throw new NoSuchElementException("No more elements in stream");
}
T result = nextItem;
nextItem = null;
hasNextItem = false;
return result;
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
private boolean readNextMessage() {
if (sseScanner == null || isStreamClosed()) {
endOfStream = true;
return false;
}
try {
while (sseScanner.hasNextLine()) {
String chunk = sseScanner.nextLine();
buffer.append(chunk).append(NEWLINE);
int terminatorIndex;
while ((terminatorIndex = buffer.indexOf(messageTerminator)) >= 0) {
String line = buffer.substring(0, terminatorIndex + messageTerminator.length());
buffer.delete(0, terminatorIndex + messageTerminator.length());
line = line.trim();
if (line.isEmpty()) {
continue;
}
if (!prefixSeen && line.startsWith(DATA_PREFIX)) {
prefixSeen = true;
line = line.substring(DATA_PREFIX.length()).trim();
} else if (!prefixSeen) {
continue;
}
if (streamTerminator != null && line.contains(streamTerminator)) {
endOfStream = true;
return false;
}
try {
nextItem = ObjectMappers.JSON_MAPPER.readValue(line, valueType);
hasNextItem = true;
prefixSeen = false;
return true;
} catch (Exception parseEx) {
continue;
}
}
}
endOfStream = true;
return false;
} catch (Exception e) {
System.err.println("Failed to parse SSE stream: " + e.getMessage());
endOfStream = true;
return false;
}
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/core/Suppliers.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.core;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;
public final class Suppliers {
private Suppliers() {}
public static <T> Supplier<T> memoize(Supplier<T> delegate) {
AtomicReference<T> value = new AtomicReference<>();
return () -> {
T val = value.get();
if (val == null) {
val = value.updateAndGet(cur -> cur == null ? Objects.requireNonNull(delegate.get()) : cur);
}
return val;
};
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/errors/BadRequestError.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.errors;
import ai.extend.core.ExtendClientApiException;
import okhttp3.Response;
public final class BadRequestError extends ExtendClientApiException {
/**
* The body of the response that triggered the exception.
*/
private final Object body;
public BadRequestError(Object body) {
super("BadRequestError", 400, body);
this.body = body;
}
public BadRequestError(Object body, Response rawResponse) {
super("BadRequestError", 400, body, rawResponse);
this.body = body;
}
/**
* @return the body
*/
@java.lang.Override
public Object body() {
return this.body;
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/errors/InternalServerError.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.errors;
import ai.extend.core.ExtendClientApiException;
import ai.extend.types.ExtendError;
import okhttp3.Response;
public final class InternalServerError extends ExtendClientApiException {
/**
* The body of the response that triggered the exception.
*/
private final ExtendError body;
public InternalServerError(ExtendError body) {
super("InternalServerError", 500, body);
this.body = body;
}
public InternalServerError(ExtendError body, Response rawResponse) {
super("InternalServerError", 500, body, rawResponse);
this.body = body;
}
/**
* @return the body
*/
@java.lang.Override
public ExtendError body() {
return this.body;
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/errors/NotFoundError.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.errors;
import ai.extend.core.ExtendClientApiException;
import okhttp3.Response;
public final class NotFoundError extends ExtendClientApiException {
/**
* The body of the response that triggered the exception.
*/
private final Object body;
public NotFoundError(Object body) {
super("NotFoundError", 404, body);
this.body = body;
}
public NotFoundError(Object body, Response rawResponse) {
super("NotFoundError", 404, body, rawResponse);
this.body = body;
}
/**
* @return the body
*/
@java.lang.Override
public Object body() {
return this.body;
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/errors/PaymentRequiredError.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.errors;
import ai.extend.core.ExtendClientApiException;
import okhttp3.Response;
public final class PaymentRequiredError extends ExtendClientApiException {
/**
* The body of the response that triggered the exception.
*/
private final Object body;
public PaymentRequiredError(Object body) {
super("PaymentRequiredError", 402, body);
this.body = body;
}
public PaymentRequiredError(Object body, Response rawResponse) {
super("PaymentRequiredError", 402, body, rawResponse);
this.body = body;
}
/**
* @return the body
*/
@java.lang.Override
public Object body() {
return this.body;
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/errors/TooManyRequestsError.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.errors;
import ai.extend.core.ExtendClientApiException;
import ai.extend.types.TooManyRequestsErrorBody;
import okhttp3.Response;
public final class TooManyRequestsError extends ExtendClientApiException {
/**
* The body of the response that triggered the exception.
*/
private final TooManyRequestsErrorBody body;
public TooManyRequestsError(TooManyRequestsErrorBody body) {
super("TooManyRequestsError", 429, body);
this.body = body;
}
public TooManyRequestsError(TooManyRequestsErrorBody body, Response rawResponse) {
super("TooManyRequestsError", 429, body, rawResponse);
this.body = body;
}
/**
* @return the body
*/
@java.lang.Override
public TooManyRequestsErrorBody body() {
return this.body;
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/errors/UnauthorizedError.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.errors;
import ai.extend.core.ExtendClientApiException;
import ai.extend.types.Error;
import okhttp3.Response;
public final class UnauthorizedError extends ExtendClientApiException {
/**
* The body of the response that triggered the exception.
*/
private final Error body;
public UnauthorizedError(Error body) {
super("UnauthorizedError", 401, body);
this.body = body;
}
public UnauthorizedError(Error body, Response rawResponse) {
super("UnauthorizedError", 401, body, rawResponse);
this.body = body;
}
/**
* @return the body
*/
@java.lang.Override
public Error body() {
return this.body;
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/errors/UnprocessableEntityError.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.errors;
import ai.extend.core.ExtendClientApiException;
import ai.extend.types.ExtendError;
import okhttp3.Response;
public final class UnprocessableEntityError extends ExtendClientApiException {
/**
* The body of the response that triggered the exception.
*/
private final ExtendError body;
public UnprocessableEntityError(ExtendError body) {
super("UnprocessableEntityError", 422, body);
this.body = body;
}
public UnprocessableEntityError(ExtendError body, Response rawResponse) {
super("UnprocessableEntityError", 422, body, rawResponse);
this.body = body;
}
/**
* @return the body
*/
@java.lang.Override
public ExtendError body() {
return this.body;
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/requests/ParseAsyncRequest.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.requests;
import ai.extend.core.ObjectMappers;
import ai.extend.types.ParseAsyncRequestFile;
import ai.extend.types.ParseConfig;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import org.jetbrains.annotations.NotNull;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = ParseAsyncRequest.Builder.class)
public final class ParseAsyncRequest {
private final ParseAsyncRequestFile file;
private final Optional<ParseConfig> config;
private final Map<String, Object> additionalProperties;
private ParseAsyncRequest(
ParseAsyncRequestFile file, Optional<ParseConfig> config, Map<String, Object> additionalProperties) {
this.file = file;
this.config = config;
this.additionalProperties = additionalProperties;
}
/**
* @return A file object containing either a URL or a fileId.
*/
@JsonProperty("file")
public ParseAsyncRequestFile getFile() {
return file;
}
@JsonProperty("config")
public Optional<ParseConfig> getConfig() {
return config;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof ParseAsyncRequest && equalTo((ParseAsyncRequest) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(ParseAsyncRequest other) {
return file.equals(other.file) && config.equals(other.config);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.file, this.config);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static FileStage builder() {
return new Builder();
}
public interface FileStage {
/**
* <p>A file object containing either a URL or a fileId.</p>
*/
_FinalStage file(@NotNull ParseAsyncRequestFile file);
Builder from(ParseAsyncRequest other);
}
public interface _FinalStage {
ParseAsyncRequest build();
_FinalStage config(Optional<ParseConfig> config);
_FinalStage config(ParseConfig config);
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements FileStage, _FinalStage {
private ParseAsyncRequestFile file;
private Optional<ParseConfig> config = Optional.empty();
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
@java.lang.Override
public Builder from(ParseAsyncRequest other) {
file(other.getFile());
config(other.getConfig());
return this;
}
/**
* <p>A file object containing either a URL or a fileId.</p>
* <p>A file object containing either a URL or a fileId.</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
@JsonSetter("file")
public _FinalStage file(@NotNull ParseAsyncRequestFile file) {
this.file = Objects.requireNonNull(file, "file must not be null");
return this;
}
@java.lang.Override
public _FinalStage config(ParseConfig config) {
this.config = Optional.ofNullable(config);
return this;
}
@java.lang.Override
@JsonSetter(value = "config", nulls = Nulls.SKIP)
public _FinalStage config(Optional<ParseConfig> config) {
this.config = config;
return this;
}
@java.lang.Override
public ParseAsyncRequest build() {
return new ParseAsyncRequest(file, config, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/requests/ParseRequest.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.requests;
import ai.extend.core.ObjectMappers;
import ai.extend.types.ParseConfig;
import ai.extend.types.ParseRequestFile;
import ai.extend.types.ParseRequestResponseType;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import org.jetbrains.annotations.NotNull;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = ParseRequest.Builder.class)
public final class ParseRequest {
private final Optional<ParseRequestResponseType> responseType;
private final ParseRequestFile file;
private final Optional<ParseConfig> config;
private final Map<String, Object> additionalProperties;
private ParseRequest(
Optional<ParseRequestResponseType> responseType,
ParseRequestFile file,
Optional<ParseConfig> config,
Map<String, Object> additionalProperties) {
this.responseType = responseType;
this.file = file;
this.config = config;
this.additionalProperties = additionalProperties;
}
/**
* @return Controls the format of the response chunks. Defaults to <code>json</code> if not specified.
* <ul>
* <li><code>json</code> - Returns parsed outputs in the response body</li>
* <li><code>url</code> - Return a presigned URL to the parsed content in the response body</li>
* </ul>
*/
@JsonProperty("responseType")
public Optional<ParseRequestResponseType> getResponseType() {
return responseType;
}
/**
* @return A file object containing either a URL or a fileId.
*/
@JsonProperty("file")
public ParseRequestFile getFile() {
return file;
}
@JsonProperty("config")
public Optional<ParseConfig> getConfig() {
return config;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof ParseRequest && equalTo((ParseRequest) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(ParseRequest other) {
return responseType.equals(other.responseType) && file.equals(other.file) && config.equals(other.config);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.responseType, this.file, this.config);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static FileStage builder() {
return new Builder();
}
public interface FileStage {
/**
* <p>A file object containing either a URL or a fileId.</p>
*/
_FinalStage file(@NotNull ParseRequestFile file);
Builder from(ParseRequest other);
}
public interface _FinalStage {
ParseRequest build();
/**
* <p>Controls the format of the response chunks. Defaults to <code>json</code> if not specified.</p>
* <ul>
* <li><code>json</code> - Returns parsed outputs in the response body</li>
* <li><code>url</code> - Return a presigned URL to the parsed content in the response body</li>
* </ul>
*/
_FinalStage responseType(Optional<ParseRequestResponseType> responseType);
_FinalStage responseType(ParseRequestResponseType responseType);
_FinalStage config(Optional<ParseConfig> config);
_FinalStage config(ParseConfig config);
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements FileStage, _FinalStage {
private ParseRequestFile file;
private Optional<ParseConfig> config = Optional.empty();
private Optional<ParseRequestResponseType> responseType = Optional.empty();
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
@java.lang.Override
public Builder from(ParseRequest other) {
responseType(other.getResponseType());
file(other.getFile());
config(other.getConfig());
return this;
}
/**
* <p>A file object containing either a URL or a fileId.</p>
* <p>A file object containing either a URL or a fileId.</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
@JsonSetter("file")
public _FinalStage file(@NotNull ParseRequestFile file) {
this.file = Objects.requireNonNull(file, "file must not be null");
return this;
}
@java.lang.Override
public _FinalStage config(ParseConfig config) {
this.config = Optional.ofNullable(config);
return this;
}
@java.lang.Override
@JsonSetter(value = "config", nulls = Nulls.SKIP)
public _FinalStage config(Optional<ParseConfig> config) {
this.config = config;
return this;
}
/**
* <p>Controls the format of the response chunks. Defaults to <code>json</code> if not specified.</p>
* <ul>
* <li><code>json</code> - Returns parsed outputs in the response body</li>
* <li><code>url</code> - Return a presigned URL to the parsed content in the response body</li>
* </ul>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
public _FinalStage responseType(ParseRequestResponseType responseType) {
this.responseType = Optional.ofNullable(responseType);
return this;
}
/**
* <p>Controls the format of the response chunks. Defaults to <code>json</code> if not specified.</p>
* <ul>
* <li><code>json</code> - Returns parsed outputs in the response body</li>
* <li><code>url</code> - Return a presigned URL to the parsed content in the response body</li>
* </ul>
*/
@java.lang.Override
@JsonSetter(value = "responseType", nulls = Nulls.SKIP)
public _FinalStage responseType(Optional<ParseRequestResponseType> responseType) {
this.responseType = responseType;
return this;
}
@java.lang.Override
public ParseRequest build() {
return new ParseRequest(responseType, file, config, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/batchprocessorrun/AsyncBatchProcessorRunClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.batchprocessorrun;
import ai.extend.core.ClientOptions;
import ai.extend.core.RequestOptions;
import ai.extend.resources.batchprocessorrun.types.BatchProcessorRunGetResponse;
import java.util.concurrent.CompletableFuture;
public class AsyncBatchProcessorRunClient {
protected final ClientOptions clientOptions;
private final AsyncRawBatchProcessorRunClient rawClient;
public AsyncBatchProcessorRunClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.rawClient = new AsyncRawBatchProcessorRunClient(clientOptions);
}
/**
* Get responses with HTTP metadata like headers
*/
public AsyncRawBatchProcessorRunClient withRawResponse() {
return this.rawClient;
}
/**
* Retrieve details about a batch processor run, including evaluation runs
*/
public CompletableFuture<BatchProcessorRunGetResponse> get(String id) {
return this.rawClient.get(id).thenApply(response -> response.body());
}
/**
* Retrieve details about a batch processor run, including evaluation runs
*/
public CompletableFuture<BatchProcessorRunGetResponse> get(String id, RequestOptions requestOptions) {
return this.rawClient.get(id, requestOptions).thenApply(response -> response.body());
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/batchprocessorrun/AsyncRawBatchProcessorRunClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.batchprocessorrun;
import ai.extend.core.ClientOptions;
import ai.extend.core.ExtendClientApiException;
import ai.extend.core.ExtendClientException;
import ai.extend.core.ExtendClientHttpResponse;
import ai.extend.core.ObjectMappers;
import ai.extend.core.RequestOptions;
import ai.extend.errors.BadRequestError;
import ai.extend.errors.NotFoundError;
import ai.extend.errors.UnauthorizedError;
import ai.extend.resources.batchprocessorrun.types.BatchProcessorRunGetResponse;
import ai.extend.types.Error;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
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;
public class AsyncRawBatchProcessorRunClient {
protected final ClientOptions clientOptions;
public AsyncRawBatchProcessorRunClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
}
/**
* Retrieve details about a batch processor run, including evaluation runs
*/
public CompletableFuture<ExtendClientHttpResponse<BatchProcessorRunGetResponse>> get(String id) {
return get(id, null);
}
/**
* Retrieve details about a batch processor run, including evaluation runs
*/
public CompletableFuture<ExtendClientHttpResponse<BatchProcessorRunGetResponse>> get(
String id, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("batch_processor_runs")
.addPathSegment(id)
.build();
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("GET", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Accept", "application/json")
.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
CompletableFuture<ExtendClientHttpResponse<BatchProcessorRunGetResponse>> 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(new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(
responseBody.string(), BatchProcessorRunGetResponse.class),
response));
return;
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
future.completeExceptionally(new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
case 401:
future.completeExceptionally(new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
response));
return;
case 404:
future.completeExceptionally(new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
future.completeExceptionally(new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
});
return future;
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/batchprocessorrun/BatchProcessorRunClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.batchprocessorrun;
import ai.extend.core.ClientOptions;
import ai.extend.core.RequestOptions;
import ai.extend.resources.batchprocessorrun.types.BatchProcessorRunGetResponse;
public class BatchProcessorRunClient {
protected final ClientOptions clientOptions;
private final RawBatchProcessorRunClient rawClient;
public BatchProcessorRunClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.rawClient = new RawBatchProcessorRunClient(clientOptions);
}
/**
* Get responses with HTTP metadata like headers
*/
public RawBatchProcessorRunClient withRawResponse() {
return this.rawClient;
}
/**
* Retrieve details about a batch processor run, including evaluation runs
*/
public BatchProcessorRunGetResponse get(String id) {
return this.rawClient.get(id).body();
}
/**
* Retrieve details about a batch processor run, including evaluation runs
*/
public BatchProcessorRunGetResponse get(String id, RequestOptions requestOptions) {
return this.rawClient.get(id, requestOptions).body();
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/batchprocessorrun/RawBatchProcessorRunClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.batchprocessorrun;
import ai.extend.core.ClientOptions;
import ai.extend.core.ExtendClientApiException;
import ai.extend.core.ExtendClientException;
import ai.extend.core.ExtendClientHttpResponse;
import ai.extend.core.ObjectMappers;
import ai.extend.core.RequestOptions;
import ai.extend.errors.BadRequestError;
import ai.extend.errors.NotFoundError;
import ai.extend.errors.UnauthorizedError;
import ai.extend.resources.batchprocessorrun.types.BatchProcessorRunGetResponse;
import ai.extend.types.Error;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
public class RawBatchProcessorRunClient {
protected final ClientOptions clientOptions;
public RawBatchProcessorRunClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
}
/**
* Retrieve details about a batch processor run, including evaluation runs
*/
public ExtendClientHttpResponse<BatchProcessorRunGetResponse> get(String id) {
return get(id, null);
}
/**
* Retrieve details about a batch processor run, including evaluation runs
*/
public ExtendClientHttpResponse<BatchProcessorRunGetResponse> get(String id, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("batch_processor_runs")
.addPathSegment(id)
.build();
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("GET", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Accept", "application/json")
.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), BatchProcessorRunGetResponse.class),
response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
throw new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
case 401:
throw new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 404:
throw new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
throw new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
throw new ExtendClientException("Network error executing HTTP request", e);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/batchprocessorrun
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/batchprocessorrun/types/BatchProcessorRunGetResponse.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.batchprocessorrun.types;
import ai.extend.core.ObjectMappers;
import ai.extend.types.BatchProcessorRun;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = BatchProcessorRunGetResponse.Builder.class)
public final class BatchProcessorRunGetResponse {
private final boolean success;
private final BatchProcessorRun batchProcessorRun;
private final Map<String, Object> additionalProperties;
private BatchProcessorRunGetResponse(
boolean success, BatchProcessorRun batchProcessorRun, Map<String, Object> additionalProperties) {
this.success = success;
this.batchProcessorRun = batchProcessorRun;
this.additionalProperties = additionalProperties;
}
@JsonProperty("success")
public boolean getSuccess() {
return success;
}
@JsonProperty("batchProcessorRun")
public BatchProcessorRun getBatchProcessorRun() {
return batchProcessorRun;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof BatchProcessorRunGetResponse && equalTo((BatchProcessorRunGetResponse) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(BatchProcessorRunGetResponse other) {
return success == other.success && batchProcessorRun.equals(other.batchProcessorRun);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.success, this.batchProcessorRun);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static SuccessStage builder() {
return new Builder();
}
public interface SuccessStage {
BatchProcessorRunStage success(boolean success);
Builder from(BatchProcessorRunGetResponse other);
}
public interface BatchProcessorRunStage {
_FinalStage batchProcessorRun(@NotNull BatchProcessorRun batchProcessorRun);
}
public interface _FinalStage {
BatchProcessorRunGetResponse build();
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements SuccessStage, BatchProcessorRunStage, _FinalStage {
private boolean success;
private BatchProcessorRun batchProcessorRun;
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
@java.lang.Override
public Builder from(BatchProcessorRunGetResponse other) {
success(other.getSuccess());
batchProcessorRun(other.getBatchProcessorRun());
return this;
}
@java.lang.Override
@JsonSetter("success")
public BatchProcessorRunStage success(boolean success) {
this.success = success;
return this;
}
@java.lang.Override
@JsonSetter("batchProcessorRun")
public _FinalStage batchProcessorRun(@NotNull BatchProcessorRun batchProcessorRun) {
this.batchProcessorRun = Objects.requireNonNull(batchProcessorRun, "batchProcessorRun must not be null");
return this;
}
@java.lang.Override
public BatchProcessorRunGetResponse build() {
return new BatchProcessorRunGetResponse(success, batchProcessorRun, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/batchworkflowrun/AsyncBatchWorkflowRunClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.batchworkflowrun;
import ai.extend.core.ClientOptions;
import ai.extend.core.RequestOptions;
import ai.extend.resources.batchworkflowrun.requests.BatchWorkflowRunCreateRequest;
import ai.extend.resources.batchworkflowrun.types.BatchWorkflowRunCreateResponse;
import java.util.concurrent.CompletableFuture;
public class AsyncBatchWorkflowRunClient {
protected final ClientOptions clientOptions;
private final AsyncRawBatchWorkflowRunClient rawClient;
public AsyncBatchWorkflowRunClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.rawClient = new AsyncRawBatchWorkflowRunClient(clientOptions);
}
/**
* Get responses with HTTP metadata like headers
*/
public AsyncRawBatchWorkflowRunClient withRawResponse() {
return this.rawClient;
}
/**
* This endpoint allows you to efficiently initiate large batches of workflow runs in a single request (up to 1,000 in a single request, but you can queue up multiple batches in rapid succession). It accepts an array of inputs, each containing a file and metadata pair. The primary use case for this endpoint is for doing large bulk runs of >1000 files at a time that can process over the course of a few hours without needing to manage rate limits that would likely occur using the primary run endpoint.
* <p>Unlike the single <a href="/developers/api-reference/workflow-endpoints/run-workflow">Run Workflow</a> endpoint which returns the details of the created workflow runs immediately, this batch endpoint returns a <code>batchId</code>.</p>
* <p>Our recommended usage pattern is to integrate with <a href="/product/webhooks/configuration">Webhooks</a> for consuming results, using the <code>metadata</code> and <code>batchId</code> to match up results to the original inputs in your downstream systems. However, you can integrate in a polling mechanism by using a combination of the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/list-workflow-runs">List Workflow Runs</a> endpoint to fetch all runs via a batch, and then <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/get-workflow-run">Get Workflow Run</a> to fetch the full outputs each run.</p>
* <p><strong>Priority:</strong> All workflow runs created through this batch endpoint are automatically assigned a priority of 90.</p>
* <p><strong>Processing and Monitoring:</strong>
* Upon successful submission, the endpoint returns a <code>batchId</code>. The individual workflow runs are then queued for processing.</p>
* <ul>
* <li><strong>Monitoring:</strong> Track the progress and consume results of individual runs using <a href="/product/webhooks/configuration">Webhooks</a>. Subscribe to events like <code>workflow_run.completed</code>, <code>workflow_run.failed</code>, etc. The webhook payload for these events will include the corresponding <code>batchId</code> and the <code>metadata</code> you provided for each input.</li>
* <li><strong>Fetching Results:</strong> You can also use the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/list-workflow-runs">List Workflow Runs</a> endpoint and filter using the <code>batchId</code> query param.</li>
* </ul>
*/
public CompletableFuture<BatchWorkflowRunCreateResponse> create(BatchWorkflowRunCreateRequest request) {
return this.rawClient.create(request).thenApply(response -> response.body());
}
/**
* This endpoint allows you to efficiently initiate large batches of workflow runs in a single request (up to 1,000 in a single request, but you can queue up multiple batches in rapid succession). It accepts an array of inputs, each containing a file and metadata pair. The primary use case for this endpoint is for doing large bulk runs of >1000 files at a time that can process over the course of a few hours without needing to manage rate limits that would likely occur using the primary run endpoint.
* <p>Unlike the single <a href="/developers/api-reference/workflow-endpoints/run-workflow">Run Workflow</a> endpoint which returns the details of the created workflow runs immediately, this batch endpoint returns a <code>batchId</code>.</p>
* <p>Our recommended usage pattern is to integrate with <a href="/product/webhooks/configuration">Webhooks</a> for consuming results, using the <code>metadata</code> and <code>batchId</code> to match up results to the original inputs in your downstream systems. However, you can integrate in a polling mechanism by using a combination of the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/list-workflow-runs">List Workflow Runs</a> endpoint to fetch all runs via a batch, and then <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/get-workflow-run">Get Workflow Run</a> to fetch the full outputs each run.</p>
* <p><strong>Priority:</strong> All workflow runs created through this batch endpoint are automatically assigned a priority of 90.</p>
* <p><strong>Processing and Monitoring:</strong>
* Upon successful submission, the endpoint returns a <code>batchId</code>. The individual workflow runs are then queued for processing.</p>
* <ul>
* <li><strong>Monitoring:</strong> Track the progress and consume results of individual runs using <a href="/product/webhooks/configuration">Webhooks</a>. Subscribe to events like <code>workflow_run.completed</code>, <code>workflow_run.failed</code>, etc. The webhook payload for these events will include the corresponding <code>batchId</code> and the <code>metadata</code> you provided for each input.</li>
* <li><strong>Fetching Results:</strong> You can also use the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/list-workflow-runs">List Workflow Runs</a> endpoint and filter using the <code>batchId</code> query param.</li>
* </ul>
*/
public CompletableFuture<BatchWorkflowRunCreateResponse> create(
BatchWorkflowRunCreateRequest request, RequestOptions requestOptions) {
return this.rawClient.create(request, requestOptions).thenApply(response -> response.body());
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/batchworkflowrun/AsyncRawBatchWorkflowRunClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.batchworkflowrun;
import ai.extend.core.ClientOptions;
import ai.extend.core.ExtendClientApiException;
import ai.extend.core.ExtendClientException;
import ai.extend.core.ExtendClientHttpResponse;
import ai.extend.core.MediaTypes;
import ai.extend.core.ObjectMappers;
import ai.extend.core.RequestOptions;
import ai.extend.errors.BadRequestError;
import ai.extend.errors.NotFoundError;
import ai.extend.errors.UnauthorizedError;
import ai.extend.resources.batchworkflowrun.requests.BatchWorkflowRunCreateRequest;
import ai.extend.resources.batchworkflowrun.types.BatchWorkflowRunCreateResponse;
import ai.extend.types.Error;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.jetbrains.annotations.NotNull;
public class AsyncRawBatchWorkflowRunClient {
protected final ClientOptions clientOptions;
public AsyncRawBatchWorkflowRunClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
}
/**
* This endpoint allows you to efficiently initiate large batches of workflow runs in a single request (up to 1,000 in a single request, but you can queue up multiple batches in rapid succession). It accepts an array of inputs, each containing a file and metadata pair. The primary use case for this endpoint is for doing large bulk runs of >1000 files at a time that can process over the course of a few hours without needing to manage rate limits that would likely occur using the primary run endpoint.
* <p>Unlike the single <a href="/developers/api-reference/workflow-endpoints/run-workflow">Run Workflow</a> endpoint which returns the details of the created workflow runs immediately, this batch endpoint returns a <code>batchId</code>.</p>
* <p>Our recommended usage pattern is to integrate with <a href="/product/webhooks/configuration">Webhooks</a> for consuming results, using the <code>metadata</code> and <code>batchId</code> to match up results to the original inputs in your downstream systems. However, you can integrate in a polling mechanism by using a combination of the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/list-workflow-runs">List Workflow Runs</a> endpoint to fetch all runs via a batch, and then <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/get-workflow-run">Get Workflow Run</a> to fetch the full outputs each run.</p>
* <p><strong>Priority:</strong> All workflow runs created through this batch endpoint are automatically assigned a priority of 90.</p>
* <p><strong>Processing and Monitoring:</strong>
* Upon successful submission, the endpoint returns a <code>batchId</code>. The individual workflow runs are then queued for processing.</p>
* <ul>
* <li><strong>Monitoring:</strong> Track the progress and consume results of individual runs using <a href="/product/webhooks/configuration">Webhooks</a>. Subscribe to events like <code>workflow_run.completed</code>, <code>workflow_run.failed</code>, etc. The webhook payload for these events will include the corresponding <code>batchId</code> and the <code>metadata</code> you provided for each input.</li>
* <li><strong>Fetching Results:</strong> You can also use the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/list-workflow-runs">List Workflow Runs</a> endpoint and filter using the <code>batchId</code> query param.</li>
* </ul>
*/
public CompletableFuture<ExtendClientHttpResponse<BatchWorkflowRunCreateResponse>> create(
BatchWorkflowRunCreateRequest request) {
return create(request, null);
}
/**
* This endpoint allows you to efficiently initiate large batches of workflow runs in a single request (up to 1,000 in a single request, but you can queue up multiple batches in rapid succession). It accepts an array of inputs, each containing a file and metadata pair. The primary use case for this endpoint is for doing large bulk runs of >1000 files at a time that can process over the course of a few hours without needing to manage rate limits that would likely occur using the primary run endpoint.
* <p>Unlike the single <a href="/developers/api-reference/workflow-endpoints/run-workflow">Run Workflow</a> endpoint which returns the details of the created workflow runs immediately, this batch endpoint returns a <code>batchId</code>.</p>
* <p>Our recommended usage pattern is to integrate with <a href="/product/webhooks/configuration">Webhooks</a> for consuming results, using the <code>metadata</code> and <code>batchId</code> to match up results to the original inputs in your downstream systems. However, you can integrate in a polling mechanism by using a combination of the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/list-workflow-runs">List Workflow Runs</a> endpoint to fetch all runs via a batch, and then <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/get-workflow-run">Get Workflow Run</a> to fetch the full outputs each run.</p>
* <p><strong>Priority:</strong> All workflow runs created through this batch endpoint are automatically assigned a priority of 90.</p>
* <p><strong>Processing and Monitoring:</strong>
* Upon successful submission, the endpoint returns a <code>batchId</code>. The individual workflow runs are then queued for processing.</p>
* <ul>
* <li><strong>Monitoring:</strong> Track the progress and consume results of individual runs using <a href="/product/webhooks/configuration">Webhooks</a>. Subscribe to events like <code>workflow_run.completed</code>, <code>workflow_run.failed</code>, etc. The webhook payload for these events will include the corresponding <code>batchId</code> and the <code>metadata</code> you provided for each input.</li>
* <li><strong>Fetching Results:</strong> You can also use the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/list-workflow-runs">List Workflow Runs</a> endpoint and filter using the <code>batchId</code> query param.</li>
* </ul>
*/
public CompletableFuture<ExtendClientHttpResponse<BatchWorkflowRunCreateResponse>> create(
BatchWorkflowRunCreateRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("workflow_runs/batch")
.build();
RequestBody body;
try {
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (JsonProcessingException e) {
throw new ExtendClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("POST", body)
.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<ExtendClientHttpResponse<BatchWorkflowRunCreateResponse>> 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(new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(
responseBody.string(), BatchWorkflowRunCreateResponse.class),
response));
return;
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
future.completeExceptionally(new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
case 401:
future.completeExceptionally(new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
response));
return;
case 404:
future.completeExceptionally(new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
future.completeExceptionally(new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
});
return future;
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/batchworkflowrun/BatchWorkflowRunClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.batchworkflowrun;
import ai.extend.core.ClientOptions;
import ai.extend.core.RequestOptions;
import ai.extend.resources.batchworkflowrun.requests.BatchWorkflowRunCreateRequest;
import ai.extend.resources.batchworkflowrun.types.BatchWorkflowRunCreateResponse;
public class BatchWorkflowRunClient {
protected final ClientOptions clientOptions;
private final RawBatchWorkflowRunClient rawClient;
public BatchWorkflowRunClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.rawClient = new RawBatchWorkflowRunClient(clientOptions);
}
/**
* Get responses with HTTP metadata like headers
*/
public RawBatchWorkflowRunClient withRawResponse() {
return this.rawClient;
}
/**
* This endpoint allows you to efficiently initiate large batches of workflow runs in a single request (up to 1,000 in a single request, but you can queue up multiple batches in rapid succession). It accepts an array of inputs, each containing a file and metadata pair. The primary use case for this endpoint is for doing large bulk runs of >1000 files at a time that can process over the course of a few hours without needing to manage rate limits that would likely occur using the primary run endpoint.
* <p>Unlike the single <a href="/developers/api-reference/workflow-endpoints/run-workflow">Run Workflow</a> endpoint which returns the details of the created workflow runs immediately, this batch endpoint returns a <code>batchId</code>.</p>
* <p>Our recommended usage pattern is to integrate with <a href="/product/webhooks/configuration">Webhooks</a> for consuming results, using the <code>metadata</code> and <code>batchId</code> to match up results to the original inputs in your downstream systems. However, you can integrate in a polling mechanism by using a combination of the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/list-workflow-runs">List Workflow Runs</a> endpoint to fetch all runs via a batch, and then <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/get-workflow-run">Get Workflow Run</a> to fetch the full outputs each run.</p>
* <p><strong>Priority:</strong> All workflow runs created through this batch endpoint are automatically assigned a priority of 90.</p>
* <p><strong>Processing and Monitoring:</strong>
* Upon successful submission, the endpoint returns a <code>batchId</code>. The individual workflow runs are then queued for processing.</p>
* <ul>
* <li><strong>Monitoring:</strong> Track the progress and consume results of individual runs using <a href="/product/webhooks/configuration">Webhooks</a>. Subscribe to events like <code>workflow_run.completed</code>, <code>workflow_run.failed</code>, etc. The webhook payload for these events will include the corresponding <code>batchId</code> and the <code>metadata</code> you provided for each input.</li>
* <li><strong>Fetching Results:</strong> You can also use the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/list-workflow-runs">List Workflow Runs</a> endpoint and filter using the <code>batchId</code> query param.</li>
* </ul>
*/
public BatchWorkflowRunCreateResponse create(BatchWorkflowRunCreateRequest request) {
return this.rawClient.create(request).body();
}
/**
* This endpoint allows you to efficiently initiate large batches of workflow runs in a single request (up to 1,000 in a single request, but you can queue up multiple batches in rapid succession). It accepts an array of inputs, each containing a file and metadata pair. The primary use case for this endpoint is for doing large bulk runs of >1000 files at a time that can process over the course of a few hours without needing to manage rate limits that would likely occur using the primary run endpoint.
* <p>Unlike the single <a href="/developers/api-reference/workflow-endpoints/run-workflow">Run Workflow</a> endpoint which returns the details of the created workflow runs immediately, this batch endpoint returns a <code>batchId</code>.</p>
* <p>Our recommended usage pattern is to integrate with <a href="/product/webhooks/configuration">Webhooks</a> for consuming results, using the <code>metadata</code> and <code>batchId</code> to match up results to the original inputs in your downstream systems. However, you can integrate in a polling mechanism by using a combination of the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/list-workflow-runs">List Workflow Runs</a> endpoint to fetch all runs via a batch, and then <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/get-workflow-run">Get Workflow Run</a> to fetch the full outputs each run.</p>
* <p><strong>Priority:</strong> All workflow runs created through this batch endpoint are automatically assigned a priority of 90.</p>
* <p><strong>Processing and Monitoring:</strong>
* Upon successful submission, the endpoint returns a <code>batchId</code>. The individual workflow runs are then queued for processing.</p>
* <ul>
* <li><strong>Monitoring:</strong> Track the progress and consume results of individual runs using <a href="/product/webhooks/configuration">Webhooks</a>. Subscribe to events like <code>workflow_run.completed</code>, <code>workflow_run.failed</code>, etc. The webhook payload for these events will include the corresponding <code>batchId</code> and the <code>metadata</code> you provided for each input.</li>
* <li><strong>Fetching Results:</strong> You can also use the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/list-workflow-runs">List Workflow Runs</a> endpoint and filter using the <code>batchId</code> query param.</li>
* </ul>
*/
public BatchWorkflowRunCreateResponse create(BatchWorkflowRunCreateRequest request, RequestOptions requestOptions) {
return this.rawClient.create(request, requestOptions).body();
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/batchworkflowrun/RawBatchWorkflowRunClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.batchworkflowrun;
import ai.extend.core.ClientOptions;
import ai.extend.core.ExtendClientApiException;
import ai.extend.core.ExtendClientException;
import ai.extend.core.ExtendClientHttpResponse;
import ai.extend.core.MediaTypes;
import ai.extend.core.ObjectMappers;
import ai.extend.core.RequestOptions;
import ai.extend.errors.BadRequestError;
import ai.extend.errors.NotFoundError;
import ai.extend.errors.UnauthorizedError;
import ai.extend.resources.batchworkflowrun.requests.BatchWorkflowRunCreateRequest;
import ai.extend.resources.batchworkflowrun.types.BatchWorkflowRunCreateResponse;
import ai.extend.types.Error;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;
public class RawBatchWorkflowRunClient {
protected final ClientOptions clientOptions;
public RawBatchWorkflowRunClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
}
/**
* This endpoint allows you to efficiently initiate large batches of workflow runs in a single request (up to 1,000 in a single request, but you can queue up multiple batches in rapid succession). It accepts an array of inputs, each containing a file and metadata pair. The primary use case for this endpoint is for doing large bulk runs of >1000 files at a time that can process over the course of a few hours without needing to manage rate limits that would likely occur using the primary run endpoint.
* <p>Unlike the single <a href="/developers/api-reference/workflow-endpoints/run-workflow">Run Workflow</a> endpoint which returns the details of the created workflow runs immediately, this batch endpoint returns a <code>batchId</code>.</p>
* <p>Our recommended usage pattern is to integrate with <a href="/product/webhooks/configuration">Webhooks</a> for consuming results, using the <code>metadata</code> and <code>batchId</code> to match up results to the original inputs in your downstream systems. However, you can integrate in a polling mechanism by using a combination of the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/list-workflow-runs">List Workflow Runs</a> endpoint to fetch all runs via a batch, and then <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/get-workflow-run">Get Workflow Run</a> to fetch the full outputs each run.</p>
* <p><strong>Priority:</strong> All workflow runs created through this batch endpoint are automatically assigned a priority of 90.</p>
* <p><strong>Processing and Monitoring:</strong>
* Upon successful submission, the endpoint returns a <code>batchId</code>. The individual workflow runs are then queued for processing.</p>
* <ul>
* <li><strong>Monitoring:</strong> Track the progress and consume results of individual runs using <a href="/product/webhooks/configuration">Webhooks</a>. Subscribe to events like <code>workflow_run.completed</code>, <code>workflow_run.failed</code>, etc. The webhook payload for these events will include the corresponding <code>batchId</code> and the <code>metadata</code> you provided for each input.</li>
* <li><strong>Fetching Results:</strong> You can also use the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/list-workflow-runs">List Workflow Runs</a> endpoint and filter using the <code>batchId</code> query param.</li>
* </ul>
*/
public ExtendClientHttpResponse<BatchWorkflowRunCreateResponse> create(BatchWorkflowRunCreateRequest request) {
return create(request, null);
}
/**
* This endpoint allows you to efficiently initiate large batches of workflow runs in a single request (up to 1,000 in a single request, but you can queue up multiple batches in rapid succession). It accepts an array of inputs, each containing a file and metadata pair. The primary use case for this endpoint is for doing large bulk runs of >1000 files at a time that can process over the course of a few hours without needing to manage rate limits that would likely occur using the primary run endpoint.
* <p>Unlike the single <a href="/developers/api-reference/workflow-endpoints/run-workflow">Run Workflow</a> endpoint which returns the details of the created workflow runs immediately, this batch endpoint returns a <code>batchId</code>.</p>
* <p>Our recommended usage pattern is to integrate with <a href="/product/webhooks/configuration">Webhooks</a> for consuming results, using the <code>metadata</code> and <code>batchId</code> to match up results to the original inputs in your downstream systems. However, you can integrate in a polling mechanism by using a combination of the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/list-workflow-runs">List Workflow Runs</a> endpoint to fetch all runs via a batch, and then <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/get-workflow-run">Get Workflow Run</a> to fetch the full outputs each run.</p>
* <p><strong>Priority:</strong> All workflow runs created through this batch endpoint are automatically assigned a priority of 90.</p>
* <p><strong>Processing and Monitoring:</strong>
* Upon successful submission, the endpoint returns a <code>batchId</code>. The individual workflow runs are then queued for processing.</p>
* <ul>
* <li><strong>Monitoring:</strong> Track the progress and consume results of individual runs using <a href="/product/webhooks/configuration">Webhooks</a>. Subscribe to events like <code>workflow_run.completed</code>, <code>workflow_run.failed</code>, etc. The webhook payload for these events will include the corresponding <code>batchId</code> and the <code>metadata</code> you provided for each input.</li>
* <li><strong>Fetching Results:</strong> You can also use the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/list-workflow-runs">List Workflow Runs</a> endpoint and filter using the <code>batchId</code> query param.</li>
* </ul>
*/
public ExtendClientHttpResponse<BatchWorkflowRunCreateResponse> create(
BatchWorkflowRunCreateRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("workflow_runs/batch")
.build();
RequestBody body;
try {
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (JsonProcessingException e) {
throw new ExtendClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("POST", body)
.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);
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(
responseBody.string(), BatchWorkflowRunCreateResponse.class),
response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
throw new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
case 401:
throw new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 404:
throw new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
throw new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
throw new ExtendClientException("Network error executing HTTP request", e);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/batchworkflowrun
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/batchworkflowrun/requests/BatchWorkflowRunCreateRequest.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.batchworkflowrun.requests;
import ai.extend.core.ObjectMappers;
import ai.extend.resources.batchworkflowrun.types.BatchWorkflowRunCreateRequestInputsItem;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import org.jetbrains.annotations.NotNull;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = BatchWorkflowRunCreateRequest.Builder.class)
public final class BatchWorkflowRunCreateRequest {
private final String workflowId;
private final Optional<String> version;
private final List<BatchWorkflowRunCreateRequestInputsItem> inputs;
private final Map<String, Object> additionalProperties;
private BatchWorkflowRunCreateRequest(
String workflowId,
Optional<String> version,
List<BatchWorkflowRunCreateRequestInputsItem> inputs,
Map<String, Object> additionalProperties) {
this.workflowId = workflowId;
this.version = version;
this.inputs = inputs;
this.additionalProperties = additionalProperties;
}
/**
* @return The ID of the workflow to run. This ID will start with "workflow_". This ID can be found viewing the workflow on the Extend platform.
* <p>Example: <code>"workflow_BMdfq_yWM3sT-ZzvCnA3f"</code></p>
*/
@JsonProperty("workflowId")
public String getWorkflowId() {
return workflowId;
}
/**
* @return An optional version of the workflow to use. This can be a specific version number (e.g., <code>"1"</code>, <code>"2"</code>) found on the Extend platform, or <code>"draft"</code> to use the current unpublished draft version. When a version is not supplied, the latest deployed version of the workflow will be used. If no deployed version exists, the draft version will be used.
*/
@JsonProperty("version")
public Optional<String> getVersion() {
return version;
}
/**
* @return An array of input objects to be processed by the workflow. Each object represents a single workflow run to be created. The array must contain at least 1 input and at most 1000 inputs.
*/
@JsonProperty("inputs")
public List<BatchWorkflowRunCreateRequestInputsItem> getInputs() {
return inputs;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof BatchWorkflowRunCreateRequest && equalTo((BatchWorkflowRunCreateRequest) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(BatchWorkflowRunCreateRequest other) {
return workflowId.equals(other.workflowId) && version.equals(other.version) && inputs.equals(other.inputs);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.workflowId, this.version, this.inputs);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static WorkflowIdStage builder() {
return new Builder();
}
public interface WorkflowIdStage {
/**
* <p>The ID of the workflow to run. This ID will start with "workflow_". This ID can be found viewing the workflow on the Extend platform.</p>
* <p>Example: <code>"workflow_BMdfq_yWM3sT-ZzvCnA3f"</code></p>
*/
_FinalStage workflowId(@NotNull String workflowId);
Builder from(BatchWorkflowRunCreateRequest other);
}
public interface _FinalStage {
BatchWorkflowRunCreateRequest build();
/**
* <p>An optional version of the workflow to use. This can be a specific version number (e.g., <code>"1"</code>, <code>"2"</code>) found on the Extend platform, or <code>"draft"</code> to use the current unpublished draft version. When a version is not supplied, the latest deployed version of the workflow will be used. If no deployed version exists, the draft version will be used.</p>
*/
_FinalStage version(Optional<String> version);
_FinalStage version(String version);
/**
* <p>An array of input objects to be processed by the workflow. Each object represents a single workflow run to be created. The array must contain at least 1 input and at most 1000 inputs.</p>
*/
_FinalStage inputs(List<BatchWorkflowRunCreateRequestInputsItem> inputs);
_FinalStage addInputs(BatchWorkflowRunCreateRequestInputsItem inputs);
_FinalStage addAllInputs(List<BatchWorkflowRunCreateRequestInputsItem> inputs);
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements WorkflowIdStage, _FinalStage {
private String workflowId;
private List<BatchWorkflowRunCreateRequestInputsItem> inputs = new ArrayList<>();
private Optional<String> version = Optional.empty();
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
@java.lang.Override
public Builder from(BatchWorkflowRunCreateRequest other) {
workflowId(other.getWorkflowId());
version(other.getVersion());
inputs(other.getInputs());
return this;
}
/**
* <p>The ID of the workflow to run. This ID will start with "workflow_". This ID can be found viewing the workflow on the Extend platform.</p>
* <p>Example: <code>"workflow_BMdfq_yWM3sT-ZzvCnA3f"</code></p>
* <p>The ID of the workflow to run. This ID will start with "workflow_". This ID can be found viewing the workflow on the Extend platform.</p>
* <p>Example: <code>"workflow_BMdfq_yWM3sT-ZzvCnA3f"</code></p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
@JsonSetter("workflowId")
public _FinalStage workflowId(@NotNull String workflowId) {
this.workflowId = Objects.requireNonNull(workflowId, "workflowId must not be null");
return this;
}
/**
* <p>An array of input objects to be processed by the workflow. Each object represents a single workflow run to be created. The array must contain at least 1 input and at most 1000 inputs.</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
public _FinalStage addAllInputs(List<BatchWorkflowRunCreateRequestInputsItem> inputs) {
this.inputs.addAll(inputs);
return this;
}
/**
* <p>An array of input objects to be processed by the workflow. Each object represents a single workflow run to be created. The array must contain at least 1 input and at most 1000 inputs.</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
public _FinalStage addInputs(BatchWorkflowRunCreateRequestInputsItem inputs) {
this.inputs.add(inputs);
return this;
}
/**
* <p>An array of input objects to be processed by the workflow. Each object represents a single workflow run to be created. The array must contain at least 1 input and at most 1000 inputs.</p>
*/
@java.lang.Override
@JsonSetter(value = "inputs", nulls = Nulls.SKIP)
public _FinalStage inputs(List<BatchWorkflowRunCreateRequestInputsItem> inputs) {
this.inputs.clear();
this.inputs.addAll(inputs);
return this;
}
/**
* <p>An optional version of the workflow to use. This can be a specific version number (e.g., <code>"1"</code>, <code>"2"</code>) found on the Extend platform, or <code>"draft"</code> to use the current unpublished draft version. When a version is not supplied, the latest deployed version of the workflow will be used. If no deployed version exists, the draft version will be used.</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
public _FinalStage version(String version) {
this.version = Optional.ofNullable(version);
return this;
}
/**
* <p>An optional version of the workflow to use. This can be a specific version number (e.g., <code>"1"</code>, <code>"2"</code>) found on the Extend platform, or <code>"draft"</code> to use the current unpublished draft version. When a version is not supplied, the latest deployed version of the workflow will be used. If no deployed version exists, the draft version will be used.</p>
*/
@java.lang.Override
@JsonSetter(value = "version", nulls = Nulls.SKIP)
public _FinalStage version(Optional<String> version) {
this.version = version;
return this;
}
@java.lang.Override
public BatchWorkflowRunCreateRequest build() {
return new BatchWorkflowRunCreateRequest(workflowId, version, inputs, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/batchworkflowrun
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/batchworkflowrun/types/BatchWorkflowRunCreateRequestInputsItem.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.batchworkflowrun.types;
import ai.extend.core.ObjectMappers;
import ai.extend.types.BatchWorkflowRunFileInput;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = BatchWorkflowRunCreateRequestInputsItem.Builder.class)
public final class BatchWorkflowRunCreateRequestInputsItem {
private final Optional<BatchWorkflowRunFileInput> file;
private final Optional<String> rawText;
private final Optional<Map<String, Object>> metadata;
private final Optional<Map<String, Object>> secrets;
private final Map<String, Object> additionalProperties;
private BatchWorkflowRunCreateRequestInputsItem(
Optional<BatchWorkflowRunFileInput> file,
Optional<String> rawText,
Optional<Map<String, Object>> metadata,
Optional<Map<String, Object>> secrets,
Map<String, Object> additionalProperties) {
this.file = file;
this.rawText = rawText;
this.metadata = metadata;
this.secrets = secrets;
this.additionalProperties = additionalProperties;
}
/**
* @return The file to be processed. Either <code>file</code> or <code>rawText</code> must be provided for each input.
*/
@JsonProperty("file")
public Optional<BatchWorkflowRunFileInput> getFile() {
return file;
}
/**
* @return A string containing raw text data to be processed. This will be treated as a <code>.txt</code> file by the workflow. Use the <code>file</code> parameter for structured data or specific file types. Either <code>file</code> or <code>rawText</code> must be provided for each input.
*/
@JsonProperty("rawText")
public Optional<String> getRawText() {
return rawText;
}
/**
* @return An optional object containing arbitrary key-value pairs to associate with this specific workflow run. This metadata will be included in webhook payloads and responses when fetching the workflow run details.
*/
@JsonProperty("metadata")
public Optional<Map<String, Object>> getMetadata() {
return metadata;
}
/**
* @return An optional object containing secrets to be used by processors within the workflow for this specific run. Secrets provided here override any globally configured secrets for the workflow.
*/
@JsonProperty("secrets")
public Optional<Map<String, Object>> getSecrets() {
return secrets;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof BatchWorkflowRunCreateRequestInputsItem
&& equalTo((BatchWorkflowRunCreateRequestInputsItem) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(BatchWorkflowRunCreateRequestInputsItem other) {
return file.equals(other.file)
&& rawText.equals(other.rawText)
&& metadata.equals(other.metadata)
&& secrets.equals(other.secrets);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.file, this.rawText, this.metadata, this.secrets);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static Builder builder() {
return new Builder();
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder {
private Optional<BatchWorkflowRunFileInput> file = Optional.empty();
private Optional<String> rawText = Optional.empty();
private Optional<Map<String, Object>> metadata = Optional.empty();
private Optional<Map<String, Object>> secrets = Optional.empty();
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
public Builder from(BatchWorkflowRunCreateRequestInputsItem other) {
file(other.getFile());
rawText(other.getRawText());
metadata(other.getMetadata());
secrets(other.getSecrets());
return this;
}
/**
* <p>The file to be processed. Either <code>file</code> or <code>rawText</code> must be provided for each input.</p>
*/
@JsonSetter(value = "file", nulls = Nulls.SKIP)
public Builder file(Optional<BatchWorkflowRunFileInput> file) {
this.file = file;
return this;
}
public Builder file(BatchWorkflowRunFileInput file) {
this.file = Optional.ofNullable(file);
return this;
}
/**
* <p>A string containing raw text data to be processed. This will be treated as a <code>.txt</code> file by the workflow. Use the <code>file</code> parameter for structured data or specific file types. Either <code>file</code> or <code>rawText</code> must be provided for each input.</p>
*/
@JsonSetter(value = "rawText", nulls = Nulls.SKIP)
public Builder rawText(Optional<String> rawText) {
this.rawText = rawText;
return this;
}
public Builder rawText(String rawText) {
this.rawText = Optional.ofNullable(rawText);
return this;
}
/**
* <p>An optional object containing arbitrary key-value pairs to associate with this specific workflow run. This metadata will be included in webhook payloads and responses when fetching the workflow run details.</p>
*/
@JsonSetter(value = "metadata", nulls = Nulls.SKIP)
public Builder metadata(Optional<Map<String, Object>> metadata) {
this.metadata = metadata;
return this;
}
public Builder metadata(Map<String, Object> metadata) {
this.metadata = Optional.ofNullable(metadata);
return this;
}
/**
* <p>An optional object containing secrets to be used by processors within the workflow for this specific run. Secrets provided here override any globally configured secrets for the workflow.</p>
*/
@JsonSetter(value = "secrets", nulls = Nulls.SKIP)
public Builder secrets(Optional<Map<String, Object>> secrets) {
this.secrets = secrets;
return this;
}
public Builder secrets(Map<String, Object> secrets) {
this.secrets = Optional.ofNullable(secrets);
return this;
}
public BatchWorkflowRunCreateRequestInputsItem build() {
return new BatchWorkflowRunCreateRequestInputsItem(file, rawText, metadata, secrets, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/batchworkflowrun
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/batchworkflowrun/types/BatchWorkflowRunCreateResponse.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.batchworkflowrun.types;
import ai.extend.core.ObjectMappers;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = BatchWorkflowRunCreateResponse.Builder.class)
public final class BatchWorkflowRunCreateResponse {
private final boolean success;
private final String batchId;
private final Map<String, Object> additionalProperties;
private BatchWorkflowRunCreateResponse(boolean success, String batchId, Map<String, Object> additionalProperties) {
this.success = success;
this.batchId = batchId;
this.additionalProperties = additionalProperties;
}
/**
* @return Indicates whether the batch request was successfully accepted and queued. <code>true</code> signifies success.
*/
@JsonProperty("success")
public boolean getSuccess() {
return success;
}
/**
* @return A unique identifier for the submitted batch. This ID can be used to correlate the workflow runs created by this request. You can find this <code>batchId</code> associated with individual runs when listing workflow runs or in webhook payloads.
*/
@JsonProperty("batchId")
public String getBatchId() {
return batchId;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof BatchWorkflowRunCreateResponse && equalTo((BatchWorkflowRunCreateResponse) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(BatchWorkflowRunCreateResponse other) {
return success == other.success && batchId.equals(other.batchId);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.success, this.batchId);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static SuccessStage builder() {
return new Builder();
}
public interface SuccessStage {
/**
* <p>Indicates whether the batch request was successfully accepted and queued. <code>true</code> signifies success.</p>
*/
BatchIdStage success(boolean success);
Builder from(BatchWorkflowRunCreateResponse other);
}
public interface BatchIdStage {
/**
* <p>A unique identifier for the submitted batch. This ID can be used to correlate the workflow runs created by this request. You can find this <code>batchId</code> associated with individual runs when listing workflow runs or in webhook payloads.</p>
*/
_FinalStage batchId(@NotNull String batchId);
}
public interface _FinalStage {
BatchWorkflowRunCreateResponse build();
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements SuccessStage, BatchIdStage, _FinalStage {
private boolean success;
private String batchId;
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
@java.lang.Override
public Builder from(BatchWorkflowRunCreateResponse other) {
success(other.getSuccess());
batchId(other.getBatchId());
return this;
}
/**
* <p>Indicates whether the batch request was successfully accepted and queued. <code>true</code> signifies success.</p>
* <p>Indicates whether the batch request was successfully accepted and queued. <code>true</code> signifies success.</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
@JsonSetter("success")
public BatchIdStage success(boolean success) {
this.success = success;
return this;
}
/**
* <p>A unique identifier for the submitted batch. This ID can be used to correlate the workflow runs created by this request. You can find this <code>batchId</code> associated with individual runs when listing workflow runs or in webhook payloads.</p>
* <p>A unique identifier for the submitted batch. This ID can be used to correlate the workflow runs created by this request. You can find this <code>batchId</code> associated with individual runs when listing workflow runs or in webhook payloads.</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
@JsonSetter("batchId")
public _FinalStage batchId(@NotNull String batchId) {
this.batchId = Objects.requireNonNull(batchId, "batchId must not be null");
return this;
}
@java.lang.Override
public BatchWorkflowRunCreateResponse build() {
return new BatchWorkflowRunCreateResponse(success, batchId, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationset/AsyncEvaluationSetClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.evaluationset;
import ai.extend.core.ClientOptions;
import ai.extend.core.RequestOptions;
import ai.extend.resources.evaluationset.requests.EvaluationSetCreateRequest;
import ai.extend.resources.evaluationset.requests.EvaluationSetListRequest;
import ai.extend.resources.evaluationset.types.EvaluationSetCreateResponse;
import ai.extend.resources.evaluationset.types.EvaluationSetGetResponse;
import ai.extend.resources.evaluationset.types.EvaluationSetListResponse;
import java.util.concurrent.CompletableFuture;
public class AsyncEvaluationSetClient {
protected final ClientOptions clientOptions;
private final AsyncRawEvaluationSetClient rawClient;
public AsyncEvaluationSetClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.rawClient = new AsyncRawEvaluationSetClient(clientOptions);
}
/**
* Get responses with HTTP metadata like headers
*/
public AsyncRawEvaluationSetClient withRawResponse() {
return this.rawClient;
}
/**
* List evaluation sets in your account. You can use the <code>processorId</code> parameter to filter evaluation sets by processor.
* <p>This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.</p>
*/
public CompletableFuture<EvaluationSetListResponse> list() {
return this.rawClient.list().thenApply(response -> response.body());
}
/**
* List evaluation sets in your account. You can use the <code>processorId</code> parameter to filter evaluation sets by processor.
* <p>This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.</p>
*/
public CompletableFuture<EvaluationSetListResponse> list(EvaluationSetListRequest request) {
return this.rawClient.list(request).thenApply(response -> response.body());
}
/**
* List evaluation sets in your account. You can use the <code>processorId</code> parameter to filter evaluation sets by processor.
* <p>This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.</p>
*/
public CompletableFuture<EvaluationSetListResponse> list(
EvaluationSetListRequest request, RequestOptions requestOptions) {
return this.rawClient.list(request, requestOptions).thenApply(response -> response.body());
}
/**
* Evaluation sets are collections of files and expected outputs that are used to evaluate the performance of a given processor in Extend. This endpoint will create a new evaluation set in Extend, which items can be added to using the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/evaluation-set-endpoints/create-evaluation-set-item">Create Evaluation Set Item</a> endpoint.
* <p>Note: it is not necessary to create an evaluation set via API. You can also create an evaluation set via the Extend dashboard and take the ID from there.</p>
*/
public CompletableFuture<EvaluationSetCreateResponse> create(EvaluationSetCreateRequest request) {
return this.rawClient.create(request).thenApply(response -> response.body());
}
/**
* Evaluation sets are collections of files and expected outputs that are used to evaluate the performance of a given processor in Extend. This endpoint will create a new evaluation set in Extend, which items can be added to using the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/evaluation-set-endpoints/create-evaluation-set-item">Create Evaluation Set Item</a> endpoint.
* <p>Note: it is not necessary to create an evaluation set via API. You can also create an evaluation set via the Extend dashboard and take the ID from there.</p>
*/
public CompletableFuture<EvaluationSetCreateResponse> create(
EvaluationSetCreateRequest request, RequestOptions requestOptions) {
return this.rawClient.create(request, requestOptions).thenApply(response -> response.body());
}
/**
* Retrieve a specific evaluation set by ID. This returns an evaluation set object, but does not include the items in the evaluation set. You can use the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/evaluation-set-endpoints/list-evaluation-set-items">List Evaluation Set Items</a> endpoint to get the items in an evaluation set.
*/
public CompletableFuture<EvaluationSetGetResponse> get(String id) {
return this.rawClient.get(id).thenApply(response -> response.body());
}
/**
* Retrieve a specific evaluation set by ID. This returns an evaluation set object, but does not include the items in the evaluation set. You can use the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/evaluation-set-endpoints/list-evaluation-set-items">List Evaluation Set Items</a> endpoint to get the items in an evaluation set.
*/
public CompletableFuture<EvaluationSetGetResponse> get(String id, RequestOptions requestOptions) {
return this.rawClient.get(id, requestOptions).thenApply(response -> response.body());
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationset/AsyncRawEvaluationSetClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.evaluationset;
import ai.extend.core.ClientOptions;
import ai.extend.core.ExtendClientApiException;
import ai.extend.core.ExtendClientException;
import ai.extend.core.ExtendClientHttpResponse;
import ai.extend.core.MediaTypes;
import ai.extend.core.ObjectMappers;
import ai.extend.core.QueryStringMapper;
import ai.extend.core.RequestOptions;
import ai.extend.errors.BadRequestError;
import ai.extend.errors.NotFoundError;
import ai.extend.errors.UnauthorizedError;
import ai.extend.resources.evaluationset.requests.EvaluationSetCreateRequest;
import ai.extend.resources.evaluationset.requests.EvaluationSetListRequest;
import ai.extend.resources.evaluationset.types.EvaluationSetCreateResponse;
import ai.extend.resources.evaluationset.types.EvaluationSetGetResponse;
import ai.extend.resources.evaluationset.types.EvaluationSetListResponse;
import ai.extend.types.Error;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.jetbrains.annotations.NotNull;
public class AsyncRawEvaluationSetClient {
protected final ClientOptions clientOptions;
public AsyncRawEvaluationSetClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
}
/**
* List evaluation sets in your account. You can use the <code>processorId</code> parameter to filter evaluation sets by processor.
* <p>This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.</p>
*/
public CompletableFuture<ExtendClientHttpResponse<EvaluationSetListResponse>> list() {
return list(EvaluationSetListRequest.builder().build());
}
/**
* List evaluation sets in your account. You can use the <code>processorId</code> parameter to filter evaluation sets by processor.
* <p>This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.</p>
*/
public CompletableFuture<ExtendClientHttpResponse<EvaluationSetListResponse>> list(
EvaluationSetListRequest request) {
return list(request, null);
}
/**
* List evaluation sets in your account. You can use the <code>processorId</code> parameter to filter evaluation sets by processor.
* <p>This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.</p>
*/
public CompletableFuture<ExtendClientHttpResponse<EvaluationSetListResponse>> list(
EvaluationSetListRequest request, RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("evaluation_sets");
if (request.getProcessorId().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "processorId", request.getProcessorId().get(), false);
}
if (request.getSortBy().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "sortBy", request.getSortBy().get(), false);
}
if (request.getSortDir().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "sortDir", request.getSortDir().get(), false);
}
if (request.getNextPageToken().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "nextPageToken", request.getNextPageToken().get(), false);
}
if (request.getMaxPageSize().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "maxPageSize", request.getMaxPageSize().get(), false);
}
Request.Builder _requestBuilder = new Request.Builder()
.url(httpUrl.build())
.method("GET", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Accept", "application/json");
Request okhttpRequest = _requestBuilder.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
CompletableFuture<ExtendClientHttpResponse<EvaluationSetListResponse>> 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(new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(
responseBody.string(), EvaluationSetListResponse.class),
response));
return;
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
future.completeExceptionally(new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
case 401:
future.completeExceptionally(new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
response));
return;
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
future.completeExceptionally(new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
});
return future;
}
/**
* Evaluation sets are collections of files and expected outputs that are used to evaluate the performance of a given processor in Extend. This endpoint will create a new evaluation set in Extend, which items can be added to using the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/evaluation-set-endpoints/create-evaluation-set-item">Create Evaluation Set Item</a> endpoint.
* <p>Note: it is not necessary to create an evaluation set via API. You can also create an evaluation set via the Extend dashboard and take the ID from there.</p>
*/
public CompletableFuture<ExtendClientHttpResponse<EvaluationSetCreateResponse>> create(
EvaluationSetCreateRequest request) {
return create(request, null);
}
/**
* Evaluation sets are collections of files and expected outputs that are used to evaluate the performance of a given processor in Extend. This endpoint will create a new evaluation set in Extend, which items can be added to using the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/evaluation-set-endpoints/create-evaluation-set-item">Create Evaluation Set Item</a> endpoint.
* <p>Note: it is not necessary to create an evaluation set via API. You can also create an evaluation set via the Extend dashboard and take the ID from there.</p>
*/
public CompletableFuture<ExtendClientHttpResponse<EvaluationSetCreateResponse>> create(
EvaluationSetCreateRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("evaluation_sets")
.build();
RequestBody body;
try {
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (JsonProcessingException e) {
throw new ExtendClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("POST", body)
.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<ExtendClientHttpResponse<EvaluationSetCreateResponse>> 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(new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(
responseBody.string(), EvaluationSetCreateResponse.class),
response));
return;
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
future.completeExceptionally(new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
case 401:
future.completeExceptionally(new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
response));
return;
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
future.completeExceptionally(new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
});
return future;
}
/**
* Retrieve a specific evaluation set by ID. This returns an evaluation set object, but does not include the items in the evaluation set. You can use the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/evaluation-set-endpoints/list-evaluation-set-items">List Evaluation Set Items</a> endpoint to get the items in an evaluation set.
*/
public CompletableFuture<ExtendClientHttpResponse<EvaluationSetGetResponse>> get(String id) {
return get(id, null);
}
/**
* Retrieve a specific evaluation set by ID. This returns an evaluation set object, but does not include the items in the evaluation set. You can use the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/evaluation-set-endpoints/list-evaluation-set-items">List Evaluation Set Items</a> endpoint to get the items in an evaluation set.
*/
public CompletableFuture<ExtendClientHttpResponse<EvaluationSetGetResponse>> get(
String id, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("evaluation_sets")
.addPathSegment(id)
.build();
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("GET", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Accept", "application/json")
.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
CompletableFuture<ExtendClientHttpResponse<EvaluationSetGetResponse>> 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(new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(
responseBody.string(), EvaluationSetGetResponse.class),
response));
return;
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
future.completeExceptionally(new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
case 401:
future.completeExceptionally(new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
response));
return;
case 404:
future.completeExceptionally(new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
future.completeExceptionally(new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
});
return future;
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationset/EvaluationSetClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.evaluationset;
import ai.extend.core.ClientOptions;
import ai.extend.core.RequestOptions;
import ai.extend.resources.evaluationset.requests.EvaluationSetCreateRequest;
import ai.extend.resources.evaluationset.requests.EvaluationSetListRequest;
import ai.extend.resources.evaluationset.types.EvaluationSetCreateResponse;
import ai.extend.resources.evaluationset.types.EvaluationSetGetResponse;
import ai.extend.resources.evaluationset.types.EvaluationSetListResponse;
public class EvaluationSetClient {
protected final ClientOptions clientOptions;
private final RawEvaluationSetClient rawClient;
public EvaluationSetClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.rawClient = new RawEvaluationSetClient(clientOptions);
}
/**
* Get responses with HTTP metadata like headers
*/
public RawEvaluationSetClient withRawResponse() {
return this.rawClient;
}
/**
* List evaluation sets in your account. You can use the <code>processorId</code> parameter to filter evaluation sets by processor.
* <p>This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.</p>
*/
public EvaluationSetListResponse list() {
return this.rawClient.list().body();
}
/**
* List evaluation sets in your account. You can use the <code>processorId</code> parameter to filter evaluation sets by processor.
* <p>This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.</p>
*/
public EvaluationSetListResponse list(EvaluationSetListRequest request) {
return this.rawClient.list(request).body();
}
/**
* List evaluation sets in your account. You can use the <code>processorId</code> parameter to filter evaluation sets by processor.
* <p>This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.</p>
*/
public EvaluationSetListResponse list(EvaluationSetListRequest request, RequestOptions requestOptions) {
return this.rawClient.list(request, requestOptions).body();
}
/**
* Evaluation sets are collections of files and expected outputs that are used to evaluate the performance of a given processor in Extend. This endpoint will create a new evaluation set in Extend, which items can be added to using the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/evaluation-set-endpoints/create-evaluation-set-item">Create Evaluation Set Item</a> endpoint.
* <p>Note: it is not necessary to create an evaluation set via API. You can also create an evaluation set via the Extend dashboard and take the ID from there.</p>
*/
public EvaluationSetCreateResponse create(EvaluationSetCreateRequest request) {
return this.rawClient.create(request).body();
}
/**
* Evaluation sets are collections of files and expected outputs that are used to evaluate the performance of a given processor in Extend. This endpoint will create a new evaluation set in Extend, which items can be added to using the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/evaluation-set-endpoints/create-evaluation-set-item">Create Evaluation Set Item</a> endpoint.
* <p>Note: it is not necessary to create an evaluation set via API. You can also create an evaluation set via the Extend dashboard and take the ID from there.</p>
*/
public EvaluationSetCreateResponse create(EvaluationSetCreateRequest request, RequestOptions requestOptions) {
return this.rawClient.create(request, requestOptions).body();
}
/**
* Retrieve a specific evaluation set by ID. This returns an evaluation set object, but does not include the items in the evaluation set. You can use the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/evaluation-set-endpoints/list-evaluation-set-items">List Evaluation Set Items</a> endpoint to get the items in an evaluation set.
*/
public EvaluationSetGetResponse get(String id) {
return this.rawClient.get(id).body();
}
/**
* Retrieve a specific evaluation set by ID. This returns an evaluation set object, but does not include the items in the evaluation set. You can use the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/evaluation-set-endpoints/list-evaluation-set-items">List Evaluation Set Items</a> endpoint to get the items in an evaluation set.
*/
public EvaluationSetGetResponse get(String id, RequestOptions requestOptions) {
return this.rawClient.get(id, requestOptions).body();
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationset/RawEvaluationSetClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.evaluationset;
import ai.extend.core.ClientOptions;
import ai.extend.core.ExtendClientApiException;
import ai.extend.core.ExtendClientException;
import ai.extend.core.ExtendClientHttpResponse;
import ai.extend.core.MediaTypes;
import ai.extend.core.ObjectMappers;
import ai.extend.core.QueryStringMapper;
import ai.extend.core.RequestOptions;
import ai.extend.errors.BadRequestError;
import ai.extend.errors.NotFoundError;
import ai.extend.errors.UnauthorizedError;
import ai.extend.resources.evaluationset.requests.EvaluationSetCreateRequest;
import ai.extend.resources.evaluationset.requests.EvaluationSetListRequest;
import ai.extend.resources.evaluationset.types.EvaluationSetCreateResponse;
import ai.extend.resources.evaluationset.types.EvaluationSetGetResponse;
import ai.extend.resources.evaluationset.types.EvaluationSetListResponse;
import ai.extend.types.Error;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;
public class RawEvaluationSetClient {
protected final ClientOptions clientOptions;
public RawEvaluationSetClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
}
/**
* List evaluation sets in your account. You can use the <code>processorId</code> parameter to filter evaluation sets by processor.
* <p>This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.</p>
*/
public ExtendClientHttpResponse<EvaluationSetListResponse> list() {
return list(EvaluationSetListRequest.builder().build());
}
/**
* List evaluation sets in your account. You can use the <code>processorId</code> parameter to filter evaluation sets by processor.
* <p>This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.</p>
*/
public ExtendClientHttpResponse<EvaluationSetListResponse> list(EvaluationSetListRequest request) {
return list(request, null);
}
/**
* List evaluation sets in your account. You can use the <code>processorId</code> parameter to filter evaluation sets by processor.
* <p>This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.</p>
*/
public ExtendClientHttpResponse<EvaluationSetListResponse> list(
EvaluationSetListRequest request, RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("evaluation_sets");
if (request.getProcessorId().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "processorId", request.getProcessorId().get(), false);
}
if (request.getSortBy().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "sortBy", request.getSortBy().get(), false);
}
if (request.getSortDir().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "sortDir", request.getSortDir().get(), false);
}
if (request.getNextPageToken().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "nextPageToken", request.getNextPageToken().get(), false);
}
if (request.getMaxPageSize().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "maxPageSize", request.getMaxPageSize().get(), false);
}
Request.Builder _requestBuilder = new Request.Builder()
.url(httpUrl.build())
.method("GET", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Accept", "application/json");
Request okhttpRequest = _requestBuilder.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), EvaluationSetListResponse.class),
response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
throw new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
case 401:
throw new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
throw new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
throw new ExtendClientException("Network error executing HTTP request", e);
}
}
/**
* Evaluation sets are collections of files and expected outputs that are used to evaluate the performance of a given processor in Extend. This endpoint will create a new evaluation set in Extend, which items can be added to using the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/evaluation-set-endpoints/create-evaluation-set-item">Create Evaluation Set Item</a> endpoint.
* <p>Note: it is not necessary to create an evaluation set via API. You can also create an evaluation set via the Extend dashboard and take the ID from there.</p>
*/
public ExtendClientHttpResponse<EvaluationSetCreateResponse> create(EvaluationSetCreateRequest request) {
return create(request, null);
}
/**
* Evaluation sets are collections of files and expected outputs that are used to evaluate the performance of a given processor in Extend. This endpoint will create a new evaluation set in Extend, which items can be added to using the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/evaluation-set-endpoints/create-evaluation-set-item">Create Evaluation Set Item</a> endpoint.
* <p>Note: it is not necessary to create an evaluation set via API. You can also create an evaluation set via the Extend dashboard and take the ID from there.</p>
*/
public ExtendClientHttpResponse<EvaluationSetCreateResponse> create(
EvaluationSetCreateRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("evaluation_sets")
.build();
RequestBody body;
try {
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (JsonProcessingException e) {
throw new ExtendClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("POST", body)
.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);
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), EvaluationSetCreateResponse.class),
response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
throw new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
case 401:
throw new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
throw new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
throw new ExtendClientException("Network error executing HTTP request", e);
}
}
/**
* Retrieve a specific evaluation set by ID. This returns an evaluation set object, but does not include the items in the evaluation set. You can use the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/evaluation-set-endpoints/list-evaluation-set-items">List Evaluation Set Items</a> endpoint to get the items in an evaluation set.
*/
public ExtendClientHttpResponse<EvaluationSetGetResponse> get(String id) {
return get(id, null);
}
/**
* Retrieve a specific evaluation set by ID. This returns an evaluation set object, but does not include the items in the evaluation set. You can use the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/evaluation-set-endpoints/list-evaluation-set-items">List Evaluation Set Items</a> endpoint to get the items in an evaluation set.
*/
public ExtendClientHttpResponse<EvaluationSetGetResponse> get(String id, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("evaluation_sets")
.addPathSegment(id)
.build();
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("GET", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Accept", "application/json")
.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), EvaluationSetGetResponse.class),
response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
throw new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
case 401:
throw new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 404:
throw new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
throw new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
throw new ExtendClientException("Network error executing HTTP request", e);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationset
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationset/requests/EvaluationSetCreateRequest.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.evaluationset.requests;
import ai.extend.core.ObjectMappers;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = EvaluationSetCreateRequest.Builder.class)
public final class EvaluationSetCreateRequest {
private final String name;
private final String description;
private final String processorId;
private final Map<String, Object> additionalProperties;
private EvaluationSetCreateRequest(
String name, String description, String processorId, Map<String, Object> additionalProperties) {
this.name = name;
this.description = description;
this.processorId = processorId;
this.additionalProperties = additionalProperties;
}
/**
* @return The name of the evaluation set.
* <p>Example: <code>"Invoice Processing Test Set"</code></p>
*/
@JsonProperty("name")
public String getName() {
return name;
}
/**
* @return A description of what this evaluation set is used for.
* <p>Example: <code>"Q4 2023 vendor invoices"</code></p>
*/
@JsonProperty("description")
public String getDescription() {
return description;
}
/**
* @return The ID of the processor to create an evaluation set for. Evaluation sets can in theory be run against any processor, but it is required to associate the evaluation set with a primary processor.
* <p>Example: <code>"dp_Xj8mK2pL9nR4vT7qY5wZ"</code></p>
*/
@JsonProperty("processorId")
public String getProcessorId() {
return processorId;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof EvaluationSetCreateRequest && equalTo((EvaluationSetCreateRequest) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(EvaluationSetCreateRequest other) {
return name.equals(other.name)
&& description.equals(other.description)
&& processorId.equals(other.processorId);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.name, this.description, this.processorId);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static NameStage builder() {
return new Builder();
}
public interface NameStage {
/**
* <p>The name of the evaluation set.</p>
* <p>Example: <code>"Invoice Processing Test Set"</code></p>
*/
DescriptionStage name(@NotNull String name);
Builder from(EvaluationSetCreateRequest other);
}
public interface DescriptionStage {
/**
* <p>A description of what this evaluation set is used for.</p>
* <p>Example: <code>"Q4 2023 vendor invoices"</code></p>
*/
ProcessorIdStage description(@NotNull String description);
}
public interface ProcessorIdStage {
/**
* <p>The ID of the processor to create an evaluation set for. Evaluation sets can in theory be run against any processor, but it is required to associate the evaluation set with a primary processor.</p>
* <p>Example: <code>"dp_Xj8mK2pL9nR4vT7qY5wZ"</code></p>
*/
_FinalStage processorId(@NotNull String processorId);
}
public interface _FinalStage {
EvaluationSetCreateRequest build();
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements NameStage, DescriptionStage, ProcessorIdStage, _FinalStage {
private String name;
private String description;
private String processorId;
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
@java.lang.Override
public Builder from(EvaluationSetCreateRequest other) {
name(other.getName());
description(other.getDescription());
processorId(other.getProcessorId());
return this;
}
/**
* <p>The name of the evaluation set.</p>
* <p>Example: <code>"Invoice Processing Test Set"</code></p>
* <p>The name of the evaluation set.</p>
* <p>Example: <code>"Invoice Processing Test Set"</code></p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
@JsonSetter("name")
public DescriptionStage name(@NotNull String name) {
this.name = Objects.requireNonNull(name, "name must not be null");
return this;
}
/**
* <p>A description of what this evaluation set is used for.</p>
* <p>Example: <code>"Q4 2023 vendor invoices"</code></p>
* <p>A description of what this evaluation set is used for.</p>
* <p>Example: <code>"Q4 2023 vendor invoices"</code></p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
@JsonSetter("description")
public ProcessorIdStage description(@NotNull String description) {
this.description = Objects.requireNonNull(description, "description must not be null");
return this;
}
/**
* <p>The ID of the processor to create an evaluation set for. Evaluation sets can in theory be run against any processor, but it is required to associate the evaluation set with a primary processor.</p>
* <p>Example: <code>"dp_Xj8mK2pL9nR4vT7qY5wZ"</code></p>
* <p>The ID of the processor to create an evaluation set for. Evaluation sets can in theory be run against any processor, but it is required to associate the evaluation set with a primary processor.</p>
* <p>Example: <code>"dp_Xj8mK2pL9nR4vT7qY5wZ"</code></p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
@JsonSetter("processorId")
public _FinalStage processorId(@NotNull String processorId) {
this.processorId = Objects.requireNonNull(processorId, "processorId must not be null");
return this;
}
@java.lang.Override
public EvaluationSetCreateRequest build() {
return new EvaluationSetCreateRequest(name, description, processorId, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationset
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationset/requests/EvaluationSetListRequest.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.evaluationset.requests;
import ai.extend.core.ObjectMappers;
import ai.extend.types.SortByEnum;
import ai.extend.types.SortDirEnum;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = EvaluationSetListRequest.Builder.class)
public final class EvaluationSetListRequest {
private final Optional<String> processorId;
private final Optional<SortByEnum> sortBy;
private final Optional<SortDirEnum> sortDir;
private final Optional<String> nextPageToken;
private final Optional<Integer> maxPageSize;
private final Map<String, Object> additionalProperties;
private EvaluationSetListRequest(
Optional<String> processorId,
Optional<SortByEnum> sortBy,
Optional<SortDirEnum> sortDir,
Optional<String> nextPageToken,
Optional<Integer> maxPageSize,
Map<String, Object> additionalProperties) {
this.processorId = processorId;
this.sortBy = sortBy;
this.sortDir = sortDir;
this.nextPageToken = nextPageToken;
this.maxPageSize = maxPageSize;
this.additionalProperties = additionalProperties;
}
/**
* @return The ID of the processor to filter evaluation sets by.
* <p>Example: <code>"dp_Xj8mK2pL9nR4vT7qY5wZ"</code></p>
*/
@JsonProperty("processorId")
public Optional<String> getProcessorId() {
return processorId;
}
/**
* @return Sorts the evaluation sets by the given field.
*/
@JsonProperty("sortBy")
public Optional<SortByEnum> getSortBy() {
return sortBy;
}
/**
* @return Sorts the evaluation sets in ascending or descending order. Ascending order means the earliest evaluation set is returned first.
*/
@JsonProperty("sortDir")
public Optional<SortDirEnum> getSortDir() {
return sortDir;
}
@JsonProperty("nextPageToken")
public Optional<String> getNextPageToken() {
return nextPageToken;
}
@JsonProperty("maxPageSize")
public Optional<Integer> getMaxPageSize() {
return maxPageSize;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof EvaluationSetListRequest && equalTo((EvaluationSetListRequest) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(EvaluationSetListRequest other) {
return processorId.equals(other.processorId)
&& sortBy.equals(other.sortBy)
&& sortDir.equals(other.sortDir)
&& nextPageToken.equals(other.nextPageToken)
&& maxPageSize.equals(other.maxPageSize);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.processorId, this.sortBy, this.sortDir, this.nextPageToken, this.maxPageSize);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static Builder builder() {
return new Builder();
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder {
private Optional<String> processorId = Optional.empty();
private Optional<SortByEnum> sortBy = Optional.empty();
private Optional<SortDirEnum> sortDir = Optional.empty();
private Optional<String> nextPageToken = Optional.empty();
private Optional<Integer> maxPageSize = Optional.empty();
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
public Builder from(EvaluationSetListRequest other) {
processorId(other.getProcessorId());
sortBy(other.getSortBy());
sortDir(other.getSortDir());
nextPageToken(other.getNextPageToken());
maxPageSize(other.getMaxPageSize());
return this;
}
/**
* <p>The ID of the processor to filter evaluation sets by.</p>
* <p>Example: <code>"dp_Xj8mK2pL9nR4vT7qY5wZ"</code></p>
*/
@JsonSetter(value = "processorId", nulls = Nulls.SKIP)
public Builder processorId(Optional<String> processorId) {
this.processorId = processorId;
return this;
}
public Builder processorId(String processorId) {
this.processorId = Optional.ofNullable(processorId);
return this;
}
/**
* <p>Sorts the evaluation sets by the given field.</p>
*/
@JsonSetter(value = "sortBy", nulls = Nulls.SKIP)
public Builder sortBy(Optional<SortByEnum> sortBy) {
this.sortBy = sortBy;
return this;
}
public Builder sortBy(SortByEnum sortBy) {
this.sortBy = Optional.ofNullable(sortBy);
return this;
}
/**
* <p>Sorts the evaluation sets in ascending or descending order. Ascending order means the earliest evaluation set is returned first.</p>
*/
@JsonSetter(value = "sortDir", nulls = Nulls.SKIP)
public Builder sortDir(Optional<SortDirEnum> sortDir) {
this.sortDir = sortDir;
return this;
}
public Builder sortDir(SortDirEnum sortDir) {
this.sortDir = Optional.ofNullable(sortDir);
return this;
}
@JsonSetter(value = "nextPageToken", nulls = Nulls.SKIP)
public Builder nextPageToken(Optional<String> nextPageToken) {
this.nextPageToken = nextPageToken;
return this;
}
public Builder nextPageToken(String nextPageToken) {
this.nextPageToken = Optional.ofNullable(nextPageToken);
return this;
}
@JsonSetter(value = "maxPageSize", nulls = Nulls.SKIP)
public Builder maxPageSize(Optional<Integer> maxPageSize) {
this.maxPageSize = maxPageSize;
return this;
}
public Builder maxPageSize(Integer maxPageSize) {
this.maxPageSize = Optional.ofNullable(maxPageSize);
return this;
}
public EvaluationSetListRequest build() {
return new EvaluationSetListRequest(
processorId, sortBy, sortDir, nextPageToken, maxPageSize, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationset
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationset/types/EvaluationSetCreateResponse.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.evaluationset.types;
import ai.extend.core.ObjectMappers;
import ai.extend.types.EvaluationSet;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = EvaluationSetCreateResponse.Builder.class)
public final class EvaluationSetCreateResponse {
private final boolean success;
private final EvaluationSet evaluationSet;
private final Map<String, Object> additionalProperties;
private EvaluationSetCreateResponse(
boolean success, EvaluationSet evaluationSet, Map<String, Object> additionalProperties) {
this.success = success;
this.evaluationSet = evaluationSet;
this.additionalProperties = additionalProperties;
}
@JsonProperty("success")
public boolean getSuccess() {
return success;
}
@JsonProperty("evaluationSet")
public EvaluationSet getEvaluationSet() {
return evaluationSet;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof EvaluationSetCreateResponse && equalTo((EvaluationSetCreateResponse) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(EvaluationSetCreateResponse other) {
return success == other.success && evaluationSet.equals(other.evaluationSet);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.success, this.evaluationSet);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static SuccessStage builder() {
return new Builder();
}
public interface SuccessStage {
EvaluationSetStage success(boolean success);
Builder from(EvaluationSetCreateResponse other);
}
public interface EvaluationSetStage {
_FinalStage evaluationSet(@NotNull EvaluationSet evaluationSet);
}
public interface _FinalStage {
EvaluationSetCreateResponse build();
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements SuccessStage, EvaluationSetStage, _FinalStage {
private boolean success;
private EvaluationSet evaluationSet;
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
@java.lang.Override
public Builder from(EvaluationSetCreateResponse other) {
success(other.getSuccess());
evaluationSet(other.getEvaluationSet());
return this;
}
@java.lang.Override
@JsonSetter("success")
public EvaluationSetStage success(boolean success) {
this.success = success;
return this;
}
@java.lang.Override
@JsonSetter("evaluationSet")
public _FinalStage evaluationSet(@NotNull EvaluationSet evaluationSet) {
this.evaluationSet = Objects.requireNonNull(evaluationSet, "evaluationSet must not be null");
return this;
}
@java.lang.Override
public EvaluationSetCreateResponse build() {
return new EvaluationSetCreateResponse(success, evaluationSet, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationset
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationset/types/EvaluationSetGetResponse.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.evaluationset.types;
import ai.extend.core.ObjectMappers;
import ai.extend.types.EvaluationSet;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = EvaluationSetGetResponse.Builder.class)
public final class EvaluationSetGetResponse {
private final boolean success;
private final EvaluationSet evaluationSet;
private final Map<String, Object> additionalProperties;
private EvaluationSetGetResponse(
boolean success, EvaluationSet evaluationSet, Map<String, Object> additionalProperties) {
this.success = success;
this.evaluationSet = evaluationSet;
this.additionalProperties = additionalProperties;
}
@JsonProperty("success")
public boolean getSuccess() {
return success;
}
@JsonProperty("evaluationSet")
public EvaluationSet getEvaluationSet() {
return evaluationSet;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof EvaluationSetGetResponse && equalTo((EvaluationSetGetResponse) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(EvaluationSetGetResponse other) {
return success == other.success && evaluationSet.equals(other.evaluationSet);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.success, this.evaluationSet);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static SuccessStage builder() {
return new Builder();
}
public interface SuccessStage {
EvaluationSetStage success(boolean success);
Builder from(EvaluationSetGetResponse other);
}
public interface EvaluationSetStage {
_FinalStage evaluationSet(@NotNull EvaluationSet evaluationSet);
}
public interface _FinalStage {
EvaluationSetGetResponse build();
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements SuccessStage, EvaluationSetStage, _FinalStage {
private boolean success;
private EvaluationSet evaluationSet;
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
@java.lang.Override
public Builder from(EvaluationSetGetResponse other) {
success(other.getSuccess());
evaluationSet(other.getEvaluationSet());
return this;
}
@java.lang.Override
@JsonSetter("success")
public EvaluationSetStage success(boolean success) {
this.success = success;
return this;
}
@java.lang.Override
@JsonSetter("evaluationSet")
public _FinalStage evaluationSet(@NotNull EvaluationSet evaluationSet) {
this.evaluationSet = Objects.requireNonNull(evaluationSet, "evaluationSet must not be null");
return this;
}
@java.lang.Override
public EvaluationSetGetResponse build() {
return new EvaluationSetGetResponse(success, evaluationSet, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationset
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationset/types/EvaluationSetListResponse.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.evaluationset.types;
import ai.extend.core.ObjectMappers;
import ai.extend.types.EvaluationSet;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = EvaluationSetListResponse.Builder.class)
public final class EvaluationSetListResponse {
private final boolean success;
private final List<EvaluationSet> evaluationSets;
private final Optional<String> nextPageToken;
private final Map<String, Object> additionalProperties;
private EvaluationSetListResponse(
boolean success,
List<EvaluationSet> evaluationSets,
Optional<String> nextPageToken,
Map<String, Object> additionalProperties) {
this.success = success;
this.evaluationSets = evaluationSets;
this.nextPageToken = nextPageToken;
this.additionalProperties = additionalProperties;
}
@JsonProperty("success")
public boolean getSuccess() {
return success;
}
@JsonProperty("evaluationSets")
public List<EvaluationSet> getEvaluationSets() {
return evaluationSets;
}
@JsonProperty("nextPageToken")
public Optional<String> getNextPageToken() {
return nextPageToken;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof EvaluationSetListResponse && equalTo((EvaluationSetListResponse) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(EvaluationSetListResponse other) {
return success == other.success
&& evaluationSets.equals(other.evaluationSets)
&& nextPageToken.equals(other.nextPageToken);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.success, this.evaluationSets, this.nextPageToken);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static SuccessStage builder() {
return new Builder();
}
public interface SuccessStage {
_FinalStage success(boolean success);
Builder from(EvaluationSetListResponse other);
}
public interface _FinalStage {
EvaluationSetListResponse build();
_FinalStage evaluationSets(List<EvaluationSet> evaluationSets);
_FinalStage addEvaluationSets(EvaluationSet evaluationSets);
_FinalStage addAllEvaluationSets(List<EvaluationSet> evaluationSets);
_FinalStage nextPageToken(Optional<String> nextPageToken);
_FinalStage nextPageToken(String nextPageToken);
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements SuccessStage, _FinalStage {
private boolean success;
private Optional<String> nextPageToken = Optional.empty();
private List<EvaluationSet> evaluationSets = new ArrayList<>();
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
@java.lang.Override
public Builder from(EvaluationSetListResponse other) {
success(other.getSuccess());
evaluationSets(other.getEvaluationSets());
nextPageToken(other.getNextPageToken());
return this;
}
@java.lang.Override
@JsonSetter("success")
public _FinalStage success(boolean success) {
this.success = success;
return this;
}
@java.lang.Override
public _FinalStage nextPageToken(String nextPageToken) {
this.nextPageToken = Optional.ofNullable(nextPageToken);
return this;
}
@java.lang.Override
@JsonSetter(value = "nextPageToken", nulls = Nulls.SKIP)
public _FinalStage nextPageToken(Optional<String> nextPageToken) {
this.nextPageToken = nextPageToken;
return this;
}
@java.lang.Override
public _FinalStage addAllEvaluationSets(List<EvaluationSet> evaluationSets) {
this.evaluationSets.addAll(evaluationSets);
return this;
}
@java.lang.Override
public _FinalStage addEvaluationSets(EvaluationSet evaluationSets) {
this.evaluationSets.add(evaluationSets);
return this;
}
@java.lang.Override
@JsonSetter(value = "evaluationSets", nulls = Nulls.SKIP)
public _FinalStage evaluationSets(List<EvaluationSet> evaluationSets) {
this.evaluationSets.clear();
this.evaluationSets.addAll(evaluationSets);
return this;
}
@java.lang.Override
public EvaluationSetListResponse build() {
return new EvaluationSetListResponse(success, evaluationSets, nextPageToken, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationsetitem/AsyncEvaluationSetItemClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.evaluationsetitem;
import ai.extend.core.ClientOptions;
import ai.extend.core.RequestOptions;
import ai.extend.resources.evaluationsetitem.requests.EvaluationSetItemCreateBatchRequest;
import ai.extend.resources.evaluationsetitem.requests.EvaluationSetItemCreateRequest;
import ai.extend.resources.evaluationsetitem.requests.EvaluationSetItemListRequest;
import ai.extend.resources.evaluationsetitem.requests.EvaluationSetItemUpdateRequest;
import ai.extend.resources.evaluationsetitem.types.EvaluationSetItemCreateBatchResponse;
import ai.extend.resources.evaluationsetitem.types.EvaluationSetItemCreateResponse;
import ai.extend.resources.evaluationsetitem.types.EvaluationSetItemListResponse;
import ai.extend.resources.evaluationsetitem.types.EvaluationSetItemUpdateResponse;
import java.util.concurrent.CompletableFuture;
public class AsyncEvaluationSetItemClient {
protected final ClientOptions clientOptions;
private final AsyncRawEvaluationSetItemClient rawClient;
public AsyncEvaluationSetItemClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.rawClient = new AsyncRawEvaluationSetItemClient(clientOptions);
}
/**
* Get responses with HTTP metadata like headers
*/
public AsyncRawEvaluationSetItemClient withRawResponse() {
return this.rawClient;
}
/**
* List all items in a specific evaluation set. Evaluation set items are the individual files and expected outputs that are used to evaluate the performance of a given processor in Extend.
* <p>This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.</p>
*/
public CompletableFuture<EvaluationSetItemListResponse> list(String id) {
return this.rawClient.list(id).thenApply(response -> response.body());
}
/**
* List all items in a specific evaluation set. Evaluation set items are the individual files and expected outputs that are used to evaluate the performance of a given processor in Extend.
* <p>This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.</p>
*/
public CompletableFuture<EvaluationSetItemListResponse> list(String id, EvaluationSetItemListRequest request) {
return this.rawClient.list(id, request).thenApply(response -> response.body());
}
/**
* List all items in a specific evaluation set. Evaluation set items are the individual files and expected outputs that are used to evaluate the performance of a given processor in Extend.
* <p>This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.</p>
*/
public CompletableFuture<EvaluationSetItemListResponse> list(
String id, EvaluationSetItemListRequest request, RequestOptions requestOptions) {
return this.rawClient.list(id, request, requestOptions).thenApply(response -> response.body());
}
/**
* Evaluation set items are the individual files and expected outputs that are used to evaluate the performance of a given processor in Extend. This endpoint will create a new evaluation set item in Extend, which will be used during an evaluation run.
* <p>Best Practices for Outputs in Evaluation Sets:</p>
* <ul>
* <li><strong>Configure First, Output Later</strong>
* <ul>
* <li>Always create and finalize your processor configuration before creating evaluation sets</li>
* <li>Field IDs in outputs must match those defined in your processor configuration</li>
* </ul>
* </li>
* <li><strong>Type Consistency</strong>
* <ul>
* <li>Ensure output types exactly match your processor configuration</li>
* <li>For example, if a field is configured as "currency", don't submit a simple number value</li>
* </ul>
* </li>
* <li><strong>Field IDs</strong>
* <ul>
* <li>Use the exact field IDs from your processor configuration</li>
* <li>Create your own semantic IDs instead in the configs for each field/type instead of using the generated ones</li>
* </ul>
* </li>
* <li><strong>Value</strong>
* <ul>
* <li>Remember that all results are inside the value key of a result object, except the values within nested structures.</li>
* </ul>
* </li>
* </ul>
*/
public CompletableFuture<EvaluationSetItemCreateResponse> create(EvaluationSetItemCreateRequest request) {
return this.rawClient.create(request).thenApply(response -> response.body());
}
/**
* Evaluation set items are the individual files and expected outputs that are used to evaluate the performance of a given processor in Extend. This endpoint will create a new evaluation set item in Extend, which will be used during an evaluation run.
* <p>Best Practices for Outputs in Evaluation Sets:</p>
* <ul>
* <li><strong>Configure First, Output Later</strong>
* <ul>
* <li>Always create and finalize your processor configuration before creating evaluation sets</li>
* <li>Field IDs in outputs must match those defined in your processor configuration</li>
* </ul>
* </li>
* <li><strong>Type Consistency</strong>
* <ul>
* <li>Ensure output types exactly match your processor configuration</li>
* <li>For example, if a field is configured as "currency", don't submit a simple number value</li>
* </ul>
* </li>
* <li><strong>Field IDs</strong>
* <ul>
* <li>Use the exact field IDs from your processor configuration</li>
* <li>Create your own semantic IDs instead in the configs for each field/type instead of using the generated ones</li>
* </ul>
* </li>
* <li><strong>Value</strong>
* <ul>
* <li>Remember that all results are inside the value key of a result object, except the values within nested structures.</li>
* </ul>
* </li>
* </ul>
*/
public CompletableFuture<EvaluationSetItemCreateResponse> create(
EvaluationSetItemCreateRequest request, RequestOptions requestOptions) {
return this.rawClient.create(request, requestOptions).thenApply(response -> response.body());
}
/**
* If you need to change the expected output for a given evaluation set item, you can use this endpoint to update the item. This can be useful if you need to correct an error in the expected output or if the output of the processor has changed.
*/
public CompletableFuture<EvaluationSetItemUpdateResponse> update(
String id, EvaluationSetItemUpdateRequest request) {
return this.rawClient.update(id, request).thenApply(response -> response.body());
}
/**
* If you need to change the expected output for a given evaluation set item, you can use this endpoint to update the item. This can be useful if you need to correct an error in the expected output or if the output of the processor has changed.
*/
public CompletableFuture<EvaluationSetItemUpdateResponse> update(
String id, EvaluationSetItemUpdateRequest request, RequestOptions requestOptions) {
return this.rawClient.update(id, request, requestOptions).thenApply(response -> response.body());
}
/**
* If you have a large number of files that you need to add to an evaluation set, you can use this endpoint to create multiple evaluation set items at once. This can be useful if you have a large dataset that you need to evaluate the performance of a processor against.
* <p>Note: you still need to create each File first using the file API.</p>
*/
public CompletableFuture<EvaluationSetItemCreateBatchResponse> createBatch(
EvaluationSetItemCreateBatchRequest request) {
return this.rawClient.createBatch(request).thenApply(response -> response.body());
}
/**
* If you have a large number of files that you need to add to an evaluation set, you can use this endpoint to create multiple evaluation set items at once. This can be useful if you have a large dataset that you need to evaluate the performance of a processor against.
* <p>Note: you still need to create each File first using the file API.</p>
*/
public CompletableFuture<EvaluationSetItemCreateBatchResponse> createBatch(
EvaluationSetItemCreateBatchRequest request, RequestOptions requestOptions) {
return this.rawClient.createBatch(request, requestOptions).thenApply(response -> response.body());
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationsetitem/AsyncRawEvaluationSetItemClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.evaluationsetitem;
import ai.extend.core.ClientOptions;
import ai.extend.core.ExtendClientApiException;
import ai.extend.core.ExtendClientException;
import ai.extend.core.ExtendClientHttpResponse;
import ai.extend.core.MediaTypes;
import ai.extend.core.ObjectMappers;
import ai.extend.core.QueryStringMapper;
import ai.extend.core.RequestOptions;
import ai.extend.errors.BadRequestError;
import ai.extend.errors.NotFoundError;
import ai.extend.errors.UnauthorizedError;
import ai.extend.resources.evaluationsetitem.requests.EvaluationSetItemCreateBatchRequest;
import ai.extend.resources.evaluationsetitem.requests.EvaluationSetItemCreateRequest;
import ai.extend.resources.evaluationsetitem.requests.EvaluationSetItemListRequest;
import ai.extend.resources.evaluationsetitem.requests.EvaluationSetItemUpdateRequest;
import ai.extend.resources.evaluationsetitem.types.EvaluationSetItemCreateBatchResponse;
import ai.extend.resources.evaluationsetitem.types.EvaluationSetItemCreateResponse;
import ai.extend.resources.evaluationsetitem.types.EvaluationSetItemListResponse;
import ai.extend.resources.evaluationsetitem.types.EvaluationSetItemUpdateResponse;
import ai.extend.types.Error;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.jetbrains.annotations.NotNull;
public class AsyncRawEvaluationSetItemClient {
protected final ClientOptions clientOptions;
public AsyncRawEvaluationSetItemClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
}
/**
* List all items in a specific evaluation set. Evaluation set items are the individual files and expected outputs that are used to evaluate the performance of a given processor in Extend.
* <p>This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.</p>
*/
public CompletableFuture<ExtendClientHttpResponse<EvaluationSetItemListResponse>> list(String id) {
return list(id, EvaluationSetItemListRequest.builder().build());
}
/**
* List all items in a specific evaluation set. Evaluation set items are the individual files and expected outputs that are used to evaluate the performance of a given processor in Extend.
* <p>This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.</p>
*/
public CompletableFuture<ExtendClientHttpResponse<EvaluationSetItemListResponse>> list(
String id, EvaluationSetItemListRequest request) {
return list(id, request, null);
}
/**
* List all items in a specific evaluation set. Evaluation set items are the individual files and expected outputs that are used to evaluate the performance of a given processor in Extend.
* <p>This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.</p>
*/
public CompletableFuture<ExtendClientHttpResponse<EvaluationSetItemListResponse>> list(
String id, EvaluationSetItemListRequest request, RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("evaluation_sets")
.addPathSegment(id)
.addPathSegments("items");
if (request.getSortBy().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "sortBy", request.getSortBy().get(), false);
}
if (request.getSortDir().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "sortDir", request.getSortDir().get(), false);
}
if (request.getNextPageToken().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "nextPageToken", request.getNextPageToken().get(), false);
}
if (request.getMaxPageSize().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "maxPageSize", request.getMaxPageSize().get(), false);
}
Request.Builder _requestBuilder = new Request.Builder()
.url(httpUrl.build())
.method("GET", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Accept", "application/json");
Request okhttpRequest = _requestBuilder.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
CompletableFuture<ExtendClientHttpResponse<EvaluationSetItemListResponse>> 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(new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(
responseBody.string(), EvaluationSetItemListResponse.class),
response));
return;
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
future.completeExceptionally(new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
case 401:
future.completeExceptionally(new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
response));
return;
case 404:
future.completeExceptionally(new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
future.completeExceptionally(new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
});
return future;
}
/**
* Evaluation set items are the individual files and expected outputs that are used to evaluate the performance of a given processor in Extend. This endpoint will create a new evaluation set item in Extend, which will be used during an evaluation run.
* <p>Best Practices for Outputs in Evaluation Sets:</p>
* <ul>
* <li><strong>Configure First, Output Later</strong>
* <ul>
* <li>Always create and finalize your processor configuration before creating evaluation sets</li>
* <li>Field IDs in outputs must match those defined in your processor configuration</li>
* </ul>
* </li>
* <li><strong>Type Consistency</strong>
* <ul>
* <li>Ensure output types exactly match your processor configuration</li>
* <li>For example, if a field is configured as "currency", don't submit a simple number value</li>
* </ul>
* </li>
* <li><strong>Field IDs</strong>
* <ul>
* <li>Use the exact field IDs from your processor configuration</li>
* <li>Create your own semantic IDs instead in the configs for each field/type instead of using the generated ones</li>
* </ul>
* </li>
* <li><strong>Value</strong>
* <ul>
* <li>Remember that all results are inside the value key of a result object, except the values within nested structures.</li>
* </ul>
* </li>
* </ul>
*/
public CompletableFuture<ExtendClientHttpResponse<EvaluationSetItemCreateResponse>> create(
EvaluationSetItemCreateRequest request) {
return create(request, null);
}
/**
* Evaluation set items are the individual files and expected outputs that are used to evaluate the performance of a given processor in Extend. This endpoint will create a new evaluation set item in Extend, which will be used during an evaluation run.
* <p>Best Practices for Outputs in Evaluation Sets:</p>
* <ul>
* <li><strong>Configure First, Output Later</strong>
* <ul>
* <li>Always create and finalize your processor configuration before creating evaluation sets</li>
* <li>Field IDs in outputs must match those defined in your processor configuration</li>
* </ul>
* </li>
* <li><strong>Type Consistency</strong>
* <ul>
* <li>Ensure output types exactly match your processor configuration</li>
* <li>For example, if a field is configured as "currency", don't submit a simple number value</li>
* </ul>
* </li>
* <li><strong>Field IDs</strong>
* <ul>
* <li>Use the exact field IDs from your processor configuration</li>
* <li>Create your own semantic IDs instead in the configs for each field/type instead of using the generated ones</li>
* </ul>
* </li>
* <li><strong>Value</strong>
* <ul>
* <li>Remember that all results are inside the value key of a result object, except the values within nested structures.</li>
* </ul>
* </li>
* </ul>
*/
public CompletableFuture<ExtendClientHttpResponse<EvaluationSetItemCreateResponse>> create(
EvaluationSetItemCreateRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("evaluation_set_items")
.build();
RequestBody body;
try {
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (JsonProcessingException e) {
throw new ExtendClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("POST", body)
.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<ExtendClientHttpResponse<EvaluationSetItemCreateResponse>> 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(new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(
responseBody.string(), EvaluationSetItemCreateResponse.class),
response));
return;
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
future.completeExceptionally(new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
case 401:
future.completeExceptionally(new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
response));
return;
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
future.completeExceptionally(new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
});
return future;
}
/**
* If you need to change the expected output for a given evaluation set item, you can use this endpoint to update the item. This can be useful if you need to correct an error in the expected output or if the output of the processor has changed.
*/
public CompletableFuture<ExtendClientHttpResponse<EvaluationSetItemUpdateResponse>> update(
String id, EvaluationSetItemUpdateRequest request) {
return update(id, request, null);
}
/**
* If you need to change the expected output for a given evaluation set item, you can use this endpoint to update the item. This can be useful if you need to correct an error in the expected output or if the output of the processor has changed.
*/
public CompletableFuture<ExtendClientHttpResponse<EvaluationSetItemUpdateResponse>> update(
String id, EvaluationSetItemUpdateRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("evaluation_set_items")
.addPathSegment(id)
.build();
RequestBody body;
try {
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (JsonProcessingException e) {
throw new ExtendClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("POST", body)
.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<ExtendClientHttpResponse<EvaluationSetItemUpdateResponse>> 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(new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(
responseBody.string(), EvaluationSetItemUpdateResponse.class),
response));
return;
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
future.completeExceptionally(new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
case 401:
future.completeExceptionally(new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
response));
return;
case 404:
future.completeExceptionally(new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
future.completeExceptionally(new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
});
return future;
}
/**
* If you have a large number of files that you need to add to an evaluation set, you can use this endpoint to create multiple evaluation set items at once. This can be useful if you have a large dataset that you need to evaluate the performance of a processor against.
* <p>Note: you still need to create each File first using the file API.</p>
*/
public CompletableFuture<ExtendClientHttpResponse<EvaluationSetItemCreateBatchResponse>> createBatch(
EvaluationSetItemCreateBatchRequest request) {
return createBatch(request, null);
}
/**
* If you have a large number of files that you need to add to an evaluation set, you can use this endpoint to create multiple evaluation set items at once. This can be useful if you have a large dataset that you need to evaluate the performance of a processor against.
* <p>Note: you still need to create each File first using the file API.</p>
*/
public CompletableFuture<ExtendClientHttpResponse<EvaluationSetItemCreateBatchResponse>> createBatch(
EvaluationSetItemCreateBatchRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("evaluation_set_items/bulk")
.build();
RequestBody body;
try {
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (JsonProcessingException e) {
throw new ExtendClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("POST", body)
.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<ExtendClientHttpResponse<EvaluationSetItemCreateBatchResponse>> 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(new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(
responseBody.string(), EvaluationSetItemCreateBatchResponse.class),
response));
return;
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
future.completeExceptionally(new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
case 401:
future.completeExceptionally(new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
response));
return;
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
future.completeExceptionally(new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
});
return future;
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationsetitem/EvaluationSetItemClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.evaluationsetitem;
import ai.extend.core.ClientOptions;
import ai.extend.core.RequestOptions;
import ai.extend.resources.evaluationsetitem.requests.EvaluationSetItemCreateBatchRequest;
import ai.extend.resources.evaluationsetitem.requests.EvaluationSetItemCreateRequest;
import ai.extend.resources.evaluationsetitem.requests.EvaluationSetItemListRequest;
import ai.extend.resources.evaluationsetitem.requests.EvaluationSetItemUpdateRequest;
import ai.extend.resources.evaluationsetitem.types.EvaluationSetItemCreateBatchResponse;
import ai.extend.resources.evaluationsetitem.types.EvaluationSetItemCreateResponse;
import ai.extend.resources.evaluationsetitem.types.EvaluationSetItemListResponse;
import ai.extend.resources.evaluationsetitem.types.EvaluationSetItemUpdateResponse;
public class EvaluationSetItemClient {
protected final ClientOptions clientOptions;
private final RawEvaluationSetItemClient rawClient;
public EvaluationSetItemClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.rawClient = new RawEvaluationSetItemClient(clientOptions);
}
/**
* Get responses with HTTP metadata like headers
*/
public RawEvaluationSetItemClient withRawResponse() {
return this.rawClient;
}
/**
* List all items in a specific evaluation set. Evaluation set items are the individual files and expected outputs that are used to evaluate the performance of a given processor in Extend.
* <p>This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.</p>
*/
public EvaluationSetItemListResponse list(String id) {
return this.rawClient.list(id).body();
}
/**
* List all items in a specific evaluation set. Evaluation set items are the individual files and expected outputs that are used to evaluate the performance of a given processor in Extend.
* <p>This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.</p>
*/
public EvaluationSetItemListResponse list(String id, EvaluationSetItemListRequest request) {
return this.rawClient.list(id, request).body();
}
/**
* List all items in a specific evaluation set. Evaluation set items are the individual files and expected outputs that are used to evaluate the performance of a given processor in Extend.
* <p>This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.</p>
*/
public EvaluationSetItemListResponse list(
String id, EvaluationSetItemListRequest request, RequestOptions requestOptions) {
return this.rawClient.list(id, request, requestOptions).body();
}
/**
* Evaluation set items are the individual files and expected outputs that are used to evaluate the performance of a given processor in Extend. This endpoint will create a new evaluation set item in Extend, which will be used during an evaluation run.
* <p>Best Practices for Outputs in Evaluation Sets:</p>
* <ul>
* <li><strong>Configure First, Output Later</strong>
* <ul>
* <li>Always create and finalize your processor configuration before creating evaluation sets</li>
* <li>Field IDs in outputs must match those defined in your processor configuration</li>
* </ul>
* </li>
* <li><strong>Type Consistency</strong>
* <ul>
* <li>Ensure output types exactly match your processor configuration</li>
* <li>For example, if a field is configured as "currency", don't submit a simple number value</li>
* </ul>
* </li>
* <li><strong>Field IDs</strong>
* <ul>
* <li>Use the exact field IDs from your processor configuration</li>
* <li>Create your own semantic IDs instead in the configs for each field/type instead of using the generated ones</li>
* </ul>
* </li>
* <li><strong>Value</strong>
* <ul>
* <li>Remember that all results are inside the value key of a result object, except the values within nested structures.</li>
* </ul>
* </li>
* </ul>
*/
public EvaluationSetItemCreateResponse create(EvaluationSetItemCreateRequest request) {
return this.rawClient.create(request).body();
}
/**
* Evaluation set items are the individual files and expected outputs that are used to evaluate the performance of a given processor in Extend. This endpoint will create a new evaluation set item in Extend, which will be used during an evaluation run.
* <p>Best Practices for Outputs in Evaluation Sets:</p>
* <ul>
* <li><strong>Configure First, Output Later</strong>
* <ul>
* <li>Always create and finalize your processor configuration before creating evaluation sets</li>
* <li>Field IDs in outputs must match those defined in your processor configuration</li>
* </ul>
* </li>
* <li><strong>Type Consistency</strong>
* <ul>
* <li>Ensure output types exactly match your processor configuration</li>
* <li>For example, if a field is configured as "currency", don't submit a simple number value</li>
* </ul>
* </li>
* <li><strong>Field IDs</strong>
* <ul>
* <li>Use the exact field IDs from your processor configuration</li>
* <li>Create your own semantic IDs instead in the configs for each field/type instead of using the generated ones</li>
* </ul>
* </li>
* <li><strong>Value</strong>
* <ul>
* <li>Remember that all results are inside the value key of a result object, except the values within nested structures.</li>
* </ul>
* </li>
* </ul>
*/
public EvaluationSetItemCreateResponse create(
EvaluationSetItemCreateRequest request, RequestOptions requestOptions) {
return this.rawClient.create(request, requestOptions).body();
}
/**
* If you need to change the expected output for a given evaluation set item, you can use this endpoint to update the item. This can be useful if you need to correct an error in the expected output or if the output of the processor has changed.
*/
public EvaluationSetItemUpdateResponse update(String id, EvaluationSetItemUpdateRequest request) {
return this.rawClient.update(id, request).body();
}
/**
* If you need to change the expected output for a given evaluation set item, you can use this endpoint to update the item. This can be useful if you need to correct an error in the expected output or if the output of the processor has changed.
*/
public EvaluationSetItemUpdateResponse update(
String id, EvaluationSetItemUpdateRequest request, RequestOptions requestOptions) {
return this.rawClient.update(id, request, requestOptions).body();
}
/**
* If you have a large number of files that you need to add to an evaluation set, you can use this endpoint to create multiple evaluation set items at once. This can be useful if you have a large dataset that you need to evaluate the performance of a processor against.
* <p>Note: you still need to create each File first using the file API.</p>
*/
public EvaluationSetItemCreateBatchResponse createBatch(EvaluationSetItemCreateBatchRequest request) {
return this.rawClient.createBatch(request).body();
}
/**
* If you have a large number of files that you need to add to an evaluation set, you can use this endpoint to create multiple evaluation set items at once. This can be useful if you have a large dataset that you need to evaluate the performance of a processor against.
* <p>Note: you still need to create each File first using the file API.</p>
*/
public EvaluationSetItemCreateBatchResponse createBatch(
EvaluationSetItemCreateBatchRequest request, RequestOptions requestOptions) {
return this.rawClient.createBatch(request, requestOptions).body();
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationsetitem/RawEvaluationSetItemClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.evaluationsetitem;
import ai.extend.core.ClientOptions;
import ai.extend.core.ExtendClientApiException;
import ai.extend.core.ExtendClientException;
import ai.extend.core.ExtendClientHttpResponse;
import ai.extend.core.MediaTypes;
import ai.extend.core.ObjectMappers;
import ai.extend.core.QueryStringMapper;
import ai.extend.core.RequestOptions;
import ai.extend.errors.BadRequestError;
import ai.extend.errors.NotFoundError;
import ai.extend.errors.UnauthorizedError;
import ai.extend.resources.evaluationsetitem.requests.EvaluationSetItemCreateBatchRequest;
import ai.extend.resources.evaluationsetitem.requests.EvaluationSetItemCreateRequest;
import ai.extend.resources.evaluationsetitem.requests.EvaluationSetItemListRequest;
import ai.extend.resources.evaluationsetitem.requests.EvaluationSetItemUpdateRequest;
import ai.extend.resources.evaluationsetitem.types.EvaluationSetItemCreateBatchResponse;
import ai.extend.resources.evaluationsetitem.types.EvaluationSetItemCreateResponse;
import ai.extend.resources.evaluationsetitem.types.EvaluationSetItemListResponse;
import ai.extend.resources.evaluationsetitem.types.EvaluationSetItemUpdateResponse;
import ai.extend.types.Error;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;
public class RawEvaluationSetItemClient {
protected final ClientOptions clientOptions;
public RawEvaluationSetItemClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
}
/**
* List all items in a specific evaluation set. Evaluation set items are the individual files and expected outputs that are used to evaluate the performance of a given processor in Extend.
* <p>This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.</p>
*/
public ExtendClientHttpResponse<EvaluationSetItemListResponse> list(String id) {
return list(id, EvaluationSetItemListRequest.builder().build());
}
/**
* List all items in a specific evaluation set. Evaluation set items are the individual files and expected outputs that are used to evaluate the performance of a given processor in Extend.
* <p>This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.</p>
*/
public ExtendClientHttpResponse<EvaluationSetItemListResponse> list(
String id, EvaluationSetItemListRequest request) {
return list(id, request, null);
}
/**
* List all items in a specific evaluation set. Evaluation set items are the individual files and expected outputs that are used to evaluate the performance of a given processor in Extend.
* <p>This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.</p>
*/
public ExtendClientHttpResponse<EvaluationSetItemListResponse> list(
String id, EvaluationSetItemListRequest request, RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("evaluation_sets")
.addPathSegment(id)
.addPathSegments("items");
if (request.getSortBy().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "sortBy", request.getSortBy().get(), false);
}
if (request.getSortDir().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "sortDir", request.getSortDir().get(), false);
}
if (request.getNextPageToken().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "nextPageToken", request.getNextPageToken().get(), false);
}
if (request.getMaxPageSize().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "maxPageSize", request.getMaxPageSize().get(), false);
}
Request.Builder _requestBuilder = new Request.Builder()
.url(httpUrl.build())
.method("GET", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Accept", "application/json");
Request okhttpRequest = _requestBuilder.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), EvaluationSetItemListResponse.class),
response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
throw new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
case 401:
throw new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 404:
throw new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
throw new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
throw new ExtendClientException("Network error executing HTTP request", e);
}
}
/**
* Evaluation set items are the individual files and expected outputs that are used to evaluate the performance of a given processor in Extend. This endpoint will create a new evaluation set item in Extend, which will be used during an evaluation run.
* <p>Best Practices for Outputs in Evaluation Sets:</p>
* <ul>
* <li><strong>Configure First, Output Later</strong>
* <ul>
* <li>Always create and finalize your processor configuration before creating evaluation sets</li>
* <li>Field IDs in outputs must match those defined in your processor configuration</li>
* </ul>
* </li>
* <li><strong>Type Consistency</strong>
* <ul>
* <li>Ensure output types exactly match your processor configuration</li>
* <li>For example, if a field is configured as "currency", don't submit a simple number value</li>
* </ul>
* </li>
* <li><strong>Field IDs</strong>
* <ul>
* <li>Use the exact field IDs from your processor configuration</li>
* <li>Create your own semantic IDs instead in the configs for each field/type instead of using the generated ones</li>
* </ul>
* </li>
* <li><strong>Value</strong>
* <ul>
* <li>Remember that all results are inside the value key of a result object, except the values within nested structures.</li>
* </ul>
* </li>
* </ul>
*/
public ExtendClientHttpResponse<EvaluationSetItemCreateResponse> create(EvaluationSetItemCreateRequest request) {
return create(request, null);
}
/**
* Evaluation set items are the individual files and expected outputs that are used to evaluate the performance of a given processor in Extend. This endpoint will create a new evaluation set item in Extend, which will be used during an evaluation run.
* <p>Best Practices for Outputs in Evaluation Sets:</p>
* <ul>
* <li><strong>Configure First, Output Later</strong>
* <ul>
* <li>Always create and finalize your processor configuration before creating evaluation sets</li>
* <li>Field IDs in outputs must match those defined in your processor configuration</li>
* </ul>
* </li>
* <li><strong>Type Consistency</strong>
* <ul>
* <li>Ensure output types exactly match your processor configuration</li>
* <li>For example, if a field is configured as "currency", don't submit a simple number value</li>
* </ul>
* </li>
* <li><strong>Field IDs</strong>
* <ul>
* <li>Use the exact field IDs from your processor configuration</li>
* <li>Create your own semantic IDs instead in the configs for each field/type instead of using the generated ones</li>
* </ul>
* </li>
* <li><strong>Value</strong>
* <ul>
* <li>Remember that all results are inside the value key of a result object, except the values within nested structures.</li>
* </ul>
* </li>
* </ul>
*/
public ExtendClientHttpResponse<EvaluationSetItemCreateResponse> create(
EvaluationSetItemCreateRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("evaluation_set_items")
.build();
RequestBody body;
try {
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (JsonProcessingException e) {
throw new ExtendClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("POST", body)
.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);
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(
responseBody.string(), EvaluationSetItemCreateResponse.class),
response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
throw new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
case 401:
throw new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
throw new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
throw new ExtendClientException("Network error executing HTTP request", e);
}
}
/**
* If you need to change the expected output for a given evaluation set item, you can use this endpoint to update the item. This can be useful if you need to correct an error in the expected output or if the output of the processor has changed.
*/
public ExtendClientHttpResponse<EvaluationSetItemUpdateResponse> update(
String id, EvaluationSetItemUpdateRequest request) {
return update(id, request, null);
}
/**
* If you need to change the expected output for a given evaluation set item, you can use this endpoint to update the item. This can be useful if you need to correct an error in the expected output or if the output of the processor has changed.
*/
public ExtendClientHttpResponse<EvaluationSetItemUpdateResponse> update(
String id, EvaluationSetItemUpdateRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("evaluation_set_items")
.addPathSegment(id)
.build();
RequestBody body;
try {
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (JsonProcessingException e) {
throw new ExtendClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("POST", body)
.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);
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(
responseBody.string(), EvaluationSetItemUpdateResponse.class),
response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
throw new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
case 401:
throw new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 404:
throw new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
throw new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
throw new ExtendClientException("Network error executing HTTP request", e);
}
}
/**
* If you have a large number of files that you need to add to an evaluation set, you can use this endpoint to create multiple evaluation set items at once. This can be useful if you have a large dataset that you need to evaluate the performance of a processor against.
* <p>Note: you still need to create each File first using the file API.</p>
*/
public ExtendClientHttpResponse<EvaluationSetItemCreateBatchResponse> createBatch(
EvaluationSetItemCreateBatchRequest request) {
return createBatch(request, null);
}
/**
* If you have a large number of files that you need to add to an evaluation set, you can use this endpoint to create multiple evaluation set items at once. This can be useful if you have a large dataset that you need to evaluate the performance of a processor against.
* <p>Note: you still need to create each File first using the file API.</p>
*/
public ExtendClientHttpResponse<EvaluationSetItemCreateBatchResponse> createBatch(
EvaluationSetItemCreateBatchRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("evaluation_set_items/bulk")
.build();
RequestBody body;
try {
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (JsonProcessingException e) {
throw new ExtendClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("POST", body)
.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);
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(
responseBody.string(), EvaluationSetItemCreateBatchResponse.class),
response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
throw new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
case 401:
throw new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
throw new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
throw new ExtendClientException("Network error executing HTTP request", e);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationsetitem
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationsetitem/requests/EvaluationSetItemCreateBatchRequest.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.evaluationsetitem.requests;
import ai.extend.core.ObjectMappers;
import ai.extend.resources.evaluationsetitem.types.EvaluationSetItemCreateBatchRequestItemsItem;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = EvaluationSetItemCreateBatchRequest.Builder.class)
public final class EvaluationSetItemCreateBatchRequest {
private final String evaluationSetId;
private final List<EvaluationSetItemCreateBatchRequestItemsItem> items;
private final Map<String, Object> additionalProperties;
private EvaluationSetItemCreateBatchRequest(
String evaluationSetId,
List<EvaluationSetItemCreateBatchRequestItemsItem> items,
Map<String, Object> additionalProperties) {
this.evaluationSetId = evaluationSetId;
this.items = items;
this.additionalProperties = additionalProperties;
}
/**
* @return The ID of the evaluation set to add the items to.
* <p>Example: <code>"ev_2LcgeY_mp2T5yPaEuq5Lw"</code></p>
*/
@JsonProperty("evaluationSetId")
public String getEvaluationSetId() {
return evaluationSetId;
}
/**
* @return An array of objects representing the evaluation set items to create
*/
@JsonProperty("items")
public List<EvaluationSetItemCreateBatchRequestItemsItem> getItems() {
return items;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof EvaluationSetItemCreateBatchRequest
&& equalTo((EvaluationSetItemCreateBatchRequest) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(EvaluationSetItemCreateBatchRequest other) {
return evaluationSetId.equals(other.evaluationSetId) && items.equals(other.items);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.evaluationSetId, this.items);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static EvaluationSetIdStage builder() {
return new Builder();
}
public interface EvaluationSetIdStage {
/**
* <p>The ID of the evaluation set to add the items to.</p>
* <p>Example: <code>"ev_2LcgeY_mp2T5yPaEuq5Lw"</code></p>
*/
_FinalStage evaluationSetId(@NotNull String evaluationSetId);
Builder from(EvaluationSetItemCreateBatchRequest other);
}
public interface _FinalStage {
EvaluationSetItemCreateBatchRequest build();
/**
* <p>An array of objects representing the evaluation set items to create</p>
*/
_FinalStage items(List<EvaluationSetItemCreateBatchRequestItemsItem> items);
_FinalStage addItems(EvaluationSetItemCreateBatchRequestItemsItem items);
_FinalStage addAllItems(List<EvaluationSetItemCreateBatchRequestItemsItem> items);
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements EvaluationSetIdStage, _FinalStage {
private String evaluationSetId;
private List<EvaluationSetItemCreateBatchRequestItemsItem> items = new ArrayList<>();
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
@java.lang.Override
public Builder from(EvaluationSetItemCreateBatchRequest other) {
evaluationSetId(other.getEvaluationSetId());
items(other.getItems());
return this;
}
/**
* <p>The ID of the evaluation set to add the items to.</p>
* <p>Example: <code>"ev_2LcgeY_mp2T5yPaEuq5Lw"</code></p>
* <p>The ID of the evaluation set to add the items to.</p>
* <p>Example: <code>"ev_2LcgeY_mp2T5yPaEuq5Lw"</code></p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
@JsonSetter("evaluationSetId")
public _FinalStage evaluationSetId(@NotNull String evaluationSetId) {
this.evaluationSetId = Objects.requireNonNull(evaluationSetId, "evaluationSetId must not be null");
return this;
}
/**
* <p>An array of objects representing the evaluation set items to create</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
public _FinalStage addAllItems(List<EvaluationSetItemCreateBatchRequestItemsItem> items) {
this.items.addAll(items);
return this;
}
/**
* <p>An array of objects representing the evaluation set items to create</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
public _FinalStage addItems(EvaluationSetItemCreateBatchRequestItemsItem items) {
this.items.add(items);
return this;
}
/**
* <p>An array of objects representing the evaluation set items to create</p>
*/
@java.lang.Override
@JsonSetter(value = "items", nulls = Nulls.SKIP)
public _FinalStage items(List<EvaluationSetItemCreateBatchRequestItemsItem> items) {
this.items.clear();
this.items.addAll(items);
return this;
}
@java.lang.Override
public EvaluationSetItemCreateBatchRequest build() {
return new EvaluationSetItemCreateBatchRequest(evaluationSetId, items, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationsetitem
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationsetitem/requests/EvaluationSetItemCreateRequest.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.evaluationsetitem.requests;
import ai.extend.core.ObjectMappers;
import ai.extend.types.ProvidedProcessorOutput;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = EvaluationSetItemCreateRequest.Builder.class)
public final class EvaluationSetItemCreateRequest {
private final String evaluationSetId;
private final String fileId;
private final ProvidedProcessorOutput expectedOutput;
private final Map<String, Object> additionalProperties;
private EvaluationSetItemCreateRequest(
String evaluationSetId,
String fileId,
ProvidedProcessorOutput expectedOutput,
Map<String, Object> additionalProperties) {
this.evaluationSetId = evaluationSetId;
this.fileId = fileId;
this.expectedOutput = expectedOutput;
this.additionalProperties = additionalProperties;
}
/**
* @return The ID of the evaluation set to add the item to.
* <p>Example: <code>"ev_Xj8mK2pL9nR4vT7qY5wZ"</code></p>
*/
@JsonProperty("evaluationSetId")
public String getEvaluationSetId() {
return evaluationSetId;
}
/**
* @return Extend's internal ID for the file. It will always start with "file_".
* <p>Example: <code>"file_xK9mLPqRtN3vS8wF5hB2cQ"</code></p>
*/
@JsonProperty("fileId")
public String getFileId() {
return fileId;
}
/**
* @return The expected output that will be used to evaluate the processor's performance.
*/
@JsonProperty("expectedOutput")
public ProvidedProcessorOutput getExpectedOutput() {
return expectedOutput;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof EvaluationSetItemCreateRequest && equalTo((EvaluationSetItemCreateRequest) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(EvaluationSetItemCreateRequest other) {
return evaluationSetId.equals(other.evaluationSetId)
&& fileId.equals(other.fileId)
&& expectedOutput.equals(other.expectedOutput);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.evaluationSetId, this.fileId, this.expectedOutput);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static EvaluationSetIdStage builder() {
return new Builder();
}
public interface EvaluationSetIdStage {
/**
* <p>The ID of the evaluation set to add the item to.</p>
* <p>Example: <code>"ev_Xj8mK2pL9nR4vT7qY5wZ"</code></p>
*/
FileIdStage evaluationSetId(@NotNull String evaluationSetId);
Builder from(EvaluationSetItemCreateRequest other);
}
public interface FileIdStage {
/**
* <p>Extend's internal ID for the file. It will always start with "file_".</p>
* <p>Example: <code>"file_xK9mLPqRtN3vS8wF5hB2cQ"</code></p>
*/
ExpectedOutputStage fileId(@NotNull String fileId);
}
public interface ExpectedOutputStage {
/**
* <p>The expected output that will be used to evaluate the processor's performance.</p>
*/
_FinalStage expectedOutput(@NotNull ProvidedProcessorOutput expectedOutput);
}
public interface _FinalStage {
EvaluationSetItemCreateRequest build();
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements EvaluationSetIdStage, FileIdStage, ExpectedOutputStage, _FinalStage {
private String evaluationSetId;
private String fileId;
private ProvidedProcessorOutput expectedOutput;
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
@java.lang.Override
public Builder from(EvaluationSetItemCreateRequest other) {
evaluationSetId(other.getEvaluationSetId());
fileId(other.getFileId());
expectedOutput(other.getExpectedOutput());
return this;
}
/**
* <p>The ID of the evaluation set to add the item to.</p>
* <p>Example: <code>"ev_Xj8mK2pL9nR4vT7qY5wZ"</code></p>
* <p>The ID of the evaluation set to add the item to.</p>
* <p>Example: <code>"ev_Xj8mK2pL9nR4vT7qY5wZ"</code></p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
@JsonSetter("evaluationSetId")
public FileIdStage evaluationSetId(@NotNull String evaluationSetId) {
this.evaluationSetId = Objects.requireNonNull(evaluationSetId, "evaluationSetId must not be null");
return this;
}
/**
* <p>Extend's internal ID for the file. It will always start with "file_".</p>
* <p>Example: <code>"file_xK9mLPqRtN3vS8wF5hB2cQ"</code></p>
* <p>Extend's internal ID for the file. It will always start with "file_".</p>
* <p>Example: <code>"file_xK9mLPqRtN3vS8wF5hB2cQ"</code></p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
@JsonSetter("fileId")
public ExpectedOutputStage fileId(@NotNull String fileId) {
this.fileId = Objects.requireNonNull(fileId, "fileId must not be null");
return this;
}
/**
* <p>The expected output that will be used to evaluate the processor's performance.</p>
* <p>The expected output that will be used to evaluate the processor's performance.</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
@JsonSetter("expectedOutput")
public _FinalStage expectedOutput(@NotNull ProvidedProcessorOutput expectedOutput) {
this.expectedOutput = Objects.requireNonNull(expectedOutput, "expectedOutput must not be null");
return this;
}
@java.lang.Override
public EvaluationSetItemCreateRequest build() {
return new EvaluationSetItemCreateRequest(evaluationSetId, fileId, expectedOutput, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationsetitem
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationsetitem/requests/EvaluationSetItemListRequest.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.evaluationsetitem.requests;
import ai.extend.core.ObjectMappers;
import ai.extend.types.SortByEnum;
import ai.extend.types.SortDirEnum;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = EvaluationSetItemListRequest.Builder.class)
public final class EvaluationSetItemListRequest {
private final Optional<SortByEnum> sortBy;
private final Optional<SortDirEnum> sortDir;
private final Optional<String> nextPageToken;
private final Optional<Integer> maxPageSize;
private final Map<String, Object> additionalProperties;
private EvaluationSetItemListRequest(
Optional<SortByEnum> sortBy,
Optional<SortDirEnum> sortDir,
Optional<String> nextPageToken,
Optional<Integer> maxPageSize,
Map<String, Object> additionalProperties) {
this.sortBy = sortBy;
this.sortDir = sortDir;
this.nextPageToken = nextPageToken;
this.maxPageSize = maxPageSize;
this.additionalProperties = additionalProperties;
}
/**
* @return Sorts the evaluation set items by the given field.
*/
@JsonProperty("sortBy")
public Optional<SortByEnum> getSortBy() {
return sortBy;
}
/**
* @return Sorts the evaluation set items in ascending or descending order. Ascending order means the earliest evaluation set is returned first.
*/
@JsonProperty("sortDir")
public Optional<SortDirEnum> getSortDir() {
return sortDir;
}
@JsonProperty("nextPageToken")
public Optional<String> getNextPageToken() {
return nextPageToken;
}
@JsonProperty("maxPageSize")
public Optional<Integer> getMaxPageSize() {
return maxPageSize;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof EvaluationSetItemListRequest && equalTo((EvaluationSetItemListRequest) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(EvaluationSetItemListRequest other) {
return sortBy.equals(other.sortBy)
&& sortDir.equals(other.sortDir)
&& nextPageToken.equals(other.nextPageToken)
&& maxPageSize.equals(other.maxPageSize);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.sortBy, this.sortDir, this.nextPageToken, this.maxPageSize);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static Builder builder() {
return new Builder();
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder {
private Optional<SortByEnum> sortBy = Optional.empty();
private Optional<SortDirEnum> sortDir = Optional.empty();
private Optional<String> nextPageToken = Optional.empty();
private Optional<Integer> maxPageSize = Optional.empty();
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
public Builder from(EvaluationSetItemListRequest other) {
sortBy(other.getSortBy());
sortDir(other.getSortDir());
nextPageToken(other.getNextPageToken());
maxPageSize(other.getMaxPageSize());
return this;
}
/**
* <p>Sorts the evaluation set items by the given field.</p>
*/
@JsonSetter(value = "sortBy", nulls = Nulls.SKIP)
public Builder sortBy(Optional<SortByEnum> sortBy) {
this.sortBy = sortBy;
return this;
}
public Builder sortBy(SortByEnum sortBy) {
this.sortBy = Optional.ofNullable(sortBy);
return this;
}
/**
* <p>Sorts the evaluation set items in ascending or descending order. Ascending order means the earliest evaluation set is returned first.</p>
*/
@JsonSetter(value = "sortDir", nulls = Nulls.SKIP)
public Builder sortDir(Optional<SortDirEnum> sortDir) {
this.sortDir = sortDir;
return this;
}
public Builder sortDir(SortDirEnum sortDir) {
this.sortDir = Optional.ofNullable(sortDir);
return this;
}
@JsonSetter(value = "nextPageToken", nulls = Nulls.SKIP)
public Builder nextPageToken(Optional<String> nextPageToken) {
this.nextPageToken = nextPageToken;
return this;
}
public Builder nextPageToken(String nextPageToken) {
this.nextPageToken = Optional.ofNullable(nextPageToken);
return this;
}
@JsonSetter(value = "maxPageSize", nulls = Nulls.SKIP)
public Builder maxPageSize(Optional<Integer> maxPageSize) {
this.maxPageSize = maxPageSize;
return this;
}
public Builder maxPageSize(Integer maxPageSize) {
this.maxPageSize = Optional.ofNullable(maxPageSize);
return this;
}
public EvaluationSetItemListRequest build() {
return new EvaluationSetItemListRequest(sortBy, sortDir, nextPageToken, maxPageSize, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationsetitem
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationsetitem/requests/EvaluationSetItemUpdateRequest.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.evaluationsetitem.requests;
import ai.extend.core.ObjectMappers;
import ai.extend.types.ProvidedProcessorOutput;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = EvaluationSetItemUpdateRequest.Builder.class)
public final class EvaluationSetItemUpdateRequest {
private final ProvidedProcessorOutput expectedOutput;
private final Map<String, Object> additionalProperties;
private EvaluationSetItemUpdateRequest(
ProvidedProcessorOutput expectedOutput, Map<String, Object> additionalProperties) {
this.expectedOutput = expectedOutput;
this.additionalProperties = additionalProperties;
}
/**
* @return The expected output of the processor when run against the file
*/
@JsonProperty("expectedOutput")
public ProvidedProcessorOutput getExpectedOutput() {
return expectedOutput;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof EvaluationSetItemUpdateRequest && equalTo((EvaluationSetItemUpdateRequest) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(EvaluationSetItemUpdateRequest other) {
return expectedOutput.equals(other.expectedOutput);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.expectedOutput);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static ExpectedOutputStage builder() {
return new Builder();
}
public interface ExpectedOutputStage {
/**
* <p>The expected output of the processor when run against the file</p>
*/
_FinalStage expectedOutput(@NotNull ProvidedProcessorOutput expectedOutput);
Builder from(EvaluationSetItemUpdateRequest other);
}
public interface _FinalStage {
EvaluationSetItemUpdateRequest build();
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements ExpectedOutputStage, _FinalStage {
private ProvidedProcessorOutput expectedOutput;
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
@java.lang.Override
public Builder from(EvaluationSetItemUpdateRequest other) {
expectedOutput(other.getExpectedOutput());
return this;
}
/**
* <p>The expected output of the processor when run against the file</p>
* <p>The expected output of the processor when run against the file</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
@JsonSetter("expectedOutput")
public _FinalStage expectedOutput(@NotNull ProvidedProcessorOutput expectedOutput) {
this.expectedOutput = Objects.requireNonNull(expectedOutput, "expectedOutput must not be null");
return this;
}
@java.lang.Override
public EvaluationSetItemUpdateRequest build() {
return new EvaluationSetItemUpdateRequest(expectedOutput, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationsetitem
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationsetitem/types/EvaluationSetItemCreateBatchRequestItemsItem.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.evaluationsetitem.types;
import ai.extend.core.ObjectMappers;
import ai.extend.types.ProvidedProcessorOutput;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = EvaluationSetItemCreateBatchRequestItemsItem.Builder.class)
public final class EvaluationSetItemCreateBatchRequestItemsItem {
private final String fileId;
private final ProvidedProcessorOutput expectedOutput;
private final Map<String, Object> additionalProperties;
private EvaluationSetItemCreateBatchRequestItemsItem(
String fileId, ProvidedProcessorOutput expectedOutput, Map<String, Object> additionalProperties) {
this.fileId = fileId;
this.expectedOutput = expectedOutput;
this.additionalProperties = additionalProperties;
}
/**
* @return Extend's internal ID for the file. It will always start with "file_".
* <p>Example: <code>"file_xK9mLPqRtN3vS8wF5hB2cQ"</code></p>
*/
@JsonProperty("fileId")
public String getFileId() {
return fileId;
}
/**
* @return The expected output of the processor when run against the file
*/
@JsonProperty("expectedOutput")
public ProvidedProcessorOutput getExpectedOutput() {
return expectedOutput;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof EvaluationSetItemCreateBatchRequestItemsItem
&& equalTo((EvaluationSetItemCreateBatchRequestItemsItem) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(EvaluationSetItemCreateBatchRequestItemsItem other) {
return fileId.equals(other.fileId) && expectedOutput.equals(other.expectedOutput);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.fileId, this.expectedOutput);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static FileIdStage builder() {
return new Builder();
}
public interface FileIdStage {
/**
* <p>Extend's internal ID for the file. It will always start with "file_".</p>
* <p>Example: <code>"file_xK9mLPqRtN3vS8wF5hB2cQ"</code></p>
*/
ExpectedOutputStage fileId(@NotNull String fileId);
Builder from(EvaluationSetItemCreateBatchRequestItemsItem other);
}
public interface ExpectedOutputStage {
/**
* <p>The expected output of the processor when run against the file</p>
*/
_FinalStage expectedOutput(@NotNull ProvidedProcessorOutput expectedOutput);
}
public interface _FinalStage {
EvaluationSetItemCreateBatchRequestItemsItem build();
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements FileIdStage, ExpectedOutputStage, _FinalStage {
private String fileId;
private ProvidedProcessorOutput expectedOutput;
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
@java.lang.Override
public Builder from(EvaluationSetItemCreateBatchRequestItemsItem other) {
fileId(other.getFileId());
expectedOutput(other.getExpectedOutput());
return this;
}
/**
* <p>Extend's internal ID for the file. It will always start with "file_".</p>
* <p>Example: <code>"file_xK9mLPqRtN3vS8wF5hB2cQ"</code></p>
* <p>Extend's internal ID for the file. It will always start with "file_".</p>
* <p>Example: <code>"file_xK9mLPqRtN3vS8wF5hB2cQ"</code></p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
@JsonSetter("fileId")
public ExpectedOutputStage fileId(@NotNull String fileId) {
this.fileId = Objects.requireNonNull(fileId, "fileId must not be null");
return this;
}
/**
* <p>The expected output of the processor when run against the file</p>
* <p>The expected output of the processor when run against the file</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
@JsonSetter("expectedOutput")
public _FinalStage expectedOutput(@NotNull ProvidedProcessorOutput expectedOutput) {
this.expectedOutput = Objects.requireNonNull(expectedOutput, "expectedOutput must not be null");
return this;
}
@java.lang.Override
public EvaluationSetItemCreateBatchRequestItemsItem build() {
return new EvaluationSetItemCreateBatchRequestItemsItem(fileId, expectedOutput, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationsetitem
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationsetitem/types/EvaluationSetItemCreateBatchResponse.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.evaluationsetitem.types;
import ai.extend.core.ObjectMappers;
import ai.extend.types.EvaluationSetItem;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = EvaluationSetItemCreateBatchResponse.Builder.class)
public final class EvaluationSetItemCreateBatchResponse {
private final boolean success;
private final List<EvaluationSetItem> evaluationSetItems;
private final Map<String, Object> additionalProperties;
private EvaluationSetItemCreateBatchResponse(
boolean success, List<EvaluationSetItem> evaluationSetItems, Map<String, Object> additionalProperties) {
this.success = success;
this.evaluationSetItems = evaluationSetItems;
this.additionalProperties = additionalProperties;
}
@JsonProperty("success")
public boolean getSuccess() {
return success;
}
@JsonProperty("evaluationSetItems")
public List<EvaluationSetItem> getEvaluationSetItems() {
return evaluationSetItems;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof EvaluationSetItemCreateBatchResponse
&& equalTo((EvaluationSetItemCreateBatchResponse) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(EvaluationSetItemCreateBatchResponse other) {
return success == other.success && evaluationSetItems.equals(other.evaluationSetItems);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.success, this.evaluationSetItems);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static SuccessStage builder() {
return new Builder();
}
public interface SuccessStage {
_FinalStage success(boolean success);
Builder from(EvaluationSetItemCreateBatchResponse other);
}
public interface _FinalStage {
EvaluationSetItemCreateBatchResponse build();
_FinalStage evaluationSetItems(List<EvaluationSetItem> evaluationSetItems);
_FinalStage addEvaluationSetItems(EvaluationSetItem evaluationSetItems);
_FinalStage addAllEvaluationSetItems(List<EvaluationSetItem> evaluationSetItems);
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements SuccessStage, _FinalStage {
private boolean success;
private List<EvaluationSetItem> evaluationSetItems = new ArrayList<>();
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
@java.lang.Override
public Builder from(EvaluationSetItemCreateBatchResponse other) {
success(other.getSuccess());
evaluationSetItems(other.getEvaluationSetItems());
return this;
}
@java.lang.Override
@JsonSetter("success")
public _FinalStage success(boolean success) {
this.success = success;
return this;
}
@java.lang.Override
public _FinalStage addAllEvaluationSetItems(List<EvaluationSetItem> evaluationSetItems) {
this.evaluationSetItems.addAll(evaluationSetItems);
return this;
}
@java.lang.Override
public _FinalStage addEvaluationSetItems(EvaluationSetItem evaluationSetItems) {
this.evaluationSetItems.add(evaluationSetItems);
return this;
}
@java.lang.Override
@JsonSetter(value = "evaluationSetItems", nulls = Nulls.SKIP)
public _FinalStage evaluationSetItems(List<EvaluationSetItem> evaluationSetItems) {
this.evaluationSetItems.clear();
this.evaluationSetItems.addAll(evaluationSetItems);
return this;
}
@java.lang.Override
public EvaluationSetItemCreateBatchResponse build() {
return new EvaluationSetItemCreateBatchResponse(success, evaluationSetItems, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationsetitem
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationsetitem/types/EvaluationSetItemCreateResponse.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.evaluationsetitem.types;
import ai.extend.core.ObjectMappers;
import ai.extend.types.EvaluationSetItem;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = EvaluationSetItemCreateResponse.Builder.class)
public final class EvaluationSetItemCreateResponse {
private final boolean success;
private final EvaluationSetItem evaluationSetItem;
private final Map<String, Object> additionalProperties;
private EvaluationSetItemCreateResponse(
boolean success, EvaluationSetItem evaluationSetItem, Map<String, Object> additionalProperties) {
this.success = success;
this.evaluationSetItem = evaluationSetItem;
this.additionalProperties = additionalProperties;
}
@JsonProperty("success")
public boolean getSuccess() {
return success;
}
@JsonProperty("evaluationSetItem")
public EvaluationSetItem getEvaluationSetItem() {
return evaluationSetItem;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof EvaluationSetItemCreateResponse && equalTo((EvaluationSetItemCreateResponse) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(EvaluationSetItemCreateResponse other) {
return success == other.success && evaluationSetItem.equals(other.evaluationSetItem);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.success, this.evaluationSetItem);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static SuccessStage builder() {
return new Builder();
}
public interface SuccessStage {
EvaluationSetItemStage success(boolean success);
Builder from(EvaluationSetItemCreateResponse other);
}
public interface EvaluationSetItemStage {
_FinalStage evaluationSetItem(@NotNull EvaluationSetItem evaluationSetItem);
}
public interface _FinalStage {
EvaluationSetItemCreateResponse build();
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements SuccessStage, EvaluationSetItemStage, _FinalStage {
private boolean success;
private EvaluationSetItem evaluationSetItem;
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
@java.lang.Override
public Builder from(EvaluationSetItemCreateResponse other) {
success(other.getSuccess());
evaluationSetItem(other.getEvaluationSetItem());
return this;
}
@java.lang.Override
@JsonSetter("success")
public EvaluationSetItemStage success(boolean success) {
this.success = success;
return this;
}
@java.lang.Override
@JsonSetter("evaluationSetItem")
public _FinalStage evaluationSetItem(@NotNull EvaluationSetItem evaluationSetItem) {
this.evaluationSetItem = Objects.requireNonNull(evaluationSetItem, "evaluationSetItem must not be null");
return this;
}
@java.lang.Override
public EvaluationSetItemCreateResponse build() {
return new EvaluationSetItemCreateResponse(success, evaluationSetItem, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationsetitem
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationsetitem/types/EvaluationSetItemListResponse.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.evaluationsetitem.types;
import ai.extend.core.ObjectMappers;
import ai.extend.types.EvaluationSetItem;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = EvaluationSetItemListResponse.Builder.class)
public final class EvaluationSetItemListResponse {
private final boolean success;
private final List<EvaluationSetItem> evaluationSetItems;
private final Optional<String> nextPageToken;
private final Map<String, Object> additionalProperties;
private EvaluationSetItemListResponse(
boolean success,
List<EvaluationSetItem> evaluationSetItems,
Optional<String> nextPageToken,
Map<String, Object> additionalProperties) {
this.success = success;
this.evaluationSetItems = evaluationSetItems;
this.nextPageToken = nextPageToken;
this.additionalProperties = additionalProperties;
}
@JsonProperty("success")
public boolean getSuccess() {
return success;
}
@JsonProperty("evaluationSetItems")
public List<EvaluationSetItem> getEvaluationSetItems() {
return evaluationSetItems;
}
@JsonProperty("nextPageToken")
public Optional<String> getNextPageToken() {
return nextPageToken;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof EvaluationSetItemListResponse && equalTo((EvaluationSetItemListResponse) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(EvaluationSetItemListResponse other) {
return success == other.success
&& evaluationSetItems.equals(other.evaluationSetItems)
&& nextPageToken.equals(other.nextPageToken);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.success, this.evaluationSetItems, this.nextPageToken);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static SuccessStage builder() {
return new Builder();
}
public interface SuccessStage {
_FinalStage success(boolean success);
Builder from(EvaluationSetItemListResponse other);
}
public interface _FinalStage {
EvaluationSetItemListResponse build();
_FinalStage evaluationSetItems(List<EvaluationSetItem> evaluationSetItems);
_FinalStage addEvaluationSetItems(EvaluationSetItem evaluationSetItems);
_FinalStage addAllEvaluationSetItems(List<EvaluationSetItem> evaluationSetItems);
_FinalStage nextPageToken(Optional<String> nextPageToken);
_FinalStage nextPageToken(String nextPageToken);
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements SuccessStage, _FinalStage {
private boolean success;
private Optional<String> nextPageToken = Optional.empty();
private List<EvaluationSetItem> evaluationSetItems = new ArrayList<>();
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
@java.lang.Override
public Builder from(EvaluationSetItemListResponse other) {
success(other.getSuccess());
evaluationSetItems(other.getEvaluationSetItems());
nextPageToken(other.getNextPageToken());
return this;
}
@java.lang.Override
@JsonSetter("success")
public _FinalStage success(boolean success) {
this.success = success;
return this;
}
@java.lang.Override
public _FinalStage nextPageToken(String nextPageToken) {
this.nextPageToken = Optional.ofNullable(nextPageToken);
return this;
}
@java.lang.Override
@JsonSetter(value = "nextPageToken", nulls = Nulls.SKIP)
public _FinalStage nextPageToken(Optional<String> nextPageToken) {
this.nextPageToken = nextPageToken;
return this;
}
@java.lang.Override
public _FinalStage addAllEvaluationSetItems(List<EvaluationSetItem> evaluationSetItems) {
this.evaluationSetItems.addAll(evaluationSetItems);
return this;
}
@java.lang.Override
public _FinalStage addEvaluationSetItems(EvaluationSetItem evaluationSetItems) {
this.evaluationSetItems.add(evaluationSetItems);
return this;
}
@java.lang.Override
@JsonSetter(value = "evaluationSetItems", nulls = Nulls.SKIP)
public _FinalStage evaluationSetItems(List<EvaluationSetItem> evaluationSetItems) {
this.evaluationSetItems.clear();
this.evaluationSetItems.addAll(evaluationSetItems);
return this;
}
@java.lang.Override
public EvaluationSetItemListResponse build() {
return new EvaluationSetItemListResponse(success, evaluationSetItems, nextPageToken, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationsetitem
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/evaluationsetitem/types/EvaluationSetItemUpdateResponse.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.evaluationsetitem.types;
import ai.extend.core.ObjectMappers;
import ai.extend.types.EvaluationSetItem;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = EvaluationSetItemUpdateResponse.Builder.class)
public final class EvaluationSetItemUpdateResponse {
private final boolean success;
private final EvaluationSetItem evaluationSetItem;
private final Map<String, Object> additionalProperties;
private EvaluationSetItemUpdateResponse(
boolean success, EvaluationSetItem evaluationSetItem, Map<String, Object> additionalProperties) {
this.success = success;
this.evaluationSetItem = evaluationSetItem;
this.additionalProperties = additionalProperties;
}
@JsonProperty("success")
public boolean getSuccess() {
return success;
}
@JsonProperty("evaluationSetItem")
public EvaluationSetItem getEvaluationSetItem() {
return evaluationSetItem;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof EvaluationSetItemUpdateResponse && equalTo((EvaluationSetItemUpdateResponse) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(EvaluationSetItemUpdateResponse other) {
return success == other.success && evaluationSetItem.equals(other.evaluationSetItem);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.success, this.evaluationSetItem);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static SuccessStage builder() {
return new Builder();
}
public interface SuccessStage {
EvaluationSetItemStage success(boolean success);
Builder from(EvaluationSetItemUpdateResponse other);
}
public interface EvaluationSetItemStage {
_FinalStage evaluationSetItem(@NotNull EvaluationSetItem evaluationSetItem);
}
public interface _FinalStage {
EvaluationSetItemUpdateResponse build();
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements SuccessStage, EvaluationSetItemStage, _FinalStage {
private boolean success;
private EvaluationSetItem evaluationSetItem;
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
@java.lang.Override
public Builder from(EvaluationSetItemUpdateResponse other) {
success(other.getSuccess());
evaluationSetItem(other.getEvaluationSetItem());
return this;
}
@java.lang.Override
@JsonSetter("success")
public EvaluationSetItemStage success(boolean success) {
this.success = success;
return this;
}
@java.lang.Override
@JsonSetter("evaluationSetItem")
public _FinalStage evaluationSetItem(@NotNull EvaluationSetItem evaluationSetItem) {
this.evaluationSetItem = Objects.requireNonNull(evaluationSetItem, "evaluationSetItem must not be null");
return this;
}
@java.lang.Override
public EvaluationSetItemUpdateResponse build() {
return new EvaluationSetItemUpdateResponse(success, evaluationSetItem, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/file/AsyncFileClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.file;
import ai.extend.core.ClientOptions;
import ai.extend.core.RequestOptions;
import ai.extend.resources.file.requests.FileGetRequest;
import ai.extend.resources.file.requests.FileListRequest;
import ai.extend.resources.file.requests.FileUploadRequest;
import ai.extend.resources.file.types.FileDeleteResponse;
import ai.extend.resources.file.types.FileGetResponse;
import ai.extend.resources.file.types.FileListResponse;
import ai.extend.resources.file.types.FileUploadResponse;
import java.io.File;
import java.util.concurrent.CompletableFuture;
public class AsyncFileClient {
protected final ClientOptions clientOptions;
private final AsyncRawFileClient rawClient;
public AsyncFileClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.rawClient = new AsyncRawFileClient(clientOptions);
}
/**
* Get responses with HTTP metadata like headers
*/
public AsyncRawFileClient withRawResponse() {
return this.rawClient;
}
/**
* List files in your account. Files represent documents that have been uploaded to Extend. This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.
*/
public CompletableFuture<FileListResponse> list() {
return this.rawClient.list().thenApply(response -> response.body());
}
/**
* List files in your account. Files represent documents that have been uploaded to Extend. This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.
*/
public CompletableFuture<FileListResponse> list(FileListRequest request) {
return this.rawClient.list(request).thenApply(response -> response.body());
}
/**
* List files in your account. Files represent documents that have been uploaded to Extend. This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.
*/
public CompletableFuture<FileListResponse> list(FileListRequest request, RequestOptions requestOptions) {
return this.rawClient.list(request, requestOptions).thenApply(response -> response.body());
}
/**
* Fetch a file by its ID to obtain additional details and the raw file content.
*/
public CompletableFuture<FileGetResponse> get(String id) {
return this.rawClient.get(id).thenApply(response -> response.body());
}
/**
* Fetch a file by its ID to obtain additional details and the raw file content.
*/
public CompletableFuture<FileGetResponse> get(String id, FileGetRequest request) {
return this.rawClient.get(id, request).thenApply(response -> response.body());
}
/**
* Fetch a file by its ID to obtain additional details and the raw file content.
*/
public CompletableFuture<FileGetResponse> get(String id, FileGetRequest request, RequestOptions requestOptions) {
return this.rawClient.get(id, request, requestOptions).thenApply(response -> response.body());
}
/**
* Delete a file and all associated data from Extend. This operation is permanent and cannot be undone.
* <p>This endpoint can be used if you'd like to manage data retention on your own rather than automated data retention policies. Or make one-off deletions for your downstream customers.</p>
*/
public CompletableFuture<FileDeleteResponse> delete(String id) {
return this.rawClient.delete(id).thenApply(response -> response.body());
}
/**
* Delete a file and all associated data from Extend. This operation is permanent and cannot be undone.
* <p>This endpoint can be used if you'd like to manage data retention on your own rather than automated data retention policies. Or make one-off deletions for your downstream customers.</p>
*/
public CompletableFuture<FileDeleteResponse> delete(String id, RequestOptions requestOptions) {
return this.rawClient.delete(id, requestOptions).thenApply(response -> response.body());
}
/**
* Upload and create a new file in Extend.
* <p>This endpoint accepts file contents and registers them as a File in Extend, which can be used for <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/run-workflow">running workflows</a>, <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/evaluation-set-endpoints/bulk-create-evaluation-set-items">creating evaluation set items</a>, <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/parse-file">parsing</a>, etc.</p>
* <p>If an uploaded file is detected as a Word or PowerPoint document, it will be automatically converted to a PDF.</p>
* <p>Supported file types can be found <a href="/product/supported-file-types">here</a>.</p>
* <p>This endpoint requires multipart form encoding. Most HTTP clients will handle this encoding automatically (see the examples).</p>
*/
public CompletableFuture<FileUploadResponse> upload(File file, FileUploadRequest request) {
return this.rawClient.upload(file, request).thenApply(response -> response.body());
}
/**
* Upload and create a new file in Extend.
* <p>This endpoint accepts file contents and registers them as a File in Extend, which can be used for <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/run-workflow">running workflows</a>, <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/evaluation-set-endpoints/bulk-create-evaluation-set-items">creating evaluation set items</a>, <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/parse-file">parsing</a>, etc.</p>
* <p>If an uploaded file is detected as a Word or PowerPoint document, it will be automatically converted to a PDF.</p>
* <p>Supported file types can be found <a href="/product/supported-file-types">here</a>.</p>
* <p>This endpoint requires multipart form encoding. Most HTTP clients will handle this encoding automatically (see the examples).</p>
*/
public CompletableFuture<FileUploadResponse> upload(
File file, FileUploadRequest request, RequestOptions requestOptions) {
return this.rawClient.upload(file, request, requestOptions).thenApply(response -> response.body());
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/file/AsyncRawFileClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.file;
import ai.extend.core.ClientOptions;
import ai.extend.core.ExtendClientApiException;
import ai.extend.core.ExtendClientException;
import ai.extend.core.ExtendClientHttpResponse;
import ai.extend.core.ObjectMappers;
import ai.extend.core.QueryStringMapper;
import ai.extend.core.RequestOptions;
import ai.extend.errors.BadRequestError;
import ai.extend.errors.InternalServerError;
import ai.extend.errors.NotFoundError;
import ai.extend.errors.UnauthorizedError;
import ai.extend.resources.file.requests.FileGetRequest;
import ai.extend.resources.file.requests.FileListRequest;
import ai.extend.resources.file.requests.FileUploadRequest;
import ai.extend.resources.file.types.FileDeleteResponse;
import ai.extend.resources.file.types.FileGetResponse;
import ai.extend.resources.file.types.FileListResponse;
import ai.extend.resources.file.types.FileUploadResponse;
import ai.extend.types.Error;
import ai.extend.types.ExtendError;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.concurrent.CompletableFuture;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.jetbrains.annotations.NotNull;
public class AsyncRawFileClient {
protected final ClientOptions clientOptions;
public AsyncRawFileClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
}
/**
* List files in your account. Files represent documents that have been uploaded to Extend. This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.
*/
public CompletableFuture<ExtendClientHttpResponse<FileListResponse>> list() {
return list(FileListRequest.builder().build());
}
/**
* List files in your account. Files represent documents that have been uploaded to Extend. This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.
*/
public CompletableFuture<ExtendClientHttpResponse<FileListResponse>> list(FileListRequest request) {
return list(request, null);
}
/**
* List files in your account. Files represent documents that have been uploaded to Extend. This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.
*/
public CompletableFuture<ExtendClientHttpResponse<FileListResponse>> list(
FileListRequest request, RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("files");
if (request.getNameContains().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "nameContains", request.getNameContains().get(), false);
}
if (request.getSortDir().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "sortDir", request.getSortDir().get(), false);
}
if (request.getNextPageToken().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "nextPageToken", request.getNextPageToken().get(), false);
}
if (request.getMaxPageSize().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "maxPageSize", request.getMaxPageSize().get(), false);
}
Request.Builder _requestBuilder = new Request.Builder()
.url(httpUrl.build())
.method("GET", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Accept", "application/json");
Request okhttpRequest = _requestBuilder.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
CompletableFuture<ExtendClientHttpResponse<FileListResponse>> 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(new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FileListResponse.class),
response));
return;
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
future.completeExceptionally(new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
case 401:
future.completeExceptionally(new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
response));
return;
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
future.completeExceptionally(new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
});
return future;
}
/**
* Fetch a file by its ID to obtain additional details and the raw file content.
*/
public CompletableFuture<ExtendClientHttpResponse<FileGetResponse>> get(String id) {
return get(id, FileGetRequest.builder().build());
}
/**
* Fetch a file by its ID to obtain additional details and the raw file content.
*/
public CompletableFuture<ExtendClientHttpResponse<FileGetResponse>> get(String id, FileGetRequest request) {
return get(id, request, null);
}
/**
* Fetch a file by its ID to obtain additional details and the raw file content.
*/
public CompletableFuture<ExtendClientHttpResponse<FileGetResponse>> get(
String id, FileGetRequest request, RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("files")
.addPathSegment(id);
if (request.getRawText().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "rawText", request.getRawText().get(), false);
}
if (request.getMarkdown().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "markdown", request.getMarkdown().get(), false);
}
if (request.getHtml().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "html", request.getHtml().get(), false);
}
Request.Builder _requestBuilder = new Request.Builder()
.url(httpUrl.build())
.method("GET", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Accept", "application/json");
Request okhttpRequest = _requestBuilder.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
CompletableFuture<ExtendClientHttpResponse<FileGetResponse>> 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(new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FileGetResponse.class),
response));
return;
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 401:
future.completeExceptionally(new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
response));
return;
case 404:
future.completeExceptionally(new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
future.completeExceptionally(new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
});
return future;
}
/**
* Delete a file and all associated data from Extend. This operation is permanent and cannot be undone.
* <p>This endpoint can be used if you'd like to manage data retention on your own rather than automated data retention policies. Or make one-off deletions for your downstream customers.</p>
*/
public CompletableFuture<ExtendClientHttpResponse<FileDeleteResponse>> delete(String id) {
return delete(id, null);
}
/**
* Delete a file and all associated data from Extend. This operation is permanent and cannot be undone.
* <p>This endpoint can be used if you'd like to manage data retention on your own rather than automated data retention policies. Or make one-off deletions for your downstream customers.</p>
*/
public CompletableFuture<ExtendClientHttpResponse<FileDeleteResponse>> delete(
String id, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("files")
.addPathSegment(id)
.build();
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("DELETE", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Accept", "application/json")
.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
CompletableFuture<ExtendClientHttpResponse<FileDeleteResponse>> 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(new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FileDeleteResponse.class),
response));
return;
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 404:
future.completeExceptionally(new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
case 500:
future.completeExceptionally(new InternalServerError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ExtendError.class),
response));
return;
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
future.completeExceptionally(new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
});
return future;
}
/**
* Upload and create a new file in Extend.
* <p>This endpoint accepts file contents and registers them as a File in Extend, which can be used for <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/run-workflow">running workflows</a>, <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/evaluation-set-endpoints/bulk-create-evaluation-set-items">creating evaluation set items</a>, <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/parse-file">parsing</a>, etc.</p>
* <p>If an uploaded file is detected as a Word or PowerPoint document, it will be automatically converted to a PDF.</p>
* <p>Supported file types can be found <a href="/product/supported-file-types">here</a>.</p>
* <p>This endpoint requires multipart form encoding. Most HTTP clients will handle this encoding automatically (see the examples).</p>
*/
public CompletableFuture<ExtendClientHttpResponse<FileUploadResponse>> upload(
File file, FileUploadRequest request) {
return upload(file, request, null);
}
/**
* Upload and create a new file in Extend.
* <p>This endpoint accepts file contents and registers them as a File in Extend, which can be used for <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/run-workflow">running workflows</a>, <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/evaluation-set-endpoints/bulk-create-evaluation-set-items">creating evaluation set items</a>, <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/parse-file">parsing</a>, etc.</p>
* <p>If an uploaded file is detected as a Word or PowerPoint document, it will be automatically converted to a PDF.</p>
* <p>Supported file types can be found <a href="/product/supported-file-types">here</a>.</p>
* <p>This endpoint requires multipart form encoding. Most HTTP clients will handle this encoding automatically (see the examples).</p>
*/
public CompletableFuture<ExtendClientHttpResponse<FileUploadResponse>> upload(
File file, FileUploadRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("files/upload")
.build();
MultipartBody.Builder body = new MultipartBody.Builder().setType(MultipartBody.FORM);
try {
String fileMimeType = Files.probeContentType(file.toPath());
MediaType fileMimeTypeMediaType = fileMimeType != null ? MediaType.parse(fileMimeType) : null;
body.addFormDataPart("file", file.getName(), RequestBody.create(file, fileMimeTypeMediaType));
} catch (Exception e) {
throw new RuntimeException(e);
}
Request.Builder _requestBuilder = new Request.Builder()
.url(httpUrl)
.method("POST", body.build())
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Accept", "application/json");
Request okhttpRequest = _requestBuilder.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
CompletableFuture<ExtendClientHttpResponse<FileUploadResponse>> 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(new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FileUploadResponse.class),
response));
return;
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
future.completeExceptionally(new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
case 401:
future.completeExceptionally(new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
response));
return;
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
future.completeExceptionally(new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
});
return future;
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/file/FileClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.file;
import ai.extend.core.ClientOptions;
import ai.extend.core.RequestOptions;
import ai.extend.resources.file.requests.FileGetRequest;
import ai.extend.resources.file.requests.FileListRequest;
import ai.extend.resources.file.requests.FileUploadRequest;
import ai.extend.resources.file.types.FileDeleteResponse;
import ai.extend.resources.file.types.FileGetResponse;
import ai.extend.resources.file.types.FileListResponse;
import ai.extend.resources.file.types.FileUploadResponse;
import java.io.File;
public class FileClient {
protected final ClientOptions clientOptions;
private final RawFileClient rawClient;
public FileClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.rawClient = new RawFileClient(clientOptions);
}
/**
* Get responses with HTTP metadata like headers
*/
public RawFileClient withRawResponse() {
return this.rawClient;
}
/**
* List files in your account. Files represent documents that have been uploaded to Extend. This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.
*/
public FileListResponse list() {
return this.rawClient.list().body();
}
/**
* List files in your account. Files represent documents that have been uploaded to Extend. This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.
*/
public FileListResponse list(FileListRequest request) {
return this.rawClient.list(request).body();
}
/**
* List files in your account. Files represent documents that have been uploaded to Extend. This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.
*/
public FileListResponse list(FileListRequest request, RequestOptions requestOptions) {
return this.rawClient.list(request, requestOptions).body();
}
/**
* Fetch a file by its ID to obtain additional details and the raw file content.
*/
public FileGetResponse get(String id) {
return this.rawClient.get(id).body();
}
/**
* Fetch a file by its ID to obtain additional details and the raw file content.
*/
public FileGetResponse get(String id, FileGetRequest request) {
return this.rawClient.get(id, request).body();
}
/**
* Fetch a file by its ID to obtain additional details and the raw file content.
*/
public FileGetResponse get(String id, FileGetRequest request, RequestOptions requestOptions) {
return this.rawClient.get(id, request, requestOptions).body();
}
/**
* Delete a file and all associated data from Extend. This operation is permanent and cannot be undone.
* <p>This endpoint can be used if you'd like to manage data retention on your own rather than automated data retention policies. Or make one-off deletions for your downstream customers.</p>
*/
public FileDeleteResponse delete(String id) {
return this.rawClient.delete(id).body();
}
/**
* Delete a file and all associated data from Extend. This operation is permanent and cannot be undone.
* <p>This endpoint can be used if you'd like to manage data retention on your own rather than automated data retention policies. Or make one-off deletions for your downstream customers.</p>
*/
public FileDeleteResponse delete(String id, RequestOptions requestOptions) {
return this.rawClient.delete(id, requestOptions).body();
}
/**
* Upload and create a new file in Extend.
* <p>This endpoint accepts file contents and registers them as a File in Extend, which can be used for <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/run-workflow">running workflows</a>, <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/evaluation-set-endpoints/bulk-create-evaluation-set-items">creating evaluation set items</a>, <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/parse-file">parsing</a>, etc.</p>
* <p>If an uploaded file is detected as a Word or PowerPoint document, it will be automatically converted to a PDF.</p>
* <p>Supported file types can be found <a href="/product/supported-file-types">here</a>.</p>
* <p>This endpoint requires multipart form encoding. Most HTTP clients will handle this encoding automatically (see the examples).</p>
*/
public FileUploadResponse upload(File file, FileUploadRequest request) {
return this.rawClient.upload(file, request).body();
}
/**
* Upload and create a new file in Extend.
* <p>This endpoint accepts file contents and registers them as a File in Extend, which can be used for <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/run-workflow">running workflows</a>, <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/evaluation-set-endpoints/bulk-create-evaluation-set-items">creating evaluation set items</a>, <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/parse-file">parsing</a>, etc.</p>
* <p>If an uploaded file is detected as a Word or PowerPoint document, it will be automatically converted to a PDF.</p>
* <p>Supported file types can be found <a href="/product/supported-file-types">here</a>.</p>
* <p>This endpoint requires multipart form encoding. Most HTTP clients will handle this encoding automatically (see the examples).</p>
*/
public FileUploadResponse upload(File file, FileUploadRequest request, RequestOptions requestOptions) {
return this.rawClient.upload(file, request, requestOptions).body();
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/file/RawFileClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.file;
import ai.extend.core.ClientOptions;
import ai.extend.core.ExtendClientApiException;
import ai.extend.core.ExtendClientException;
import ai.extend.core.ExtendClientHttpResponse;
import ai.extend.core.ObjectMappers;
import ai.extend.core.QueryStringMapper;
import ai.extend.core.RequestOptions;
import ai.extend.errors.BadRequestError;
import ai.extend.errors.InternalServerError;
import ai.extend.errors.NotFoundError;
import ai.extend.errors.UnauthorizedError;
import ai.extend.resources.file.requests.FileGetRequest;
import ai.extend.resources.file.requests.FileListRequest;
import ai.extend.resources.file.requests.FileUploadRequest;
import ai.extend.resources.file.types.FileDeleteResponse;
import ai.extend.resources.file.types.FileGetResponse;
import ai.extend.resources.file.types.FileListResponse;
import ai.extend.resources.file.types.FileUploadResponse;
import ai.extend.types.Error;
import ai.extend.types.ExtendError;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;
public class RawFileClient {
protected final ClientOptions clientOptions;
public RawFileClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
}
/**
* List files in your account. Files represent documents that have been uploaded to Extend. This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.
*/
public ExtendClientHttpResponse<FileListResponse> list() {
return list(FileListRequest.builder().build());
}
/**
* List files in your account. Files represent documents that have been uploaded to Extend. This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.
*/
public ExtendClientHttpResponse<FileListResponse> list(FileListRequest request) {
return list(request, null);
}
/**
* List files in your account. Files represent documents that have been uploaded to Extend. This endpoint returns a paginated response. You can use the <code>nextPageToken</code> to fetch subsequent results.
*/
public ExtendClientHttpResponse<FileListResponse> list(FileListRequest request, RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("files");
if (request.getNameContains().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "nameContains", request.getNameContains().get(), false);
}
if (request.getSortDir().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "sortDir", request.getSortDir().get(), false);
}
if (request.getNextPageToken().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "nextPageToken", request.getNextPageToken().get(), false);
}
if (request.getMaxPageSize().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "maxPageSize", request.getMaxPageSize().get(), false);
}
Request.Builder _requestBuilder = new Request.Builder()
.url(httpUrl.build())
.method("GET", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Accept", "application/json");
Request okhttpRequest = _requestBuilder.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FileListResponse.class), response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
throw new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
case 401:
throw new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
throw new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
throw new ExtendClientException("Network error executing HTTP request", e);
}
}
/**
* Fetch a file by its ID to obtain additional details and the raw file content.
*/
public ExtendClientHttpResponse<FileGetResponse> get(String id) {
return get(id, FileGetRequest.builder().build());
}
/**
* Fetch a file by its ID to obtain additional details and the raw file content.
*/
public ExtendClientHttpResponse<FileGetResponse> get(String id, FileGetRequest request) {
return get(id, request, null);
}
/**
* Fetch a file by its ID to obtain additional details and the raw file content.
*/
public ExtendClientHttpResponse<FileGetResponse> get(
String id, FileGetRequest request, RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("files")
.addPathSegment(id);
if (request.getRawText().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "rawText", request.getRawText().get(), false);
}
if (request.getMarkdown().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "markdown", request.getMarkdown().get(), false);
}
if (request.getHtml().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "html", request.getHtml().get(), false);
}
Request.Builder _requestBuilder = new Request.Builder()
.url(httpUrl.build())
.method("GET", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Accept", "application/json");
Request okhttpRequest = _requestBuilder.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FileGetResponse.class), response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 401:
throw new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 404:
throw new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
throw new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
throw new ExtendClientException("Network error executing HTTP request", e);
}
}
/**
* Delete a file and all associated data from Extend. This operation is permanent and cannot be undone.
* <p>This endpoint can be used if you'd like to manage data retention on your own rather than automated data retention policies. Or make one-off deletions for your downstream customers.</p>
*/
public ExtendClientHttpResponse<FileDeleteResponse> delete(String id) {
return delete(id, null);
}
/**
* Delete a file and all associated data from Extend. This operation is permanent and cannot be undone.
* <p>This endpoint can be used if you'd like to manage data retention on your own rather than automated data retention policies. Or make one-off deletions for your downstream customers.</p>
*/
public ExtendClientHttpResponse<FileDeleteResponse> delete(String id, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("files")
.addPathSegment(id)
.build();
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("DELETE", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Accept", "application/json")
.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FileDeleteResponse.class), response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 404:
throw new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
case 500:
throw new InternalServerError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ExtendError.class), response);
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
throw new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
throw new ExtendClientException("Network error executing HTTP request", e);
}
}
/**
* Upload and create a new file in Extend.
* <p>This endpoint accepts file contents and registers them as a File in Extend, which can be used for <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/run-workflow">running workflows</a>, <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/evaluation-set-endpoints/bulk-create-evaluation-set-items">creating evaluation set items</a>, <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/parse-file">parsing</a>, etc.</p>
* <p>If an uploaded file is detected as a Word or PowerPoint document, it will be automatically converted to a PDF.</p>
* <p>Supported file types can be found <a href="/product/supported-file-types">here</a>.</p>
* <p>This endpoint requires multipart form encoding. Most HTTP clients will handle this encoding automatically (see the examples).</p>
*/
public ExtendClientHttpResponse<FileUploadResponse> upload(File file, FileUploadRequest request) {
return upload(file, request, null);
}
/**
* Upload and create a new file in Extend.
* <p>This endpoint accepts file contents and registers them as a File in Extend, which can be used for <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/workflow-endpoints/run-workflow">running workflows</a>, <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/evaluation-set-endpoints/bulk-create-evaluation-set-items">creating evaluation set items</a>, <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/parse-file">parsing</a>, etc.</p>
* <p>If an uploaded file is detected as a Word or PowerPoint document, it will be automatically converted to a PDF.</p>
* <p>Supported file types can be found <a href="/product/supported-file-types">here</a>.</p>
* <p>This endpoint requires multipart form encoding. Most HTTP clients will handle this encoding automatically (see the examples).</p>
*/
public ExtendClientHttpResponse<FileUploadResponse> upload(
File file, FileUploadRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("files/upload")
.build();
MultipartBody.Builder body = new MultipartBody.Builder().setType(MultipartBody.FORM);
try {
String fileMimeType = Files.probeContentType(file.toPath());
MediaType fileMimeTypeMediaType = fileMimeType != null ? MediaType.parse(fileMimeType) : null;
body.addFormDataPart("file", file.getName(), RequestBody.create(file, fileMimeTypeMediaType));
} catch (Exception e) {
throw new RuntimeException(e);
}
Request.Builder _requestBuilder = new Request.Builder()
.url(httpUrl)
.method("POST", body.build())
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Accept", "application/json");
Request okhttpRequest = _requestBuilder.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FileUploadResponse.class), response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
throw new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
case 401:
throw new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
throw new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
throw new ExtendClientException("Network error executing HTTP request", e);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/file
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/file/requests/FileGetRequest.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.file.requests;
import ai.extend.core.ObjectMappers;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = FileGetRequest.Builder.class)
public final class FileGetRequest {
private final Optional<Boolean> rawText;
private final Optional<Boolean> markdown;
private final Optional<Boolean> html;
private final Map<String, Object> additionalProperties;
private FileGetRequest(
Optional<Boolean> rawText,
Optional<Boolean> markdown,
Optional<Boolean> html,
Map<String, Object> additionalProperties) {
this.rawText = rawText;
this.markdown = markdown;
this.html = html;
this.additionalProperties = additionalProperties;
}
/**
* @return If set to true, the raw text content of the file will be included in the response. This is useful for indexing text-based files like PDFs, Word Documents, etc.
*/
@JsonProperty("rawText")
public Optional<Boolean> getRawText() {
return rawText;
}
/**
* @return If set to true, the markdown content of the file will be included in the response. This is useful for indexing very clean content into RAG pipelines for files like PDFs, Word Documents, etc.
* <p>Only available for files with a type of PDF, IMG, or .doc/.docx files that were auto-converted to PDFs.</p>
*/
@JsonProperty("markdown")
public Optional<Boolean> getMarkdown() {
return markdown;
}
/**
* @return If set to true, the html content of the file will be included in the response. This is useful for indexing html content into RAG pipelines.
* <p>Only available for files with a type of DOCX.</p>
*/
@JsonProperty("html")
public Optional<Boolean> getHtml() {
return html;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof FileGetRequest && equalTo((FileGetRequest) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(FileGetRequest other) {
return rawText.equals(other.rawText) && markdown.equals(other.markdown) && html.equals(other.html);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.rawText, this.markdown, this.html);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static Builder builder() {
return new Builder();
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder {
private Optional<Boolean> rawText = Optional.empty();
private Optional<Boolean> markdown = Optional.empty();
private Optional<Boolean> html = Optional.empty();
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
public Builder from(FileGetRequest other) {
rawText(other.getRawText());
markdown(other.getMarkdown());
html(other.getHtml());
return this;
}
/**
* <p>If set to true, the raw text content of the file will be included in the response. This is useful for indexing text-based files like PDFs, Word Documents, etc.</p>
*/
@JsonSetter(value = "rawText", nulls = Nulls.SKIP)
public Builder rawText(Optional<Boolean> rawText) {
this.rawText = rawText;
return this;
}
public Builder rawText(Boolean rawText) {
this.rawText = Optional.ofNullable(rawText);
return this;
}
/**
* <p>If set to true, the markdown content of the file will be included in the response. This is useful for indexing very clean content into RAG pipelines for files like PDFs, Word Documents, etc.</p>
* <p>Only available for files with a type of PDF, IMG, or .doc/.docx files that were auto-converted to PDFs.</p>
*/
@JsonSetter(value = "markdown", nulls = Nulls.SKIP)
public Builder markdown(Optional<Boolean> markdown) {
this.markdown = markdown;
return this;
}
public Builder markdown(Boolean markdown) {
this.markdown = Optional.ofNullable(markdown);
return this;
}
/**
* <p>If set to true, the html content of the file will be included in the response. This is useful for indexing html content into RAG pipelines.</p>
* <p>Only available for files with a type of DOCX.</p>
*/
@JsonSetter(value = "html", nulls = Nulls.SKIP)
public Builder html(Optional<Boolean> html) {
this.html = html;
return this;
}
public Builder html(Boolean html) {
this.html = Optional.ofNullable(html);
return this;
}
public FileGetRequest build() {
return new FileGetRequest(rawText, markdown, html, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/file
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/file/requests/FileListRequest.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.file.requests;
import ai.extend.core.ObjectMappers;
import ai.extend.types.SortDirEnum;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = FileListRequest.Builder.class)
public final class FileListRequest {
private final Optional<String> nameContains;
private final Optional<SortDirEnum> sortDir;
private final Optional<String> nextPageToken;
private final Optional<Integer> maxPageSize;
private final Map<String, Object> additionalProperties;
private FileListRequest(
Optional<String> nameContains,
Optional<SortDirEnum> sortDir,
Optional<String> nextPageToken,
Optional<Integer> maxPageSize,
Map<String, Object> additionalProperties) {
this.nameContains = nameContains;
this.sortDir = sortDir;
this.nextPageToken = nextPageToken;
this.maxPageSize = maxPageSize;
this.additionalProperties = additionalProperties;
}
/**
* @return Filters files to only include those that contain the given string in the name.
* <p>Example: <code>"invoice"</code></p>
*/
@JsonProperty("nameContains")
public Optional<String> getNameContains() {
return nameContains;
}
/**
* @return Sorts the files in ascending or descending order. Ascending order means the earliest file is returned first.
*/
@JsonProperty("sortDir")
public Optional<SortDirEnum> getSortDir() {
return sortDir;
}
@JsonProperty("nextPageToken")
public Optional<String> getNextPageToken() {
return nextPageToken;
}
@JsonProperty("maxPageSize")
public Optional<Integer> getMaxPageSize() {
return maxPageSize;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof FileListRequest && equalTo((FileListRequest) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(FileListRequest other) {
return nameContains.equals(other.nameContains)
&& sortDir.equals(other.sortDir)
&& nextPageToken.equals(other.nextPageToken)
&& maxPageSize.equals(other.maxPageSize);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.nameContains, this.sortDir, this.nextPageToken, this.maxPageSize);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static Builder builder() {
return new Builder();
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder {
private Optional<String> nameContains = Optional.empty();
private Optional<SortDirEnum> sortDir = Optional.empty();
private Optional<String> nextPageToken = Optional.empty();
private Optional<Integer> maxPageSize = Optional.empty();
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
public Builder from(FileListRequest other) {
nameContains(other.getNameContains());
sortDir(other.getSortDir());
nextPageToken(other.getNextPageToken());
maxPageSize(other.getMaxPageSize());
return this;
}
/**
* <p>Filters files to only include those that contain the given string in the name.</p>
* <p>Example: <code>"invoice"</code></p>
*/
@JsonSetter(value = "nameContains", nulls = Nulls.SKIP)
public Builder nameContains(Optional<String> nameContains) {
this.nameContains = nameContains;
return this;
}
public Builder nameContains(String nameContains) {
this.nameContains = Optional.ofNullable(nameContains);
return this;
}
/**
* <p>Sorts the files in ascending or descending order. Ascending order means the earliest file is returned first.</p>
*/
@JsonSetter(value = "sortDir", nulls = Nulls.SKIP)
public Builder sortDir(Optional<SortDirEnum> sortDir) {
this.sortDir = sortDir;
return this;
}
public Builder sortDir(SortDirEnum sortDir) {
this.sortDir = Optional.ofNullable(sortDir);
return this;
}
@JsonSetter(value = "nextPageToken", nulls = Nulls.SKIP)
public Builder nextPageToken(Optional<String> nextPageToken) {
this.nextPageToken = nextPageToken;
return this;
}
public Builder nextPageToken(String nextPageToken) {
this.nextPageToken = Optional.ofNullable(nextPageToken);
return this;
}
@JsonSetter(value = "maxPageSize", nulls = Nulls.SKIP)
public Builder maxPageSize(Optional<Integer> maxPageSize) {
this.maxPageSize = maxPageSize;
return this;
}
public Builder maxPageSize(Integer maxPageSize) {
this.maxPageSize = Optional.ofNullable(maxPageSize);
return this;
}
public FileListRequest build() {
return new FileListRequest(nameContains, sortDir, nextPageToken, maxPageSize, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/file
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/file/requests/FileUploadRequest.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.file.requests;
import ai.extend.core.ObjectMappers;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = FileUploadRequest.Builder.class)
public final class FileUploadRequest {
private final Map<String, Object> additionalProperties;
private FileUploadRequest(Map<String, Object> additionalProperties) {
this.additionalProperties = additionalProperties;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof FileUploadRequest;
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static Builder builder() {
return new Builder();
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder {
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
public Builder from(FileUploadRequest other) {
return this;
}
public FileUploadRequest build() {
return new FileUploadRequest(additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/file
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/file/types/FileDeleteResponse.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.file.types;
import ai.extend.core.ObjectMappers;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = FileDeleteResponse.Builder.class)
public final class FileDeleteResponse {
private final boolean success;
private final String fileId;
private final String message;
private final Map<String, Object> additionalProperties;
private FileDeleteResponse(
boolean success, String fileId, String message, Map<String, Object> additionalProperties) {
this.success = success;
this.fileId = fileId;
this.message = message;
this.additionalProperties = additionalProperties;
}
@JsonProperty("success")
public boolean getSuccess() {
return success;
}
/**
* @return The ID of the deleted file
*/
@JsonProperty("fileId")
public String getFileId() {
return fileId;
}
/**
* @return Confirmation message
*/
@JsonProperty("message")
public String getMessage() {
return message;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof FileDeleteResponse && equalTo((FileDeleteResponse) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(FileDeleteResponse other) {
return success == other.success && fileId.equals(other.fileId) && message.equals(other.message);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.success, this.fileId, this.message);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static SuccessStage builder() {
return new Builder();
}
public interface SuccessStage {
FileIdStage success(boolean success);
Builder from(FileDeleteResponse other);
}
public interface FileIdStage {
/**
* <p>The ID of the deleted file</p>
*/
MessageStage fileId(@NotNull String fileId);
}
public interface MessageStage {
/**
* <p>Confirmation message</p>
*/
_FinalStage message(@NotNull String message);
}
public interface _FinalStage {
FileDeleteResponse build();
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements SuccessStage, FileIdStage, MessageStage, _FinalStage {
private boolean success;
private String fileId;
private String message;
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
@java.lang.Override
public Builder from(FileDeleteResponse other) {
success(other.getSuccess());
fileId(other.getFileId());
message(other.getMessage());
return this;
}
@java.lang.Override
@JsonSetter("success")
public FileIdStage success(boolean success) {
this.success = success;
return this;
}
/**
* <p>The ID of the deleted file</p>
* <p>The ID of the deleted file</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
@JsonSetter("fileId")
public MessageStage fileId(@NotNull String fileId) {
this.fileId = Objects.requireNonNull(fileId, "fileId must not be null");
return this;
}
/**
* <p>Confirmation message</p>
* <p>Confirmation message</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
@JsonSetter("message")
public _FinalStage message(@NotNull String message) {
this.message = Objects.requireNonNull(message, "message must not be null");
return this;
}
@java.lang.Override
public FileDeleteResponse build() {
return new FileDeleteResponse(success, fileId, message, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/file
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/file/types/FileGetResponse.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.file.types;
import ai.extend.core.ObjectMappers;
import ai.extend.types.File;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = FileGetResponse.Builder.class)
public final class FileGetResponse {
private final boolean success;
private final File file;
private final Map<String, Object> additionalProperties;
private FileGetResponse(boolean success, File file, Map<String, Object> additionalProperties) {
this.success = success;
this.file = file;
this.additionalProperties = additionalProperties;
}
@JsonProperty("success")
public boolean getSuccess() {
return success;
}
@JsonProperty("file")
public File getFile() {
return file;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof FileGetResponse && equalTo((FileGetResponse) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(FileGetResponse other) {
return success == other.success && file.equals(other.file);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.success, this.file);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static SuccessStage builder() {
return new Builder();
}
public interface SuccessStage {
FileStage success(boolean success);
Builder from(FileGetResponse other);
}
public interface FileStage {
_FinalStage file(@NotNull File file);
}
public interface _FinalStage {
FileGetResponse build();
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements SuccessStage, FileStage, _FinalStage {
private boolean success;
private File file;
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
@java.lang.Override
public Builder from(FileGetResponse other) {
success(other.getSuccess());
file(other.getFile());
return this;
}
@java.lang.Override
@JsonSetter("success")
public FileStage success(boolean success) {
this.success = success;
return this;
}
@java.lang.Override
@JsonSetter("file")
public _FinalStage file(@NotNull File file) {
this.file = Objects.requireNonNull(file, "file must not be null");
return this;
}
@java.lang.Override
public FileGetResponse build() {
return new FileGetResponse(success, file, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/file
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/file/types/FileListResponse.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.file.types;
import ai.extend.core.ObjectMappers;
import ai.extend.types.File;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = FileListResponse.Builder.class)
public final class FileListResponse {
private final boolean success;
private final List<File> files;
private final Optional<String> nextPageToken;
private final Map<String, Object> additionalProperties;
private FileListResponse(
boolean success,
List<File> files,
Optional<String> nextPageToken,
Map<String, Object> additionalProperties) {
this.success = success;
this.files = files;
this.nextPageToken = nextPageToken;
this.additionalProperties = additionalProperties;
}
@JsonProperty("success")
public boolean getSuccess() {
return success;
}
@JsonProperty("files")
public List<File> getFiles() {
return files;
}
@JsonProperty("nextPageToken")
public Optional<String> getNextPageToken() {
return nextPageToken;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof FileListResponse && equalTo((FileListResponse) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(FileListResponse other) {
return success == other.success && files.equals(other.files) && nextPageToken.equals(other.nextPageToken);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.success, this.files, this.nextPageToken);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static SuccessStage builder() {
return new Builder();
}
public interface SuccessStage {
_FinalStage success(boolean success);
Builder from(FileListResponse other);
}
public interface _FinalStage {
FileListResponse build();
_FinalStage files(List<File> files);
_FinalStage addFiles(File files);
_FinalStage addAllFiles(List<File> files);
_FinalStage nextPageToken(Optional<String> nextPageToken);
_FinalStage nextPageToken(String nextPageToken);
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements SuccessStage, _FinalStage {
private boolean success;
private Optional<String> nextPageToken = Optional.empty();
private List<File> files = new ArrayList<>();
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
@java.lang.Override
public Builder from(FileListResponse other) {
success(other.getSuccess());
files(other.getFiles());
nextPageToken(other.getNextPageToken());
return this;
}
@java.lang.Override
@JsonSetter("success")
public _FinalStage success(boolean success) {
this.success = success;
return this;
}
@java.lang.Override
public _FinalStage nextPageToken(String nextPageToken) {
this.nextPageToken = Optional.ofNullable(nextPageToken);
return this;
}
@java.lang.Override
@JsonSetter(value = "nextPageToken", nulls = Nulls.SKIP)
public _FinalStage nextPageToken(Optional<String> nextPageToken) {
this.nextPageToken = nextPageToken;
return this;
}
@java.lang.Override
public _FinalStage addAllFiles(List<File> files) {
this.files.addAll(files);
return this;
}
@java.lang.Override
public _FinalStage addFiles(File files) {
this.files.add(files);
return this;
}
@java.lang.Override
@JsonSetter(value = "files", nulls = Nulls.SKIP)
public _FinalStage files(List<File> files) {
this.files.clear();
this.files.addAll(files);
return this;
}
@java.lang.Override
public FileListResponse build() {
return new FileListResponse(success, files, nextPageToken, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/file
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/file/types/FileUploadResponse.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.file.types;
import ai.extend.core.ObjectMappers;
import ai.extend.types.File;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = FileUploadResponse.Builder.class)
public final class FileUploadResponse {
private final boolean success;
private final File file;
private final Map<String, Object> additionalProperties;
private FileUploadResponse(boolean success, File file, Map<String, Object> additionalProperties) {
this.success = success;
this.file = file;
this.additionalProperties = additionalProperties;
}
@JsonProperty("success")
public boolean getSuccess() {
return success;
}
@JsonProperty("file")
public File getFile() {
return file;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof FileUploadResponse && equalTo((FileUploadResponse) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(FileUploadResponse other) {
return success == other.success && file.equals(other.file);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.success, this.file);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static SuccessStage builder() {
return new Builder();
}
public interface SuccessStage {
FileStage success(boolean success);
Builder from(FileUploadResponse other);
}
public interface FileStage {
_FinalStage file(@NotNull File file);
}
public interface _FinalStage {
FileUploadResponse build();
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements SuccessStage, FileStage, _FinalStage {
private boolean success;
private File file;
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
@java.lang.Override
public Builder from(FileUploadResponse other) {
success(other.getSuccess());
file(other.getFile());
return this;
}
@java.lang.Override
@JsonSetter("success")
public FileStage success(boolean success) {
this.success = success;
return this;
}
@java.lang.Override
@JsonSetter("file")
public _FinalStage file(@NotNull File file) {
this.file = Objects.requireNonNull(file, "file must not be null");
return this;
}
@java.lang.Override
public FileUploadResponse build() {
return new FileUploadResponse(success, file, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/parserrun/AsyncParserRunClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.parserrun;
import ai.extend.core.ClientOptions;
import ai.extend.core.RequestOptions;
import ai.extend.resources.parserrun.requests.ParserRunGetRequest;
import ai.extend.resources.parserrun.types.ParserRunDeleteResponse;
import ai.extend.resources.parserrun.types.ParserRunGetResponse;
import java.util.concurrent.CompletableFuture;
public class AsyncParserRunClient {
protected final ClientOptions clientOptions;
private final AsyncRawParserRunClient rawClient;
public AsyncParserRunClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.rawClient = new AsyncRawParserRunClient(clientOptions);
}
/**
* Get responses with HTTP metadata like headers
*/
public AsyncRawParserRunClient withRawResponse() {
return this.rawClient;
}
/**
* Retrieve the status and results of a parser run.
* <p>Use this endpoint to get results for a parser run that has already completed, or to check on the status of an asynchronous parser run initiated via the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/parse-file-async">Parse File Asynchronously</a> endpoint.</p>
* <p>If parsing is still in progress, you'll receive a response with just the status. Once complete, you'll receive the full parsed content in the response.</p>
*/
public CompletableFuture<ParserRunGetResponse> get(String id) {
return this.rawClient.get(id).thenApply(response -> response.body());
}
/**
* Retrieve the status and results of a parser run.
* <p>Use this endpoint to get results for a parser run that has already completed, or to check on the status of an asynchronous parser run initiated via the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/parse-file-async">Parse File Asynchronously</a> endpoint.</p>
* <p>If parsing is still in progress, you'll receive a response with just the status. Once complete, you'll receive the full parsed content in the response.</p>
*/
public CompletableFuture<ParserRunGetResponse> get(String id, ParserRunGetRequest request) {
return this.rawClient.get(id, request).thenApply(response -> response.body());
}
/**
* Retrieve the status and results of a parser run.
* <p>Use this endpoint to get results for a parser run that has already completed, or to check on the status of an asynchronous parser run initiated via the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/parse-file-async">Parse File Asynchronously</a> endpoint.</p>
* <p>If parsing is still in progress, you'll receive a response with just the status. Once complete, you'll receive the full parsed content in the response.</p>
*/
public CompletableFuture<ParserRunGetResponse> get(
String id, ParserRunGetRequest request, RequestOptions requestOptions) {
return this.rawClient.get(id, request, requestOptions).thenApply(response -> response.body());
}
/**
* Delete a parser run and all associated data from Extend. This operation is permanent and cannot be undone.
* <p>This endpoint can be used if you'd like to manage data retention on your own rather than automated data retention policies. Or make one-off deletions for your downstream customers.</p>
*/
public CompletableFuture<ParserRunDeleteResponse> delete(String id) {
return this.rawClient.delete(id).thenApply(response -> response.body());
}
/**
* Delete a parser run and all associated data from Extend. This operation is permanent and cannot be undone.
* <p>This endpoint can be used if you'd like to manage data retention on your own rather than automated data retention policies. Or make one-off deletions for your downstream customers.</p>
*/
public CompletableFuture<ParserRunDeleteResponse> delete(String id, RequestOptions requestOptions) {
return this.rawClient.delete(id, requestOptions).thenApply(response -> response.body());
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/parserrun/AsyncRawParserRunClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.parserrun;
import ai.extend.core.ClientOptions;
import ai.extend.core.ExtendClientApiException;
import ai.extend.core.ExtendClientException;
import ai.extend.core.ExtendClientHttpResponse;
import ai.extend.core.ObjectMappers;
import ai.extend.core.QueryStringMapper;
import ai.extend.core.RequestOptions;
import ai.extend.errors.BadRequestError;
import ai.extend.errors.InternalServerError;
import ai.extend.errors.NotFoundError;
import ai.extend.errors.UnauthorizedError;
import ai.extend.resources.parserrun.requests.ParserRunGetRequest;
import ai.extend.resources.parserrun.types.ParserRunDeleteResponse;
import ai.extend.resources.parserrun.types.ParserRunGetResponse;
import ai.extend.types.Error;
import ai.extend.types.ExtendError;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
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;
public class AsyncRawParserRunClient {
protected final ClientOptions clientOptions;
public AsyncRawParserRunClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
}
/**
* Retrieve the status and results of a parser run.
* <p>Use this endpoint to get results for a parser run that has already completed, or to check on the status of an asynchronous parser run initiated via the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/parse-file-async">Parse File Asynchronously</a> endpoint.</p>
* <p>If parsing is still in progress, you'll receive a response with just the status. Once complete, you'll receive the full parsed content in the response.</p>
*/
public CompletableFuture<ExtendClientHttpResponse<ParserRunGetResponse>> get(String id) {
return get(id, ParserRunGetRequest.builder().build());
}
/**
* Retrieve the status and results of a parser run.
* <p>Use this endpoint to get results for a parser run that has already completed, or to check on the status of an asynchronous parser run initiated via the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/parse-file-async">Parse File Asynchronously</a> endpoint.</p>
* <p>If parsing is still in progress, you'll receive a response with just the status. Once complete, you'll receive the full parsed content in the response.</p>
*/
public CompletableFuture<ExtendClientHttpResponse<ParserRunGetResponse>> get(
String id, ParserRunGetRequest request) {
return get(id, request, null);
}
/**
* Retrieve the status and results of a parser run.
* <p>Use this endpoint to get results for a parser run that has already completed, or to check on the status of an asynchronous parser run initiated via the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/parse-file-async">Parse File Asynchronously</a> endpoint.</p>
* <p>If parsing is still in progress, you'll receive a response with just the status. Once complete, you'll receive the full parsed content in the response.</p>
*/
public CompletableFuture<ExtendClientHttpResponse<ParserRunGetResponse>> get(
String id, ParserRunGetRequest request, RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("parser_runs")
.addPathSegment(id);
if (request.getResponseType().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "responseType", request.getResponseType().get(), false);
}
Request.Builder _requestBuilder = new Request.Builder()
.url(httpUrl.build())
.method("GET", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Accept", "application/json");
Request okhttpRequest = _requestBuilder.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
CompletableFuture<ExtendClientHttpResponse<ParserRunGetResponse>> 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(new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ParserRunGetResponse.class),
response));
return;
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
future.completeExceptionally(new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
case 401:
future.completeExceptionally(new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
response));
return;
case 404:
future.completeExceptionally(new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
future.completeExceptionally(new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
});
return future;
}
/**
* Delete a parser run and all associated data from Extend. This operation is permanent and cannot be undone.
* <p>This endpoint can be used if you'd like to manage data retention on your own rather than automated data retention policies. Or make one-off deletions for your downstream customers.</p>
*/
public CompletableFuture<ExtendClientHttpResponse<ParserRunDeleteResponse>> delete(String id) {
return delete(id, null);
}
/**
* Delete a parser run and all associated data from Extend. This operation is permanent and cannot be undone.
* <p>This endpoint can be used if you'd like to manage data retention on your own rather than automated data retention policies. Or make one-off deletions for your downstream customers.</p>
*/
public CompletableFuture<ExtendClientHttpResponse<ParserRunDeleteResponse>> delete(
String id, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("parser_runs")
.addPathSegment(id)
.build();
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("DELETE", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Accept", "application/json")
.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
CompletableFuture<ExtendClientHttpResponse<ParserRunDeleteResponse>> 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(new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(
responseBody.string(), ParserRunDeleteResponse.class),
response));
return;
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 404:
future.completeExceptionally(new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
case 500:
future.completeExceptionally(new InternalServerError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ExtendError.class),
response));
return;
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
future.completeExceptionally(new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
});
return future;
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/parserrun/ParserRunClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.parserrun;
import ai.extend.core.ClientOptions;
import ai.extend.core.RequestOptions;
import ai.extend.resources.parserrun.requests.ParserRunGetRequest;
import ai.extend.resources.parserrun.types.ParserRunDeleteResponse;
import ai.extend.resources.parserrun.types.ParserRunGetResponse;
public class ParserRunClient {
protected final ClientOptions clientOptions;
private final RawParserRunClient rawClient;
public ParserRunClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.rawClient = new RawParserRunClient(clientOptions);
}
/**
* Get responses with HTTP metadata like headers
*/
public RawParserRunClient withRawResponse() {
return this.rawClient;
}
/**
* Retrieve the status and results of a parser run.
* <p>Use this endpoint to get results for a parser run that has already completed, or to check on the status of an asynchronous parser run initiated via the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/parse-file-async">Parse File Asynchronously</a> endpoint.</p>
* <p>If parsing is still in progress, you'll receive a response with just the status. Once complete, you'll receive the full parsed content in the response.</p>
*/
public ParserRunGetResponse get(String id) {
return this.rawClient.get(id).body();
}
/**
* Retrieve the status and results of a parser run.
* <p>Use this endpoint to get results for a parser run that has already completed, or to check on the status of an asynchronous parser run initiated via the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/parse-file-async">Parse File Asynchronously</a> endpoint.</p>
* <p>If parsing is still in progress, you'll receive a response with just the status. Once complete, you'll receive the full parsed content in the response.</p>
*/
public ParserRunGetResponse get(String id, ParserRunGetRequest request) {
return this.rawClient.get(id, request).body();
}
/**
* Retrieve the status and results of a parser run.
* <p>Use this endpoint to get results for a parser run that has already completed, or to check on the status of an asynchronous parser run initiated via the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/parse-file-async">Parse File Asynchronously</a> endpoint.</p>
* <p>If parsing is still in progress, you'll receive a response with just the status. Once complete, you'll receive the full parsed content in the response.</p>
*/
public ParserRunGetResponse get(String id, ParserRunGetRequest request, RequestOptions requestOptions) {
return this.rawClient.get(id, request, requestOptions).body();
}
/**
* Delete a parser run and all associated data from Extend. This operation is permanent and cannot be undone.
* <p>This endpoint can be used if you'd like to manage data retention on your own rather than automated data retention policies. Or make one-off deletions for your downstream customers.</p>
*/
public ParserRunDeleteResponse delete(String id) {
return this.rawClient.delete(id).body();
}
/**
* Delete a parser run and all associated data from Extend. This operation is permanent and cannot be undone.
* <p>This endpoint can be used if you'd like to manage data retention on your own rather than automated data retention policies. Or make one-off deletions for your downstream customers.</p>
*/
public ParserRunDeleteResponse delete(String id, RequestOptions requestOptions) {
return this.rawClient.delete(id, requestOptions).body();
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/parserrun/RawParserRunClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.parserrun;
import ai.extend.core.ClientOptions;
import ai.extend.core.ExtendClientApiException;
import ai.extend.core.ExtendClientException;
import ai.extend.core.ExtendClientHttpResponse;
import ai.extend.core.ObjectMappers;
import ai.extend.core.QueryStringMapper;
import ai.extend.core.RequestOptions;
import ai.extend.errors.BadRequestError;
import ai.extend.errors.InternalServerError;
import ai.extend.errors.NotFoundError;
import ai.extend.errors.UnauthorizedError;
import ai.extend.resources.parserrun.requests.ParserRunGetRequest;
import ai.extend.resources.parserrun.types.ParserRunDeleteResponse;
import ai.extend.resources.parserrun.types.ParserRunGetResponse;
import ai.extend.types.Error;
import ai.extend.types.ExtendError;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
public class RawParserRunClient {
protected final ClientOptions clientOptions;
public RawParserRunClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
}
/**
* Retrieve the status and results of a parser run.
* <p>Use this endpoint to get results for a parser run that has already completed, or to check on the status of an asynchronous parser run initiated via the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/parse-file-async">Parse File Asynchronously</a> endpoint.</p>
* <p>If parsing is still in progress, you'll receive a response with just the status. Once complete, you'll receive the full parsed content in the response.</p>
*/
public ExtendClientHttpResponse<ParserRunGetResponse> get(String id) {
return get(id, ParserRunGetRequest.builder().build());
}
/**
* Retrieve the status and results of a parser run.
* <p>Use this endpoint to get results for a parser run that has already completed, or to check on the status of an asynchronous parser run initiated via the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/parse-file-async">Parse File Asynchronously</a> endpoint.</p>
* <p>If parsing is still in progress, you'll receive a response with just the status. Once complete, you'll receive the full parsed content in the response.</p>
*/
public ExtendClientHttpResponse<ParserRunGetResponse> get(String id, ParserRunGetRequest request) {
return get(id, request, null);
}
/**
* Retrieve the status and results of a parser run.
* <p>Use this endpoint to get results for a parser run that has already completed, or to check on the status of an asynchronous parser run initiated via the <a href="https://docs.extend.ai/2025-04-21/developers/api-reference/parse-endpoints/parse-file-async">Parse File Asynchronously</a> endpoint.</p>
* <p>If parsing is still in progress, you'll receive a response with just the status. Once complete, you'll receive the full parsed content in the response.</p>
*/
public ExtendClientHttpResponse<ParserRunGetResponse> get(
String id, ParserRunGetRequest request, RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("parser_runs")
.addPathSegment(id);
if (request.getResponseType().isPresent()) {
QueryStringMapper.addQueryParameter(
httpUrl, "responseType", request.getResponseType().get(), false);
}
Request.Builder _requestBuilder = new Request.Builder()
.url(httpUrl.build())
.method("GET", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Accept", "application/json");
Request okhttpRequest = _requestBuilder.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ParserRunGetResponse.class),
response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
throw new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
case 401:
throw new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 404:
throw new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
throw new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
throw new ExtendClientException("Network error executing HTTP request", e);
}
}
/**
* Delete a parser run and all associated data from Extend. This operation is permanent and cannot be undone.
* <p>This endpoint can be used if you'd like to manage data retention on your own rather than automated data retention policies. Or make one-off deletions for your downstream customers.</p>
*/
public ExtendClientHttpResponse<ParserRunDeleteResponse> delete(String id) {
return delete(id, null);
}
/**
* Delete a parser run and all associated data from Extend. This operation is permanent and cannot be undone.
* <p>This endpoint can be used if you'd like to manage data retention on your own rather than automated data retention policies. Or make one-off deletions for your downstream customers.</p>
*/
public ExtendClientHttpResponse<ParserRunDeleteResponse> delete(String id, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("parser_runs")
.addPathSegment(id)
.build();
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("DELETE", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Accept", "application/json")
.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ParserRunDeleteResponse.class),
response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 404:
throw new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
case 500:
throw new InternalServerError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ExtendError.class), response);
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
throw new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
throw new ExtendClientException("Network error executing HTTP request", e);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/parserrun
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/parserrun/requests/ParserRunGetRequest.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.parserrun.requests;
import ai.extend.core.ObjectMappers;
import ai.extend.resources.parserrun.types.ParserRunGetRequestResponseType;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = ParserRunGetRequest.Builder.class)
public final class ParserRunGetRequest {
private final Optional<ParserRunGetRequestResponseType> responseType;
private final Map<String, Object> additionalProperties;
private ParserRunGetRequest(
Optional<ParserRunGetRequestResponseType> responseType, Map<String, Object> additionalProperties) {
this.responseType = responseType;
this.additionalProperties = additionalProperties;
}
/**
* @return Controls the format of the response chunks. Defaults to <code>json</code> if not specified.
* <ul>
* <li><code>json</code> - Returns chunks with inline content</li>
* <li><code>url</code> - Returns chunks with presigned URLs to content instead of inline data</li>
* </ul>
*/
@JsonProperty("responseType")
public Optional<ParserRunGetRequestResponseType> getResponseType() {
return responseType;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof ParserRunGetRequest && equalTo((ParserRunGetRequest) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(ParserRunGetRequest other) {
return responseType.equals(other.responseType);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.responseType);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static Builder builder() {
return new Builder();
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder {
private Optional<ParserRunGetRequestResponseType> responseType = Optional.empty();
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
public Builder from(ParserRunGetRequest other) {
responseType(other.getResponseType());
return this;
}
/**
* <p>Controls the format of the response chunks. Defaults to <code>json</code> if not specified.</p>
* <ul>
* <li><code>json</code> - Returns chunks with inline content</li>
* <li><code>url</code> - Returns chunks with presigned URLs to content instead of inline data</li>
* </ul>
*/
@JsonSetter(value = "responseType", nulls = Nulls.SKIP)
public Builder responseType(Optional<ParserRunGetRequestResponseType> responseType) {
this.responseType = responseType;
return this;
}
public Builder responseType(ParserRunGetRequestResponseType responseType) {
this.responseType = Optional.ofNullable(responseType);
return this;
}
public ParserRunGetRequest build() {
return new ParserRunGetRequest(responseType, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/parserrun
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/parserrun/types/ParserRunDeleteResponse.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.parserrun.types;
import ai.extend.core.ObjectMappers;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = ParserRunDeleteResponse.Builder.class)
public final class ParserRunDeleteResponse {
private final boolean success;
private final String parserRunId;
private final String message;
private final Map<String, Object> additionalProperties;
private ParserRunDeleteResponse(
boolean success, String parserRunId, String message, Map<String, Object> additionalProperties) {
this.success = success;
this.parserRunId = parserRunId;
this.message = message;
this.additionalProperties = additionalProperties;
}
@JsonProperty("success")
public boolean getSuccess() {
return success;
}
/**
* @return The ID of the deleted parser run
*/
@JsonProperty("parserRunId")
public String getParserRunId() {
return parserRunId;
}
/**
* @return Confirmation message
*/
@JsonProperty("message")
public String getMessage() {
return message;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof ParserRunDeleteResponse && equalTo((ParserRunDeleteResponse) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(ParserRunDeleteResponse other) {
return success == other.success && parserRunId.equals(other.parserRunId) && message.equals(other.message);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.success, this.parserRunId, this.message);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static SuccessStage builder() {
return new Builder();
}
public interface SuccessStage {
ParserRunIdStage success(boolean success);
Builder from(ParserRunDeleteResponse other);
}
public interface ParserRunIdStage {
/**
* <p>The ID of the deleted parser run</p>
*/
MessageStage parserRunId(@NotNull String parserRunId);
}
public interface MessageStage {
/**
* <p>Confirmation message</p>
*/
_FinalStage message(@NotNull String message);
}
public interface _FinalStage {
ParserRunDeleteResponse build();
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements SuccessStage, ParserRunIdStage, MessageStage, _FinalStage {
private boolean success;
private String parserRunId;
private String message;
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
@java.lang.Override
public Builder from(ParserRunDeleteResponse other) {
success(other.getSuccess());
parserRunId(other.getParserRunId());
message(other.getMessage());
return this;
}
@java.lang.Override
@JsonSetter("success")
public ParserRunIdStage success(boolean success) {
this.success = success;
return this;
}
/**
* <p>The ID of the deleted parser run</p>
* <p>The ID of the deleted parser run</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
@JsonSetter("parserRunId")
public MessageStage parserRunId(@NotNull String parserRunId) {
this.parserRunId = Objects.requireNonNull(parserRunId, "parserRunId must not be null");
return this;
}
/**
* <p>Confirmation message</p>
* <p>Confirmation message</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
@JsonSetter("message")
public _FinalStage message(@NotNull String message) {
this.message = Objects.requireNonNull(message, "message must not be null");
return this;
}
@java.lang.Override
public ParserRunDeleteResponse build() {
return new ParserRunDeleteResponse(success, parserRunId, message, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/parserrun
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/parserrun/types/ParserRunGetRequestResponseType.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.parserrun.types;
import com.fasterxml.jackson.annotation.JsonValue;
public enum ParserRunGetRequestResponseType {
JSON("json"),
URL("url");
private final String value;
ParserRunGetRequestResponseType(String value) {
this.value = value;
}
@JsonValue
@java.lang.Override
public String toString() {
return this.value;
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/parserrun
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/parserrun/types/ParserRunGetResponse.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.parserrun.types;
import ai.extend.core.ObjectMappers;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import org.jetbrains.annotations.NotNull;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = ParserRunGetResponse.Builder.class)
public final class ParserRunGetResponse {
private final boolean success;
private final Optional<String> warning;
private final ParserRunGetResponseParserRun parserRun;
private final Map<String, Object> additionalProperties;
private ParserRunGetResponse(
boolean success,
Optional<String> warning,
ParserRunGetResponseParserRun parserRun,
Map<String, Object> additionalProperties) {
this.success = success;
this.warning = warning;
this.parserRun = parserRun;
this.additionalProperties = additionalProperties;
}
@JsonProperty("success")
public boolean getSuccess() {
return success;
}
/**
* @return Warning message about missing API version header if applicable
*/
@JsonProperty("warning")
public Optional<String> getWarning() {
return warning;
}
@JsonProperty("parserRun")
public ParserRunGetResponseParserRun getParserRun() {
return parserRun;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof ParserRunGetResponse && equalTo((ParserRunGetResponse) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(ParserRunGetResponse other) {
return success == other.success && warning.equals(other.warning) && parserRun.equals(other.parserRun);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.success, this.warning, this.parserRun);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static SuccessStage builder() {
return new Builder();
}
public interface SuccessStage {
ParserRunStage success(boolean success);
Builder from(ParserRunGetResponse other);
}
public interface ParserRunStage {
_FinalStage parserRun(@NotNull ParserRunGetResponseParserRun parserRun);
}
public interface _FinalStage {
ParserRunGetResponse build();
/**
* <p>Warning message about missing API version header if applicable</p>
*/
_FinalStage warning(Optional<String> warning);
_FinalStage warning(String warning);
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements SuccessStage, ParserRunStage, _FinalStage {
private boolean success;
private ParserRunGetResponseParserRun parserRun;
private Optional<String> warning = Optional.empty();
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
@java.lang.Override
public Builder from(ParserRunGetResponse other) {
success(other.getSuccess());
warning(other.getWarning());
parserRun(other.getParserRun());
return this;
}
@java.lang.Override
@JsonSetter("success")
public ParserRunStage success(boolean success) {
this.success = success;
return this;
}
@java.lang.Override
@JsonSetter("parserRun")
public _FinalStage parserRun(@NotNull ParserRunGetResponseParserRun parserRun) {
this.parserRun = Objects.requireNonNull(parserRun, "parserRun must not be null");
return this;
}
/**
* <p>Warning message about missing API version header if applicable</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
public _FinalStage warning(String warning) {
this.warning = Optional.ofNullable(warning);
return this;
}
/**
* <p>Warning message about missing API version header if applicable</p>
*/
@java.lang.Override
@JsonSetter(value = "warning", nulls = Nulls.SKIP)
public _FinalStage warning(Optional<String> warning) {
this.warning = warning;
return this;
}
@java.lang.Override
public ParserRunGetResponse build() {
return new ParserRunGetResponse(success, warning, parserRun, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/parserrun
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/parserrun/types/ParserRunGetResponseParserRun.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.parserrun.types;
import ai.extend.types.ParserRun;
import ai.extend.types.ParserRunStatus;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.Objects;
import java.util.Optional;
public final class ParserRunGetResponseParserRun {
private final Value value;
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
private ParserRunGetResponseParserRun(Value value) {
this.value = value;
}
public <T> T visit(Visitor<T> visitor) {
return value.visit(visitor);
}
public static ParserRunGetResponseParserRun parserRunStatus(ParserRunStatus value) {
return new ParserRunGetResponseParserRun(new ParserRunStatusValue(value));
}
public static ParserRunGetResponseParserRun parserRun(ParserRun value) {
return new ParserRunGetResponseParserRun(new ParserRunValue(value));
}
public boolean isParserRunStatus() {
return value instanceof ParserRunStatusValue;
}
public boolean isParserRun() {
return value instanceof ParserRunValue;
}
public boolean _isUnknown() {
return value instanceof _UnknownValue;
}
public Optional<ParserRunStatus> getParserRunStatus() {
if (isParserRunStatus()) {
return Optional.of(((ParserRunStatusValue) value).value);
}
return Optional.empty();
}
public Optional<ParserRun> getParserRun() {
if (isParserRun()) {
return Optional.of(((ParserRunValue) value).value);
}
return Optional.empty();
}
public Optional<Object> _getUnknown() {
if (_isUnknown()) {
return Optional.of(((_UnknownValue) value).value);
}
return Optional.empty();
}
@JsonValue
private Value getValue() {
return this.value;
}
public interface Visitor<T> {
T visitParserRunStatus(ParserRunStatus parserRunStatus);
T visitParserRun(ParserRun parserRun);
T _visitUnknown(Object unknownType);
}
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "object", visible = true, defaultImpl = _UnknownValue.class)
@JsonSubTypes({@JsonSubTypes.Type(ParserRunStatusValue.class), @JsonSubTypes.Type(ParserRunValue.class)})
@JsonIgnoreProperties(ignoreUnknown = true)
private interface Value {
<T> T visit(Visitor<T> visitor);
}
@JsonTypeName("parser_run_status")
@JsonIgnoreProperties("object")
private static final class ParserRunStatusValue implements Value {
@JsonUnwrapped
private ParserRunStatus value;
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
private ParserRunStatusValue() {}
private ParserRunStatusValue(ParserRunStatus value) {
this.value = value;
}
@java.lang.Override
public <T> T visit(Visitor<T> visitor) {
return visitor.visitParserRunStatus(value);
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof ParserRunStatusValue && equalTo((ParserRunStatusValue) other);
}
private boolean equalTo(ParserRunStatusValue other) {
return value.equals(other.value);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.value);
}
@java.lang.Override
public String toString() {
return "ParserRunGetResponseParserRun{" + "value: " + value + "}";
}
}
@JsonTypeName("parser_run")
@JsonIgnoreProperties("object")
private static final class ParserRunValue implements Value {
@JsonUnwrapped
private ParserRun value;
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
private ParserRunValue() {}
private ParserRunValue(ParserRun value) {
this.value = value;
}
@java.lang.Override
public <T> T visit(Visitor<T> visitor) {
return visitor.visitParserRun(value);
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof ParserRunValue && equalTo((ParserRunValue) other);
}
private boolean equalTo(ParserRunValue other) {
return value.equals(other.value);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.value);
}
@java.lang.Override
public String toString() {
return "ParserRunGetResponseParserRun{" + "value: " + value + "}";
}
}
@JsonIgnoreProperties("object")
private static final class _UnknownValue implements Value {
private String type;
@JsonValue
private Object value;
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
private _UnknownValue(@JsonProperty("value") Object value) {}
@java.lang.Override
public <T> T visit(Visitor<T> visitor) {
return visitor._visitUnknown(value);
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof _UnknownValue && equalTo((_UnknownValue) other);
}
private boolean equalTo(_UnknownValue other) {
return type.equals(other.type) && value.equals(other.value);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.type, this.value);
}
@java.lang.Override
public String toString() {
return "ParserRunGetResponseParserRun{" + "type: " + type + ", value: " + value + "}";
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/processor/AsyncProcessorClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.processor;
import ai.extend.core.ClientOptions;
import ai.extend.core.RequestOptions;
import ai.extend.resources.processor.requests.ProcessorCreateRequest;
import ai.extend.resources.processor.requests.ProcessorUpdateRequest;
import ai.extend.resources.processor.types.ProcessorCreateResponse;
import ai.extend.resources.processor.types.ProcessorUpdateResponse;
import java.util.concurrent.CompletableFuture;
public class AsyncProcessorClient {
protected final ClientOptions clientOptions;
private final AsyncRawProcessorClient rawClient;
public AsyncProcessorClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.rawClient = new AsyncRawProcessorClient(clientOptions);
}
/**
* Get responses with HTTP metadata like headers
*/
public AsyncRawProcessorClient withRawResponse() {
return this.rawClient;
}
/**
* Create a new processor in Extend, optionally cloning from an existing processor
*/
public CompletableFuture<ProcessorCreateResponse> create(ProcessorCreateRequest request) {
return this.rawClient.create(request).thenApply(response -> response.body());
}
/**
* Create a new processor in Extend, optionally cloning from an existing processor
*/
public CompletableFuture<ProcessorCreateResponse> create(
ProcessorCreateRequest request, RequestOptions requestOptions) {
return this.rawClient.create(request, requestOptions).thenApply(response -> response.body());
}
/**
* Update an existing processor in Extend
*/
public CompletableFuture<ProcessorUpdateResponse> update(String id) {
return this.rawClient.update(id).thenApply(response -> response.body());
}
/**
* Update an existing processor in Extend
*/
public CompletableFuture<ProcessorUpdateResponse> update(String id, ProcessorUpdateRequest request) {
return this.rawClient.update(id, request).thenApply(response -> response.body());
}
/**
* Update an existing processor in Extend
*/
public CompletableFuture<ProcessorUpdateResponse> update(
String id, ProcessorUpdateRequest request, RequestOptions requestOptions) {
return this.rawClient.update(id, request, requestOptions).thenApply(response -> response.body());
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/processor/AsyncRawProcessorClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.processor;
import ai.extend.core.ClientOptions;
import ai.extend.core.ExtendClientApiException;
import ai.extend.core.ExtendClientException;
import ai.extend.core.ExtendClientHttpResponse;
import ai.extend.core.MediaTypes;
import ai.extend.core.ObjectMappers;
import ai.extend.core.RequestOptions;
import ai.extend.errors.BadRequestError;
import ai.extend.errors.NotFoundError;
import ai.extend.errors.UnauthorizedError;
import ai.extend.resources.processor.requests.ProcessorCreateRequest;
import ai.extend.resources.processor.requests.ProcessorUpdateRequest;
import ai.extend.resources.processor.types.ProcessorCreateResponse;
import ai.extend.resources.processor.types.ProcessorUpdateResponse;
import ai.extend.types.Error;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.jetbrains.annotations.NotNull;
public class AsyncRawProcessorClient {
protected final ClientOptions clientOptions;
public AsyncRawProcessorClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
}
/**
* Create a new processor in Extend, optionally cloning from an existing processor
*/
public CompletableFuture<ExtendClientHttpResponse<ProcessorCreateResponse>> create(ProcessorCreateRequest request) {
return create(request, null);
}
/**
* Create a new processor in Extend, optionally cloning from an existing processor
*/
public CompletableFuture<ExtendClientHttpResponse<ProcessorCreateResponse>> create(
ProcessorCreateRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("processors")
.build();
RequestBody body;
try {
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (JsonProcessingException e) {
throw new ExtendClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("POST", body)
.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<ExtendClientHttpResponse<ProcessorCreateResponse>> 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(new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(
responseBody.string(), ProcessorCreateResponse.class),
response));
return;
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
future.completeExceptionally(new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
case 401:
future.completeExceptionally(new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
response));
return;
case 404:
future.completeExceptionally(new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
future.completeExceptionally(new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
});
return future;
}
/**
* Update an existing processor in Extend
*/
public CompletableFuture<ExtendClientHttpResponse<ProcessorUpdateResponse>> update(String id) {
return update(id, ProcessorUpdateRequest.builder().build());
}
/**
* Update an existing processor in Extend
*/
public CompletableFuture<ExtendClientHttpResponse<ProcessorUpdateResponse>> update(
String id, ProcessorUpdateRequest request) {
return update(id, request, null);
}
/**
* Update an existing processor in Extend
*/
public CompletableFuture<ExtendClientHttpResponse<ProcessorUpdateResponse>> update(
String id, ProcessorUpdateRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("processors")
.addPathSegment(id)
.build();
RequestBody body;
try {
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (JsonProcessingException e) {
throw new ExtendClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("POST", body)
.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<ExtendClientHttpResponse<ProcessorUpdateResponse>> 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(new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(
responseBody.string(), ProcessorUpdateResponse.class),
response));
return;
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
future.completeExceptionally(new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
case 401:
future.completeExceptionally(new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
response));
return;
case 404:
future.completeExceptionally(new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
future.completeExceptionally(new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
future.completeExceptionally(new ExtendClientException("Network error executing HTTP request", e));
}
});
return future;
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/processor/ProcessorClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.processor;
import ai.extend.core.ClientOptions;
import ai.extend.core.RequestOptions;
import ai.extend.resources.processor.requests.ProcessorCreateRequest;
import ai.extend.resources.processor.requests.ProcessorUpdateRequest;
import ai.extend.resources.processor.types.ProcessorCreateResponse;
import ai.extend.resources.processor.types.ProcessorUpdateResponse;
public class ProcessorClient {
protected final ClientOptions clientOptions;
private final RawProcessorClient rawClient;
public ProcessorClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.rawClient = new RawProcessorClient(clientOptions);
}
/**
* Get responses with HTTP metadata like headers
*/
public RawProcessorClient withRawResponse() {
return this.rawClient;
}
/**
* Create a new processor in Extend, optionally cloning from an existing processor
*/
public ProcessorCreateResponse create(ProcessorCreateRequest request) {
return this.rawClient.create(request).body();
}
/**
* Create a new processor in Extend, optionally cloning from an existing processor
*/
public ProcessorCreateResponse create(ProcessorCreateRequest request, RequestOptions requestOptions) {
return this.rawClient.create(request, requestOptions).body();
}
/**
* Update an existing processor in Extend
*/
public ProcessorUpdateResponse update(String id) {
return this.rawClient.update(id).body();
}
/**
* Update an existing processor in Extend
*/
public ProcessorUpdateResponse update(String id, ProcessorUpdateRequest request) {
return this.rawClient.update(id, request).body();
}
/**
* Update an existing processor in Extend
*/
public ProcessorUpdateResponse update(String id, ProcessorUpdateRequest request, RequestOptions requestOptions) {
return this.rawClient.update(id, request, requestOptions).body();
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/processor/RawProcessorClient.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.processor;
import ai.extend.core.ClientOptions;
import ai.extend.core.ExtendClientApiException;
import ai.extend.core.ExtendClientException;
import ai.extend.core.ExtendClientHttpResponse;
import ai.extend.core.MediaTypes;
import ai.extend.core.ObjectMappers;
import ai.extend.core.RequestOptions;
import ai.extend.errors.BadRequestError;
import ai.extend.errors.NotFoundError;
import ai.extend.errors.UnauthorizedError;
import ai.extend.resources.processor.requests.ProcessorCreateRequest;
import ai.extend.resources.processor.requests.ProcessorUpdateRequest;
import ai.extend.resources.processor.types.ProcessorCreateResponse;
import ai.extend.resources.processor.types.ProcessorUpdateResponse;
import ai.extend.types.Error;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;
public class RawProcessorClient {
protected final ClientOptions clientOptions;
public RawProcessorClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
}
/**
* Create a new processor in Extend, optionally cloning from an existing processor
*/
public ExtendClientHttpResponse<ProcessorCreateResponse> create(ProcessorCreateRequest request) {
return create(request, null);
}
/**
* Create a new processor in Extend, optionally cloning from an existing processor
*/
public ExtendClientHttpResponse<ProcessorCreateResponse> create(
ProcessorCreateRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("processors")
.build();
RequestBody body;
try {
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (JsonProcessingException e) {
throw new ExtendClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("POST", body)
.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);
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ProcessorCreateResponse.class),
response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
throw new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
case 401:
throw new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 404:
throw new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
throw new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
throw new ExtendClientException("Network error executing HTTP request", e);
}
}
/**
* Update an existing processor in Extend
*/
public ExtendClientHttpResponse<ProcessorUpdateResponse> update(String id) {
return update(id, ProcessorUpdateRequest.builder().build());
}
/**
* Update an existing processor in Extend
*/
public ExtendClientHttpResponse<ProcessorUpdateResponse> update(String id, ProcessorUpdateRequest request) {
return update(id, request, null);
}
/**
* Update an existing processor in Extend
*/
public ExtendClientHttpResponse<ProcessorUpdateResponse> update(
String id, ProcessorUpdateRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("processors")
.addPathSegment(id)
.build();
RequestBody body;
try {
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (JsonProcessingException e) {
throw new ExtendClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("POST", body)
.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);
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return new ExtendClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ProcessorUpdateResponse.class),
response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
throw new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
case 401:
throw new UnauthorizedError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 404:
throw new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
throw new ExtendClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
throw new ExtendClientException("Network error executing HTTP request", e);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/processor
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/processor/requests/ProcessorCreateRequest.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.processor.requests;
import ai.extend.core.ObjectMappers;
import ai.extend.resources.processor.types.ProcessorCreateRequestConfig;
import ai.extend.types.ProcessorType;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import org.jetbrains.annotations.NotNull;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = ProcessorCreateRequest.Builder.class)
public final class ProcessorCreateRequest {
private final String name;
private final ProcessorType type;
private final Optional<String> cloneProcessorId;
private final Optional<ProcessorCreateRequestConfig> config;
private final Map<String, Object> additionalProperties;
private ProcessorCreateRequest(
String name,
ProcessorType type,
Optional<String> cloneProcessorId,
Optional<ProcessorCreateRequestConfig> config,
Map<String, Object> additionalProperties) {
this.name = name;
this.type = type;
this.cloneProcessorId = cloneProcessorId;
this.config = config;
this.additionalProperties = additionalProperties;
}
/**
* @return The name of the new processor
*/
@JsonProperty("name")
public String getName() {
return name;
}
@JsonProperty("type")
public ProcessorType getType() {
return type;
}
/**
* @return The ID of an existing processor to clone. One of <code>cloneProcessorId</code> or <code>config</code> must be provided.
* <p>Example: <code>"dp_Xj8mK2pL9nR4vT7qY5wZ"</code></p>
*/
@JsonProperty("cloneProcessorId")
public Optional<String> getCloneProcessorId() {
return cloneProcessorId;
}
/**
* @return The configuration for the processor. The type of configuration must match the processor type. One of <code>cloneProcessorId</code> or <code>config</code> must be provided.
*/
@JsonProperty("config")
public Optional<ProcessorCreateRequestConfig> getConfig() {
return config;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof ProcessorCreateRequest && equalTo((ProcessorCreateRequest) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(ProcessorCreateRequest other) {
return name.equals(other.name)
&& type.equals(other.type)
&& cloneProcessorId.equals(other.cloneProcessorId)
&& config.equals(other.config);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.name, this.type, this.cloneProcessorId, this.config);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static NameStage builder() {
return new Builder();
}
public interface NameStage {
/**
* <p>The name of the new processor</p>
*/
TypeStage name(@NotNull String name);
Builder from(ProcessorCreateRequest other);
}
public interface TypeStage {
_FinalStage type(@NotNull ProcessorType type);
}
public interface _FinalStage {
ProcessorCreateRequest build();
/**
* <p>The ID of an existing processor to clone. One of <code>cloneProcessorId</code> or <code>config</code> must be provided.</p>
* <p>Example: <code>"dp_Xj8mK2pL9nR4vT7qY5wZ"</code></p>
*/
_FinalStage cloneProcessorId(Optional<String> cloneProcessorId);
_FinalStage cloneProcessorId(String cloneProcessorId);
/**
* <p>The configuration for the processor. The type of configuration must match the processor type. One of <code>cloneProcessorId</code> or <code>config</code> must be provided.</p>
*/
_FinalStage config(Optional<ProcessorCreateRequestConfig> config);
_FinalStage config(ProcessorCreateRequestConfig config);
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements NameStage, TypeStage, _FinalStage {
private String name;
private ProcessorType type;
private Optional<ProcessorCreateRequestConfig> config = Optional.empty();
private Optional<String> cloneProcessorId = Optional.empty();
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
@java.lang.Override
public Builder from(ProcessorCreateRequest other) {
name(other.getName());
type(other.getType());
cloneProcessorId(other.getCloneProcessorId());
config(other.getConfig());
return this;
}
/**
* <p>The name of the new processor</p>
* <p>The name of the new processor</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
@JsonSetter("name")
public TypeStage name(@NotNull String name) {
this.name = Objects.requireNonNull(name, "name must not be null");
return this;
}
@java.lang.Override
@JsonSetter("type")
public _FinalStage type(@NotNull ProcessorType type) {
this.type = Objects.requireNonNull(type, "type must not be null");
return this;
}
/**
* <p>The configuration for the processor. The type of configuration must match the processor type. One of <code>cloneProcessorId</code> or <code>config</code> must be provided.</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
public _FinalStage config(ProcessorCreateRequestConfig config) {
this.config = Optional.ofNullable(config);
return this;
}
/**
* <p>The configuration for the processor. The type of configuration must match the processor type. One of <code>cloneProcessorId</code> or <code>config</code> must be provided.</p>
*/
@java.lang.Override
@JsonSetter(value = "config", nulls = Nulls.SKIP)
public _FinalStage config(Optional<ProcessorCreateRequestConfig> config) {
this.config = config;
return this;
}
/**
* <p>The ID of an existing processor to clone. One of <code>cloneProcessorId</code> or <code>config</code> must be provided.</p>
* <p>Example: <code>"dp_Xj8mK2pL9nR4vT7qY5wZ"</code></p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
public _FinalStage cloneProcessorId(String cloneProcessorId) {
this.cloneProcessorId = Optional.ofNullable(cloneProcessorId);
return this;
}
/**
* <p>The ID of an existing processor to clone. One of <code>cloneProcessorId</code> or <code>config</code> must be provided.</p>
* <p>Example: <code>"dp_Xj8mK2pL9nR4vT7qY5wZ"</code></p>
*/
@java.lang.Override
@JsonSetter(value = "cloneProcessorId", nulls = Nulls.SKIP)
public _FinalStage cloneProcessorId(Optional<String> cloneProcessorId) {
this.cloneProcessorId = cloneProcessorId;
return this;
}
@java.lang.Override
public ProcessorCreateRequest build() {
return new ProcessorCreateRequest(name, type, cloneProcessorId, config, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/processor
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/processor/requests/ProcessorUpdateRequest.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.processor.requests;
import ai.extend.core.ObjectMappers;
import ai.extend.resources.processor.types.ProcessorUpdateRequestConfig;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = ProcessorUpdateRequest.Builder.class)
public final class ProcessorUpdateRequest {
private final Optional<String> name;
private final Optional<ProcessorUpdateRequestConfig> config;
private final Map<String, Object> additionalProperties;
private ProcessorUpdateRequest(
Optional<String> name,
Optional<ProcessorUpdateRequestConfig> config,
Map<String, Object> additionalProperties) {
this.name = name;
this.config = config;
this.additionalProperties = additionalProperties;
}
/**
* @return The new name for the processor
*/
@JsonProperty("name")
public Optional<String> getName() {
return name;
}
/**
* @return The new configuration for the processor. The type of configuration must match the processor type:
* <ul>
* <li>For classification processors, use <code>ClassificationConfig</code></li>
* <li>For extraction processors, use <code>ExtractionConfig</code></li>
* <li>For splitter processors, use <code>SplitterConfig</code></li>
* </ul>
*/
@JsonProperty("config")
public Optional<ProcessorUpdateRequestConfig> getConfig() {
return config;
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof ProcessorUpdateRequest && equalTo((ProcessorUpdateRequest) other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
private boolean equalTo(ProcessorUpdateRequest other) {
return name.equals(other.name) && config.equals(other.config);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.name, this.config);
}
@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}
public static Builder builder() {
return new Builder();
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder {
private Optional<String> name = Optional.empty();
private Optional<ProcessorUpdateRequestConfig> config = Optional.empty();
@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
private Builder() {}
public Builder from(ProcessorUpdateRequest other) {
name(other.getName());
config(other.getConfig());
return this;
}
/**
* <p>The new name for the processor</p>
*/
@JsonSetter(value = "name", nulls = Nulls.SKIP)
public Builder name(Optional<String> name) {
this.name = name;
return this;
}
public Builder name(String name) {
this.name = Optional.ofNullable(name);
return this;
}
/**
* <p>The new configuration for the processor. The type of configuration must match the processor type:</p>
* <ul>
* <li>For classification processors, use <code>ClassificationConfig</code></li>
* <li>For extraction processors, use <code>ExtractionConfig</code></li>
* <li>For splitter processors, use <code>SplitterConfig</code></li>
* </ul>
*/
@JsonSetter(value = "config", nulls = Nulls.SKIP)
public Builder config(Optional<ProcessorUpdateRequestConfig> config) {
this.config = config;
return this;
}
public Builder config(ProcessorUpdateRequestConfig config) {
this.config = Optional.ofNullable(config);
return this;
}
public ProcessorUpdateRequest build() {
return new ProcessorUpdateRequest(name, config, additionalProperties);
}
}
}
|
0
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/processor
|
java-sources/ai/extend/extend-java-sdk/0.0.3-beta/ai/extend/resources/processor/types/ProcessorCreateRequestConfig.java
|
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend.resources.processor.types;
import ai.extend.types.ClassificationConfig;
import ai.extend.types.ExtractionConfig;
import ai.extend.types.SplitterConfig;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.Objects;
import java.util.Optional;
public final class ProcessorCreateRequestConfig {
private final Value value;
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
private ProcessorCreateRequestConfig(Value value) {
this.value = value;
}
public <T> T visit(Visitor<T> visitor) {
return value.visit(visitor);
}
public static ProcessorCreateRequestConfig classify(ClassificationConfig value) {
return new ProcessorCreateRequestConfig(new ClassifyValue(value));
}
public static ProcessorCreateRequestConfig extract(ExtractionConfig value) {
return new ProcessorCreateRequestConfig(new ExtractValue(value));
}
public static ProcessorCreateRequestConfig splitter(SplitterConfig value) {
return new ProcessorCreateRequestConfig(new SplitterValue(value));
}
public boolean isClassify() {
return value instanceof ClassifyValue;
}
public boolean isExtract() {
return value instanceof ExtractValue;
}
public boolean isSplitter() {
return value instanceof SplitterValue;
}
public boolean _isUnknown() {
return value instanceof _UnknownValue;
}
public Optional<ClassificationConfig> getClassify() {
if (isClassify()) {
return Optional.of(((ClassifyValue) value).value);
}
return Optional.empty();
}
public Optional<ExtractionConfig> getExtract() {
if (isExtract()) {
return Optional.of(((ExtractValue) value).value);
}
return Optional.empty();
}
public Optional<SplitterConfig> getSplitter() {
if (isSplitter()) {
return Optional.of(((SplitterValue) value).value);
}
return Optional.empty();
}
public Optional<Object> _getUnknown() {
if (_isUnknown()) {
return Optional.of(((_UnknownValue) value).value);
}
return Optional.empty();
}
@JsonValue
private Value getValue() {
return this.value;
}
public interface Visitor<T> {
T visitClassify(ClassificationConfig classify);
T visitExtract(ExtractionConfig extract);
T visitSplitter(SplitterConfig splitter);
T _visitUnknown(Object unknownType);
}
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", visible = true, defaultImpl = _UnknownValue.class)
@JsonSubTypes({
@JsonSubTypes.Type(ClassifyValue.class),
@JsonSubTypes.Type(ExtractValue.class),
@JsonSubTypes.Type(SplitterValue.class)
})
@JsonIgnoreProperties(ignoreUnknown = true)
private interface Value {
<T> T visit(Visitor<T> visitor);
}
@JsonTypeName("CLASSIFY")
@JsonIgnoreProperties("type")
private static final class ClassifyValue implements Value {
@JsonUnwrapped
private ClassificationConfig value;
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
private ClassifyValue() {}
private ClassifyValue(ClassificationConfig value) {
this.value = value;
}
@java.lang.Override
public <T> T visit(Visitor<T> visitor) {
return visitor.visitClassify(value);
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof ClassifyValue && equalTo((ClassifyValue) other);
}
private boolean equalTo(ClassifyValue other) {
return value.equals(other.value);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.value);
}
@java.lang.Override
public String toString() {
return "ProcessorCreateRequestConfig{" + "value: " + value + "}";
}
}
@JsonTypeName("EXTRACT")
@JsonIgnoreProperties("type")
private static final class ExtractValue implements Value {
@JsonUnwrapped
private ExtractionConfig value;
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
private ExtractValue() {}
private ExtractValue(ExtractionConfig value) {
this.value = value;
}
@java.lang.Override
public <T> T visit(Visitor<T> visitor) {
return visitor.visitExtract(value);
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof ExtractValue && equalTo((ExtractValue) other);
}
private boolean equalTo(ExtractValue other) {
return value.equals(other.value);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.value);
}
@java.lang.Override
public String toString() {
return "ProcessorCreateRequestConfig{" + "value: " + value + "}";
}
}
@JsonTypeName("SPLITTER")
@JsonIgnoreProperties("type")
private static final class SplitterValue implements Value {
@JsonUnwrapped
private SplitterConfig value;
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
private SplitterValue() {}
private SplitterValue(SplitterConfig value) {
this.value = value;
}
@java.lang.Override
public <T> T visit(Visitor<T> visitor) {
return visitor.visitSplitter(value);
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof SplitterValue && equalTo((SplitterValue) other);
}
private boolean equalTo(SplitterValue other) {
return value.equals(other.value);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.value);
}
@java.lang.Override
public String toString() {
return "ProcessorCreateRequestConfig{" + "value: " + value + "}";
}
}
@JsonIgnoreProperties("type")
private static final class _UnknownValue implements Value {
private String type;
@JsonValue
private Object value;
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
private _UnknownValue(@JsonProperty("value") Object value) {}
@java.lang.Override
public <T> T visit(Visitor<T> visitor) {
return visitor._visitUnknown(value);
}
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof _UnknownValue && equalTo((_UnknownValue) other);
}
private boolean equalTo(_UnknownValue other) {
return type.equals(other.type) && value.equals(other.value);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(this.type, this.value);
}
@java.lang.Override
public String toString() {
return "ProcessorCreateRequestConfig{" + "type: " + type + ", value: " + value + "}";
}
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.