diff --git a/.gitignore b/.gitignore index 5ff6309..ae8516b 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ target/ *.iws *.iml *.ipr +*.idea ### Eclipse ### .apt_generated diff --git a/src/main/java/com/langfuse/client/LangfuseClient.java b/src/main/java/com/langfuse/client/LangfuseClient.java index 18644b1..e50129c 100644 --- a/src/main/java/com/langfuse/client/LangfuseClient.java +++ b/src/main/java/com/langfuse/client/LangfuseClient.java @@ -7,6 +7,7 @@ import com.langfuse.client.core.ClientOptions; import com.langfuse.client.core.Suppliers; import java.util.function.Supplier; +import com.langfuse.client.resources.annotationqueues.AnnotationQueuesClient; import com.langfuse.client.resources.comments.CommentsClient; import com.langfuse.client.resources.datasetitems.DatasetItemsClient; import com.langfuse.client.resources.datasetrunitems.DatasetRunItemsClient; @@ -17,17 +18,22 @@ import com.langfuse.client.resources.metrics.MetricsClient; import com.langfuse.client.resources.models.ModelsClient; import com.langfuse.client.resources.observations.ObservationsClient; +import com.langfuse.client.resources.organizations.OrganizationsClient; import com.langfuse.client.resources.projects.ProjectsClient; import com.langfuse.client.resources.prompts.PromptsClient; import com.langfuse.client.resources.promptversion.PromptVersionClient; +import com.langfuse.client.resources.scim.ScimClient; import com.langfuse.client.resources.score.ScoreClient; import com.langfuse.client.resources.scoreconfigs.ScoreConfigsClient; +import com.langfuse.client.resources.scorev2.ScoreV2Client; import com.langfuse.client.resources.sessions.SessionsClient; import com.langfuse.client.resources.trace.TraceClient; public class LangfuseClient { protected final ClientOptions clientOptions; + protected final Supplier annotationQueuesClient; + protected final Supplier commentsClient; protected final Supplier datasetItemsClient; @@ -48,14 +54,20 @@ public class LangfuseClient { protected final Supplier observationsClient; + protected final Supplier organizationsClient; + protected final Supplier projectsClient; protected final Supplier promptVersionClient; protected final Supplier promptsClient; + protected final Supplier scimClient; + protected final Supplier scoreConfigsClient; + protected final Supplier scoreV2Client; + protected final Supplier scoreClient; protected final Supplier sessionsClient; @@ -64,6 +76,7 @@ public class LangfuseClient { public LangfuseClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.annotationQueuesClient = Suppliers.memoize(() -> new AnnotationQueuesClient(clientOptions)); this.commentsClient = Suppliers.memoize(() -> new CommentsClient(clientOptions)); this.datasetItemsClient = Suppliers.memoize(() -> new DatasetItemsClient(clientOptions)); this.datasetRunItemsClient = Suppliers.memoize(() -> new DatasetRunItemsClient(clientOptions)); @@ -74,15 +87,22 @@ public LangfuseClient(ClientOptions clientOptions) { this.metricsClient = Suppliers.memoize(() -> new MetricsClient(clientOptions)); this.modelsClient = Suppliers.memoize(() -> new ModelsClient(clientOptions)); this.observationsClient = Suppliers.memoize(() -> new ObservationsClient(clientOptions)); + this.organizationsClient = Suppliers.memoize(() -> new OrganizationsClient(clientOptions)); this.projectsClient = Suppliers.memoize(() -> new ProjectsClient(clientOptions)); this.promptVersionClient = Suppliers.memoize(() -> new PromptVersionClient(clientOptions)); this.promptsClient = Suppliers.memoize(() -> new PromptsClient(clientOptions)); + this.scimClient = Suppliers.memoize(() -> new ScimClient(clientOptions)); this.scoreConfigsClient = Suppliers.memoize(() -> new ScoreConfigsClient(clientOptions)); + this.scoreV2Client = Suppliers.memoize(() -> new ScoreV2Client(clientOptions)); this.scoreClient = Suppliers.memoize(() -> new ScoreClient(clientOptions)); this.sessionsClient = Suppliers.memoize(() -> new SessionsClient(clientOptions)); this.traceClient = Suppliers.memoize(() -> new TraceClient(clientOptions)); } + public AnnotationQueuesClient annotationQueues() { + return this.annotationQueuesClient.get(); + } + public CommentsClient comments() { return this.commentsClient.get(); } @@ -123,6 +143,10 @@ public ObservationsClient observations() { return this.observationsClient.get(); } + public OrganizationsClient organizations() { + return this.organizationsClient.get(); + } + public ProjectsClient projects() { return this.projectsClient.get(); } @@ -135,10 +159,18 @@ public PromptsClient prompts() { return this.promptsClient.get(); } + public ScimClient scim() { + return this.scimClient.get(); + } + public ScoreConfigsClient scoreConfigs() { return this.scoreConfigsClient.get(); } + public ScoreV2Client scoreV2() { + return this.scoreV2Client.get(); + } + public ScoreClient score() { return this.scoreClient.get(); } diff --git a/src/main/java/com/langfuse/client/resources/annotationqueues/AnnotationQueuesClient.java b/src/main/java/com/langfuse/client/resources/annotationqueues/AnnotationQueuesClient.java new file mode 100644 index 0000000..3727837 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/annotationqueues/AnnotationQueuesClient.java @@ -0,0 +1,472 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.annotationqueues; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.langfuse.client.core.ClientOptions; +import com.langfuse.client.core.LangfuseClientApiException; +import com.langfuse.client.core.LangfuseClientException; +import com.langfuse.client.core.MediaTypes; +import com.langfuse.client.core.ObjectMappers; +import com.langfuse.client.core.QueryStringMapper; +import com.langfuse.client.core.RequestOptions; +import java.io.IOException; +import java.lang.Object; +import java.lang.String; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import com.langfuse.client.resources.annotationqueues.requests.GetAnnotationQueueItemsRequest; +import com.langfuse.client.resources.annotationqueues.requests.GetAnnotationQueuesRequest; +import com.langfuse.client.resources.annotationqueues.types.AnnotationQueue; +import com.langfuse.client.resources.annotationqueues.types.AnnotationQueueItem; +import com.langfuse.client.resources.annotationqueues.types.CreateAnnotationQueueItemRequest; +import com.langfuse.client.resources.annotationqueues.types.DeleteAnnotationQueueItemResponse; +import com.langfuse.client.resources.annotationqueues.types.PaginatedAnnotationQueueItems; +import com.langfuse.client.resources.annotationqueues.types.PaginatedAnnotationQueues; +import com.langfuse.client.resources.annotationqueues.types.UpdateAnnotationQueueItemRequest; +import com.langfuse.client.resources.commons.errors.AccessDeniedError; +import com.langfuse.client.resources.commons.errors.Error; +import com.langfuse.client.resources.commons.errors.MethodNotAllowedError; +import com.langfuse.client.resources.commons.errors.NotFoundError; +import com.langfuse.client.resources.commons.errors.UnauthorizedError; + +public class AnnotationQueuesClient { + protected final ClientOptions clientOptions; + + public AnnotationQueuesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get all annotation queues + */ + public PaginatedAnnotationQueues listQueues() { + return listQueues(GetAnnotationQueuesRequest.builder().build()); + } + + /** + * Get all annotation queues + */ + public PaginatedAnnotationQueues listQueues(GetAnnotationQueuesRequest request) { + return listQueues(request,null); + } + + /** + * Get all annotation queues + */ + public PaginatedAnnotationQueues listQueues(GetAnnotationQueuesRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public") + .addPathSegments("annotation-queues");if (request.getPage().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "page", request.getPage().get().toString(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "limit", request.getLimit().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAnnotationQueues.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + + /** + * Get an annotation queue by ID + */ + public AnnotationQueue getQueue(String queueId) { + return getQueue(queueId,null); + } + + /** + * Get an annotation queue by ID + */ + public AnnotationQueue getQueue(String queueId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public") + .addPathSegments("annotation-queues") + .addPathSegment(queueId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AnnotationQueue.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + + /** + * Get items for a specific annotation queue + */ + public PaginatedAnnotationQueueItems listQueueItems(String queueId) { + return listQueueItems(queueId,GetAnnotationQueueItemsRequest.builder().build()); + } + + /** + * Get items for a specific annotation queue + */ + public PaginatedAnnotationQueueItems listQueueItems(String queueId, + GetAnnotationQueueItemsRequest request) { + return listQueueItems(queueId,request,null); + } + + /** + * Get items for a specific annotation queue + */ + public PaginatedAnnotationQueueItems listQueueItems(String queueId, + GetAnnotationQueueItemsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public") + .addPathSegments("annotation-queues") + .addPathSegment(queueId) + .addPathSegments("items");if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "status", request.getStatus().get().toString(), false); + } + if (request.getPage().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "page", request.getPage().get().toString(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "limit", request.getLimit().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAnnotationQueueItems.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + + /** + * Get a specific item from an annotation queue + */ + public AnnotationQueueItem getQueueItem(String queueId, String itemId) { + return getQueueItem(queueId,itemId,null); + } + + /** + * Get a specific item from an annotation queue + */ + public AnnotationQueueItem getQueueItem(String queueId, String itemId, + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public") + .addPathSegments("annotation-queues") + .addPathSegment(queueId) + .addPathSegments("items") + .addPathSegment(itemId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AnnotationQueueItem.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + + /** + * Add an item to an annotation queue + */ + public AnnotationQueueItem createQueueItem(String queueId, + CreateAnnotationQueueItemRequest request) { + return createQueueItem(queueId,request,null); + } + + /** + * Add an item to an annotation queue + */ + public AnnotationQueueItem createQueueItem(String queueId, + CreateAnnotationQueueItemRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public") + .addPathSegments("annotation-queues") + .addPathSegment(queueId) + .addPathSegments("items") + .build(); + RequestBody body; + try { + body = RequestBody.create(ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } + catch(JsonProcessingException e) { + throw new LangfuseClientException("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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AnnotationQueueItem.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + + /** + * Update an annotation queue item + */ + public AnnotationQueueItem updateQueueItem(String queueId, String itemId) { + return updateQueueItem(queueId,itemId,UpdateAnnotationQueueItemRequest.builder().build()); + } + + /** + * Update an annotation queue item + */ + public AnnotationQueueItem updateQueueItem(String queueId, String itemId, + UpdateAnnotationQueueItemRequest request) { + return updateQueueItem(queueId,itemId,request,null); + } + + /** + * Update an annotation queue item + */ + public AnnotationQueueItem updateQueueItem(String queueId, String itemId, + UpdateAnnotationQueueItemRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public") + .addPathSegments("annotation-queues") + .addPathSegment(queueId) + .addPathSegments("items") + .addPathSegment(itemId) + .build(); + RequestBody body; + try { + body = RequestBody.create(ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } + catch(JsonProcessingException e) { + throw new LangfuseClientException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PATCH", 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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AnnotationQueueItem.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + + /** + * Remove an item from an annotation queue + */ + public DeleteAnnotationQueueItemResponse deleteQueueItem(String queueId, String itemId) { + return deleteQueueItem(queueId,itemId,null); + } + + /** + * Remove an item from an annotation queue + */ + public DeleteAnnotationQueueItemResponse deleteQueueItem(String queueId, String itemId, + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public") + .addPathSegments("annotation-queues") + .addPathSegment(queueId) + .addPathSegments("items") + .addPathSegment(itemId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteAnnotationQueueItemResponse.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + } diff --git a/src/main/java/com/langfuse/client/resources/annotationqueues/requests/GetAnnotationQueueItemsRequest.java b/src/main/java/com/langfuse/client/resources/annotationqueues/requests/GetAnnotationQueueItemsRequest.java new file mode 100644 index 0000000..6ffba05 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/annotationqueues/requests/GetAnnotationQueueItemsRequest.java @@ -0,0 +1,168 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.annotationqueues.requests; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Integer; +import java.lang.Object; +import java.lang.String; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import com.langfuse.client.resources.annotationqueues.types.AnnotationQueueStatus; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = GetAnnotationQueueItemsRequest.Builder.class +) +public final class GetAnnotationQueueItemsRequest { + private final Optional status; + + private final Optional page; + + private final Optional limit; + + private final Map additionalProperties; + + private GetAnnotationQueueItemsRequest(Optional status, + Optional page, Optional limit, Map additionalProperties) { + this.status = status; + this.page = page; + this.limit = limit; + this.additionalProperties = additionalProperties; + } + + /** + * @return Filter by status + */ + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + /** + * @return page number, starts at 1 + */ + @JsonProperty("page") + public Optional getPage() { + return page; + } + + /** + * @return limit of items per page + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetAnnotationQueueItemsRequest && equalTo((GetAnnotationQueueItemsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetAnnotationQueueItemsRequest other) { + return status.equals(other.status) && page.equals(other.page) && limit.equals(other.limit); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.status, this.page, this.limit); + } + + @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 status = Optional.empty(); + + private Optional page = Optional.empty(); + + private Optional limit = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + public Builder from(GetAnnotationQueueItemsRequest other) { + status(other.getStatus()); + page(other.getPage()); + limit(other.getLimit()); + return this; + } + + @JsonSetter( + value = "status", + nulls = Nulls.SKIP + ) + public Builder status(Optional status) { + this.status = status; + return this; + } + + public Builder status(AnnotationQueueStatus status) { + this.status = Optional.ofNullable(status); + return this; + } + + @JsonSetter( + value = "page", + nulls = Nulls.SKIP + ) + public Builder page(Optional page) { + this.page = page; + return this; + } + + public Builder page(Integer page) { + this.page = Optional.ofNullable(page); + return this; + } + + @JsonSetter( + value = "limit", + nulls = Nulls.SKIP + ) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + public GetAnnotationQueueItemsRequest build() { + return new GetAnnotationQueueItemsRequest(status, page, limit, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/annotationqueues/requests/GetAnnotationQueuesRequest.java b/src/main/java/com/langfuse/client/resources/annotationqueues/requests/GetAnnotationQueuesRequest.java new file mode 100644 index 0000000..725b191 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/annotationqueues/requests/GetAnnotationQueuesRequest.java @@ -0,0 +1,139 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.annotationqueues.requests; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Integer; +import java.lang.Object; +import java.lang.String; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = GetAnnotationQueuesRequest.Builder.class +) +public final class GetAnnotationQueuesRequest { + private final Optional page; + + private final Optional limit; + + private final Map additionalProperties; + + private GetAnnotationQueuesRequest(Optional page, Optional limit, + Map additionalProperties) { + this.page = page; + this.limit = limit; + this.additionalProperties = additionalProperties; + } + + /** + * @return page number, starts at 1 + */ + @JsonProperty("page") + public Optional getPage() { + return page; + } + + /** + * @return limit of items per page + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetAnnotationQueuesRequest && equalTo((GetAnnotationQueuesRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetAnnotationQueuesRequest other) { + return page.equals(other.page) && limit.equals(other.limit); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.page, this.limit); + } + + @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 page = Optional.empty(); + + private Optional limit = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + public Builder from(GetAnnotationQueuesRequest other) { + page(other.getPage()); + limit(other.getLimit()); + return this; + } + + @JsonSetter( + value = "page", + nulls = Nulls.SKIP + ) + public Builder page(Optional page) { + this.page = page; + return this; + } + + public Builder page(Integer page) { + this.page = Optional.ofNullable(page); + return this; + } + + @JsonSetter( + value = "limit", + nulls = Nulls.SKIP + ) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + public GetAnnotationQueuesRequest build() { + return new GetAnnotationQueuesRequest(page, limit, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/annotationqueues/types/AnnotationQueue.java b/src/main/java/com/langfuse/client/resources/annotationqueues/types/AnnotationQueue.java new file mode 100644 index 0000000..6fed5b4 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/annotationqueues/types/AnnotationQueue.java @@ -0,0 +1,254 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.annotationqueues.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.time.OffsetDateTime; +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 = AnnotationQueue.Builder.class +) +public final class AnnotationQueue { + private final String id; + + private final String name; + + private final Optional description; + + private final List scoreConfigIds; + + private final OffsetDateTime createdAt; + + private final OffsetDateTime updatedAt; + + private final Map additionalProperties; + + private AnnotationQueue(String id, String name, Optional description, + List scoreConfigIds, OffsetDateTime createdAt, OffsetDateTime updatedAt, + Map additionalProperties) { + this.id = id; + this.name = name; + this.description = description; + this.scoreConfigIds = scoreConfigIds; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + @JsonProperty("scoreConfigIds") + public List getScoreConfigIds() { + return scoreConfigIds; + } + + @JsonProperty("createdAt") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("updatedAt") + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AnnotationQueue && equalTo((AnnotationQueue) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AnnotationQueue other) { + return id.equals(other.id) && name.equals(other.name) && description.equals(other.description) && scoreConfigIds.equals(other.scoreConfigIds) && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.name, this.description, this.scoreConfigIds, this.createdAt, this.updatedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + NameStage id(@NotNull String id); + + Builder from(AnnotationQueue other); + } + + public interface NameStage { + CreatedAtStage name(@NotNull String name); + } + + public interface CreatedAtStage { + UpdatedAtStage createdAt(@NotNull OffsetDateTime createdAt); + } + + public interface UpdatedAtStage { + _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt); + } + + public interface _FinalStage { + AnnotationQueue build(); + + _FinalStage description(Optional description); + + _FinalStage description(String description); + + _FinalStage scoreConfigIds(List scoreConfigIds); + + _FinalStage addScoreConfigIds(String scoreConfigIds); + + _FinalStage addAllScoreConfigIds(List scoreConfigIds); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements IdStage, NameStage, CreatedAtStage, UpdatedAtStage, _FinalStage { + private String id; + + private String name; + + private OffsetDateTime createdAt; + + private OffsetDateTime updatedAt; + + private List scoreConfigIds = new ArrayList<>(); + + private Optional description = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(AnnotationQueue other) { + id(other.getId()); + name(other.getName()); + description(other.getDescription()); + scoreConfigIds(other.getScoreConfigIds()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public NameStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public CreatedAtStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("createdAt") + public UpdatedAtStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("updatedAt") + public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { + this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllScoreConfigIds(List scoreConfigIds) { + this.scoreConfigIds.addAll(scoreConfigIds); + return this; + } + + @java.lang.Override + public _FinalStage addScoreConfigIds(String scoreConfigIds) { + this.scoreConfigIds.add(scoreConfigIds); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "scoreConfigIds", + nulls = Nulls.SKIP + ) + public _FinalStage scoreConfigIds(List scoreConfigIds) { + this.scoreConfigIds.clear(); + this.scoreConfigIds.addAll(scoreConfigIds); + return this; + } + + @java.lang.Override + public _FinalStage description(String description) { + this.description = Optional.ofNullable(description); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "description", + nulls = Nulls.SKIP + ) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + @java.lang.Override + public AnnotationQueue build() { + return new AnnotationQueue(id, name, description, scoreConfigIds, createdAt, updatedAt, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/annotationqueues/types/AnnotationQueueItem.java b/src/main/java/com/langfuse/client/resources/annotationqueues/types/AnnotationQueueItem.java new file mode 100644 index 0000000..30c4352 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/annotationqueues/types/AnnotationQueueItem.java @@ -0,0 +1,279 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.annotationqueues.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.time.OffsetDateTime; +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 = AnnotationQueueItem.Builder.class +) +public final class AnnotationQueueItem { + private final String id; + + private final String queueId; + + private final String objectId; + + private final AnnotationQueueObjectType objectType; + + private final AnnotationQueueStatus status; + + private final Optional completedAt; + + private final OffsetDateTime createdAt; + + private final OffsetDateTime updatedAt; + + private final Map additionalProperties; + + private AnnotationQueueItem(String id, String queueId, String objectId, + AnnotationQueueObjectType objectType, AnnotationQueueStatus status, + Optional completedAt, OffsetDateTime createdAt, OffsetDateTime updatedAt, + Map additionalProperties) { + this.id = id; + this.queueId = queueId; + this.objectId = objectId; + this.objectType = objectType; + this.status = status; + this.completedAt = completedAt; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("queueId") + public String getQueueId() { + return queueId; + } + + @JsonProperty("objectId") + public String getObjectId() { + return objectId; + } + + @JsonProperty("objectType") + public AnnotationQueueObjectType getObjectType() { + return objectType; + } + + @JsonProperty("status") + public AnnotationQueueStatus getStatus() { + return status; + } + + @JsonProperty("completedAt") + public Optional getCompletedAt() { + return completedAt; + } + + @JsonProperty("createdAt") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("updatedAt") + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AnnotationQueueItem && equalTo((AnnotationQueueItem) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AnnotationQueueItem other) { + return id.equals(other.id) && queueId.equals(other.queueId) && objectId.equals(other.objectId) && objectType.equals(other.objectType) && status.equals(other.status) && completedAt.equals(other.completedAt) && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.queueId, this.objectId, this.objectType, this.status, this.completedAt, this.createdAt, this.updatedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + QueueIdStage id(@NotNull String id); + + Builder from(AnnotationQueueItem other); + } + + public interface QueueIdStage { + ObjectIdStage queueId(@NotNull String queueId); + } + + public interface ObjectIdStage { + ObjectTypeStage objectId(@NotNull String objectId); + } + + public interface ObjectTypeStage { + StatusStage objectType(@NotNull AnnotationQueueObjectType objectType); + } + + public interface StatusStage { + CreatedAtStage status(@NotNull AnnotationQueueStatus status); + } + + public interface CreatedAtStage { + UpdatedAtStage createdAt(@NotNull OffsetDateTime createdAt); + } + + public interface UpdatedAtStage { + _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt); + } + + public interface _FinalStage { + AnnotationQueueItem build(); + + _FinalStage completedAt(Optional completedAt); + + _FinalStage completedAt(OffsetDateTime completedAt); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements IdStage, QueueIdStage, ObjectIdStage, ObjectTypeStage, StatusStage, CreatedAtStage, UpdatedAtStage, _FinalStage { + private String id; + + private String queueId; + + private String objectId; + + private AnnotationQueueObjectType objectType; + + private AnnotationQueueStatus status; + + private OffsetDateTime createdAt; + + private OffsetDateTime updatedAt; + + private Optional completedAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(AnnotationQueueItem other) { + id(other.getId()); + queueId(other.getQueueId()); + objectId(other.getObjectId()); + objectType(other.getObjectType()); + status(other.getStatus()); + completedAt(other.getCompletedAt()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public QueueIdStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("queueId") + public ObjectIdStage queueId(@NotNull String queueId) { + this.queueId = Objects.requireNonNull(queueId, "queueId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("objectId") + public ObjectTypeStage objectId(@NotNull String objectId) { + this.objectId = Objects.requireNonNull(objectId, "objectId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("objectType") + public StatusStage objectType(@NotNull AnnotationQueueObjectType objectType) { + this.objectType = Objects.requireNonNull(objectType, "objectType must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("status") + public CreatedAtStage status(@NotNull AnnotationQueueStatus status) { + this.status = Objects.requireNonNull(status, "status must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("createdAt") + public UpdatedAtStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("updatedAt") + public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { + this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage completedAt(OffsetDateTime completedAt) { + this.completedAt = Optional.ofNullable(completedAt); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "completedAt", + nulls = Nulls.SKIP + ) + public _FinalStage completedAt(Optional completedAt) { + this.completedAt = completedAt; + return this; + } + + @java.lang.Override + public AnnotationQueueItem build() { + return new AnnotationQueueItem(id, queueId, objectId, objectType, status, completedAt, createdAt, updatedAt, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/annotationqueues/types/AnnotationQueueObjectType.java b/src/main/java/com/langfuse/client/resources/annotationqueues/types/AnnotationQueueObjectType.java new file mode 100644 index 0000000..1aad395 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/annotationqueues/types/AnnotationQueueObjectType.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.annotationqueues.types; + +import com.fasterxml.jackson.annotation.JsonValue; +import java.lang.String; + +public enum AnnotationQueueObjectType { + TRACE("TRACE"), + + OBSERVATION("OBSERVATION"); + + private final String value; + + AnnotationQueueObjectType(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/langfuse/client/resources/annotationqueues/types/AnnotationQueueStatus.java b/src/main/java/com/langfuse/client/resources/annotationqueues/types/AnnotationQueueStatus.java new file mode 100644 index 0000000..96e462e --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/annotationqueues/types/AnnotationQueueStatus.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.annotationqueues.types; + +import com.fasterxml.jackson.annotation.JsonValue; +import java.lang.String; + +public enum AnnotationQueueStatus { + PENDING("PENDING"), + + COMPLETED("COMPLETED"); + + private final String value; + + AnnotationQueueStatus(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/langfuse/client/resources/annotationqueues/types/CreateAnnotationQueueItemRequest.java b/src/main/java/com/langfuse/client/resources/annotationqueues/types/CreateAnnotationQueueItemRequest.java new file mode 100644 index 0000000..b50b960 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/annotationqueues/types/CreateAnnotationQueueItemRequest.java @@ -0,0 +1,173 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.annotationqueues.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +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 = CreateAnnotationQueueItemRequest.Builder.class +) +public final class CreateAnnotationQueueItemRequest { + private final String objectId; + + private final AnnotationQueueObjectType objectType; + + private final Optional status; + + private final Map additionalProperties; + + private CreateAnnotationQueueItemRequest(String objectId, AnnotationQueueObjectType objectType, + Optional status, Map additionalProperties) { + this.objectId = objectId; + this.objectType = objectType; + this.status = status; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("objectId") + public String getObjectId() { + return objectId; + } + + @JsonProperty("objectType") + public AnnotationQueueObjectType getObjectType() { + return objectType; + } + + /** + * @return Defaults to PENDING for new queue items + */ + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateAnnotationQueueItemRequest && equalTo((CreateAnnotationQueueItemRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateAnnotationQueueItemRequest other) { + return objectId.equals(other.objectId) && objectType.equals(other.objectType) && status.equals(other.status); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.objectId, this.objectType, this.status); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ObjectIdStage builder() { + return new Builder(); + } + + public interface ObjectIdStage { + ObjectTypeStage objectId(@NotNull String objectId); + + Builder from(CreateAnnotationQueueItemRequest other); + } + + public interface ObjectTypeStage { + _FinalStage objectType(@NotNull AnnotationQueueObjectType objectType); + } + + public interface _FinalStage { + CreateAnnotationQueueItemRequest build(); + + _FinalStage status(Optional status); + + _FinalStage status(AnnotationQueueStatus status); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements ObjectIdStage, ObjectTypeStage, _FinalStage { + private String objectId; + + private AnnotationQueueObjectType objectType; + + private Optional status = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(CreateAnnotationQueueItemRequest other) { + objectId(other.getObjectId()); + objectType(other.getObjectType()); + status(other.getStatus()); + return this; + } + + @java.lang.Override + @JsonSetter("objectId") + public ObjectTypeStage objectId(@NotNull String objectId) { + this.objectId = Objects.requireNonNull(objectId, "objectId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("objectType") + public _FinalStage objectType(@NotNull AnnotationQueueObjectType objectType) { + this.objectType = Objects.requireNonNull(objectType, "objectType must not be null"); + return this; + } + + /** + *

Defaults to PENDING for new queue items

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage status(AnnotationQueueStatus status) { + this.status = Optional.ofNullable(status); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "status", + nulls = Nulls.SKIP + ) + public _FinalStage status(Optional status) { + this.status = status; + return this; + } + + @java.lang.Override + public CreateAnnotationQueueItemRequest build() { + return new CreateAnnotationQueueItemRequest(objectId, objectType, status, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/annotationqueues/types/DeleteAnnotationQueueItemResponse.java b/src/main/java/com/langfuse/client/resources/annotationqueues/types/DeleteAnnotationQueueItemResponse.java new file mode 100644 index 0000000..842bdb7 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/annotationqueues/types/DeleteAnnotationQueueItemResponse.java @@ -0,0 +1,133 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.annotationqueues.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = DeleteAnnotationQueueItemResponse.Builder.class +) +public final class DeleteAnnotationQueueItemResponse { + private final boolean success; + + private final String message; + + private final Map additionalProperties; + + private DeleteAnnotationQueueItemResponse(boolean success, String message, + Map additionalProperties) { + this.success = success; + this.message = message; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("success") + public boolean getSuccess() { + return success; + } + + @JsonProperty("message") + public String getMessage() { + return message; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteAnnotationQueueItemResponse && equalTo((DeleteAnnotationQueueItemResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteAnnotationQueueItemResponse other) { + return success == other.success && message.equals(other.message); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.success, this.message); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SuccessStage builder() { + return new Builder(); + } + + public interface SuccessStage { + MessageStage success(boolean success); + + Builder from(DeleteAnnotationQueueItemResponse other); + } + + public interface MessageStage { + _FinalStage message(@NotNull String message); + } + + public interface _FinalStage { + DeleteAnnotationQueueItemResponse build(); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements SuccessStage, MessageStage, _FinalStage { + private boolean success; + + private String message; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(DeleteAnnotationQueueItemResponse other) { + success(other.getSuccess()); + message(other.getMessage()); + return this; + } + + @java.lang.Override + @JsonSetter("success") + public MessageStage success(boolean success) { + this.success = success; + return this; + } + + @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 DeleteAnnotationQueueItemResponse build() { + return new DeleteAnnotationQueueItemResponse(success, message, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/metrics/types/DailyMetrics.java b/src/main/java/com/langfuse/client/resources/annotationqueues/types/PaginatedAnnotationQueueItems.java similarity index 66% rename from src/main/java/com/langfuse/client/resources/metrics/types/DailyMetrics.java rename to src/main/java/com/langfuse/client/resources/annotationqueues/types/PaginatedAnnotationQueueItems.java index 2445b8b..083c787 100644 --- a/src/main/java/com/langfuse/client/resources/metrics/types/DailyMetrics.java +++ b/src/main/java/com/langfuse/client/resources/annotationqueues/types/PaginatedAnnotationQueueItems.java @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -package com.langfuse.client.resources.metrics.types; +package com.langfuse.client.resources.annotationqueues.types; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -25,27 +25,24 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize( - builder = DailyMetrics.Builder.class + builder = PaginatedAnnotationQueueItems.Builder.class ) -public final class DailyMetrics { - private final List data; +public final class PaginatedAnnotationQueueItems { + private final List data; private final MetaResponse meta; private final Map additionalProperties; - private DailyMetrics(List data, MetaResponse meta, + private PaginatedAnnotationQueueItems(List data, MetaResponse meta, Map additionalProperties) { this.data = data; this.meta = meta; this.additionalProperties = additionalProperties; } - /** - * @return A list of daily metrics, only days with ingested data are included. - */ @JsonProperty("data") - public List getData() { + public List getData() { return data; } @@ -57,7 +54,7 @@ public MetaResponse getMeta() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof DailyMetrics && equalTo((DailyMetrics) other); + return other instanceof PaginatedAnnotationQueueItems && equalTo((PaginatedAnnotationQueueItems) other); } @JsonAnyGetter @@ -65,7 +62,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(DailyMetrics other) { + private boolean equalTo(PaginatedAnnotationQueueItems other) { return data.equals(other.data) && meta.equals(other.meta); } @@ -86,17 +83,17 @@ public static MetaStage builder() { public interface MetaStage { _FinalStage meta(@NotNull MetaResponse meta); - Builder from(DailyMetrics other); + Builder from(PaginatedAnnotationQueueItems other); } public interface _FinalStage { - DailyMetrics build(); + PaginatedAnnotationQueueItems build(); - _FinalStage data(List data); + _FinalStage data(List data); - _FinalStage addData(DailyMetricsDetails data); + _FinalStage addData(AnnotationQueueItem data); - _FinalStage addAllData(List data); + _FinalStage addAllData(List data); } @JsonIgnoreProperties( @@ -105,7 +102,7 @@ public interface _FinalStage { public static final class Builder implements MetaStage, _FinalStage { private MetaResponse meta; - private List data = new ArrayList<>(); + private List data = new ArrayList<>(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -114,7 +111,7 @@ private Builder() { } @java.lang.Override - public Builder from(DailyMetrics other) { + public Builder from(PaginatedAnnotationQueueItems other) { data(other.getData()); meta(other.getMeta()); return this; @@ -127,22 +124,14 @@ public _FinalStage meta(@NotNull MetaResponse meta) { return this; } - /** - *

A list of daily metrics, only days with ingested data are included.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override - public _FinalStage addAllData(List data) { + public _FinalStage addAllData(List data) { this.data.addAll(data); return this; } - /** - *

A list of daily metrics, only days with ingested data are included.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override - public _FinalStage addData(DailyMetricsDetails data) { + public _FinalStage addData(AnnotationQueueItem data) { this.data.add(data); return this; } @@ -152,15 +141,15 @@ public _FinalStage addData(DailyMetricsDetails data) { value = "data", nulls = Nulls.SKIP ) - public _FinalStage data(List data) { + public _FinalStage data(List data) { this.data.clear(); this.data.addAll(data); return this; } @java.lang.Override - public DailyMetrics build() { - return new DailyMetrics(data, meta, additionalProperties); + public PaginatedAnnotationQueueItems build() { + return new PaginatedAnnotationQueueItems(data, meta, additionalProperties); } } } diff --git a/src/main/java/com/langfuse/client/resources/annotationqueues/types/PaginatedAnnotationQueues.java b/src/main/java/com/langfuse/client/resources/annotationqueues/types/PaginatedAnnotationQueues.java new file mode 100644 index 0000000..ebc0bbc --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/annotationqueues/types/PaginatedAnnotationQueues.java @@ -0,0 +1,155 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.annotationqueues.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +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; +import com.langfuse.client.resources.utils.pagination.types.MetaResponse; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = PaginatedAnnotationQueues.Builder.class +) +public final class PaginatedAnnotationQueues { + private final List data; + + private final MetaResponse meta; + + private final Map additionalProperties; + + private PaginatedAnnotationQueues(List data, MetaResponse meta, + Map additionalProperties) { + this.data = data; + this.meta = meta; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public List getData() { + return data; + } + + @JsonProperty("meta") + public MetaResponse getMeta() { + return meta; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PaginatedAnnotationQueues && equalTo((PaginatedAnnotationQueues) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PaginatedAnnotationQueues other) { + return data.equals(other.data) && meta.equals(other.meta); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.meta); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static MetaStage builder() { + return new Builder(); + } + + public interface MetaStage { + _FinalStage meta(@NotNull MetaResponse meta); + + Builder from(PaginatedAnnotationQueues other); + } + + public interface _FinalStage { + PaginatedAnnotationQueues build(); + + _FinalStage data(List data); + + _FinalStage addData(AnnotationQueue data); + + _FinalStage addAllData(List data); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements MetaStage, _FinalStage { + private MetaResponse meta; + + private List data = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(PaginatedAnnotationQueues other) { + data(other.getData()); + meta(other.getMeta()); + return this; + } + + @java.lang.Override + @JsonSetter("meta") + public _FinalStage meta(@NotNull MetaResponse meta) { + this.meta = Objects.requireNonNull(meta, "meta must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllData(List data) { + this.data.addAll(data); + return this; + } + + @java.lang.Override + public _FinalStage addData(AnnotationQueue data) { + this.data.add(data); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "data", + nulls = Nulls.SKIP + ) + public _FinalStage data(List data) { + this.data.clear(); + this.data.addAll(data); + return this; + } + + @java.lang.Override + public PaginatedAnnotationQueues build() { + return new PaginatedAnnotationQueues(data, meta, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/annotationqueues/types/UpdateAnnotationQueueItemRequest.java b/src/main/java/com/langfuse/client/resources/annotationqueues/types/UpdateAnnotationQueueItemRequest.java new file mode 100644 index 0000000..cd61d0d --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/annotationqueues/types/UpdateAnnotationQueueItemRequest.java @@ -0,0 +1,107 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.annotationqueues.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = UpdateAnnotationQueueItemRequest.Builder.class +) +public final class UpdateAnnotationQueueItemRequest { + private final Optional status; + + private final Map additionalProperties; + + private UpdateAnnotationQueueItemRequest(Optional status, + Map additionalProperties) { + this.status = status; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateAnnotationQueueItemRequest && equalTo((UpdateAnnotationQueueItemRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateAnnotationQueueItemRequest other) { + return status.equals(other.status); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.status); + } + + @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 status = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + public Builder from(UpdateAnnotationQueueItemRequest other) { + status(other.getStatus()); + return this; + } + + @JsonSetter( + value = "status", + nulls = Nulls.SKIP + ) + public Builder status(Optional status) { + this.status = status; + return this; + } + + public Builder status(AnnotationQueueStatus status) { + this.status = Optional.ofNullable(status); + return this; + } + + public UpdateAnnotationQueueItemRequest build() { + return new UpdateAnnotationQueueItemRequest(status, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/commons/types/BaseScore.java b/src/main/java/com/langfuse/client/resources/commons/types/BaseScore.java index 8c16144..14b4b95 100644 --- a/src/main/java/com/langfuse/client/resources/commons/types/BaseScore.java +++ b/src/main/java/com/langfuse/client/resources/commons/types/BaseScore.java @@ -29,14 +29,18 @@ public final class BaseScore implements IBaseScore { private final String id; - private final String traceId; + private final Optional traceId; + + private final Optional sessionId; + + private final Optional observationId; + + private final Optional datasetRunId; private final String name; private final ScoreSource source; - private final Optional observationId; - private final OffsetDateTime timestamp; private final OffsetDateTime createdAt; @@ -47,6 +51,8 @@ public final class BaseScore implements IBaseScore { private final Optional comment; + private final Optional metadata; + private final Optional configId; private final Optional queueId; @@ -55,21 +61,25 @@ public final class BaseScore implements IBaseScore { private final Map additionalProperties; - private BaseScore(String id, String traceId, String name, ScoreSource source, - Optional observationId, OffsetDateTime timestamp, OffsetDateTime createdAt, + private BaseScore(String id, Optional traceId, Optional sessionId, + Optional observationId, Optional datasetRunId, String name, + ScoreSource source, OffsetDateTime timestamp, OffsetDateTime createdAt, OffsetDateTime updatedAt, Optional authorUserId, Optional comment, - Optional configId, Optional queueId, Optional environment, - Map additionalProperties) { + Optional metadata, Optional configId, Optional queueId, + Optional environment, Map additionalProperties) { this.id = id; this.traceId = traceId; + this.sessionId = sessionId; + this.observationId = observationId; + this.datasetRunId = datasetRunId; this.name = name; this.source = source; - this.observationId = observationId; this.timestamp = timestamp; this.createdAt = createdAt; this.updatedAt = updatedAt; this.authorUserId = authorUserId; this.comment = comment; + this.metadata = metadata; this.configId = configId; this.queueId = queueId; this.environment = environment; @@ -84,10 +94,28 @@ public String getId() { @JsonProperty("traceId") @java.lang.Override - public String getTraceId() { + public Optional getTraceId() { return traceId; } + @JsonProperty("sessionId") + @java.lang.Override + public Optional getSessionId() { + return sessionId; + } + + @JsonProperty("observationId") + @java.lang.Override + public Optional getObservationId() { + return observationId; + } + + @JsonProperty("datasetRunId") + @java.lang.Override + public Optional getDatasetRunId() { + return datasetRunId; + } + @JsonProperty("name") @java.lang.Override public String getName() { @@ -100,12 +128,6 @@ public ScoreSource getSource() { return source; } - @JsonProperty("observationId") - @java.lang.Override - public Optional getObservationId() { - return observationId; - } - @JsonProperty("timestamp") @java.lang.Override public OffsetDateTime getTimestamp() { @@ -136,6 +158,12 @@ public Optional getComment() { return comment; } + @JsonProperty("metadata") + @java.lang.Override + public Optional getMetadata() { + return metadata; + } + /** * @return Reference a score config on a score. When set, config and score name must be equal and value must comply to optionally defined numerical range */ @@ -175,12 +203,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(BaseScore other) { - return id.equals(other.id) && traceId.equals(other.traceId) && name.equals(other.name) && source.equals(other.source) && observationId.equals(other.observationId) && timestamp.equals(other.timestamp) && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt) && authorUserId.equals(other.authorUserId) && comment.equals(other.comment) && configId.equals(other.configId) && queueId.equals(other.queueId) && environment.equals(other.environment); + return id.equals(other.id) && traceId.equals(other.traceId) && sessionId.equals(other.sessionId) && observationId.equals(other.observationId) && datasetRunId.equals(other.datasetRunId) && name.equals(other.name) && source.equals(other.source) && timestamp.equals(other.timestamp) && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt) && authorUserId.equals(other.authorUserId) && comment.equals(other.comment) && metadata.equals(other.metadata) && configId.equals(other.configId) && queueId.equals(other.queueId) && environment.equals(other.environment); } @java.lang.Override public int hashCode() { - return Objects.hash(this.id, this.traceId, this.name, this.source, this.observationId, this.timestamp, this.createdAt, this.updatedAt, this.authorUserId, this.comment, this.configId, this.queueId, this.environment); + return Objects.hash(this.id, this.traceId, this.sessionId, this.observationId, this.datasetRunId, this.name, this.source, this.timestamp, this.createdAt, this.updatedAt, this.authorUserId, this.comment, this.metadata, this.configId, this.queueId, this.environment); } @java.lang.Override @@ -193,15 +221,11 @@ public static IdStage builder() { } public interface IdStage { - TraceIdStage id(@NotNull String id); + NameStage id(@NotNull String id); Builder from(BaseScore other); } - public interface TraceIdStage { - NameStage traceId(@NotNull String traceId); - } - public interface NameStage { SourceStage name(@NotNull String name); } @@ -225,10 +249,22 @@ public interface UpdatedAtStage { public interface _FinalStage { BaseScore build(); + _FinalStage traceId(Optional traceId); + + _FinalStage traceId(String traceId); + + _FinalStage sessionId(Optional sessionId); + + _FinalStage sessionId(String sessionId); + _FinalStage observationId(Optional observationId); _FinalStage observationId(String observationId); + _FinalStage datasetRunId(Optional datasetRunId); + + _FinalStage datasetRunId(String datasetRunId); + _FinalStage authorUserId(Optional authorUserId); _FinalStage authorUserId(String authorUserId); @@ -237,6 +273,10 @@ public interface _FinalStage { _FinalStage comment(String comment); + _FinalStage metadata(Optional metadata); + + _FinalStage metadata(Object metadata); + _FinalStage configId(Optional configId); _FinalStage configId(String configId); @@ -253,11 +293,9 @@ public interface _FinalStage { @JsonIgnoreProperties( ignoreUnknown = true ) - public static final class Builder implements IdStage, TraceIdStage, NameStage, SourceStage, TimestampStage, CreatedAtStage, UpdatedAtStage, _FinalStage { + public static final class Builder implements IdStage, NameStage, SourceStage, TimestampStage, CreatedAtStage, UpdatedAtStage, _FinalStage { private String id; - private String traceId; - private String name; private ScoreSource source; @@ -274,12 +312,20 @@ public static final class Builder implements IdStage, TraceIdStage, NameStage, S private Optional configId = Optional.empty(); + private Optional metadata = Optional.empty(); + private Optional comment = Optional.empty(); private Optional authorUserId = Optional.empty(); + private Optional datasetRunId = Optional.empty(); + private Optional observationId = Optional.empty(); + private Optional sessionId = Optional.empty(); + + private Optional traceId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -290,14 +336,17 @@ private Builder() { public Builder from(BaseScore other) { id(other.getId()); traceId(other.getTraceId()); + sessionId(other.getSessionId()); + observationId(other.getObservationId()); + datasetRunId(other.getDatasetRunId()); name(other.getName()); source(other.getSource()); - observationId(other.getObservationId()); timestamp(other.getTimestamp()); createdAt(other.getCreatedAt()); updatedAt(other.getUpdatedAt()); authorUserId(other.getAuthorUserId()); comment(other.getComment()); + metadata(other.getMetadata()); configId(other.getConfigId()); queueId(other.getQueueId()); environment(other.getEnvironment()); @@ -306,18 +355,11 @@ public Builder from(BaseScore other) { @java.lang.Override @JsonSetter("id") - public TraceIdStage id(@NotNull String id) { + public NameStage id(@NotNull String id) { this.id = Objects.requireNonNull(id, "id must not be null"); return this; } - @java.lang.Override - @JsonSetter("traceId") - public NameStage traceId(@NotNull String traceId) { - this.traceId = Objects.requireNonNull(traceId, "traceId must not be null"); - return this; - } - @java.lang.Override @JsonSetter("name") public SourceStage name(@NotNull String name) { @@ -413,6 +455,22 @@ public _FinalStage configId(Optional configId) { return this; } + @java.lang.Override + public _FinalStage metadata(Object metadata) { + this.metadata = Optional.ofNullable(metadata); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "metadata", + nulls = Nulls.SKIP + ) + public _FinalStage metadata(Optional metadata) { + this.metadata = metadata; + return this; + } + @java.lang.Override public _FinalStage comment(String comment) { this.comment = Optional.ofNullable(comment); @@ -445,6 +503,22 @@ public _FinalStage authorUserId(Optional authorUserId) { return this; } + @java.lang.Override + public _FinalStage datasetRunId(String datasetRunId) { + this.datasetRunId = Optional.ofNullable(datasetRunId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "datasetRunId", + nulls = Nulls.SKIP + ) + public _FinalStage datasetRunId(Optional datasetRunId) { + this.datasetRunId = datasetRunId; + return this; + } + @java.lang.Override public _FinalStage observationId(String observationId) { this.observationId = Optional.ofNullable(observationId); @@ -461,9 +535,41 @@ public _FinalStage observationId(Optional observationId) { return this; } + @java.lang.Override + public _FinalStage sessionId(String sessionId) { + this.sessionId = Optional.ofNullable(sessionId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "sessionId", + nulls = Nulls.SKIP + ) + public _FinalStage sessionId(Optional sessionId) { + this.sessionId = sessionId; + return this; + } + + @java.lang.Override + public _FinalStage traceId(String traceId) { + this.traceId = Optional.ofNullable(traceId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "traceId", + nulls = Nulls.SKIP + ) + public _FinalStage traceId(Optional traceId) { + this.traceId = traceId; + return this; + } + @java.lang.Override public BaseScore build() { - return new BaseScore(id, traceId, name, source, observationId, timestamp, createdAt, updatedAt, authorUserId, comment, configId, queueId, environment, additionalProperties); + return new BaseScore(id, traceId, sessionId, observationId, datasetRunId, name, source, timestamp, createdAt, updatedAt, authorUserId, comment, metadata, configId, queueId, environment, additionalProperties); } } } diff --git a/src/main/java/com/langfuse/client/resources/commons/types/BaseScoreV1.java b/src/main/java/com/langfuse/client/resources/commons/types/BaseScoreV1.java new file mode 100644 index 0000000..549f7bf --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/commons/types/BaseScoreV1.java @@ -0,0 +1,501 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.commons.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.time.OffsetDateTime; +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 = BaseScoreV1.Builder.class +) +public final class BaseScoreV1 implements IBaseScoreV1 { + private final String id; + + private final String traceId; + + private final String name; + + private final ScoreSource source; + + private final Optional observationId; + + private final OffsetDateTime timestamp; + + private final OffsetDateTime createdAt; + + private final OffsetDateTime updatedAt; + + private final Optional authorUserId; + + private final Optional comment; + + private final Optional metadata; + + private final Optional configId; + + private final Optional queueId; + + private final Optional environment; + + private final Map additionalProperties; + + private BaseScoreV1(String id, String traceId, String name, ScoreSource source, + Optional observationId, OffsetDateTime timestamp, OffsetDateTime createdAt, + OffsetDateTime updatedAt, Optional authorUserId, Optional comment, + Optional metadata, Optional configId, Optional queueId, + Optional environment, Map additionalProperties) { + this.id = id; + this.traceId = traceId; + this.name = name; + this.source = source; + this.observationId = observationId; + this.timestamp = timestamp; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.authorUserId = authorUserId; + this.comment = comment; + this.metadata = metadata; + this.configId = configId; + this.queueId = queueId; + this.environment = environment; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + @java.lang.Override + public String getId() { + return id; + } + + @JsonProperty("traceId") + @java.lang.Override + public String getTraceId() { + return traceId; + } + + @JsonProperty("name") + @java.lang.Override + public String getName() { + return name; + } + + @JsonProperty("source") + @java.lang.Override + public ScoreSource getSource() { + return source; + } + + @JsonProperty("observationId") + @java.lang.Override + public Optional getObservationId() { + return observationId; + } + + @JsonProperty("timestamp") + @java.lang.Override + public OffsetDateTime getTimestamp() { + return timestamp; + } + + @JsonProperty("createdAt") + @java.lang.Override + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("updatedAt") + @java.lang.Override + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @JsonProperty("authorUserId") + @java.lang.Override + public Optional getAuthorUserId() { + return authorUserId; + } + + @JsonProperty("comment") + @java.lang.Override + public Optional getComment() { + return comment; + } + + @JsonProperty("metadata") + @java.lang.Override + public Optional getMetadata() { + return metadata; + } + + /** + * @return Reference a score config on a score. When set, config and score name must be equal and value must comply to optionally defined numerical range + */ + @JsonProperty("configId") + @java.lang.Override + public Optional getConfigId() { + return configId; + } + + /** + * @return Reference an annotation queue on a score. Populated if the score was initially created in an annotation queue. + */ + @JsonProperty("queueId") + @java.lang.Override + public Optional getQueueId() { + return queueId; + } + + /** + * @return The environment from which this score originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'. + */ + @JsonProperty("environment") + @java.lang.Override + public Optional getEnvironment() { + return environment; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BaseScoreV1 && equalTo((BaseScoreV1) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(BaseScoreV1 other) { + return id.equals(other.id) && traceId.equals(other.traceId) && name.equals(other.name) && source.equals(other.source) && observationId.equals(other.observationId) && timestamp.equals(other.timestamp) && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt) && authorUserId.equals(other.authorUserId) && comment.equals(other.comment) && metadata.equals(other.metadata) && configId.equals(other.configId) && queueId.equals(other.queueId) && environment.equals(other.environment); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.traceId, this.name, this.source, this.observationId, this.timestamp, this.createdAt, this.updatedAt, this.authorUserId, this.comment, this.metadata, this.configId, this.queueId, this.environment); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + TraceIdStage id(@NotNull String id); + + Builder from(BaseScoreV1 other); + } + + public interface TraceIdStage { + NameStage traceId(@NotNull String traceId); + } + + public interface NameStage { + SourceStage name(@NotNull String name); + } + + public interface SourceStage { + TimestampStage source(@NotNull ScoreSource source); + } + + public interface TimestampStage { + CreatedAtStage timestamp(@NotNull OffsetDateTime timestamp); + } + + public interface CreatedAtStage { + UpdatedAtStage createdAt(@NotNull OffsetDateTime createdAt); + } + + public interface UpdatedAtStage { + _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt); + } + + public interface _FinalStage { + BaseScoreV1 build(); + + _FinalStage observationId(Optional observationId); + + _FinalStage observationId(String observationId); + + _FinalStage authorUserId(Optional authorUserId); + + _FinalStage authorUserId(String authorUserId); + + _FinalStage comment(Optional comment); + + _FinalStage comment(String comment); + + _FinalStage metadata(Optional metadata); + + _FinalStage metadata(Object metadata); + + _FinalStage configId(Optional configId); + + _FinalStage configId(String configId); + + _FinalStage queueId(Optional queueId); + + _FinalStage queueId(String queueId); + + _FinalStage environment(Optional environment); + + _FinalStage environment(String environment); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements IdStage, TraceIdStage, NameStage, SourceStage, TimestampStage, CreatedAtStage, UpdatedAtStage, _FinalStage { + private String id; + + private String traceId; + + private String name; + + private ScoreSource source; + + private OffsetDateTime timestamp; + + private OffsetDateTime createdAt; + + private OffsetDateTime updatedAt; + + private Optional environment = Optional.empty(); + + private Optional queueId = Optional.empty(); + + private Optional configId = Optional.empty(); + + private Optional metadata = Optional.empty(); + + private Optional comment = Optional.empty(); + + private Optional authorUserId = Optional.empty(); + + private Optional observationId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(BaseScoreV1 other) { + id(other.getId()); + traceId(other.getTraceId()); + name(other.getName()); + source(other.getSource()); + observationId(other.getObservationId()); + timestamp(other.getTimestamp()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + authorUserId(other.getAuthorUserId()); + comment(other.getComment()); + metadata(other.getMetadata()); + configId(other.getConfigId()); + queueId(other.getQueueId()); + environment(other.getEnvironment()); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public TraceIdStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("traceId") + public NameStage traceId(@NotNull String traceId) { + this.traceId = Objects.requireNonNull(traceId, "traceId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public SourceStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("source") + public TimestampStage source(@NotNull ScoreSource source) { + this.source = Objects.requireNonNull(source, "source must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("timestamp") + public CreatedAtStage timestamp(@NotNull OffsetDateTime timestamp) { + this.timestamp = Objects.requireNonNull(timestamp, "timestamp must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("createdAt") + public UpdatedAtStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("updatedAt") + public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { + this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); + return this; + } + + /** + *

The environment from which this score originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage environment(String environment) { + this.environment = Optional.ofNullable(environment); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "environment", + nulls = Nulls.SKIP + ) + public _FinalStage environment(Optional environment) { + this.environment = environment; + return this; + } + + /** + *

Reference an annotation queue on a score. Populated if the score was initially created in an annotation queue.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage queueId(String queueId) { + this.queueId = Optional.ofNullable(queueId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "queueId", + nulls = Nulls.SKIP + ) + public _FinalStage queueId(Optional queueId) { + this.queueId = queueId; + return this; + } + + /** + *

Reference a score config on a score. When set, config and score name must be equal and value must comply to optionally defined numerical range

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage configId(String configId) { + this.configId = Optional.ofNullable(configId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "configId", + nulls = Nulls.SKIP + ) + public _FinalStage configId(Optional configId) { + this.configId = configId; + return this; + } + + @java.lang.Override + public _FinalStage metadata(Object metadata) { + this.metadata = Optional.ofNullable(metadata); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "metadata", + nulls = Nulls.SKIP + ) + public _FinalStage metadata(Optional metadata) { + this.metadata = metadata; + return this; + } + + @java.lang.Override + public _FinalStage comment(String comment) { + this.comment = Optional.ofNullable(comment); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "comment", + nulls = Nulls.SKIP + ) + public _FinalStage comment(Optional comment) { + this.comment = comment; + return this; + } + + @java.lang.Override + public _FinalStage authorUserId(String authorUserId) { + this.authorUserId = Optional.ofNullable(authorUserId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "authorUserId", + nulls = Nulls.SKIP + ) + public _FinalStage authorUserId(Optional authorUserId) { + this.authorUserId = authorUserId; + return this; + } + + @java.lang.Override + public _FinalStage observationId(String observationId) { + this.observationId = Optional.ofNullable(observationId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "observationId", + nulls = Nulls.SKIP + ) + public _FinalStage observationId(Optional observationId) { + this.observationId = observationId; + return this; + } + + @java.lang.Override + public BaseScoreV1 build() { + return new BaseScoreV1(id, traceId, name, source, observationId, timestamp, createdAt, updatedAt, authorUserId, comment, metadata, configId, queueId, environment, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/commons/types/BooleanScore.java b/src/main/java/com/langfuse/client/resources/commons/types/BooleanScore.java index d2981e4..8bc485d 100644 --- a/src/main/java/com/langfuse/client/resources/commons/types/BooleanScore.java +++ b/src/main/java/com/langfuse/client/resources/commons/types/BooleanScore.java @@ -33,14 +33,18 @@ public final class BooleanScore implements IBooleanScore, IBaseScore { private final String id; - private final String traceId; + private final Optional traceId; + + private final Optional sessionId; + + private final Optional observationId; + + private final Optional datasetRunId; private final String name; private final ScoreSource source; - private final Optional observationId; - private final OffsetDateTime timestamp; private final OffsetDateTime createdAt; @@ -51,6 +55,8 @@ public final class BooleanScore implements IBooleanScore, IBaseScore { private final Optional comment; + private final Optional metadata; + private final Optional configId; private final Optional queueId; @@ -59,23 +65,27 @@ public final class BooleanScore implements IBooleanScore, IBaseScore { private final Map additionalProperties; - private BooleanScore(double value, String stringValue, String id, String traceId, String name, - ScoreSource source, Optional observationId, OffsetDateTime timestamp, - OffsetDateTime createdAt, OffsetDateTime updatedAt, Optional authorUserId, - Optional comment, Optional configId, Optional queueId, + private BooleanScore(double value, String stringValue, String id, Optional traceId, + Optional sessionId, Optional observationId, Optional datasetRunId, + String name, ScoreSource source, OffsetDateTime timestamp, OffsetDateTime createdAt, + OffsetDateTime updatedAt, Optional authorUserId, Optional comment, + Optional metadata, Optional configId, Optional queueId, Optional environment, Map additionalProperties) { this.value = value; this.stringValue = stringValue; this.id = id; this.traceId = traceId; + this.sessionId = sessionId; + this.observationId = observationId; + this.datasetRunId = datasetRunId; this.name = name; this.source = source; - this.observationId = observationId; this.timestamp = timestamp; this.createdAt = createdAt; this.updatedAt = updatedAt; this.authorUserId = authorUserId; this.comment = comment; + this.metadata = metadata; this.configId = configId; this.queueId = queueId; this.environment = environment; @@ -108,10 +118,28 @@ public String getId() { @JsonProperty("traceId") @java.lang.Override - public String getTraceId() { + public Optional getTraceId() { return traceId; } + @JsonProperty("sessionId") + @java.lang.Override + public Optional getSessionId() { + return sessionId; + } + + @JsonProperty("observationId") + @java.lang.Override + public Optional getObservationId() { + return observationId; + } + + @JsonProperty("datasetRunId") + @java.lang.Override + public Optional getDatasetRunId() { + return datasetRunId; + } + @JsonProperty("name") @java.lang.Override public String getName() { @@ -124,12 +152,6 @@ public ScoreSource getSource() { return source; } - @JsonProperty("observationId") - @java.lang.Override - public Optional getObservationId() { - return observationId; - } - @JsonProperty("timestamp") @java.lang.Override public OffsetDateTime getTimestamp() { @@ -160,6 +182,12 @@ public Optional getComment() { return comment; } + @JsonProperty("metadata") + @java.lang.Override + public Optional getMetadata() { + return metadata; + } + /** * @return Reference a score config on a score. When set, config and score name must be equal and value must comply to optionally defined numerical range */ @@ -199,12 +227,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(BooleanScore other) { - return value == other.value && stringValue.equals(other.stringValue) && id.equals(other.id) && traceId.equals(other.traceId) && name.equals(other.name) && source.equals(other.source) && observationId.equals(other.observationId) && timestamp.equals(other.timestamp) && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt) && authorUserId.equals(other.authorUserId) && comment.equals(other.comment) && configId.equals(other.configId) && queueId.equals(other.queueId) && environment.equals(other.environment); + return value == other.value && stringValue.equals(other.stringValue) && id.equals(other.id) && traceId.equals(other.traceId) && sessionId.equals(other.sessionId) && observationId.equals(other.observationId) && datasetRunId.equals(other.datasetRunId) && name.equals(other.name) && source.equals(other.source) && timestamp.equals(other.timestamp) && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt) && authorUserId.equals(other.authorUserId) && comment.equals(other.comment) && metadata.equals(other.metadata) && configId.equals(other.configId) && queueId.equals(other.queueId) && environment.equals(other.environment); } @java.lang.Override public int hashCode() { - return Objects.hash(this.value, this.stringValue, this.id, this.traceId, this.name, this.source, this.observationId, this.timestamp, this.createdAt, this.updatedAt, this.authorUserId, this.comment, this.configId, this.queueId, this.environment); + return Objects.hash(this.value, this.stringValue, this.id, this.traceId, this.sessionId, this.observationId, this.datasetRunId, this.name, this.source, this.timestamp, this.createdAt, this.updatedAt, this.authorUserId, this.comment, this.metadata, this.configId, this.queueId, this.environment); } @java.lang.Override @@ -227,11 +255,7 @@ public interface StringValueStage { } public interface IdStage { - TraceIdStage id(@NotNull String id); - } - - public interface TraceIdStage { - NameStage traceId(@NotNull String traceId); + NameStage id(@NotNull String id); } public interface NameStage { @@ -257,10 +281,22 @@ public interface UpdatedAtStage { public interface _FinalStage { BooleanScore build(); + _FinalStage traceId(Optional traceId); + + _FinalStage traceId(String traceId); + + _FinalStage sessionId(Optional sessionId); + + _FinalStage sessionId(String sessionId); + _FinalStage observationId(Optional observationId); _FinalStage observationId(String observationId); + _FinalStage datasetRunId(Optional datasetRunId); + + _FinalStage datasetRunId(String datasetRunId); + _FinalStage authorUserId(Optional authorUserId); _FinalStage authorUserId(String authorUserId); @@ -269,6 +305,10 @@ public interface _FinalStage { _FinalStage comment(String comment); + _FinalStage metadata(Optional metadata); + + _FinalStage metadata(Object metadata); + _FinalStage configId(Optional configId); _FinalStage configId(String configId); @@ -285,15 +325,13 @@ public interface _FinalStage { @JsonIgnoreProperties( ignoreUnknown = true ) - public static final class Builder implements ValueStage, StringValueStage, IdStage, TraceIdStage, NameStage, SourceStage, TimestampStage, CreatedAtStage, UpdatedAtStage, _FinalStage { + public static final class Builder implements ValueStage, StringValueStage, IdStage, NameStage, SourceStage, TimestampStage, CreatedAtStage, UpdatedAtStage, _FinalStage { private double value; private String stringValue; private String id; - private String traceId; - private String name; private ScoreSource source; @@ -310,12 +348,20 @@ public static final class Builder implements ValueStage, StringValueStage, IdSta private Optional configId = Optional.empty(); + private Optional metadata = Optional.empty(); + private Optional comment = Optional.empty(); private Optional authorUserId = Optional.empty(); + private Optional datasetRunId = Optional.empty(); + private Optional observationId = Optional.empty(); + private Optional sessionId = Optional.empty(); + + private Optional traceId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -328,14 +374,17 @@ public Builder from(BooleanScore other) { stringValue(other.getStringValue()); id(other.getId()); traceId(other.getTraceId()); + sessionId(other.getSessionId()); + observationId(other.getObservationId()); + datasetRunId(other.getDatasetRunId()); name(other.getName()); source(other.getSource()); - observationId(other.getObservationId()); timestamp(other.getTimestamp()); createdAt(other.getCreatedAt()); updatedAt(other.getUpdatedAt()); authorUserId(other.getAuthorUserId()); comment(other.getComment()); + metadata(other.getMetadata()); configId(other.getConfigId()); queueId(other.getQueueId()); environment(other.getEnvironment()); @@ -366,18 +415,11 @@ public IdStage stringValue(@NotNull String stringValue) { @java.lang.Override @JsonSetter("id") - public TraceIdStage id(@NotNull String id) { + public NameStage id(@NotNull String id) { this.id = Objects.requireNonNull(id, "id must not be null"); return this; } - @java.lang.Override - @JsonSetter("traceId") - public NameStage traceId(@NotNull String traceId) { - this.traceId = Objects.requireNonNull(traceId, "traceId must not be null"); - return this; - } - @java.lang.Override @JsonSetter("name") public SourceStage name(@NotNull String name) { @@ -473,6 +515,22 @@ public _FinalStage configId(Optional configId) { return this; } + @java.lang.Override + public _FinalStage metadata(Object metadata) { + this.metadata = Optional.ofNullable(metadata); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "metadata", + nulls = Nulls.SKIP + ) + public _FinalStage metadata(Optional metadata) { + this.metadata = metadata; + return this; + } + @java.lang.Override public _FinalStage comment(String comment) { this.comment = Optional.ofNullable(comment); @@ -505,6 +563,22 @@ public _FinalStage authorUserId(Optional authorUserId) { return this; } + @java.lang.Override + public _FinalStage datasetRunId(String datasetRunId) { + this.datasetRunId = Optional.ofNullable(datasetRunId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "datasetRunId", + nulls = Nulls.SKIP + ) + public _FinalStage datasetRunId(Optional datasetRunId) { + this.datasetRunId = datasetRunId; + return this; + } + @java.lang.Override public _FinalStage observationId(String observationId) { this.observationId = Optional.ofNullable(observationId); @@ -521,9 +595,41 @@ public _FinalStage observationId(Optional observationId) { return this; } + @java.lang.Override + public _FinalStage sessionId(String sessionId) { + this.sessionId = Optional.ofNullable(sessionId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "sessionId", + nulls = Nulls.SKIP + ) + public _FinalStage sessionId(Optional sessionId) { + this.sessionId = sessionId; + return this; + } + + @java.lang.Override + public _FinalStage traceId(String traceId) { + this.traceId = Optional.ofNullable(traceId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "traceId", + nulls = Nulls.SKIP + ) + public _FinalStage traceId(Optional traceId) { + this.traceId = traceId; + return this; + } + @java.lang.Override public BooleanScore build() { - return new BooleanScore(value, stringValue, id, traceId, name, source, observationId, timestamp, createdAt, updatedAt, authorUserId, comment, configId, queueId, environment, additionalProperties); + return new BooleanScore(value, stringValue, id, traceId, sessionId, observationId, datasetRunId, name, source, timestamp, createdAt, updatedAt, authorUserId, comment, metadata, configId, queueId, environment, additionalProperties); } } } diff --git a/src/main/java/com/langfuse/client/resources/score/types/GetScoresResponseDataBoolean.java b/src/main/java/com/langfuse/client/resources/commons/types/BooleanScoreV1.java similarity index 80% rename from src/main/java/com/langfuse/client/resources/score/types/GetScoresResponseDataBoolean.java rename to src/main/java/com/langfuse/client/resources/commons/types/BooleanScoreV1.java index 8fc91c4..90986c7 100644 --- a/src/main/java/com/langfuse/client/resources/score/types/GetScoresResponseDataBoolean.java +++ b/src/main/java/com/langfuse/client/resources/commons/types/BooleanScoreV1.java @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -package com.langfuse.client.resources.score.types; +package com.langfuse.client.resources.commons.types; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -21,19 +21,12 @@ import java.util.Objects; import java.util.Optional; import org.jetbrains.annotations.NotNull; -import com.langfuse.client.resources.commons.types.IBaseScore; -import com.langfuse.client.resources.commons.types.IBooleanScore; -import com.langfuse.client.resources.commons.types.ScoreSource; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize( - builder = GetScoresResponseDataBoolean.Builder.class + builder = BooleanScoreV1.Builder.class ) -public final class GetScoresResponseDataBoolean implements IBooleanScore, IBaseScore { - private final double value; - - private final String stringValue; - +public final class BooleanScoreV1 implements IBaseScoreV1 { private final String id; private final String traceId; @@ -54,24 +47,26 @@ public final class GetScoresResponseDataBoolean implements IBooleanScore, IBaseS private final Optional comment; + private final Optional metadata; + private final Optional configId; private final Optional queueId; private final Optional environment; - private final GetScoresResponseTraceData trace; + private final double value; + + private final String stringValue; private final Map additionalProperties; - private GetScoresResponseDataBoolean(double value, String stringValue, String id, String traceId, - String name, ScoreSource source, Optional observationId, OffsetDateTime timestamp, - OffsetDateTime createdAt, OffsetDateTime updatedAt, Optional authorUserId, - Optional comment, Optional configId, Optional queueId, - Optional environment, GetScoresResponseTraceData trace, + private BooleanScoreV1(String id, String traceId, String name, ScoreSource source, + Optional observationId, OffsetDateTime timestamp, OffsetDateTime createdAt, + OffsetDateTime updatedAt, Optional authorUserId, Optional comment, + Optional metadata, Optional configId, Optional queueId, + Optional environment, double value, String stringValue, Map additionalProperties) { - this.value = value; - this.stringValue = stringValue; this.id = id; this.traceId = traceId; this.name = name; @@ -82,31 +77,15 @@ private GetScoresResponseDataBoolean(double value, String stringValue, String id this.updatedAt = updatedAt; this.authorUserId = authorUserId; this.comment = comment; + this.metadata = metadata; this.configId = configId; this.queueId = queueId; this.environment = environment; - this.trace = trace; + this.value = value; + this.stringValue = stringValue; this.additionalProperties = additionalProperties; } - /** - * @return The numeric value of the score. Equals 1 for "True" and 0 for "False" - */ - @JsonProperty("value") - @java.lang.Override - public double getValue() { - return value; - } - - /** - * @return The string representation of the score value. Is inferred from the numeric value and equals "True" or "False" - */ - @JsonProperty("stringValue") - @java.lang.Override - public String getStringValue() { - return stringValue; - } - @JsonProperty("id") @java.lang.Override public String getId() { @@ -167,6 +146,12 @@ public Optional getComment() { return comment; } + @JsonProperty("metadata") + @java.lang.Override + public Optional getMetadata() { + return metadata; + } + /** * @return Reference a score config on a score. When set, config and score name must be equal and value must comply to optionally defined numerical range */ @@ -194,15 +179,26 @@ public Optional getEnvironment() { return environment; } - @JsonProperty("trace") - public GetScoresResponseTraceData getTrace() { - return trace; + /** + * @return The numeric value of the score. Equals 1 for "True" and 0 for "False" + */ + @JsonProperty("value") + public double getValue() { + return value; + } + + /** + * @return The string representation of the score value. Is inferred from the numeric value and equals "True" or "False" + */ + @JsonProperty("stringValue") + public String getStringValue() { + return stringValue; } @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof GetScoresResponseDataBoolean && equalTo((GetScoresResponseDataBoolean) other); + return other instanceof BooleanScoreV1 && equalTo((BooleanScoreV1) other); } @JsonAnyGetter @@ -210,13 +206,13 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(GetScoresResponseDataBoolean other) { - return value == other.value && stringValue.equals(other.stringValue) && id.equals(other.id) && traceId.equals(other.traceId) && name.equals(other.name) && source.equals(other.source) && observationId.equals(other.observationId) && timestamp.equals(other.timestamp) && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt) && authorUserId.equals(other.authorUserId) && comment.equals(other.comment) && configId.equals(other.configId) && queueId.equals(other.queueId) && environment.equals(other.environment) && trace.equals(other.trace); + private boolean equalTo(BooleanScoreV1 other) { + return id.equals(other.id) && traceId.equals(other.traceId) && name.equals(other.name) && source.equals(other.source) && observationId.equals(other.observationId) && timestamp.equals(other.timestamp) && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt) && authorUserId.equals(other.authorUserId) && comment.equals(other.comment) && metadata.equals(other.metadata) && configId.equals(other.configId) && queueId.equals(other.queueId) && environment.equals(other.environment) && value == other.value && stringValue.equals(other.stringValue); } @java.lang.Override public int hashCode() { - return Objects.hash(this.value, this.stringValue, this.id, this.traceId, this.name, this.source, this.observationId, this.timestamp, this.createdAt, this.updatedAt, this.authorUserId, this.comment, this.configId, this.queueId, this.environment, this.trace); + return Objects.hash(this.id, this.traceId, this.name, this.source, this.observationId, this.timestamp, this.createdAt, this.updatedAt, this.authorUserId, this.comment, this.metadata, this.configId, this.queueId, this.environment, this.value, this.stringValue); } @java.lang.Override @@ -224,22 +220,14 @@ public String toString() { return ObjectMappers.stringify(this); } - public static ValueStage builder() { + public static IdStage builder() { return new Builder(); } - public interface ValueStage { - StringValueStage value(double value); - - Builder from(GetScoresResponseDataBoolean other); - } - - public interface StringValueStage { - IdStage stringValue(@NotNull String stringValue); - } - public interface IdStage { TraceIdStage id(@NotNull String id); + + Builder from(BooleanScoreV1 other); } public interface TraceIdStage { @@ -263,15 +251,19 @@ public interface CreatedAtStage { } public interface UpdatedAtStage { - TraceStage updatedAt(@NotNull OffsetDateTime updatedAt); + ValueStage updatedAt(@NotNull OffsetDateTime updatedAt); } - public interface TraceStage { - _FinalStage trace(@NotNull GetScoresResponseTraceData trace); + public interface ValueStage { + StringValueStage value(double value); + } + + public interface StringValueStage { + _FinalStage stringValue(@NotNull String stringValue); } public interface _FinalStage { - GetScoresResponseDataBoolean build(); + BooleanScoreV1 build(); _FinalStage observationId(Optional observationId); @@ -285,6 +277,10 @@ public interface _FinalStage { _FinalStage comment(String comment); + _FinalStage metadata(Optional metadata); + + _FinalStage metadata(Object metadata); + _FinalStage configId(Optional configId); _FinalStage configId(String configId); @@ -301,11 +297,7 @@ public interface _FinalStage { @JsonIgnoreProperties( ignoreUnknown = true ) - public static final class Builder implements ValueStage, StringValueStage, IdStage, TraceIdStage, NameStage, SourceStage, TimestampStage, CreatedAtStage, UpdatedAtStage, TraceStage, _FinalStage { - private double value; - - private String stringValue; - + public static final class Builder implements IdStage, TraceIdStage, NameStage, SourceStage, TimestampStage, CreatedAtStage, UpdatedAtStage, ValueStage, StringValueStage, _FinalStage { private String id; private String traceId; @@ -320,7 +312,9 @@ public static final class Builder implements ValueStage, StringValueStage, IdSta private OffsetDateTime updatedAt; - private GetScoresResponseTraceData trace; + private double value; + + private String stringValue; private Optional environment = Optional.empty(); @@ -328,6 +322,8 @@ public static final class Builder implements ValueStage, StringValueStage, IdSta private Optional configId = Optional.empty(); + private Optional metadata = Optional.empty(); + private Optional comment = Optional.empty(); private Optional authorUserId = Optional.empty(); @@ -341,9 +337,7 @@ private Builder() { } @java.lang.Override - public Builder from(GetScoresResponseDataBoolean other) { - value(other.getValue()); - stringValue(other.getStringValue()); + public Builder from(BooleanScoreV1 other) { id(other.getId()); traceId(other.getTraceId()); name(other.getName()); @@ -354,32 +348,12 @@ public Builder from(GetScoresResponseDataBoolean other) { updatedAt(other.getUpdatedAt()); authorUserId(other.getAuthorUserId()); comment(other.getComment()); + metadata(other.getMetadata()); configId(other.getConfigId()); queueId(other.getQueueId()); environment(other.getEnvironment()); - trace(other.getTrace()); - return this; - } - - /** - *

The numeric value of the score. Equals 1 for "True" and 0 for "False"

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("value") - public StringValueStage value(double value) { - this.value = value; - return this; - } - - /** - *

The string representation of the score value. Is inferred from the numeric value and equals "True" or "False"

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("stringValue") - public IdStage stringValue(@NotNull String stringValue) { - this.stringValue = Objects.requireNonNull(stringValue, "stringValue must not be null"); + value(other.getValue()); + stringValue(other.getStringValue()); return this; } @@ -427,15 +401,30 @@ public UpdatedAtStage createdAt(@NotNull OffsetDateTime createdAt) { @java.lang.Override @JsonSetter("updatedAt") - public TraceStage updatedAt(@NotNull OffsetDateTime updatedAt) { + public ValueStage updatedAt(@NotNull OffsetDateTime updatedAt) { this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); return this; } + /** + *

The numeric value of the score. Equals 1 for "True" and 0 for "False"

+ * @return Reference to {@code this} so that method calls can be chained together. + */ @java.lang.Override - @JsonSetter("trace") - public _FinalStage trace(@NotNull GetScoresResponseTraceData trace) { - this.trace = Objects.requireNonNull(trace, "trace must not be null"); + @JsonSetter("value") + public StringValueStage value(double value) { + this.value = value; + return this; + } + + /** + *

The string representation of the score value. Is inferred from the numeric value and equals "True" or "False"

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("stringValue") + public _FinalStage stringValue(@NotNull String stringValue) { + this.stringValue = Objects.requireNonNull(stringValue, "stringValue must not be null"); return this; } @@ -499,6 +488,22 @@ public _FinalStage configId(Optional configId) { return this; } + @java.lang.Override + public _FinalStage metadata(Object metadata) { + this.metadata = Optional.ofNullable(metadata); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "metadata", + nulls = Nulls.SKIP + ) + public _FinalStage metadata(Optional metadata) { + this.metadata = metadata; + return this; + } + @java.lang.Override public _FinalStage comment(String comment) { this.comment = Optional.ofNullable(comment); @@ -548,8 +553,8 @@ public _FinalStage observationId(Optional observationId) { } @java.lang.Override - public GetScoresResponseDataBoolean build() { - return new GetScoresResponseDataBoolean(value, stringValue, id, traceId, name, source, observationId, timestamp, createdAt, updatedAt, authorUserId, comment, configId, queueId, environment, trace, additionalProperties); + public BooleanScoreV1 build() { + return new BooleanScoreV1(id, traceId, name, source, observationId, timestamp, createdAt, updatedAt, authorUserId, comment, metadata, configId, queueId, environment, value, stringValue, additionalProperties); } } } diff --git a/src/main/java/com/langfuse/client/resources/commons/types/CategoricalScore.java b/src/main/java/com/langfuse/client/resources/commons/types/CategoricalScore.java index f1361e1..4b39ee8 100644 --- a/src/main/java/com/langfuse/client/resources/commons/types/CategoricalScore.java +++ b/src/main/java/com/langfuse/client/resources/commons/types/CategoricalScore.java @@ -34,14 +34,18 @@ public final class CategoricalScore implements ICategoricalScore, IBaseScore { private final String id; - private final String traceId; + private final Optional traceId; + + private final Optional sessionId; + + private final Optional observationId; + + private final Optional datasetRunId; private final String name; private final ScoreSource source; - private final Optional observationId; - private final OffsetDateTime timestamp; private final OffsetDateTime createdAt; @@ -52,6 +56,8 @@ public final class CategoricalScore implements ICategoricalScore, IBaseScore { private final Optional comment; + private final Optional metadata; + private final Optional configId; private final Optional queueId; @@ -60,23 +66,28 @@ public final class CategoricalScore implements ICategoricalScore, IBaseScore { private final Map additionalProperties; - private CategoricalScore(Optional value, String stringValue, String id, String traceId, - String name, ScoreSource source, Optional observationId, OffsetDateTime timestamp, + private CategoricalScore(Optional value, String stringValue, String id, + Optional traceId, Optional sessionId, Optional observationId, + Optional datasetRunId, String name, ScoreSource source, OffsetDateTime timestamp, OffsetDateTime createdAt, OffsetDateTime updatedAt, Optional authorUserId, - Optional comment, Optional configId, Optional queueId, - Optional environment, Map additionalProperties) { + Optional comment, Optional metadata, Optional configId, + Optional queueId, Optional environment, + Map additionalProperties) { this.value = value; this.stringValue = stringValue; this.id = id; this.traceId = traceId; + this.sessionId = sessionId; + this.observationId = observationId; + this.datasetRunId = datasetRunId; this.name = name; this.source = source; - this.observationId = observationId; this.timestamp = timestamp; this.createdAt = createdAt; this.updatedAt = updatedAt; this.authorUserId = authorUserId; this.comment = comment; + this.metadata = metadata; this.configId = configId; this.queueId = queueId; this.environment = environment; @@ -109,10 +120,28 @@ public String getId() { @JsonProperty("traceId") @java.lang.Override - public String getTraceId() { + public Optional getTraceId() { return traceId; } + @JsonProperty("sessionId") + @java.lang.Override + public Optional getSessionId() { + return sessionId; + } + + @JsonProperty("observationId") + @java.lang.Override + public Optional getObservationId() { + return observationId; + } + + @JsonProperty("datasetRunId") + @java.lang.Override + public Optional getDatasetRunId() { + return datasetRunId; + } + @JsonProperty("name") @java.lang.Override public String getName() { @@ -125,12 +154,6 @@ public ScoreSource getSource() { return source; } - @JsonProperty("observationId") - @java.lang.Override - public Optional getObservationId() { - return observationId; - } - @JsonProperty("timestamp") @java.lang.Override public OffsetDateTime getTimestamp() { @@ -161,6 +184,12 @@ public Optional getComment() { return comment; } + @JsonProperty("metadata") + @java.lang.Override + public Optional getMetadata() { + return metadata; + } + /** * @return Reference a score config on a score. When set, config and score name must be equal and value must comply to optionally defined numerical range */ @@ -200,12 +229,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(CategoricalScore other) { - return value.equals(other.value) && stringValue.equals(other.stringValue) && id.equals(other.id) && traceId.equals(other.traceId) && name.equals(other.name) && source.equals(other.source) && observationId.equals(other.observationId) && timestamp.equals(other.timestamp) && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt) && authorUserId.equals(other.authorUserId) && comment.equals(other.comment) && configId.equals(other.configId) && queueId.equals(other.queueId) && environment.equals(other.environment); + return value.equals(other.value) && stringValue.equals(other.stringValue) && id.equals(other.id) && traceId.equals(other.traceId) && sessionId.equals(other.sessionId) && observationId.equals(other.observationId) && datasetRunId.equals(other.datasetRunId) && name.equals(other.name) && source.equals(other.source) && timestamp.equals(other.timestamp) && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt) && authorUserId.equals(other.authorUserId) && comment.equals(other.comment) && metadata.equals(other.metadata) && configId.equals(other.configId) && queueId.equals(other.queueId) && environment.equals(other.environment); } @java.lang.Override public int hashCode() { - return Objects.hash(this.value, this.stringValue, this.id, this.traceId, this.name, this.source, this.observationId, this.timestamp, this.createdAt, this.updatedAt, this.authorUserId, this.comment, this.configId, this.queueId, this.environment); + return Objects.hash(this.value, this.stringValue, this.id, this.traceId, this.sessionId, this.observationId, this.datasetRunId, this.name, this.source, this.timestamp, this.createdAt, this.updatedAt, this.authorUserId, this.comment, this.metadata, this.configId, this.queueId, this.environment); } @java.lang.Override @@ -224,11 +253,7 @@ public interface StringValueStage { } public interface IdStage { - TraceIdStage id(@NotNull String id); - } - - public interface TraceIdStage { - NameStage traceId(@NotNull String traceId); + NameStage id(@NotNull String id); } public interface NameStage { @@ -258,10 +283,22 @@ public interface _FinalStage { _FinalStage value(Double value); + _FinalStage traceId(Optional traceId); + + _FinalStage traceId(String traceId); + + _FinalStage sessionId(Optional sessionId); + + _FinalStage sessionId(String sessionId); + _FinalStage observationId(Optional observationId); _FinalStage observationId(String observationId); + _FinalStage datasetRunId(Optional datasetRunId); + + _FinalStage datasetRunId(String datasetRunId); + _FinalStage authorUserId(Optional authorUserId); _FinalStage authorUserId(String authorUserId); @@ -270,6 +307,10 @@ public interface _FinalStage { _FinalStage comment(String comment); + _FinalStage metadata(Optional metadata); + + _FinalStage metadata(Object metadata); + _FinalStage configId(Optional configId); _FinalStage configId(String configId); @@ -286,13 +327,11 @@ public interface _FinalStage { @JsonIgnoreProperties( ignoreUnknown = true ) - public static final class Builder implements StringValueStage, IdStage, TraceIdStage, NameStage, SourceStage, TimestampStage, CreatedAtStage, UpdatedAtStage, _FinalStage { + public static final class Builder implements StringValueStage, IdStage, NameStage, SourceStage, TimestampStage, CreatedAtStage, UpdatedAtStage, _FinalStage { private String stringValue; private String id; - private String traceId; - private String name; private ScoreSource source; @@ -309,12 +348,20 @@ public static final class Builder implements StringValueStage, IdStage, TraceIdS private Optional configId = Optional.empty(); + private Optional metadata = Optional.empty(); + private Optional comment = Optional.empty(); private Optional authorUserId = Optional.empty(); + private Optional datasetRunId = Optional.empty(); + private Optional observationId = Optional.empty(); + private Optional sessionId = Optional.empty(); + + private Optional traceId = Optional.empty(); + private Optional value = Optional.empty(); @JsonAnySetter @@ -329,14 +376,17 @@ public Builder from(CategoricalScore other) { stringValue(other.getStringValue()); id(other.getId()); traceId(other.getTraceId()); + sessionId(other.getSessionId()); + observationId(other.getObservationId()); + datasetRunId(other.getDatasetRunId()); name(other.getName()); source(other.getSource()); - observationId(other.getObservationId()); timestamp(other.getTimestamp()); createdAt(other.getCreatedAt()); updatedAt(other.getUpdatedAt()); authorUserId(other.getAuthorUserId()); comment(other.getComment()); + metadata(other.getMetadata()); configId(other.getConfigId()); queueId(other.getQueueId()); environment(other.getEnvironment()); @@ -356,18 +406,11 @@ public IdStage stringValue(@NotNull String stringValue) { @java.lang.Override @JsonSetter("id") - public TraceIdStage id(@NotNull String id) { + public NameStage id(@NotNull String id) { this.id = Objects.requireNonNull(id, "id must not be null"); return this; } - @java.lang.Override - @JsonSetter("traceId") - public NameStage traceId(@NotNull String traceId) { - this.traceId = Objects.requireNonNull(traceId, "traceId must not be null"); - return this; - } - @java.lang.Override @JsonSetter("name") public SourceStage name(@NotNull String name) { @@ -463,6 +506,22 @@ public _FinalStage configId(Optional configId) { return this; } + @java.lang.Override + public _FinalStage metadata(Object metadata) { + this.metadata = Optional.ofNullable(metadata); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "metadata", + nulls = Nulls.SKIP + ) + public _FinalStage metadata(Optional metadata) { + this.metadata = metadata; + return this; + } + @java.lang.Override public _FinalStage comment(String comment) { this.comment = Optional.ofNullable(comment); @@ -495,6 +554,22 @@ public _FinalStage authorUserId(Optional authorUserId) { return this; } + @java.lang.Override + public _FinalStage datasetRunId(String datasetRunId) { + this.datasetRunId = Optional.ofNullable(datasetRunId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "datasetRunId", + nulls = Nulls.SKIP + ) + public _FinalStage datasetRunId(Optional datasetRunId) { + this.datasetRunId = datasetRunId; + return this; + } + @java.lang.Override public _FinalStage observationId(String observationId) { this.observationId = Optional.ofNullable(observationId); @@ -511,6 +586,38 @@ public _FinalStage observationId(Optional observationId) { return this; } + @java.lang.Override + public _FinalStage sessionId(String sessionId) { + this.sessionId = Optional.ofNullable(sessionId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "sessionId", + nulls = Nulls.SKIP + ) + public _FinalStage sessionId(Optional sessionId) { + this.sessionId = sessionId; + return this; + } + + @java.lang.Override + public _FinalStage traceId(String traceId) { + this.traceId = Optional.ofNullable(traceId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "traceId", + nulls = Nulls.SKIP + ) + public _FinalStage traceId(Optional traceId) { + this.traceId = traceId; + return this; + } + /** *

Only defined if a config is linked. Represents the numeric category mapping of the stringValue

* @return Reference to {@code this} so that method calls can be chained together. @@ -533,7 +640,7 @@ public _FinalStage value(Optional value) { @java.lang.Override public CategoricalScore build() { - return new CategoricalScore(value, stringValue, id, traceId, name, source, observationId, timestamp, createdAt, updatedAt, authorUserId, comment, configId, queueId, environment, additionalProperties); + return new CategoricalScore(value, stringValue, id, traceId, sessionId, observationId, datasetRunId, name, source, timestamp, createdAt, updatedAt, authorUserId, comment, metadata, configId, queueId, environment, additionalProperties); } } } diff --git a/src/main/java/com/langfuse/client/resources/score/types/GetScoresResponseDataCategorical.java b/src/main/java/com/langfuse/client/resources/commons/types/CategoricalScoreV1.java similarity index 80% rename from src/main/java/com/langfuse/client/resources/score/types/GetScoresResponseDataCategorical.java rename to src/main/java/com/langfuse/client/resources/commons/types/CategoricalScoreV1.java index ed71d77..6d576ae 100644 --- a/src/main/java/com/langfuse/client/resources/score/types/GetScoresResponseDataCategorical.java +++ b/src/main/java/com/langfuse/client/resources/commons/types/CategoricalScoreV1.java @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -package com.langfuse.client.resources.score.types; +package com.langfuse.client.resources.commons.types; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -22,19 +22,12 @@ import java.util.Objects; import java.util.Optional; import org.jetbrains.annotations.NotNull; -import com.langfuse.client.resources.commons.types.IBaseScore; -import com.langfuse.client.resources.commons.types.ICategoricalScore; -import com.langfuse.client.resources.commons.types.ScoreSource; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize( - builder = GetScoresResponseDataCategorical.Builder.class + builder = CategoricalScoreV1.Builder.class ) -public final class GetScoresResponseDataCategorical implements ICategoricalScore, IBaseScore { - private final Optional value; - - private final String stringValue; - +public final class CategoricalScoreV1 implements IBaseScoreV1 { private final String id; private final String traceId; @@ -55,24 +48,26 @@ public final class GetScoresResponseDataCategorical implements ICategoricalScore private final Optional comment; + private final Optional metadata; + private final Optional configId; private final Optional queueId; private final Optional environment; - private final GetScoresResponseTraceData trace; + private final Optional value; + + private final String stringValue; private final Map additionalProperties; - private GetScoresResponseDataCategorical(Optional value, String stringValue, String id, - String traceId, String name, ScoreSource source, Optional observationId, - OffsetDateTime timestamp, OffsetDateTime createdAt, OffsetDateTime updatedAt, - Optional authorUserId, Optional comment, Optional configId, - Optional queueId, Optional environment, GetScoresResponseTraceData trace, + private CategoricalScoreV1(String id, String traceId, String name, ScoreSource source, + Optional observationId, OffsetDateTime timestamp, OffsetDateTime createdAt, + OffsetDateTime updatedAt, Optional authorUserId, Optional comment, + Optional metadata, Optional configId, Optional queueId, + Optional environment, Optional value, String stringValue, Map additionalProperties) { - this.value = value; - this.stringValue = stringValue; this.id = id; this.traceId = traceId; this.name = name; @@ -83,31 +78,15 @@ private GetScoresResponseDataCategorical(Optional value, String stringVa this.updatedAt = updatedAt; this.authorUserId = authorUserId; this.comment = comment; + this.metadata = metadata; this.configId = configId; this.queueId = queueId; this.environment = environment; - this.trace = trace; + this.value = value; + this.stringValue = stringValue; this.additionalProperties = additionalProperties; } - /** - * @return Only defined if a config is linked. Represents the numeric category mapping of the stringValue - */ - @JsonProperty("value") - @java.lang.Override - public Optional getValue() { - return value; - } - - /** - * @return The string representation of the score value. If no config is linked, can be any string. Otherwise, must map to a config category - */ - @JsonProperty("stringValue") - @java.lang.Override - public String getStringValue() { - return stringValue; - } - @JsonProperty("id") @java.lang.Override public String getId() { @@ -168,6 +147,12 @@ public Optional getComment() { return comment; } + @JsonProperty("metadata") + @java.lang.Override + public Optional getMetadata() { + return metadata; + } + /** * @return Reference a score config on a score. When set, config and score name must be equal and value must comply to optionally defined numerical range */ @@ -195,15 +180,26 @@ public Optional getEnvironment() { return environment; } - @JsonProperty("trace") - public GetScoresResponseTraceData getTrace() { - return trace; + /** + * @return Only defined if a config is linked. Represents the numeric category mapping of the stringValue + */ + @JsonProperty("value") + public Optional getValue() { + return value; + } + + /** + * @return The string representation of the score value. If no config is linked, can be any string. Otherwise, must map to a config category + */ + @JsonProperty("stringValue") + public String getStringValue() { + return stringValue; } @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof GetScoresResponseDataCategorical && equalTo((GetScoresResponseDataCategorical) other); + return other instanceof CategoricalScoreV1 && equalTo((CategoricalScoreV1) other); } @JsonAnyGetter @@ -211,13 +207,13 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(GetScoresResponseDataCategorical other) { - return value.equals(other.value) && stringValue.equals(other.stringValue) && id.equals(other.id) && traceId.equals(other.traceId) && name.equals(other.name) && source.equals(other.source) && observationId.equals(other.observationId) && timestamp.equals(other.timestamp) && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt) && authorUserId.equals(other.authorUserId) && comment.equals(other.comment) && configId.equals(other.configId) && queueId.equals(other.queueId) && environment.equals(other.environment) && trace.equals(other.trace); + private boolean equalTo(CategoricalScoreV1 other) { + return id.equals(other.id) && traceId.equals(other.traceId) && name.equals(other.name) && source.equals(other.source) && observationId.equals(other.observationId) && timestamp.equals(other.timestamp) && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt) && authorUserId.equals(other.authorUserId) && comment.equals(other.comment) && metadata.equals(other.metadata) && configId.equals(other.configId) && queueId.equals(other.queueId) && environment.equals(other.environment) && value.equals(other.value) && stringValue.equals(other.stringValue); } @java.lang.Override public int hashCode() { - return Objects.hash(this.value, this.stringValue, this.id, this.traceId, this.name, this.source, this.observationId, this.timestamp, this.createdAt, this.updatedAt, this.authorUserId, this.comment, this.configId, this.queueId, this.environment, this.trace); + return Objects.hash(this.id, this.traceId, this.name, this.source, this.observationId, this.timestamp, this.createdAt, this.updatedAt, this.authorUserId, this.comment, this.metadata, this.configId, this.queueId, this.environment, this.value, this.stringValue); } @java.lang.Override @@ -225,18 +221,14 @@ public String toString() { return ObjectMappers.stringify(this); } - public static StringValueStage builder() { + public static IdStage builder() { return new Builder(); } - public interface StringValueStage { - IdStage stringValue(@NotNull String stringValue); - - Builder from(GetScoresResponseDataCategorical other); - } - public interface IdStage { TraceIdStage id(@NotNull String id); + + Builder from(CategoricalScoreV1 other); } public interface TraceIdStage { @@ -260,19 +252,15 @@ public interface CreatedAtStage { } public interface UpdatedAtStage { - TraceStage updatedAt(@NotNull OffsetDateTime updatedAt); + StringValueStage updatedAt(@NotNull OffsetDateTime updatedAt); } - public interface TraceStage { - _FinalStage trace(@NotNull GetScoresResponseTraceData trace); + public interface StringValueStage { + _FinalStage stringValue(@NotNull String stringValue); } public interface _FinalStage { - GetScoresResponseDataCategorical build(); - - _FinalStage value(Optional value); - - _FinalStage value(Double value); + CategoricalScoreV1 build(); _FinalStage observationId(Optional observationId); @@ -286,6 +274,10 @@ public interface _FinalStage { _FinalStage comment(String comment); + _FinalStage metadata(Optional metadata); + + _FinalStage metadata(Object metadata); + _FinalStage configId(Optional configId); _FinalStage configId(String configId); @@ -297,14 +289,16 @@ public interface _FinalStage { _FinalStage environment(Optional environment); _FinalStage environment(String environment); + + _FinalStage value(Optional value); + + _FinalStage value(Double value); } @JsonIgnoreProperties( ignoreUnknown = true ) - public static final class Builder implements StringValueStage, IdStage, TraceIdStage, NameStage, SourceStage, TimestampStage, CreatedAtStage, UpdatedAtStage, TraceStage, _FinalStage { - private String stringValue; - + public static final class Builder implements IdStage, TraceIdStage, NameStage, SourceStage, TimestampStage, CreatedAtStage, UpdatedAtStage, StringValueStage, _FinalStage { private String id; private String traceId; @@ -319,7 +313,9 @@ public static final class Builder implements StringValueStage, IdStage, TraceIdS private OffsetDateTime updatedAt; - private GetScoresResponseTraceData trace; + private String stringValue; + + private Optional value = Optional.empty(); private Optional environment = Optional.empty(); @@ -327,14 +323,14 @@ public static final class Builder implements StringValueStage, IdStage, TraceIdS private Optional configId = Optional.empty(); + private Optional metadata = Optional.empty(); + private Optional comment = Optional.empty(); private Optional authorUserId = Optional.empty(); private Optional observationId = Optional.empty(); - private Optional value = Optional.empty(); - @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -342,9 +338,7 @@ private Builder() { } @java.lang.Override - public Builder from(GetScoresResponseDataCategorical other) { - value(other.getValue()); - stringValue(other.getStringValue()); + public Builder from(CategoricalScoreV1 other) { id(other.getId()); traceId(other.getTraceId()); name(other.getName()); @@ -355,21 +349,12 @@ public Builder from(GetScoresResponseDataCategorical other) { updatedAt(other.getUpdatedAt()); authorUserId(other.getAuthorUserId()); comment(other.getComment()); + metadata(other.getMetadata()); configId(other.getConfigId()); queueId(other.getQueueId()); environment(other.getEnvironment()); - trace(other.getTrace()); - return this; - } - - /** - *

The string representation of the score value. If no config is linked, can be any string. Otherwise, must map to a config category

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("stringValue") - public IdStage stringValue(@NotNull String stringValue) { - this.stringValue = Objects.requireNonNull(stringValue, "stringValue must not be null"); + value(other.getValue()); + stringValue(other.getStringValue()); return this; } @@ -417,15 +402,39 @@ public UpdatedAtStage createdAt(@NotNull OffsetDateTime createdAt) { @java.lang.Override @JsonSetter("updatedAt") - public TraceStage updatedAt(@NotNull OffsetDateTime updatedAt) { + public StringValueStage updatedAt(@NotNull OffsetDateTime updatedAt) { this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); return this; } + /** + *

The string representation of the score value. If no config is linked, can be any string. Otherwise, must map to a config category

+ * @return Reference to {@code this} so that method calls can be chained together. + */ @java.lang.Override - @JsonSetter("trace") - public _FinalStage trace(@NotNull GetScoresResponseTraceData trace) { - this.trace = Objects.requireNonNull(trace, "trace must not be null"); + @JsonSetter("stringValue") + public _FinalStage stringValue(@NotNull String stringValue) { + this.stringValue = Objects.requireNonNull(stringValue, "stringValue must not be null"); + return this; + } + + /** + *

Only defined if a config is linked. Represents the numeric category mapping of the stringValue

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage value(Double value) { + this.value = Optional.ofNullable(value); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "value", + nulls = Nulls.SKIP + ) + public _FinalStage value(Optional value) { + this.value = value; return this; } @@ -489,6 +498,22 @@ public _FinalStage configId(Optional configId) { return this; } + @java.lang.Override + public _FinalStage metadata(Object metadata) { + this.metadata = Optional.ofNullable(metadata); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "metadata", + nulls = Nulls.SKIP + ) + public _FinalStage metadata(Optional metadata) { + this.metadata = metadata; + return this; + } + @java.lang.Override public _FinalStage comment(String comment) { this.comment = Optional.ofNullable(comment); @@ -537,29 +562,9 @@ public _FinalStage observationId(Optional observationId) { return this; } - /** - *

Only defined if a config is linked. Represents the numeric category mapping of the stringValue

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage value(Double value) { - this.value = Optional.ofNullable(value); - return this; - } - - @java.lang.Override - @JsonSetter( - value = "value", - nulls = Nulls.SKIP - ) - public _FinalStage value(Optional value) { - this.value = value; - return this; - } - @java.lang.Override - public GetScoresResponseDataCategorical build() { - return new GetScoresResponseDataCategorical(value, stringValue, id, traceId, name, source, observationId, timestamp, createdAt, updatedAt, authorUserId, comment, configId, queueId, environment, trace, additionalProperties); + public CategoricalScoreV1 build() { + return new CategoricalScoreV1(id, traceId, name, source, observationId, timestamp, createdAt, updatedAt, authorUserId, comment, metadata, configId, queueId, environment, value, stringValue, additionalProperties); } } } diff --git a/src/main/java/com/langfuse/client/resources/commons/types/IBaseScore.java b/src/main/java/com/langfuse/client/resources/commons/types/IBaseScore.java index 942c268..4970bef 100644 --- a/src/main/java/com/langfuse/client/resources/commons/types/IBaseScore.java +++ b/src/main/java/com/langfuse/client/resources/commons/types/IBaseScore.java @@ -4,6 +4,7 @@ package com.langfuse.client.resources.commons.types; +import java.lang.Object; import java.lang.String; import java.time.OffsetDateTime; import java.util.Optional; @@ -11,14 +12,18 @@ public interface IBaseScore { String getId(); - String getTraceId(); + Optional getTraceId(); + + Optional getSessionId(); + + Optional getObservationId(); + + Optional getDatasetRunId(); String getName(); ScoreSource getSource(); - Optional getObservationId(); - OffsetDateTime getTimestamp(); OffsetDateTime getCreatedAt(); @@ -29,6 +34,8 @@ public interface IBaseScore { Optional getComment(); + Optional getMetadata(); + Optional getConfigId(); Optional getQueueId(); diff --git a/src/main/java/com/langfuse/client/resources/commons/types/IBaseScoreV1.java b/src/main/java/com/langfuse/client/resources/commons/types/IBaseScoreV1.java new file mode 100644 index 0000000..365dfdd --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/commons/types/IBaseScoreV1.java @@ -0,0 +1,40 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.commons.types; + +import java.lang.Object; +import java.lang.String; +import java.time.OffsetDateTime; +import java.util.Optional; + +public interface IBaseScoreV1 { + String getId(); + + String getTraceId(); + + String getName(); + + ScoreSource getSource(); + + Optional getObservationId(); + + OffsetDateTime getTimestamp(); + + OffsetDateTime getCreatedAt(); + + OffsetDateTime getUpdatedAt(); + + Optional getAuthorUserId(); + + Optional getComment(); + + Optional getMetadata(); + + Optional getConfigId(); + + Optional getQueueId(); + + Optional getEnvironment(); +} diff --git a/src/main/java/com/langfuse/client/resources/commons/types/Model.java b/src/main/java/com/langfuse/client/resources/commons/types/Model.java index faeafc6..e2aadb9 100644 --- a/src/main/java/com/langfuse/client/resources/commons/types/Model.java +++ b/src/main/java/com/langfuse/client/resources/commons/types/Model.java @@ -18,6 +18,7 @@ import java.lang.String; import java.time.OffsetDateTime; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -50,13 +51,15 @@ public final class Model { private final boolean isLangfuseManaged; + private final Map prices; + private final Map additionalProperties; private Model(String id, String modelName, String matchPattern, Optional startDate, Optional unit, Optional inputPrice, Optional outputPrice, Optional totalPrice, Optional tokenizerId, Optional tokenizerConfig, boolean isLangfuseManaged, - Map additionalProperties) { + Map prices, Map additionalProperties) { this.id = id; this.modelName = modelName; this.matchPattern = matchPattern; @@ -68,6 +71,7 @@ private Model(String id, String modelName, String matchPattern, this.tokenizerId = tokenizerId; this.tokenizerConfig = tokenizerConfig; this.isLangfuseManaged = isLangfuseManaged; + this.prices = prices; this.additionalProperties = additionalProperties; } @@ -109,7 +113,7 @@ public Optional getUnit() { } /** - * @return Price (USD) per input unit + * @return Deprecated. See 'prices' instead. Price (USD) per input unit */ @JsonProperty("inputPrice") public Optional getInputPrice() { @@ -117,7 +121,7 @@ public Optional getInputPrice() { } /** - * @return Price (USD) per output unit + * @return Deprecated. See 'prices' instead. Price (USD) per output unit */ @JsonProperty("outputPrice") public Optional getOutputPrice() { @@ -125,7 +129,7 @@ public Optional getOutputPrice() { } /** - * @return Price (USD) per total unit. Cannot be set if input or output price is set. + * @return Deprecated. See 'prices' instead. Price (USD) per total unit. Cannot be set if input or output price is set. */ @JsonProperty("totalPrice") public Optional getTotalPrice() { @@ -153,6 +157,14 @@ public boolean getIsLangfuseManaged() { return isLangfuseManaged; } + /** + * @return Price (USD) by usage type + */ + @JsonProperty("prices") + public Map getPrices() { + return prices; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -165,12 +177,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(Model other) { - return id.equals(other.id) && modelName.equals(other.modelName) && matchPattern.equals(other.matchPattern) && startDate.equals(other.startDate) && unit.equals(other.unit) && inputPrice.equals(other.inputPrice) && outputPrice.equals(other.outputPrice) && totalPrice.equals(other.totalPrice) && tokenizerId.equals(other.tokenizerId) && tokenizerConfig.equals(other.tokenizerConfig) && isLangfuseManaged == other.isLangfuseManaged; + return id.equals(other.id) && modelName.equals(other.modelName) && matchPattern.equals(other.matchPattern) && startDate.equals(other.startDate) && unit.equals(other.unit) && inputPrice.equals(other.inputPrice) && outputPrice.equals(other.outputPrice) && totalPrice.equals(other.totalPrice) && tokenizerId.equals(other.tokenizerId) && tokenizerConfig.equals(other.tokenizerConfig) && isLangfuseManaged == other.isLangfuseManaged && prices.equals(other.prices); } @java.lang.Override public int hashCode() { - return Objects.hash(this.id, this.modelName, this.matchPattern, this.startDate, this.unit, this.inputPrice, this.outputPrice, this.totalPrice, this.tokenizerId, this.tokenizerConfig, this.isLangfuseManaged); + return Objects.hash(this.id, this.modelName, this.matchPattern, this.startDate, this.unit, this.inputPrice, this.outputPrice, this.totalPrice, this.tokenizerId, this.tokenizerConfig, this.isLangfuseManaged, this.prices); } @java.lang.Override @@ -230,6 +242,12 @@ public interface _FinalStage { _FinalStage tokenizerConfig(Optional tokenizerConfig); _FinalStage tokenizerConfig(Object tokenizerConfig); + + _FinalStage prices(Map prices); + + _FinalStage putAllPrices(Map prices); + + _FinalStage prices(String key, ModelPrice value); } @JsonIgnoreProperties( @@ -244,6 +262,8 @@ public static final class Builder implements IdStage, ModelNameStage, MatchPatte private boolean isLangfuseManaged; + private Map prices = new LinkedHashMap<>(); + private Optional tokenizerConfig = Optional.empty(); private Optional tokenizerId = Optional.empty(); @@ -277,6 +297,7 @@ public Builder from(Model other) { tokenizerId(other.getTokenizerId()); tokenizerConfig(other.getTokenizerConfig()); isLangfuseManaged(other.getIsLangfuseManaged()); + prices(other.getPrices()); return this; } @@ -316,6 +337,37 @@ public _FinalStage isLangfuseManaged(boolean isLangfuseManaged) { return this; } + /** + *

Price (USD) by usage type

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage prices(String key, ModelPrice value) { + this.prices.put(key, value); + return this; + } + + /** + *

Price (USD) by usage type

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage putAllPrices(Map prices) { + this.prices.putAll(prices); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "prices", + nulls = Nulls.SKIP + ) + public _FinalStage prices(Map prices) { + this.prices.clear(); + this.prices.putAll(prices); + return this; + } + /** *

Optional. Configuration for the selected tokenizer. Needs to be JSON. See docs for more details.

* @return Reference to {@code this} so that method calls can be chained together. @@ -357,7 +409,7 @@ public _FinalStage tokenizerId(Optional tokenizerId) { } /** - *

Price (USD) per total unit. Cannot be set if input or output price is set.

+ *

Deprecated. See 'prices' instead. Price (USD) per total unit. Cannot be set if input or output price is set.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -377,7 +429,7 @@ public _FinalStage totalPrice(Optional totalPrice) { } /** - *

Price (USD) per output unit

+ *

Deprecated. See 'prices' instead. Price (USD) per output unit

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -397,7 +449,7 @@ public _FinalStage outputPrice(Optional outputPrice) { } /** - *

Price (USD) per input unit

+ *

Deprecated. See 'prices' instead. Price (USD) per input unit

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -458,7 +510,7 @@ public _FinalStage startDate(Optional startDate) { @java.lang.Override public Model build() { - return new Model(id, modelName, matchPattern, startDate, unit, inputPrice, outputPrice, totalPrice, tokenizerId, tokenizerConfig, isLangfuseManaged, additionalProperties); + return new Model(id, modelName, matchPattern, startDate, unit, inputPrice, outputPrice, totalPrice, tokenizerId, tokenizerConfig, isLangfuseManaged, prices, additionalProperties); } } } diff --git a/src/main/java/com/langfuse/client/resources/commons/types/ModelPrice.java b/src/main/java/com/langfuse/client/resources/commons/types/ModelPrice.java new file mode 100644 index 0000000..6a737f4 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/commons/types/ModelPrice.java @@ -0,0 +1,109 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.commons.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = ModelPrice.Builder.class +) +public final class ModelPrice { + private final double price; + + private final Map additionalProperties; + + private ModelPrice(double price, Map additionalProperties) { + this.price = price; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("price") + public double getPrice() { + return price; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ModelPrice && equalTo((ModelPrice) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ModelPrice other) { + return price == other.price; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.price); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static PriceStage builder() { + return new Builder(); + } + + public interface PriceStage { + _FinalStage price(double price); + + Builder from(ModelPrice other); + } + + public interface _FinalStage { + ModelPrice build(); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements PriceStage, _FinalStage { + private double price; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(ModelPrice other) { + price(other.getPrice()); + return this; + } + + @java.lang.Override + @JsonSetter("price") + public _FinalStage price(double price) { + this.price = price; + return this; + } + + @java.lang.Override + public ModelPrice build() { + return new ModelPrice(price, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/commons/types/NumericScore.java b/src/main/java/com/langfuse/client/resources/commons/types/NumericScore.java index 16a5d9f..b0a5d58 100644 --- a/src/main/java/com/langfuse/client/resources/commons/types/NumericScore.java +++ b/src/main/java/com/langfuse/client/resources/commons/types/NumericScore.java @@ -31,14 +31,18 @@ public final class NumericScore implements INumericScore, IBaseScore { private final String id; - private final String traceId; + private final Optional traceId; + + private final Optional sessionId; + + private final Optional observationId; + + private final Optional datasetRunId; private final String name; private final ScoreSource source; - private final Optional observationId; - private final OffsetDateTime timestamp; private final OffsetDateTime createdAt; @@ -49,6 +53,8 @@ public final class NumericScore implements INumericScore, IBaseScore { private final Optional comment; + private final Optional metadata; + private final Optional configId; private final Optional queueId; @@ -57,22 +63,26 @@ public final class NumericScore implements INumericScore, IBaseScore { private final Map additionalProperties; - private NumericScore(double value, String id, String traceId, String name, ScoreSource source, - Optional observationId, OffsetDateTime timestamp, OffsetDateTime createdAt, + private NumericScore(double value, String id, Optional traceId, + Optional sessionId, Optional observationId, Optional datasetRunId, + String name, ScoreSource source, OffsetDateTime timestamp, OffsetDateTime createdAt, OffsetDateTime updatedAt, Optional authorUserId, Optional comment, - Optional configId, Optional queueId, Optional environment, - Map additionalProperties) { + Optional metadata, Optional configId, Optional queueId, + Optional environment, Map additionalProperties) { this.value = value; this.id = id; this.traceId = traceId; + this.sessionId = sessionId; + this.observationId = observationId; + this.datasetRunId = datasetRunId; this.name = name; this.source = source; - this.observationId = observationId; this.timestamp = timestamp; this.createdAt = createdAt; this.updatedAt = updatedAt; this.authorUserId = authorUserId; this.comment = comment; + this.metadata = metadata; this.configId = configId; this.queueId = queueId; this.environment = environment; @@ -96,10 +106,28 @@ public String getId() { @JsonProperty("traceId") @java.lang.Override - public String getTraceId() { + public Optional getTraceId() { return traceId; } + @JsonProperty("sessionId") + @java.lang.Override + public Optional getSessionId() { + return sessionId; + } + + @JsonProperty("observationId") + @java.lang.Override + public Optional getObservationId() { + return observationId; + } + + @JsonProperty("datasetRunId") + @java.lang.Override + public Optional getDatasetRunId() { + return datasetRunId; + } + @JsonProperty("name") @java.lang.Override public String getName() { @@ -112,12 +140,6 @@ public ScoreSource getSource() { return source; } - @JsonProperty("observationId") - @java.lang.Override - public Optional getObservationId() { - return observationId; - } - @JsonProperty("timestamp") @java.lang.Override public OffsetDateTime getTimestamp() { @@ -148,6 +170,12 @@ public Optional getComment() { return comment; } + @JsonProperty("metadata") + @java.lang.Override + public Optional getMetadata() { + return metadata; + } + /** * @return Reference a score config on a score. When set, config and score name must be equal and value must comply to optionally defined numerical range */ @@ -187,12 +215,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(NumericScore other) { - return value == other.value && id.equals(other.id) && traceId.equals(other.traceId) && name.equals(other.name) && source.equals(other.source) && observationId.equals(other.observationId) && timestamp.equals(other.timestamp) && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt) && authorUserId.equals(other.authorUserId) && comment.equals(other.comment) && configId.equals(other.configId) && queueId.equals(other.queueId) && environment.equals(other.environment); + return value == other.value && id.equals(other.id) && traceId.equals(other.traceId) && sessionId.equals(other.sessionId) && observationId.equals(other.observationId) && datasetRunId.equals(other.datasetRunId) && name.equals(other.name) && source.equals(other.source) && timestamp.equals(other.timestamp) && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt) && authorUserId.equals(other.authorUserId) && comment.equals(other.comment) && metadata.equals(other.metadata) && configId.equals(other.configId) && queueId.equals(other.queueId) && environment.equals(other.environment); } @java.lang.Override public int hashCode() { - return Objects.hash(this.value, this.id, this.traceId, this.name, this.source, this.observationId, this.timestamp, this.createdAt, this.updatedAt, this.authorUserId, this.comment, this.configId, this.queueId, this.environment); + return Objects.hash(this.value, this.id, this.traceId, this.sessionId, this.observationId, this.datasetRunId, this.name, this.source, this.timestamp, this.createdAt, this.updatedAt, this.authorUserId, this.comment, this.metadata, this.configId, this.queueId, this.environment); } @java.lang.Override @@ -211,11 +239,7 @@ public interface ValueStage { } public interface IdStage { - TraceIdStage id(@NotNull String id); - } - - public interface TraceIdStage { - NameStage traceId(@NotNull String traceId); + NameStage id(@NotNull String id); } public interface NameStage { @@ -241,10 +265,22 @@ public interface UpdatedAtStage { public interface _FinalStage { NumericScore build(); + _FinalStage traceId(Optional traceId); + + _FinalStage traceId(String traceId); + + _FinalStage sessionId(Optional sessionId); + + _FinalStage sessionId(String sessionId); + _FinalStage observationId(Optional observationId); _FinalStage observationId(String observationId); + _FinalStage datasetRunId(Optional datasetRunId); + + _FinalStage datasetRunId(String datasetRunId); + _FinalStage authorUserId(Optional authorUserId); _FinalStage authorUserId(String authorUserId); @@ -253,6 +289,10 @@ public interface _FinalStage { _FinalStage comment(String comment); + _FinalStage metadata(Optional metadata); + + _FinalStage metadata(Object metadata); + _FinalStage configId(Optional configId); _FinalStage configId(String configId); @@ -269,13 +309,11 @@ public interface _FinalStage { @JsonIgnoreProperties( ignoreUnknown = true ) - public static final class Builder implements ValueStage, IdStage, TraceIdStage, NameStage, SourceStage, TimestampStage, CreatedAtStage, UpdatedAtStage, _FinalStage { + public static final class Builder implements ValueStage, IdStage, NameStage, SourceStage, TimestampStage, CreatedAtStage, UpdatedAtStage, _FinalStage { private double value; private String id; - private String traceId; - private String name; private ScoreSource source; @@ -292,12 +330,20 @@ public static final class Builder implements ValueStage, IdStage, TraceIdStage, private Optional configId = Optional.empty(); + private Optional metadata = Optional.empty(); + private Optional comment = Optional.empty(); private Optional authorUserId = Optional.empty(); + private Optional datasetRunId = Optional.empty(); + private Optional observationId = Optional.empty(); + private Optional sessionId = Optional.empty(); + + private Optional traceId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -309,14 +355,17 @@ public Builder from(NumericScore other) { value(other.getValue()); id(other.getId()); traceId(other.getTraceId()); + sessionId(other.getSessionId()); + observationId(other.getObservationId()); + datasetRunId(other.getDatasetRunId()); name(other.getName()); source(other.getSource()); - observationId(other.getObservationId()); timestamp(other.getTimestamp()); createdAt(other.getCreatedAt()); updatedAt(other.getUpdatedAt()); authorUserId(other.getAuthorUserId()); comment(other.getComment()); + metadata(other.getMetadata()); configId(other.getConfigId()); queueId(other.getQueueId()); environment(other.getEnvironment()); @@ -336,18 +385,11 @@ public IdStage value(double value) { @java.lang.Override @JsonSetter("id") - public TraceIdStage id(@NotNull String id) { + public NameStage id(@NotNull String id) { this.id = Objects.requireNonNull(id, "id must not be null"); return this; } - @java.lang.Override - @JsonSetter("traceId") - public NameStage traceId(@NotNull String traceId) { - this.traceId = Objects.requireNonNull(traceId, "traceId must not be null"); - return this; - } - @java.lang.Override @JsonSetter("name") public SourceStage name(@NotNull String name) { @@ -443,6 +485,22 @@ public _FinalStage configId(Optional configId) { return this; } + @java.lang.Override + public _FinalStage metadata(Object metadata) { + this.metadata = Optional.ofNullable(metadata); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "metadata", + nulls = Nulls.SKIP + ) + public _FinalStage metadata(Optional metadata) { + this.metadata = metadata; + return this; + } + @java.lang.Override public _FinalStage comment(String comment) { this.comment = Optional.ofNullable(comment); @@ -475,6 +533,22 @@ public _FinalStage authorUserId(Optional authorUserId) { return this; } + @java.lang.Override + public _FinalStage datasetRunId(String datasetRunId) { + this.datasetRunId = Optional.ofNullable(datasetRunId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "datasetRunId", + nulls = Nulls.SKIP + ) + public _FinalStage datasetRunId(Optional datasetRunId) { + this.datasetRunId = datasetRunId; + return this; + } + @java.lang.Override public _FinalStage observationId(String observationId) { this.observationId = Optional.ofNullable(observationId); @@ -491,9 +565,41 @@ public _FinalStage observationId(Optional observationId) { return this; } + @java.lang.Override + public _FinalStage sessionId(String sessionId) { + this.sessionId = Optional.ofNullable(sessionId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "sessionId", + nulls = Nulls.SKIP + ) + public _FinalStage sessionId(Optional sessionId) { + this.sessionId = sessionId; + return this; + } + + @java.lang.Override + public _FinalStage traceId(String traceId) { + this.traceId = Optional.ofNullable(traceId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "traceId", + nulls = Nulls.SKIP + ) + public _FinalStage traceId(Optional traceId) { + this.traceId = traceId; + return this; + } + @java.lang.Override public NumericScore build() { - return new NumericScore(value, id, traceId, name, source, observationId, timestamp, createdAt, updatedAt, authorUserId, comment, configId, queueId, environment, additionalProperties); + return new NumericScore(value, id, traceId, sessionId, observationId, datasetRunId, name, source, timestamp, createdAt, updatedAt, authorUserId, comment, metadata, configId, queueId, environment, additionalProperties); } } } diff --git a/src/main/java/com/langfuse/client/resources/score/types/GetScoresResponseDataNumeric.java b/src/main/java/com/langfuse/client/resources/commons/types/NumericScoreV1.java similarity index 79% rename from src/main/java/com/langfuse/client/resources/score/types/GetScoresResponseDataNumeric.java rename to src/main/java/com/langfuse/client/resources/commons/types/NumericScoreV1.java index 730cd3d..6df61d6 100644 --- a/src/main/java/com/langfuse/client/resources/score/types/GetScoresResponseDataNumeric.java +++ b/src/main/java/com/langfuse/client/resources/commons/types/NumericScoreV1.java @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -package com.langfuse.client.resources.score.types; +package com.langfuse.client.resources.commons.types; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -21,17 +21,12 @@ import java.util.Objects; import java.util.Optional; import org.jetbrains.annotations.NotNull; -import com.langfuse.client.resources.commons.types.IBaseScore; -import com.langfuse.client.resources.commons.types.INumericScore; -import com.langfuse.client.resources.commons.types.ScoreSource; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize( - builder = GetScoresResponseDataNumeric.Builder.class + builder = NumericScoreV1.Builder.class ) -public final class GetScoresResponseDataNumeric implements INumericScore, IBaseScore { - private final double value; - +public final class NumericScoreV1 implements IBaseScoreV1 { private final String id; private final String traceId; @@ -52,23 +47,23 @@ public final class GetScoresResponseDataNumeric implements INumericScore, IBaseS private final Optional comment; + private final Optional metadata; + private final Optional configId; private final Optional queueId; private final Optional environment; - private final GetScoresResponseTraceData trace; + private final double value; private final Map additionalProperties; - private GetScoresResponseDataNumeric(double value, String id, String traceId, String name, - ScoreSource source, Optional observationId, OffsetDateTime timestamp, - OffsetDateTime createdAt, OffsetDateTime updatedAt, Optional authorUserId, - Optional comment, Optional configId, Optional queueId, - Optional environment, GetScoresResponseTraceData trace, - Map additionalProperties) { - this.value = value; + private NumericScoreV1(String id, String traceId, String name, ScoreSource source, + Optional observationId, OffsetDateTime timestamp, OffsetDateTime createdAt, + OffsetDateTime updatedAt, Optional authorUserId, Optional comment, + Optional metadata, Optional configId, Optional queueId, + Optional environment, double value, Map additionalProperties) { this.id = id; this.traceId = traceId; this.name = name; @@ -79,22 +74,14 @@ private GetScoresResponseDataNumeric(double value, String id, String traceId, St this.updatedAt = updatedAt; this.authorUserId = authorUserId; this.comment = comment; + this.metadata = metadata; this.configId = configId; this.queueId = queueId; this.environment = environment; - this.trace = trace; + this.value = value; this.additionalProperties = additionalProperties; } - /** - * @return The numeric value of the score - */ - @JsonProperty("value") - @java.lang.Override - public double getValue() { - return value; - } - @JsonProperty("id") @java.lang.Override public String getId() { @@ -155,6 +142,12 @@ public Optional getComment() { return comment; } + @JsonProperty("metadata") + @java.lang.Override + public Optional getMetadata() { + return metadata; + } + /** * @return Reference a score config on a score. When set, config and score name must be equal and value must comply to optionally defined numerical range */ @@ -182,15 +175,18 @@ public Optional getEnvironment() { return environment; } - @JsonProperty("trace") - public GetScoresResponseTraceData getTrace() { - return trace; + /** + * @return The numeric value of the score + */ + @JsonProperty("value") + public double getValue() { + return value; } @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof GetScoresResponseDataNumeric && equalTo((GetScoresResponseDataNumeric) other); + return other instanceof NumericScoreV1 && equalTo((NumericScoreV1) other); } @JsonAnyGetter @@ -198,13 +194,13 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(GetScoresResponseDataNumeric other) { - return value == other.value && id.equals(other.id) && traceId.equals(other.traceId) && name.equals(other.name) && source.equals(other.source) && observationId.equals(other.observationId) && timestamp.equals(other.timestamp) && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt) && authorUserId.equals(other.authorUserId) && comment.equals(other.comment) && configId.equals(other.configId) && queueId.equals(other.queueId) && environment.equals(other.environment) && trace.equals(other.trace); + private boolean equalTo(NumericScoreV1 other) { + return id.equals(other.id) && traceId.equals(other.traceId) && name.equals(other.name) && source.equals(other.source) && observationId.equals(other.observationId) && timestamp.equals(other.timestamp) && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt) && authorUserId.equals(other.authorUserId) && comment.equals(other.comment) && metadata.equals(other.metadata) && configId.equals(other.configId) && queueId.equals(other.queueId) && environment.equals(other.environment) && value == other.value; } @java.lang.Override public int hashCode() { - return Objects.hash(this.value, this.id, this.traceId, this.name, this.source, this.observationId, this.timestamp, this.createdAt, this.updatedAt, this.authorUserId, this.comment, this.configId, this.queueId, this.environment, this.trace); + return Objects.hash(this.id, this.traceId, this.name, this.source, this.observationId, this.timestamp, this.createdAt, this.updatedAt, this.authorUserId, this.comment, this.metadata, this.configId, this.queueId, this.environment, this.value); } @java.lang.Override @@ -212,18 +208,14 @@ public String toString() { return ObjectMappers.stringify(this); } - public static ValueStage builder() { + public static IdStage builder() { return new Builder(); } - public interface ValueStage { - IdStage value(double value); - - Builder from(GetScoresResponseDataNumeric other); - } - public interface IdStage { TraceIdStage id(@NotNull String id); + + Builder from(NumericScoreV1 other); } public interface TraceIdStage { @@ -247,15 +239,15 @@ public interface CreatedAtStage { } public interface UpdatedAtStage { - TraceStage updatedAt(@NotNull OffsetDateTime updatedAt); + ValueStage updatedAt(@NotNull OffsetDateTime updatedAt); } - public interface TraceStage { - _FinalStage trace(@NotNull GetScoresResponseTraceData trace); + public interface ValueStage { + _FinalStage value(double value); } public interface _FinalStage { - GetScoresResponseDataNumeric build(); + NumericScoreV1 build(); _FinalStage observationId(Optional observationId); @@ -269,6 +261,10 @@ public interface _FinalStage { _FinalStage comment(String comment); + _FinalStage metadata(Optional metadata); + + _FinalStage metadata(Object metadata); + _FinalStage configId(Optional configId); _FinalStage configId(String configId); @@ -285,9 +281,7 @@ public interface _FinalStage { @JsonIgnoreProperties( ignoreUnknown = true ) - public static final class Builder implements ValueStage, IdStage, TraceIdStage, NameStage, SourceStage, TimestampStage, CreatedAtStage, UpdatedAtStage, TraceStage, _FinalStage { - private double value; - + public static final class Builder implements IdStage, TraceIdStage, NameStage, SourceStage, TimestampStage, CreatedAtStage, UpdatedAtStage, ValueStage, _FinalStage { private String id; private String traceId; @@ -302,7 +296,7 @@ public static final class Builder implements ValueStage, IdStage, TraceIdStage, private OffsetDateTime updatedAt; - private GetScoresResponseTraceData trace; + private double value; private Optional environment = Optional.empty(); @@ -310,6 +304,8 @@ public static final class Builder implements ValueStage, IdStage, TraceIdStage, private Optional configId = Optional.empty(); + private Optional metadata = Optional.empty(); + private Optional comment = Optional.empty(); private Optional authorUserId = Optional.empty(); @@ -323,8 +319,7 @@ private Builder() { } @java.lang.Override - public Builder from(GetScoresResponseDataNumeric other) { - value(other.getValue()); + public Builder from(NumericScoreV1 other) { id(other.getId()); traceId(other.getTraceId()); name(other.getName()); @@ -335,21 +330,11 @@ public Builder from(GetScoresResponseDataNumeric other) { updatedAt(other.getUpdatedAt()); authorUserId(other.getAuthorUserId()); comment(other.getComment()); + metadata(other.getMetadata()); configId(other.getConfigId()); queueId(other.getQueueId()); environment(other.getEnvironment()); - trace(other.getTrace()); - return this; - } - - /** - *

The numeric value of the score

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("value") - public IdStage value(double value) { - this.value = value; + value(other.getValue()); return this; } @@ -397,15 +382,19 @@ public UpdatedAtStage createdAt(@NotNull OffsetDateTime createdAt) { @java.lang.Override @JsonSetter("updatedAt") - public TraceStage updatedAt(@NotNull OffsetDateTime updatedAt) { + public ValueStage updatedAt(@NotNull OffsetDateTime updatedAt) { this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); return this; } + /** + *

The numeric value of the score

+ * @return Reference to {@code this} so that method calls can be chained together. + */ @java.lang.Override - @JsonSetter("trace") - public _FinalStage trace(@NotNull GetScoresResponseTraceData trace) { - this.trace = Objects.requireNonNull(trace, "trace must not be null"); + @JsonSetter("value") + public _FinalStage value(double value) { + this.value = value; return this; } @@ -469,6 +458,22 @@ public _FinalStage configId(Optional configId) { return this; } + @java.lang.Override + public _FinalStage metadata(Object metadata) { + this.metadata = Optional.ofNullable(metadata); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "metadata", + nulls = Nulls.SKIP + ) + public _FinalStage metadata(Optional metadata) { + this.metadata = metadata; + return this; + } + @java.lang.Override public _FinalStage comment(String comment) { this.comment = Optional.ofNullable(comment); @@ -518,8 +523,8 @@ public _FinalStage observationId(Optional observationId) { } @java.lang.Override - public GetScoresResponseDataNumeric build() { - return new GetScoresResponseDataNumeric(value, id, traceId, name, source, observationId, timestamp, createdAt, updatedAt, authorUserId, comment, configId, queueId, environment, trace, additionalProperties); + public NumericScoreV1 build() { + return new NumericScoreV1(id, traceId, name, source, observationId, timestamp, createdAt, updatedAt, authorUserId, comment, metadata, configId, queueId, environment, value, additionalProperties); } } } diff --git a/src/main/java/com/langfuse/client/resources/commons/types/ScoreV1.java b/src/main/java/com/langfuse/client/resources/commons/types/ScoreV1.java new file mode 100644 index 0000000..1747bbb --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/commons/types/ScoreV1.java @@ -0,0 +1,287 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.commons.types; + +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.lang.Object; +import java.lang.String; +import java.util.Objects; +import java.util.Optional; + +public final class ScoreV1 { + private final Value value; + + @JsonCreator( + mode = JsonCreator.Mode.DELEGATING + ) + private ScoreV1(Value value) { + this.value = value; + } + + public T visit(Visitor visitor) { + return value.visit(visitor); + } + + public static ScoreV1 numeric(NumericScoreV1 value) { + return new ScoreV1(new NumericValue(value)); + } + + public static ScoreV1 categorical(CategoricalScoreV1 value) { + return new ScoreV1(new CategoricalValue(value)); + } + + public static ScoreV1 boolean_(BooleanScoreV1 value) { + return new ScoreV1(new BooleanValue(value)); + } + + public boolean isNumeric() { + return value instanceof NumericValue; + } + + public boolean isCategorical() { + return value instanceof CategoricalValue; + } + + public boolean isBoolean() { + return value instanceof BooleanValue; + } + + public boolean _isUnknown() { + return value instanceof _UnknownValue; + } + + public Optional getNumeric() { + if (isNumeric()) { + return Optional.of(((NumericValue) value).value); + } + return Optional.empty(); + } + + public Optional getCategorical() { + if (isCategorical()) { + return Optional.of(((CategoricalValue) value).value); + } + return Optional.empty(); + } + + public Optional getBoolean() { + if (isBoolean()) { + return Optional.of(((BooleanValue) value).value); + } + return Optional.empty(); + } + + public Optional _getUnknown() { + if (_isUnknown()) { + return Optional.of(((_UnknownValue) value).value); + } + return Optional.empty(); + } + + @JsonValue + private Value getValue() { + return this.value; + } + + public interface Visitor { + T visitNumeric(NumericScoreV1 numeric); + + T visitCategorical(CategoricalScoreV1 categorical); + + T visitBoolean(BooleanScoreV1 boolean_); + + T _visitUnknown(Object unknownType); + } + + @JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + property = "dataType", + visible = true, + defaultImpl = _UnknownValue.class + ) + @JsonSubTypes({ + @JsonSubTypes.Type(NumericValue.class), + @JsonSubTypes.Type(CategoricalValue.class), + @JsonSubTypes.Type(BooleanValue.class) + }) + @JsonIgnoreProperties( + ignoreUnknown = true + ) + private interface Value { + T visit(Visitor visitor); + } + + @JsonTypeName("NUMERIC") + @JsonIgnoreProperties("dataType") + private static final class NumericValue implements Value { + @JsonUnwrapped + private NumericScoreV1 value; + + @JsonCreator( + mode = JsonCreator.Mode.PROPERTIES + ) + private NumericValue() { + } + + private NumericValue(NumericScoreV1 value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitNumeric(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof NumericValue && equalTo((NumericValue) other); + } + + private boolean equalTo(NumericValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ScoreV1{" + "value: " + value + "}"; + } + } + + @JsonTypeName("CATEGORICAL") + @JsonIgnoreProperties("dataType") + private static final class CategoricalValue implements Value { + @JsonUnwrapped + private CategoricalScoreV1 value; + + @JsonCreator( + mode = JsonCreator.Mode.PROPERTIES + ) + private CategoricalValue() { + } + + private CategoricalValue(CategoricalScoreV1 value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitCategorical(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CategoricalValue && equalTo((CategoricalValue) other); + } + + private boolean equalTo(CategoricalValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ScoreV1{" + "value: " + value + "}"; + } + } + + @JsonTypeName("BOOLEAN") + @JsonIgnoreProperties("dataType") + private static final class BooleanValue implements Value { + @JsonUnwrapped + private BooleanScoreV1 value; + + @JsonCreator( + mode = JsonCreator.Mode.PROPERTIES + ) + private BooleanValue() { + } + + private BooleanValue(BooleanScoreV1 value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitBoolean(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BooleanValue && equalTo((BooleanValue) other); + } + + private boolean equalTo(BooleanValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ScoreV1{" + "value: " + value + "}"; + } + } + + @JsonIgnoreProperties("dataType") + 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 visit(Visitor 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 "ScoreV1{" + "type: " + type + ", value: " + value + "}"; + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/commons/types/TraceWithFullDetails.java b/src/main/java/com/langfuse/client/resources/commons/types/TraceWithFullDetails.java index 6813a2d..41aa688 100644 --- a/src/main/java/com/langfuse/client/resources/commons/types/TraceWithFullDetails.java +++ b/src/main/java/com/langfuse/client/resources/commons/types/TraceWithFullDetails.java @@ -64,7 +64,7 @@ public final class TraceWithFullDetails implements ITrace { private final List observations; - private final List scores; + private final List scores; private final Map additionalProperties; @@ -73,7 +73,7 @@ private TraceWithFullDetails(String id, OffsetDateTime timestamp, Optional release, Optional version, Optional userId, Optional metadata, Optional> tags, Optional public_, Optional environment, String htmlPath, double latency, double totalCost, - List observations, List scores, + List observations, List scores, Map additionalProperties) { this.id = id; this.timestamp = timestamp; @@ -249,7 +249,7 @@ public List getObservations() { * @return List of scores */ @JsonProperty("scores") - public List getScores() { + public List getScores() { return scores; } @@ -357,11 +357,11 @@ public interface _FinalStage { _FinalStage addAllObservations(List observations); - _FinalStage scores(List scores); + _FinalStage scores(List scores); - _FinalStage addScores(Score scores); + _FinalStage addScores(ScoreV1 scores); - _FinalStage addAllScores(List scores); + _FinalStage addAllScores(List scores); } @JsonIgnoreProperties( @@ -378,7 +378,7 @@ public static final class Builder implements IdStage, TimestampStage, HtmlPathSt private double totalCost; - private List scores = new ArrayList<>(); + private List scores = new ArrayList<>(); private List observations = new ArrayList<>(); @@ -493,7 +493,7 @@ public _FinalStage totalCost(double totalCost) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage addAllScores(List scores) { + public _FinalStage addAllScores(List scores) { this.scores.addAll(scores); return this; } @@ -503,7 +503,7 @@ public _FinalStage addAllScores(List scores) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage addScores(Score scores) { + public _FinalStage addScores(ScoreV1 scores) { this.scores.add(scores); return this; } @@ -513,7 +513,7 @@ public _FinalStage addScores(Score scores) { value = "scores", nulls = Nulls.SKIP ) - public _FinalStage scores(List scores) { + public _FinalStage scores(List scores) { this.scores.clear(); this.scores.addAll(scores); return this; diff --git a/src/main/java/com/langfuse/client/resources/datasetrunitems/DatasetRunItemsClient.java b/src/main/java/com/langfuse/client/resources/datasetrunitems/DatasetRunItemsClient.java index 511909f..71f1de5 100644 --- a/src/main/java/com/langfuse/client/resources/datasetrunitems/DatasetRunItemsClient.java +++ b/src/main/java/com/langfuse/client/resources/datasetrunitems/DatasetRunItemsClient.java @@ -10,6 +10,7 @@ import com.langfuse.client.core.LangfuseClientException; import com.langfuse.client.core.MediaTypes; import com.langfuse.client.core.ObjectMappers; +import com.langfuse.client.core.QueryStringMapper; import com.langfuse.client.core.RequestOptions; import java.io.IOException; import java.lang.Object; @@ -27,6 +28,7 @@ import com.langfuse.client.resources.commons.errors.NotFoundError; import com.langfuse.client.resources.commons.errors.UnauthorizedError; import com.langfuse.client.resources.commons.types.DatasetRunItem; +import com.langfuse.client.resources.datasetrunitems.requests.ListDatasetRunItemsRequest; import com.langfuse.client.resources.datasetrunitems.types.CreateDatasetRunItemRequest; public class DatasetRunItemsClient { @@ -93,4 +95,61 @@ public DatasetRunItem create(CreateDatasetRunItemRequest request, RequestOptions throw new LangfuseClientException("Network error executing HTTP request", e); } } -} + + /** + * List dataset run items + */ + public void list(ListDatasetRunItemsRequest request) { + list(request,null); + } + + /** + * List dataset run items + */ + public void list(ListDatasetRunItemsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public") + .addPathSegments("dataset-run-items");QueryStringMapper.addQueryParameter(httpUrl, "datasetId", request.getDatasetId(), false); + QueryStringMapper.addQueryParameter(httpUrl, "runName", request.getRunName(), false); + if (request.getPage().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "page", request.getPage().get().toString(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "limit", request.getLimit().get().toString(), false); + } + QueryStringMapper.addQueryParameter(httpUrl, "response", request.getResponse().toString(), 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; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + } diff --git a/src/main/java/com/langfuse/client/resources/datasetrunitems/requests/ListDatasetRunItemsRequest.java b/src/main/java/com/langfuse/client/resources/datasetrunitems/requests/ListDatasetRunItemsRequest.java new file mode 100644 index 0000000..5236edf --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/datasetrunitems/requests/ListDatasetRunItemsRequest.java @@ -0,0 +1,236 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.datasetrunitems.requests; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Integer; +import java.lang.Object; +import java.lang.String; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; +import com.langfuse.client.resources.datasetrunitems.types.PaginatedDatasetRunItems; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = ListDatasetRunItemsRequest.Builder.class +) +public final class ListDatasetRunItemsRequest { + private final String datasetId; + + private final String runName; + + private final Optional page; + + private final Optional limit; + + private final PaginatedDatasetRunItems response; + + private final Map additionalProperties; + + private ListDatasetRunItemsRequest(String datasetId, String runName, Optional page, + Optional limit, PaginatedDatasetRunItems response, + Map additionalProperties) { + this.datasetId = datasetId; + this.runName = runName; + this.page = page; + this.limit = limit; + this.response = response; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("datasetId") + public String getDatasetId() { + return datasetId; + } + + @JsonProperty("runName") + public String getRunName() { + return runName; + } + + /** + * @return page number, starts at 1 + */ + @JsonProperty("page") + public Optional getPage() { + return page; + } + + /** + * @return limit of items per page + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + @JsonProperty("response") + public PaginatedDatasetRunItems getResponse() { + return response; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListDatasetRunItemsRequest && equalTo((ListDatasetRunItemsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListDatasetRunItemsRequest other) { + return datasetId.equals(other.datasetId) && runName.equals(other.runName) && page.equals(other.page) && limit.equals(other.limit) && response.equals(other.response); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.datasetId, this.runName, this.page, this.limit, this.response); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DatasetIdStage builder() { + return new Builder(); + } + + public interface DatasetIdStage { + RunNameStage datasetId(@NotNull String datasetId); + + Builder from(ListDatasetRunItemsRequest other); + } + + public interface RunNameStage { + ResponseStage runName(@NotNull String runName); + } + + public interface ResponseStage { + _FinalStage response(@NotNull PaginatedDatasetRunItems response); + } + + public interface _FinalStage { + ListDatasetRunItemsRequest build(); + + _FinalStage page(Optional page); + + _FinalStage page(Integer page); + + _FinalStage limit(Optional limit); + + _FinalStage limit(Integer limit); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements DatasetIdStage, RunNameStage, ResponseStage, _FinalStage { + private String datasetId; + + private String runName; + + private PaginatedDatasetRunItems response; + + private Optional limit = Optional.empty(); + + private Optional page = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(ListDatasetRunItemsRequest other) { + datasetId(other.getDatasetId()); + runName(other.getRunName()); + page(other.getPage()); + limit(other.getLimit()); + response(other.getResponse()); + return this; + } + + @java.lang.Override + @JsonSetter("datasetId") + public RunNameStage datasetId(@NotNull String datasetId) { + this.datasetId = Objects.requireNonNull(datasetId, "datasetId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("runName") + public ResponseStage runName(@NotNull String runName) { + this.runName = Objects.requireNonNull(runName, "runName must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("response") + public _FinalStage response(@NotNull PaginatedDatasetRunItems response) { + this.response = Objects.requireNonNull(response, "response must not be null"); + return this; + } + + /** + *

limit of items per page

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "limit", + nulls = Nulls.SKIP + ) + public _FinalStage limit(Optional limit) { + this.limit = limit; + return this; + } + + /** + *

page number, starts at 1

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage page(Integer page) { + this.page = Optional.ofNullable(page); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "page", + nulls = Nulls.SKIP + ) + public _FinalStage page(Optional page) { + this.page = page; + return this; + } + + @java.lang.Override + public ListDatasetRunItemsRequest build() { + return new ListDatasetRunItemsRequest(datasetId, runName, page, limit, response, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/datasetrunitems/types/PaginatedDatasetRunItems.java b/src/main/java/com/langfuse/client/resources/datasetrunitems/types/PaginatedDatasetRunItems.java new file mode 100644 index 0000000..fce1c56 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/datasetrunitems/types/PaginatedDatasetRunItems.java @@ -0,0 +1,156 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.datasetrunitems.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +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; +import com.langfuse.client.resources.commons.types.DatasetRunItem; +import com.langfuse.client.resources.utils.pagination.types.MetaResponse; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = PaginatedDatasetRunItems.Builder.class +) +public final class PaginatedDatasetRunItems { + private final List data; + + private final MetaResponse meta; + + private final Map additionalProperties; + + private PaginatedDatasetRunItems(List data, MetaResponse meta, + Map additionalProperties) { + this.data = data; + this.meta = meta; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public List getData() { + return data; + } + + @JsonProperty("meta") + public MetaResponse getMeta() { + return meta; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PaginatedDatasetRunItems && equalTo((PaginatedDatasetRunItems) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PaginatedDatasetRunItems other) { + return data.equals(other.data) && meta.equals(other.meta); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.meta); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static MetaStage builder() { + return new Builder(); + } + + public interface MetaStage { + _FinalStage meta(@NotNull MetaResponse meta); + + Builder from(PaginatedDatasetRunItems other); + } + + public interface _FinalStage { + PaginatedDatasetRunItems build(); + + _FinalStage data(List data); + + _FinalStage addData(DatasetRunItem data); + + _FinalStage addAllData(List data); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements MetaStage, _FinalStage { + private MetaResponse meta; + + private List data = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(PaginatedDatasetRunItems other) { + data(other.getData()); + meta(other.getMeta()); + return this; + } + + @java.lang.Override + @JsonSetter("meta") + public _FinalStage meta(@NotNull MetaResponse meta) { + this.meta = Objects.requireNonNull(meta, "meta must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllData(List data) { + this.data.addAll(data); + return this; + } + + @java.lang.Override + public _FinalStage addData(DatasetRunItem data) { + this.data.add(data); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "data", + nulls = Nulls.SKIP + ) + public _FinalStage data(List data) { + this.data.clear(); + this.data.addAll(data); + return this; + } + + @java.lang.Override + public PaginatedDatasetRunItems build() { + return new PaginatedDatasetRunItems(data, meta, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/ingestion/types/OpenAiUsageSchema.java b/src/main/java/com/langfuse/client/resources/ingestion/types/OpenAiCompletionUsageSchema.java similarity index 71% rename from src/main/java/com/langfuse/client/resources/ingestion/types/OpenAiUsageSchema.java rename to src/main/java/com/langfuse/client/resources/ingestion/types/OpenAiCompletionUsageSchema.java index 682b7e0..e5d7530 100644 --- a/src/main/java/com/langfuse/client/resources/ingestion/types/OpenAiUsageSchema.java +++ b/src/main/java/com/langfuse/client/resources/ingestion/types/OpenAiCompletionUsageSchema.java @@ -23,24 +23,24 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize( - builder = OpenAiUsageSchema.Builder.class + builder = OpenAiCompletionUsageSchema.Builder.class ) -public final class OpenAiUsageSchema { +public final class OpenAiCompletionUsageSchema { private final int promptTokens; private final int completionTokens; private final int totalTokens; - private final Optional> promptTokensDetails; + private final Optional>> promptTokensDetails; - private final Optional> completionTokensDetails; + private final Optional>> completionTokensDetails; private final Map additionalProperties; - private OpenAiUsageSchema(int promptTokens, int completionTokens, int totalTokens, - Optional> promptTokensDetails, - Optional> completionTokensDetails, + private OpenAiCompletionUsageSchema(int promptTokens, int completionTokens, int totalTokens, + Optional>> promptTokensDetails, + Optional>> completionTokensDetails, Map additionalProperties) { this.promptTokens = promptTokens; this.completionTokens = completionTokens; @@ -66,19 +66,19 @@ public int getTotalTokens() { } @JsonProperty("prompt_tokens_details") - public Optional> getPromptTokensDetails() { + public Optional>> getPromptTokensDetails() { return promptTokensDetails; } @JsonProperty("completion_tokens_details") - public Optional> getCompletionTokensDetails() { + public Optional>> getCompletionTokensDetails() { return completionTokensDetails; } @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof OpenAiUsageSchema && equalTo((OpenAiUsageSchema) other); + return other instanceof OpenAiCompletionUsageSchema && equalTo((OpenAiCompletionUsageSchema) other); } @JsonAnyGetter @@ -86,7 +86,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(OpenAiUsageSchema other) { + private boolean equalTo(OpenAiCompletionUsageSchema other) { return promptTokens == other.promptTokens && completionTokens == other.completionTokens && totalTokens == other.totalTokens && promptTokensDetails.equals(other.promptTokensDetails) && completionTokensDetails.equals(other.completionTokensDetails); } @@ -107,7 +107,7 @@ public static PromptTokensStage builder() { public interface PromptTokensStage { CompletionTokensStage promptTokens(int promptTokens); - Builder from(OpenAiUsageSchema other); + Builder from(OpenAiCompletionUsageSchema other); } public interface CompletionTokensStage { @@ -119,15 +119,16 @@ public interface TotalTokensStage { } public interface _FinalStage { - OpenAiUsageSchema build(); + OpenAiCompletionUsageSchema build(); - _FinalStage promptTokensDetails(Optional> promptTokensDetails); + _FinalStage promptTokensDetails(Optional>> promptTokensDetails); - _FinalStage promptTokensDetails(Map promptTokensDetails); + _FinalStage promptTokensDetails(Map> promptTokensDetails); - _FinalStage completionTokensDetails(Optional> completionTokensDetails); + _FinalStage completionTokensDetails( + Optional>> completionTokensDetails); - _FinalStage completionTokensDetails(Map completionTokensDetails); + _FinalStage completionTokensDetails(Map> completionTokensDetails); } @JsonIgnoreProperties( @@ -140,9 +141,9 @@ public static final class Builder implements PromptTokensStage, CompletionTokens private int totalTokens; - private Optional> completionTokensDetails = Optional.empty(); + private Optional>> completionTokensDetails = Optional.empty(); - private Optional> promptTokensDetails = Optional.empty(); + private Optional>> promptTokensDetails = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -151,7 +152,7 @@ private Builder() { } @java.lang.Override - public Builder from(OpenAiUsageSchema other) { + public Builder from(OpenAiCompletionUsageSchema other) { promptTokens(other.getPromptTokens()); completionTokens(other.getCompletionTokens()); totalTokens(other.getTotalTokens()); @@ -182,7 +183,8 @@ public _FinalStage totalTokens(int totalTokens) { } @java.lang.Override - public _FinalStage completionTokensDetails(Map completionTokensDetails) { + public _FinalStage completionTokensDetails( + Map> completionTokensDetails) { this.completionTokensDetails = Optional.ofNullable(completionTokensDetails); return this; } @@ -193,13 +195,13 @@ public _FinalStage completionTokensDetails(Map completionTokens nulls = Nulls.SKIP ) public _FinalStage completionTokensDetails( - Optional> completionTokensDetails) { + Optional>> completionTokensDetails) { this.completionTokensDetails = completionTokensDetails; return this; } @java.lang.Override - public _FinalStage promptTokensDetails(Map promptTokensDetails) { + public _FinalStage promptTokensDetails(Map> promptTokensDetails) { this.promptTokensDetails = Optional.ofNullable(promptTokensDetails); return this; } @@ -209,14 +211,15 @@ public _FinalStage promptTokensDetails(Map promptTokensDetails) value = "prompt_tokens_details", nulls = Nulls.SKIP ) - public _FinalStage promptTokensDetails(Optional> promptTokensDetails) { + public _FinalStage promptTokensDetails( + Optional>> promptTokensDetails) { this.promptTokensDetails = promptTokensDetails; return this; } @java.lang.Override - public OpenAiUsageSchema build() { - return new OpenAiUsageSchema(promptTokens, completionTokens, totalTokens, promptTokensDetails, completionTokensDetails, additionalProperties); + public OpenAiCompletionUsageSchema build() { + return new OpenAiCompletionUsageSchema(promptTokens, completionTokens, totalTokens, promptTokensDetails, completionTokensDetails, additionalProperties); } } } diff --git a/src/main/java/com/langfuse/client/resources/ingestion/types/OpenAiResponseUsageSchema.java b/src/main/java/com/langfuse/client/resources/ingestion/types/OpenAiResponseUsageSchema.java new file mode 100644 index 0000000..5c914d4 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/ingestion/types/OpenAiResponseUsageSchema.java @@ -0,0 +1,223 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.ingestion.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Integer; +import java.lang.Object; +import java.lang.String; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = OpenAiResponseUsageSchema.Builder.class +) +public final class OpenAiResponseUsageSchema { + private final int inputTokens; + + private final int outputTokens; + + private final int totalTokens; + + private final Optional>> inputTokensDetails; + + private final Optional>> outputTokensDetails; + + private final Map additionalProperties; + + private OpenAiResponseUsageSchema(int inputTokens, int outputTokens, int totalTokens, + Optional>> inputTokensDetails, + Optional>> outputTokensDetails, + Map additionalProperties) { + this.inputTokens = inputTokens; + this.outputTokens = outputTokens; + this.totalTokens = totalTokens; + this.inputTokensDetails = inputTokensDetails; + this.outputTokensDetails = outputTokensDetails; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("input_tokens") + public int getInputTokens() { + return inputTokens; + } + + @JsonProperty("output_tokens") + public int getOutputTokens() { + return outputTokens; + } + + @JsonProperty("total_tokens") + public int getTotalTokens() { + return totalTokens; + } + + @JsonProperty("input_tokens_details") + public Optional>> getInputTokensDetails() { + return inputTokensDetails; + } + + @JsonProperty("output_tokens_details") + public Optional>> getOutputTokensDetails() { + return outputTokensDetails; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof OpenAiResponseUsageSchema && equalTo((OpenAiResponseUsageSchema) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(OpenAiResponseUsageSchema other) { + return inputTokens == other.inputTokens && outputTokens == other.outputTokens && totalTokens == other.totalTokens && inputTokensDetails.equals(other.inputTokensDetails) && outputTokensDetails.equals(other.outputTokensDetails); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.inputTokens, this.outputTokens, this.totalTokens, this.inputTokensDetails, this.outputTokensDetails); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static InputTokensStage builder() { + return new Builder(); + } + + public interface InputTokensStage { + OutputTokensStage inputTokens(int inputTokens); + + Builder from(OpenAiResponseUsageSchema other); + } + + public interface OutputTokensStage { + TotalTokensStage outputTokens(int outputTokens); + } + + public interface TotalTokensStage { + _FinalStage totalTokens(int totalTokens); + } + + public interface _FinalStage { + OpenAiResponseUsageSchema build(); + + _FinalStage inputTokensDetails(Optional>> inputTokensDetails); + + _FinalStage inputTokensDetails(Map> inputTokensDetails); + + _FinalStage outputTokensDetails(Optional>> outputTokensDetails); + + _FinalStage outputTokensDetails(Map> outputTokensDetails); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements InputTokensStage, OutputTokensStage, TotalTokensStage, _FinalStage { + private int inputTokens; + + private int outputTokens; + + private int totalTokens; + + private Optional>> outputTokensDetails = Optional.empty(); + + private Optional>> inputTokensDetails = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(OpenAiResponseUsageSchema other) { + inputTokens(other.getInputTokens()); + outputTokens(other.getOutputTokens()); + totalTokens(other.getTotalTokens()); + inputTokensDetails(other.getInputTokensDetails()); + outputTokensDetails(other.getOutputTokensDetails()); + return this; + } + + @java.lang.Override + @JsonSetter("input_tokens") + public OutputTokensStage inputTokens(int inputTokens) { + this.inputTokens = inputTokens; + return this; + } + + @java.lang.Override + @JsonSetter("output_tokens") + public TotalTokensStage outputTokens(int outputTokens) { + this.outputTokens = outputTokens; + return this; + } + + @java.lang.Override + @JsonSetter("total_tokens") + public _FinalStage totalTokens(int totalTokens) { + this.totalTokens = totalTokens; + return this; + } + + @java.lang.Override + public _FinalStage outputTokensDetails(Map> outputTokensDetails) { + this.outputTokensDetails = Optional.ofNullable(outputTokensDetails); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "output_tokens_details", + nulls = Nulls.SKIP + ) + public _FinalStage outputTokensDetails( + Optional>> outputTokensDetails) { + this.outputTokensDetails = outputTokensDetails; + return this; + } + + @java.lang.Override + public _FinalStage inputTokensDetails(Map> inputTokensDetails) { + this.inputTokensDetails = Optional.ofNullable(inputTokensDetails); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "input_tokens_details", + nulls = Nulls.SKIP + ) + public _FinalStage inputTokensDetails( + Optional>> inputTokensDetails) { + this.inputTokensDetails = inputTokensDetails; + return this; + } + + @java.lang.Override + public OpenAiResponseUsageSchema build() { + return new OpenAiResponseUsageSchema(inputTokens, outputTokens, totalTokens, inputTokensDetails, outputTokensDetails, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/ingestion/types/ScoreBody.java b/src/main/java/com/langfuse/client/resources/ingestion/types/ScoreBody.java index 745cd8c..9ab870a 100644 --- a/src/main/java/com/langfuse/client/resources/ingestion/types/ScoreBody.java +++ b/src/main/java/com/langfuse/client/resources/ingestion/types/ScoreBody.java @@ -30,7 +30,13 @@ public final class ScoreBody { private final Optional id; - private final String traceId; + private final Optional traceId; + + private final Optional sessionId; + + private final Optional observationId; + + private final Optional datasetRunId; private final String name; @@ -38,27 +44,31 @@ public final class ScoreBody { private final CreateScoreValue value; - private final Optional observationId; - private final Optional comment; + private final Optional metadata; + private final Optional dataType; private final Optional configId; private final Map additionalProperties; - private ScoreBody(Optional id, String traceId, String name, Optional environment, - CreateScoreValue value, Optional observationId, Optional comment, - Optional dataType, Optional configId, + private ScoreBody(Optional id, Optional traceId, Optional sessionId, + Optional observationId, Optional datasetRunId, String name, + Optional environment, CreateScoreValue value, Optional comment, + Optional metadata, Optional dataType, Optional configId, Map additionalProperties) { this.id = id; this.traceId = traceId; + this.sessionId = sessionId; + this.observationId = observationId; + this.datasetRunId = datasetRunId; this.name = name; this.environment = environment; this.value = value; - this.observationId = observationId; this.comment = comment; + this.metadata = metadata; this.dataType = dataType; this.configId = configId; this.additionalProperties = additionalProperties; @@ -70,10 +80,25 @@ public Optional getId() { } @JsonProperty("traceId") - public String getTraceId() { + public Optional getTraceId() { return traceId; } + @JsonProperty("sessionId") + public Optional getSessionId() { + return sessionId; + } + + @JsonProperty("observationId") + public Optional getObservationId() { + return observationId; + } + + @JsonProperty("datasetRunId") + public Optional getDatasetRunId() { + return datasetRunId; + } + @JsonProperty("name") public String getName() { return name; @@ -92,16 +117,16 @@ public CreateScoreValue getValue() { return value; } - @JsonProperty("observationId") - public Optional getObservationId() { - return observationId; - } - @JsonProperty("comment") public Optional getComment() { return comment; } + @JsonProperty("metadata") + public Optional getMetadata() { + return metadata; + } + /** * @return When set, must match the score value's type. If not set, will be inferred from the score value or config */ @@ -130,12 +155,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(ScoreBody other) { - return id.equals(other.id) && traceId.equals(other.traceId) && name.equals(other.name) && environment.equals(other.environment) && value.equals(other.value) && observationId.equals(other.observationId) && comment.equals(other.comment) && dataType.equals(other.dataType) && configId.equals(other.configId); + return id.equals(other.id) && traceId.equals(other.traceId) && sessionId.equals(other.sessionId) && observationId.equals(other.observationId) && datasetRunId.equals(other.datasetRunId) && name.equals(other.name) && environment.equals(other.environment) && value.equals(other.value) && comment.equals(other.comment) && metadata.equals(other.metadata) && dataType.equals(other.dataType) && configId.equals(other.configId); } @java.lang.Override public int hashCode() { - return Objects.hash(this.id, this.traceId, this.name, this.environment, this.value, this.observationId, this.comment, this.dataType, this.configId); + return Objects.hash(this.id, this.traceId, this.sessionId, this.observationId, this.datasetRunId, this.name, this.environment, this.value, this.comment, this.metadata, this.dataType, this.configId); } @java.lang.Override @@ -143,18 +168,14 @@ public String toString() { return ObjectMappers.stringify(this); } - public static TraceIdStage builder() { + public static NameStage builder() { return new Builder(); } - public interface TraceIdStage { - NameStage traceId(@NotNull String traceId); - - Builder from(ScoreBody other); - } - public interface NameStage { ValueStage name(@NotNull String name); + + Builder from(ScoreBody other); } public interface ValueStage { @@ -168,18 +189,34 @@ public interface _FinalStage { _FinalStage id(String id); - _FinalStage environment(Optional environment); + _FinalStage traceId(Optional traceId); - _FinalStage environment(String environment); + _FinalStage traceId(String traceId); + + _FinalStage sessionId(Optional sessionId); + + _FinalStage sessionId(String sessionId); _FinalStage observationId(Optional observationId); _FinalStage observationId(String observationId); + _FinalStage datasetRunId(Optional datasetRunId); + + _FinalStage datasetRunId(String datasetRunId); + + _FinalStage environment(Optional environment); + + _FinalStage environment(String environment); + _FinalStage comment(Optional comment); _FinalStage comment(String comment); + _FinalStage metadata(Optional metadata); + + _FinalStage metadata(Object metadata); + _FinalStage dataType(Optional dataType); _FinalStage dataType(ScoreDataType dataType); @@ -192,9 +229,7 @@ public interface _FinalStage { @JsonIgnoreProperties( ignoreUnknown = true ) - public static final class Builder implements TraceIdStage, NameStage, ValueStage, _FinalStage { - private String traceId; - + public static final class Builder implements NameStage, ValueStage, _FinalStage { private String name; private CreateScoreValue value; @@ -203,11 +238,19 @@ public static final class Builder implements TraceIdStage, NameStage, ValueStage private Optional dataType = Optional.empty(); + private Optional metadata = Optional.empty(); + private Optional comment = Optional.empty(); + private Optional environment = Optional.empty(); + + private Optional datasetRunId = Optional.empty(); + private Optional observationId = Optional.empty(); - private Optional environment = Optional.empty(); + private Optional sessionId = Optional.empty(); + + private Optional traceId = Optional.empty(); private Optional id = Optional.empty(); @@ -221,23 +264,19 @@ private Builder() { public Builder from(ScoreBody other) { id(other.getId()); traceId(other.getTraceId()); + sessionId(other.getSessionId()); + observationId(other.getObservationId()); + datasetRunId(other.getDatasetRunId()); name(other.getName()); environment(other.getEnvironment()); value(other.getValue()); - observationId(other.getObservationId()); comment(other.getComment()); + metadata(other.getMetadata()); dataType(other.getDataType()); configId(other.getConfigId()); return this; } - @java.lang.Override - @JsonSetter("traceId") - public NameStage traceId(@NotNull String traceId) { - this.traceId = Objects.requireNonNull(traceId, "traceId must not be null"); - return this; - } - @java.lang.Override @JsonSetter("name") public ValueStage name(@NotNull String name) { @@ -296,6 +335,22 @@ public _FinalStage dataType(Optional dataType) { return this; } + @java.lang.Override + public _FinalStage metadata(Object metadata) { + this.metadata = Optional.ofNullable(metadata); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "metadata", + nulls = Nulls.SKIP + ) + public _FinalStage metadata(Optional metadata) { + this.metadata = metadata; + return this; + } + @java.lang.Override public _FinalStage comment(String comment) { this.comment = Optional.ofNullable(comment); @@ -312,6 +367,38 @@ public _FinalStage comment(Optional comment) { return this; } + @java.lang.Override + public _FinalStage environment(String environment) { + this.environment = Optional.ofNullable(environment); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "environment", + nulls = Nulls.SKIP + ) + public _FinalStage environment(Optional environment) { + this.environment = environment; + return this; + } + + @java.lang.Override + public _FinalStage datasetRunId(String datasetRunId) { + this.datasetRunId = Optional.ofNullable(datasetRunId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "datasetRunId", + nulls = Nulls.SKIP + ) + public _FinalStage datasetRunId(Optional datasetRunId) { + this.datasetRunId = datasetRunId; + return this; + } + @java.lang.Override public _FinalStage observationId(String observationId) { this.observationId = Optional.ofNullable(observationId); @@ -329,18 +416,34 @@ public _FinalStage observationId(Optional observationId) { } @java.lang.Override - public _FinalStage environment(String environment) { - this.environment = Optional.ofNullable(environment); + public _FinalStage sessionId(String sessionId) { + this.sessionId = Optional.ofNullable(sessionId); return this; } @java.lang.Override @JsonSetter( - value = "environment", + value = "sessionId", nulls = Nulls.SKIP ) - public _FinalStage environment(Optional environment) { - this.environment = environment; + public _FinalStage sessionId(Optional sessionId) { + this.sessionId = sessionId; + return this; + } + + @java.lang.Override + public _FinalStage traceId(String traceId) { + this.traceId = Optional.ofNullable(traceId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "traceId", + nulls = Nulls.SKIP + ) + public _FinalStage traceId(Optional traceId) { + this.traceId = traceId; return this; } @@ -362,7 +465,7 @@ public _FinalStage id(Optional id) { @java.lang.Override public ScoreBody build() { - return new ScoreBody(id, traceId, name, environment, value, observationId, comment, dataType, configId, additionalProperties); + return new ScoreBody(id, traceId, sessionId, observationId, datasetRunId, name, environment, value, comment, metadata, dataType, configId, additionalProperties); } } } diff --git a/src/main/java/com/langfuse/client/resources/ingestion/types/UsageDetails.java b/src/main/java/com/langfuse/client/resources/ingestion/types/UsageDetails.java index d7fb275..438819d 100644 --- a/src/main/java/com/langfuse/client/resources/ingestion/types/UsageDetails.java +++ b/src/main/java/com/langfuse/client/resources/ingestion/types/UsageDetails.java @@ -43,7 +43,9 @@ public T visit(Visitor visitor) { if(this.type == 0) { return visitor.visit((Map) this.value); } else if(this.type == 1) { - return visitor.visit((OpenAiUsageSchema) this.value); + return visitor.visit((OpenAiCompletionUsageSchema) this.value); + } else if(this.type == 2) { + return visitor.visit((OpenAiResponseUsageSchema) this.value); } throw new IllegalStateException("Failed to visit value. This should never happen."); } @@ -72,14 +74,20 @@ public static UsageDetails of(Map value) { return new UsageDetails(value, 0); } - public static UsageDetails of(OpenAiUsageSchema value) { + public static UsageDetails of(OpenAiCompletionUsageSchema value) { return new UsageDetails(value, 1); } + public static UsageDetails of(OpenAiResponseUsageSchema value) { + return new UsageDetails(value, 2); + } + public interface Visitor { T visit(Map value); - T visit(OpenAiUsageSchema value); + T visit(OpenAiCompletionUsageSchema value); + + T visit(OpenAiResponseUsageSchema value); } static final class Deserializer extends StdDeserializer { @@ -96,7 +104,11 @@ public UsageDetails deserialize(JsonParser p, DeserializationContext context) th } catch(IllegalArgumentException e) { } try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, OpenAiUsageSchema.class)); + return of(ObjectMappers.JSON_MAPPER.convertValue(value, OpenAiCompletionUsageSchema.class)); + } catch(IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, OpenAiResponseUsageSchema.class)); } catch(IllegalArgumentException e) { } throw new JsonParseException(p, "Failed to deserialize"); diff --git a/src/main/java/com/langfuse/client/resources/metrics/MetricsClient.java b/src/main/java/com/langfuse/client/resources/metrics/MetricsClient.java index 0a586e6..176b7a0 100644 --- a/src/main/java/com/langfuse/client/resources/metrics/MetricsClient.java +++ b/src/main/java/com/langfuse/client/resources/metrics/MetricsClient.java @@ -25,8 +25,8 @@ import com.langfuse.client.resources.commons.errors.MethodNotAllowedError; import com.langfuse.client.resources.commons.errors.NotFoundError; import com.langfuse.client.resources.commons.errors.UnauthorizedError; -import com.langfuse.client.resources.metrics.requests.GetDailyMetricsRequest; -import com.langfuse.client.resources.metrics.types.DailyMetrics; +import com.langfuse.client.resources.metrics.requests.GetMetricsRequest; +import com.langfuse.client.resources.metrics.types.MetricsResponse; public class MetricsClient { protected final ClientOptions clientOptions; @@ -36,49 +36,19 @@ public MetricsClient(ClientOptions clientOptions) { } /** - * Get daily metrics of the Langfuse project + * Get metrics from the Langfuse project using a query object */ - public DailyMetrics daily() { - return daily(GetDailyMetricsRequest.builder().build()); + public MetricsResponse metrics(GetMetricsRequest request) { + return metrics(request,null); } /** - * Get daily metrics of the Langfuse project + * Get metrics from the Langfuse project using a query object */ - public DailyMetrics daily(GetDailyMetricsRequest request) { - return daily(request,null); - } - - /** - * Get daily metrics of the Langfuse project - */ - public DailyMetrics daily(GetDailyMetricsRequest request, RequestOptions requestOptions) { + public MetricsResponse metrics(GetMetricsRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() .addPathSegments("api/public") - .addPathSegments("metrics/daily");if (request.getPage().isPresent()) { - QueryStringMapper.addQueryParameter(httpUrl, "page", request.getPage().get().toString(), false); - } - if (request.getLimit().isPresent()) { - QueryStringMapper.addQueryParameter(httpUrl, "limit", request.getLimit().get().toString(), false); - } - if (request.getTraceName().isPresent()) { - QueryStringMapper.addQueryParameter(httpUrl, "traceName", request.getTraceName().get(), false); - } - if (request.getUserId().isPresent()) { - QueryStringMapper.addQueryParameter(httpUrl, "userId", request.getUserId().get(), false); - } - if (request.getTags().isPresent()) { - QueryStringMapper.addQueryParameter(httpUrl, "tags", request.getTags().get(), false); - } - if (request.getEnvironment().isPresent()) { - QueryStringMapper.addQueryParameter(httpUrl, "environment", request.getEnvironment().get(), false); - } - if (request.getFromTimestamp().isPresent()) { - QueryStringMapper.addQueryParameter(httpUrl, "fromTimestamp", request.getFromTimestamp().get().toString(), false); - } - if (request.getToTimestamp().isPresent()) { - QueryStringMapper.addQueryParameter(httpUrl, "toTimestamp", request.getToTimestamp().get().toString(), false); - } + .addPathSegments("metrics");QueryStringMapper.addQueryParameter(httpUrl, "query", request.getQuery(), false); Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl.build()) .method("GET", null) @@ -93,7 +63,7 @@ public DailyMetrics daily(GetDailyMetricsRequest request, RequestOptions request try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DailyMetrics.class); + return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetricsResponse.class); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { diff --git a/src/main/java/com/langfuse/client/resources/metrics/requests/GetDailyMetricsRequest.java b/src/main/java/com/langfuse/client/resources/metrics/requests/GetDailyMetricsRequest.java deleted file mode 100644 index cfb3d9d..0000000 --- a/src/main/java/com/langfuse/client/resources/metrics/requests/GetDailyMetricsRequest.java +++ /dev/null @@ -1,310 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -package com.langfuse.client.resources.metrics.requests; - -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 com.langfuse.client.core.ObjectMappers; -import java.lang.Integer; -import java.lang.Object; -import java.lang.String; -import java.time.OffsetDateTime; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize( - builder = GetDailyMetricsRequest.Builder.class -) -public final class GetDailyMetricsRequest { - private final Optional page; - - private final Optional limit; - - private final Optional traceName; - - private final Optional userId; - - private final Optional tags; - - private final Optional environment; - - private final Optional fromTimestamp; - - private final Optional toTimestamp; - - private final Map additionalProperties; - - private GetDailyMetricsRequest(Optional page, Optional limit, - Optional traceName, Optional userId, Optional tags, - Optional environment, Optional fromTimestamp, - Optional toTimestamp, Map additionalProperties) { - this.page = page; - this.limit = limit; - this.traceName = traceName; - this.userId = userId; - this.tags = tags; - this.environment = environment; - this.fromTimestamp = fromTimestamp; - this.toTimestamp = toTimestamp; - this.additionalProperties = additionalProperties; - } - - /** - * @return page number, starts at 1 - */ - @JsonProperty("page") - public Optional getPage() { - return page; - } - - /** - * @return limit of items per page - */ - @JsonProperty("limit") - public Optional getLimit() { - return limit; - } - - /** - * @return Optional filter by the name of the trace - */ - @JsonProperty("traceName") - public Optional getTraceName() { - return traceName; - } - - /** - * @return Optional filter by the userId associated with the trace - */ - @JsonProperty("userId") - public Optional getUserId() { - return userId; - } - - /** - * @return Optional filter for metrics where traces include all of these tags - */ - @JsonProperty("tags") - public Optional getTags() { - return tags; - } - - /** - * @return Optional filter for metrics where events include any of these environments - */ - @JsonProperty("environment") - public Optional getEnvironment() { - return environment; - } - - /** - * @return Optional filter to only include traces and observations on or after a certain datetime (ISO 8601) - */ - @JsonProperty("fromTimestamp") - public Optional getFromTimestamp() { - return fromTimestamp; - } - - /** - * @return Optional filter to only include traces and observations before a certain datetime (ISO 8601) - */ - @JsonProperty("toTimestamp") - public Optional getToTimestamp() { - return toTimestamp; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GetDailyMetricsRequest && equalTo((GetDailyMetricsRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(GetDailyMetricsRequest other) { - return page.equals(other.page) && limit.equals(other.limit) && traceName.equals(other.traceName) && userId.equals(other.userId) && tags.equals(other.tags) && environment.equals(other.environment) && fromTimestamp.equals(other.fromTimestamp) && toTimestamp.equals(other.toTimestamp); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.page, this.limit, this.traceName, this.userId, this.tags, this.environment, this.fromTimestamp, this.toTimestamp); - } - - @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 page = Optional.empty(); - - private Optional limit = Optional.empty(); - - private Optional traceName = Optional.empty(); - - private Optional userId = Optional.empty(); - - private Optional tags = Optional.empty(); - - private Optional environment = Optional.empty(); - - private Optional fromTimestamp = Optional.empty(); - - private Optional toTimestamp = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() { - } - - public Builder from(GetDailyMetricsRequest other) { - page(other.getPage()); - limit(other.getLimit()); - traceName(other.getTraceName()); - userId(other.getUserId()); - tags(other.getTags()); - environment(other.getEnvironment()); - fromTimestamp(other.getFromTimestamp()); - toTimestamp(other.getToTimestamp()); - return this; - } - - @JsonSetter( - value = "page", - nulls = Nulls.SKIP - ) - public Builder page(Optional page) { - this.page = page; - return this; - } - - public Builder page(Integer page) { - this.page = Optional.ofNullable(page); - return this; - } - - @JsonSetter( - value = "limit", - nulls = Nulls.SKIP - ) - public Builder limit(Optional limit) { - this.limit = limit; - return this; - } - - public Builder limit(Integer limit) { - this.limit = Optional.ofNullable(limit); - return this; - } - - @JsonSetter( - value = "traceName", - nulls = Nulls.SKIP - ) - public Builder traceName(Optional traceName) { - this.traceName = traceName; - return this; - } - - public Builder traceName(String traceName) { - this.traceName = Optional.ofNullable(traceName); - return this; - } - - @JsonSetter( - value = "userId", - nulls = Nulls.SKIP - ) - public Builder userId(Optional userId) { - this.userId = userId; - return this; - } - - public Builder userId(String userId) { - this.userId = Optional.ofNullable(userId); - return this; - } - - @JsonSetter( - value = "tags", - nulls = Nulls.SKIP - ) - public Builder tags(Optional tags) { - this.tags = tags; - return this; - } - - public Builder tags(String tags) { - this.tags = Optional.ofNullable(tags); - return this; - } - - @JsonSetter( - value = "environment", - nulls = Nulls.SKIP - ) - public Builder environment(Optional environment) { - this.environment = environment; - return this; - } - - public Builder environment(String environment) { - this.environment = Optional.ofNullable(environment); - return this; - } - - @JsonSetter( - value = "fromTimestamp", - nulls = Nulls.SKIP - ) - public Builder fromTimestamp(Optional fromTimestamp) { - this.fromTimestamp = fromTimestamp; - return this; - } - - public Builder fromTimestamp(OffsetDateTime fromTimestamp) { - this.fromTimestamp = Optional.ofNullable(fromTimestamp); - return this; - } - - @JsonSetter( - value = "toTimestamp", - nulls = Nulls.SKIP - ) - public Builder toTimestamp(Optional toTimestamp) { - this.toTimestamp = toTimestamp; - return this; - } - - public Builder toTimestamp(OffsetDateTime toTimestamp) { - this.toTimestamp = Optional.ofNullable(toTimestamp); - return this; - } - - public GetDailyMetricsRequest build() { - return new GetDailyMetricsRequest(page, limit, traceName, userId, tags, environment, fromTimestamp, toTimestamp, additionalProperties); - } - } -} diff --git a/src/main/java/com/langfuse/client/resources/metrics/requests/GetMetricsRequest.java b/src/main/java/com/langfuse/client/resources/metrics/requests/GetMetricsRequest.java new file mode 100644 index 0000000..6a0423e --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/metrics/requests/GetMetricsRequest.java @@ -0,0 +1,195 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.metrics.requests; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = GetMetricsRequest.Builder.class +) +public final class GetMetricsRequest { + private final String query; + + private final Map additionalProperties; + + private GetMetricsRequest(String query, Map additionalProperties) { + this.query = query; + this.additionalProperties = additionalProperties; + } + + /** + * @return JSON string containing the query parameters with the following structure: + *
{
+   *   "view": string,           // Required. One of "traces", "observations", "scores-numeric", "scores-categorical"
+   *   "dimensions": [           // Optional. Default: []
+   *     {
+   *       "field": string       // Field to group by, e.g. "name", "userId", "sessionId"
+   *     }
+   *   ],
+   *   "metrics": [              // Required. At least one metric must be provided
+   *     {
+   *       "measure": string,    // What to measure, e.g. "count", "latency", "value"
+   *       "aggregation": string // How to aggregate, e.g. "count", "sum", "avg", "p95", "histogram"
+   *     }
+   *   ],
+   *   "filters": [              // Optional. Default: []
+   *     {
+   *       "column": string,     // Column to filter on
+   *       "operator": string,   // Operator, e.g. "=", ">", "<", "contains"
+   *       "value": any,         // Value to compare against
+   *       "type": string,       // Data type, e.g. "string", "number", "stringObject"
+   *       "key": string         // Required only when filtering on metadata
+   *     }
+   *   ],
+   *   "timeDimension": {        // Optional. Default: null. If provided, results will be grouped by time
+   *     "granularity": string   // One of "minute", "hour", "day", "week", "month", "auto"
+   *   },
+   *   "fromTimestamp": string,  // Required. ISO datetime string for start of time range
+   *   "toTimestamp": string,    // Required. ISO datetime string for end of time range
+   *   "orderBy": [              // Optional. Default: null
+   *     {
+   *       "field": string,      // Field to order by
+   *       "direction": string   // "asc" or "desc"
+   *     }
+   *   ],
+   *   "config": {               // Optional. Query-specific configuration
+   *     "bins": number,         // Optional. Number of bins for histogram (1-100), default: 10
+   *     "row_limit": number     // Optional. Row limit for results (1-1000)
+   *   }
+   * }
+   * 
+ */ + @JsonProperty("query") + public String getQuery() { + return query; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetMetricsRequest && equalTo((GetMetricsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetMetricsRequest other) { + return query.equals(other.query); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.query); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static QueryStage builder() { + return new Builder(); + } + + public interface QueryStage { + _FinalStage query(@NotNull String query); + + Builder from(GetMetricsRequest other); + } + + public interface _FinalStage { + GetMetricsRequest build(); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements QueryStage, _FinalStage { + private String query; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(GetMetricsRequest other) { + query(other.getQuery()); + return this; + } + + /** + *

JSON string containing the query parameters with the following structure:

+ *
{
+     *   "view": string,           // Required. One of "traces", "observations", "scores-numeric", "scores-categorical"
+     *   "dimensions": [           // Optional. Default: []
+     *     {
+     *       "field": string       // Field to group by, e.g. "name", "userId", "sessionId"
+     *     }
+     *   ],
+     *   "metrics": [              // Required. At least one metric must be provided
+     *     {
+     *       "measure": string,    // What to measure, e.g. "count", "latency", "value"
+     *       "aggregation": string // How to aggregate, e.g. "count", "sum", "avg", "p95", "histogram"
+     *     }
+     *   ],
+     *   "filters": [              // Optional. Default: []
+     *     {
+     *       "column": string,     // Column to filter on
+     *       "operator": string,   // Operator, e.g. "=", ">", "<", "contains"
+     *       "value": any,         // Value to compare against
+     *       "type": string,       // Data type, e.g. "string", "number", "stringObject"
+     *       "key": string         // Required only when filtering on metadata
+     *     }
+     *   ],
+     *   "timeDimension": {        // Optional. Default: null. If provided, results will be grouped by time
+     *     "granularity": string   // One of "minute", "hour", "day", "week", "month", "auto"
+     *   },
+     *   "fromTimestamp": string,  // Required. ISO datetime string for start of time range
+     *   "toTimestamp": string,    // Required. ISO datetime string for end of time range
+     *   "orderBy": [              // Optional. Default: null
+     *     {
+     *       "field": string,      // Field to order by
+     *       "direction": string   // "asc" or "desc"
+     *     }
+     *   ],
+     *   "config": {               // Optional. Query-specific configuration
+     *     "bins": number,         // Optional. Number of bins for histogram (1-100), default: 10
+     *     "row_limit": number     // Optional. Row limit for results (1-1000)
+     *   }
+     * }
+     * 
+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("query") + public _FinalStage query(@NotNull String query) { + this.query = Objects.requireNonNull(query, "query must not be null"); + return this; + } + + @java.lang.Override + public GetMetricsRequest build() { + return new GetMetricsRequest(query, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/metrics/types/DailyMetricsDetails.java b/src/main/java/com/langfuse/client/resources/metrics/types/DailyMetricsDetails.java deleted file mode 100644 index d10f651..0000000 --- a/src/main/java/com/langfuse/client/resources/metrics/types/DailyMetricsDetails.java +++ /dev/null @@ -1,227 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -package com.langfuse.client.resources.metrics.types; - -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 com.langfuse.client.core.ObjectMappers; -import java.lang.Object; -import java.lang.String; -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 = DailyMetricsDetails.Builder.class -) -public final class DailyMetricsDetails { - private final String date; - - private final int countTraces; - - private final int countObservations; - - private final double totalCost; - - private final List usage; - - private final Map additionalProperties; - - private DailyMetricsDetails(String date, int countTraces, int countObservations, double totalCost, - List usage, Map additionalProperties) { - this.date = date; - this.countTraces = countTraces; - this.countObservations = countObservations; - this.totalCost = totalCost; - this.usage = usage; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("date") - public String getDate() { - return date; - } - - @JsonProperty("countTraces") - public int getCountTraces() { - return countTraces; - } - - @JsonProperty("countObservations") - public int getCountObservations() { - return countObservations; - } - - /** - * @return Total model cost in USD - */ - @JsonProperty("totalCost") - public double getTotalCost() { - return totalCost; - } - - @JsonProperty("usage") - public List getUsage() { - return usage; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DailyMetricsDetails && equalTo((DailyMetricsDetails) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DailyMetricsDetails other) { - return date.equals(other.date) && countTraces == other.countTraces && countObservations == other.countObservations && totalCost == other.totalCost && usage.equals(other.usage); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.date, this.countTraces, this.countObservations, this.totalCost, this.usage); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static DateStage builder() { - return new Builder(); - } - - public interface DateStage { - CountTracesStage date(@NotNull String date); - - Builder from(DailyMetricsDetails other); - } - - public interface CountTracesStage { - CountObservationsStage countTraces(int countTraces); - } - - public interface CountObservationsStage { - TotalCostStage countObservations(int countObservations); - } - - public interface TotalCostStage { - _FinalStage totalCost(double totalCost); - } - - public interface _FinalStage { - DailyMetricsDetails build(); - - _FinalStage usage(List usage); - - _FinalStage addUsage(UsageByModel usage); - - _FinalStage addAllUsage(List usage); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder implements DateStage, CountTracesStage, CountObservationsStage, TotalCostStage, _FinalStage { - private String date; - - private int countTraces; - - private int countObservations; - - private double totalCost; - - private List usage = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() { - } - - @java.lang.Override - public Builder from(DailyMetricsDetails other) { - date(other.getDate()); - countTraces(other.getCountTraces()); - countObservations(other.getCountObservations()); - totalCost(other.getTotalCost()); - usage(other.getUsage()); - return this; - } - - @java.lang.Override - @JsonSetter("date") - public CountTracesStage date(@NotNull String date) { - this.date = Objects.requireNonNull(date, "date must not be null"); - return this; - } - - @java.lang.Override - @JsonSetter("countTraces") - public CountObservationsStage countTraces(int countTraces) { - this.countTraces = countTraces; - return this; - } - - @java.lang.Override - @JsonSetter("countObservations") - public TotalCostStage countObservations(int countObservations) { - this.countObservations = countObservations; - return this; - } - - /** - *

Total model cost in USD

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("totalCost") - public _FinalStage totalCost(double totalCost) { - this.totalCost = totalCost; - return this; - } - - @java.lang.Override - public _FinalStage addAllUsage(List usage) { - this.usage.addAll(usage); - return this; - } - - @java.lang.Override - public _FinalStage addUsage(UsageByModel usage) { - this.usage.add(usage); - return this; - } - - @java.lang.Override - @JsonSetter( - value = "usage", - nulls = Nulls.SKIP - ) - public _FinalStage usage(List usage) { - this.usage.clear(); - this.usage.addAll(usage); - return this; - } - - @java.lang.Override - public DailyMetricsDetails build() { - return new DailyMetricsDetails(date, countTraces, countObservations, totalCost, usage, additionalProperties); - } - } -} diff --git a/src/main/java/com/langfuse/client/resources/metrics/types/MetricsResponse.java b/src/main/java/com/langfuse/client/resources/metrics/types/MetricsResponse.java new file mode 100644 index 0000000..2f3dacb --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/metrics/types/MetricsResponse.java @@ -0,0 +1,119 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.metrics.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +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 = MetricsResponse.Builder.class +) +public final class MetricsResponse { + private final List> data; + + private final Map additionalProperties; + + private MetricsResponse(List> data, + Map additionalProperties) { + this.data = data; + this.additionalProperties = additionalProperties; + } + + /** + * @return The metrics data. Each item in the list contains the metric values and dimensions requested in the query. + * Format varies based on the query parameters. + * Histograms will return an array with [lower, upper, height] tuples. + */ + @JsonProperty("data") + public List> getData() { + return data; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof MetricsResponse && equalTo((MetricsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(MetricsResponse other) { + return data.equals(other.data); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data); + } + + @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 List> data = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + public Builder from(MetricsResponse other) { + data(other.getData()); + return this; + } + + @JsonSetter( + value = "data", + nulls = Nulls.SKIP + ) + public Builder data(List> data) { + this.data.clear(); + this.data.addAll(data); + return this; + } + + public Builder addData(Map data) { + this.data.add(data); + return this; + } + + public Builder addAllData(List> data) { + this.data.addAll(data); + return this; + } + + public MetricsResponse build() { + return new MetricsResponse(data, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/metrics/types/UsageByModel.java b/src/main/java/com/langfuse/client/resources/metrics/types/UsageByModel.java deleted file mode 100644 index 334e4f1..0000000 --- a/src/main/java/com/langfuse/client/resources/metrics/types/UsageByModel.java +++ /dev/null @@ -1,282 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -package com.langfuse.client.resources.metrics.types; - -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 com.langfuse.client.core.ObjectMappers; -import java.lang.Object; -import java.lang.String; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize( - builder = UsageByModel.Builder.class -) -public final class UsageByModel { - private final Optional model; - - private final int inputUsage; - - private final int outputUsage; - - private final int totalUsage; - - private final int countTraces; - - private final int countObservations; - - private final double totalCost; - - private final Map additionalProperties; - - private UsageByModel(Optional model, int inputUsage, int outputUsage, int totalUsage, - int countTraces, int countObservations, double totalCost, - Map additionalProperties) { - this.model = model; - this.inputUsage = inputUsage; - this.outputUsage = outputUsage; - this.totalUsage = totalUsage; - this.countTraces = countTraces; - this.countObservations = countObservations; - this.totalCost = totalCost; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("model") - public Optional getModel() { - return model; - } - - /** - * @return Total number of generation input units (e.g. tokens) - */ - @JsonProperty("inputUsage") - public int getInputUsage() { - return inputUsage; - } - - /** - * @return Total number of generation output units (e.g. tokens) - */ - @JsonProperty("outputUsage") - public int getOutputUsage() { - return outputUsage; - } - - /** - * @return Total number of generation total units (e.g. tokens) - */ - @JsonProperty("totalUsage") - public int getTotalUsage() { - return totalUsage; - } - - @JsonProperty("countTraces") - public int getCountTraces() { - return countTraces; - } - - @JsonProperty("countObservations") - public int getCountObservations() { - return countObservations; - } - - /** - * @return Total model cost in USD - */ - @JsonProperty("totalCost") - public double getTotalCost() { - return totalCost; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UsageByModel && equalTo((UsageByModel) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(UsageByModel other) { - return model.equals(other.model) && inputUsage == other.inputUsage && outputUsage == other.outputUsage && totalUsage == other.totalUsage && countTraces == other.countTraces && countObservations == other.countObservations && totalCost == other.totalCost; - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.model, this.inputUsage, this.outputUsage, this.totalUsage, this.countTraces, this.countObservations, this.totalCost); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static InputUsageStage builder() { - return new Builder(); - } - - public interface InputUsageStage { - OutputUsageStage inputUsage(int inputUsage); - - Builder from(UsageByModel other); - } - - public interface OutputUsageStage { - TotalUsageStage outputUsage(int outputUsage); - } - - public interface TotalUsageStage { - CountTracesStage totalUsage(int totalUsage); - } - - public interface CountTracesStage { - CountObservationsStage countTraces(int countTraces); - } - - public interface CountObservationsStage { - TotalCostStage countObservations(int countObservations); - } - - public interface TotalCostStage { - _FinalStage totalCost(double totalCost); - } - - public interface _FinalStage { - UsageByModel build(); - - _FinalStage model(Optional model); - - _FinalStage model(String model); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder implements InputUsageStage, OutputUsageStage, TotalUsageStage, CountTracesStage, CountObservationsStage, TotalCostStage, _FinalStage { - private int inputUsage; - - private int outputUsage; - - private int totalUsage; - - private int countTraces; - - private int countObservations; - - private double totalCost; - - private Optional model = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() { - } - - @java.lang.Override - public Builder from(UsageByModel other) { - model(other.getModel()); - inputUsage(other.getInputUsage()); - outputUsage(other.getOutputUsage()); - totalUsage(other.getTotalUsage()); - countTraces(other.getCountTraces()); - countObservations(other.getCountObservations()); - totalCost(other.getTotalCost()); - return this; - } - - /** - *

Total number of generation input units (e.g. tokens)

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("inputUsage") - public OutputUsageStage inputUsage(int inputUsage) { - this.inputUsage = inputUsage; - return this; - } - - /** - *

Total number of generation output units (e.g. tokens)

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("outputUsage") - public TotalUsageStage outputUsage(int outputUsage) { - this.outputUsage = outputUsage; - return this; - } - - /** - *

Total number of generation total units (e.g. tokens)

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("totalUsage") - public CountTracesStage totalUsage(int totalUsage) { - this.totalUsage = totalUsage; - return this; - } - - @java.lang.Override - @JsonSetter("countTraces") - public CountObservationsStage countTraces(int countTraces) { - this.countTraces = countTraces; - return this; - } - - @java.lang.Override - @JsonSetter("countObservations") - public TotalCostStage countObservations(int countObservations) { - this.countObservations = countObservations; - return this; - } - - /** - *

Total model cost in USD

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("totalCost") - public _FinalStage totalCost(double totalCost) { - this.totalCost = totalCost; - return this; - } - - @java.lang.Override - public _FinalStage model(String model) { - this.model = Optional.ofNullable(model); - return this; - } - - @java.lang.Override - @JsonSetter( - value = "model", - nulls = Nulls.SKIP - ) - public _FinalStage model(Optional model) { - this.model = model; - return this; - } - - @java.lang.Override - public UsageByModel build() { - return new UsageByModel(model, inputUsage, outputUsage, totalUsage, countTraces, countObservations, totalCost, additionalProperties); - } - } -} diff --git a/src/main/java/com/langfuse/client/resources/observations/requests/GetObservationsRequest.java b/src/main/java/com/langfuse/client/resources/observations/requests/GetObservationsRequest.java index bc177f4..6c2d396 100644 --- a/src/main/java/com/langfuse/client/resources/observations/requests/GetObservationsRequest.java +++ b/src/main/java/com/langfuse/client/resources/observations/requests/GetObservationsRequest.java @@ -120,7 +120,7 @@ public Optional getEnvironment() { } /** - * @return Retrieve only observations with a start_time or or after this datetime (ISO 8601). + * @return Retrieve only observations with a start_time on or after this datetime (ISO 8601). */ @JsonProperty("fromStartTime") public Optional getFromStartTime() { diff --git a/src/main/java/com/langfuse/client/resources/organizations/OrganizationsClient.java b/src/main/java/com/langfuse/client/resources/organizations/OrganizationsClient.java new file mode 100644 index 0000000..83f9bab --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/organizations/OrganizationsClient.java @@ -0,0 +1,316 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.organizations; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.langfuse.client.core.ClientOptions; +import com.langfuse.client.core.LangfuseClientApiException; +import com.langfuse.client.core.LangfuseClientException; +import com.langfuse.client.core.MediaTypes; +import com.langfuse.client.core.ObjectMappers; +import com.langfuse.client.core.RequestOptions; +import java.io.IOException; +import java.lang.Object; +import java.lang.String; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import com.langfuse.client.resources.commons.errors.AccessDeniedError; +import com.langfuse.client.resources.commons.errors.Error; +import com.langfuse.client.resources.commons.errors.MethodNotAllowedError; +import com.langfuse.client.resources.commons.errors.NotFoundError; +import com.langfuse.client.resources.commons.errors.UnauthorizedError; +import com.langfuse.client.resources.organizations.types.MembershipRequest; +import com.langfuse.client.resources.organizations.types.MembershipResponse; +import com.langfuse.client.resources.organizations.types.MembershipsResponse; +import com.langfuse.client.resources.organizations.types.OrganizationProjectsResponse; + +public class OrganizationsClient { + protected final ClientOptions clientOptions; + + public OrganizationsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get all memberships for the organization associated with the API key (requires organization-scoped API key) + */ + public MembershipsResponse getOrganizationMemberships() { + return getOrganizationMemberships(null); + } + + /** + * Get all memberships for the organization associated with the API key (requires organization-scoped API key) + */ + public MembershipsResponse getOrganizationMemberships(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public") + .addPathSegments("organizations/memberships") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MembershipsResponse.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + + /** + * Create or update a membership for the organization associated with the API key (requires organization-scoped API key) + */ + public MembershipResponse updateOrganizationMembership(MembershipRequest request) { + return updateOrganizationMembership(request,null); + } + + /** + * Create or update a membership for the organization associated with the API key (requires organization-scoped API key) + */ + public MembershipResponse updateOrganizationMembership(MembershipRequest request, + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public") + .addPathSegments("organizations/memberships") + .build(); + RequestBody body; + try { + body = RequestBody.create(ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } + catch(JsonProcessingException e) { + throw new LangfuseClientException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", 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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MembershipResponse.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + + /** + * Get all memberships for a specific project (requires organization-scoped API key) + */ + public MembershipsResponse getProjectMemberships(String projectId) { + return getProjectMemberships(projectId,null); + } + + /** + * Get all memberships for a specific project (requires organization-scoped API key) + */ + public MembershipsResponse getProjectMemberships(String projectId, + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public") + .addPathSegments("projects") + .addPathSegment(projectId) + .addPathSegments("memberships") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MembershipsResponse.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + + /** + * Create or update a membership for a specific project (requires organization-scoped API key). The user must already be a member of the organization. + */ + public MembershipResponse updateProjectMembership(String projectId, MembershipRequest request) { + return updateProjectMembership(projectId,request,null); + } + + /** + * Create or update a membership for a specific project (requires organization-scoped API key). The user must already be a member of the organization. + */ + public MembershipResponse updateProjectMembership(String projectId, MembershipRequest request, + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public") + .addPathSegments("projects") + .addPathSegment(projectId) + .addPathSegments("memberships") + .build(); + RequestBody body; + try { + body = RequestBody.create(ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } + catch(JsonProcessingException e) { + throw new LangfuseClientException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", 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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MembershipResponse.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + + /** + * Get all projects for the organization associated with the API key (requires organization-scoped API key) + */ + public OrganizationProjectsResponse getOrganizationProjects() { + return getOrganizationProjects(null); + } + + /** + * Get all projects for the organization associated with the API key (requires organization-scoped API key) + */ + public OrganizationProjectsResponse getOrganizationProjects(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public") + .addPathSegments("organizations/projects") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), OrganizationProjectsResponse.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/organizations/types/MembershipRequest.java b/src/main/java/com/langfuse/client/resources/organizations/types/MembershipRequest.java new file mode 100644 index 0000000..e7f113f --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/organizations/types/MembershipRequest.java @@ -0,0 +1,133 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.organizations.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = MembershipRequest.Builder.class +) +public final class MembershipRequest { + private final String userId; + + private final MembershipRole role; + + private final Map additionalProperties; + + private MembershipRequest(String userId, MembershipRole role, + Map additionalProperties) { + this.userId = userId; + this.role = role; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("userId") + public String getUserId() { + return userId; + } + + @JsonProperty("role") + public MembershipRole getRole() { + return role; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof MembershipRequest && equalTo((MembershipRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(MembershipRequest other) { + return userId.equals(other.userId) && role.equals(other.role); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.userId, this.role); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static UserIdStage builder() { + return new Builder(); + } + + public interface UserIdStage { + RoleStage userId(@NotNull String userId); + + Builder from(MembershipRequest other); + } + + public interface RoleStage { + _FinalStage role(@NotNull MembershipRole role); + } + + public interface _FinalStage { + MembershipRequest build(); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements UserIdStage, RoleStage, _FinalStage { + private String userId; + + private MembershipRole role; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(MembershipRequest other) { + userId(other.getUserId()); + role(other.getRole()); + return this; + } + + @java.lang.Override + @JsonSetter("userId") + public RoleStage userId(@NotNull String userId) { + this.userId = Objects.requireNonNull(userId, "userId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("role") + public _FinalStage role(@NotNull MembershipRole role) { + this.role = Objects.requireNonNull(role, "role must not be null"); + return this; + } + + @java.lang.Override + public MembershipRequest build() { + return new MembershipRequest(userId, role, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/organizations/types/MembershipResponse.java b/src/main/java/com/langfuse/client/resources/organizations/types/MembershipResponse.java new file mode 100644 index 0000000..6270b99 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/organizations/types/MembershipResponse.java @@ -0,0 +1,177 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.organizations.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = MembershipResponse.Builder.class +) +public final class MembershipResponse { + private final String userId; + + private final MembershipRole role; + + private final String email; + + private final String name; + + private final Map additionalProperties; + + private MembershipResponse(String userId, MembershipRole role, String email, String name, + Map additionalProperties) { + this.userId = userId; + this.role = role; + this.email = email; + this.name = name; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("userId") + public String getUserId() { + return userId; + } + + @JsonProperty("role") + public MembershipRole getRole() { + return role; + } + + @JsonProperty("email") + public String getEmail() { + return email; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof MembershipResponse && equalTo((MembershipResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(MembershipResponse other) { + return userId.equals(other.userId) && role.equals(other.role) && email.equals(other.email) && name.equals(other.name); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.userId, this.role, this.email, this.name); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static UserIdStage builder() { + return new Builder(); + } + + public interface UserIdStage { + RoleStage userId(@NotNull String userId); + + Builder from(MembershipResponse other); + } + + public interface RoleStage { + EmailStage role(@NotNull MembershipRole role); + } + + public interface EmailStage { + NameStage email(@NotNull String email); + } + + public interface NameStage { + _FinalStage name(@NotNull String name); + } + + public interface _FinalStage { + MembershipResponse build(); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements UserIdStage, RoleStage, EmailStage, NameStage, _FinalStage { + private String userId; + + private MembershipRole role; + + private String email; + + private String name; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(MembershipResponse other) { + userId(other.getUserId()); + role(other.getRole()); + email(other.getEmail()); + name(other.getName()); + return this; + } + + @java.lang.Override + @JsonSetter("userId") + public RoleStage userId(@NotNull String userId) { + this.userId = Objects.requireNonNull(userId, "userId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("role") + public EmailStage role(@NotNull MembershipRole role) { + this.role = Objects.requireNonNull(role, "role must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("email") + public NameStage email(@NotNull String email) { + this.email = Objects.requireNonNull(email, "email must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public _FinalStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + public MembershipResponse build() { + return new MembershipResponse(userId, role, email, name, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/organizations/types/MembershipRole.java b/src/main/java/com/langfuse/client/resources/organizations/types/MembershipRole.java new file mode 100644 index 0000000..53f2c79 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/organizations/types/MembershipRole.java @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.organizations.types; + +import com.fasterxml.jackson.annotation.JsonValue; +import java.lang.String; + +public enum MembershipRole { + OWNER("OWNER"), + + ADMIN("ADMIN"), + + MEMBER("MEMBER"), + + VIEWER("VIEWER"); + + private final String value; + + MembershipRole(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/langfuse/client/resources/organizations/types/MembershipsResponse.java b/src/main/java/com/langfuse/client/resources/organizations/types/MembershipsResponse.java new file mode 100644 index 0000000..e8c8bee --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/organizations/types/MembershipsResponse.java @@ -0,0 +1,114 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.organizations.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +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 = MembershipsResponse.Builder.class +) +public final class MembershipsResponse { + private final List memberships; + + private final Map additionalProperties; + + private MembershipsResponse(List memberships, + Map additionalProperties) { + this.memberships = memberships; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("memberships") + public List getMemberships() { + return memberships; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof MembershipsResponse && equalTo((MembershipsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(MembershipsResponse other) { + return memberships.equals(other.memberships); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.memberships); + } + + @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 List memberships = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + public Builder from(MembershipsResponse other) { + memberships(other.getMemberships()); + return this; + } + + @JsonSetter( + value = "memberships", + nulls = Nulls.SKIP + ) + public Builder memberships(List memberships) { + this.memberships.clear(); + this.memberships.addAll(memberships); + return this; + } + + public Builder addMemberships(MembershipResponse memberships) { + this.memberships.add(memberships); + return this; + } + + public Builder addAllMemberships(List memberships) { + this.memberships.addAll(memberships); + return this; + } + + public MembershipsResponse build() { + return new MembershipsResponse(memberships, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/organizations/types/OrganizationProject.java b/src/main/java/com/langfuse/client/resources/organizations/types/OrganizationProject.java new file mode 100644 index 0000000..1f4e181 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/organizations/types/OrganizationProject.java @@ -0,0 +1,212 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.organizations.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.time.OffsetDateTime; +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 = OrganizationProject.Builder.class +) +public final class OrganizationProject { + private final String id; + + private final String name; + + private final Optional> metadata; + + private final OffsetDateTime createdAt; + + private final OffsetDateTime updatedAt; + + private final Map additionalProperties; + + private OrganizationProject(String id, String name, Optional> metadata, + OffsetDateTime createdAt, OffsetDateTime updatedAt, + Map additionalProperties) { + this.id = id; + this.name = name; + this.metadata = metadata; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("metadata") + public Optional> getMetadata() { + return metadata; + } + + @JsonProperty("createdAt") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("updatedAt") + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof OrganizationProject && equalTo((OrganizationProject) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(OrganizationProject other) { + return id.equals(other.id) && name.equals(other.name) && metadata.equals(other.metadata) && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.name, this.metadata, this.createdAt, this.updatedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + NameStage id(@NotNull String id); + + Builder from(OrganizationProject other); + } + + public interface NameStage { + CreatedAtStage name(@NotNull String name); + } + + public interface CreatedAtStage { + UpdatedAtStage createdAt(@NotNull OffsetDateTime createdAt); + } + + public interface UpdatedAtStage { + _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt); + } + + public interface _FinalStage { + OrganizationProject build(); + + _FinalStage metadata(Optional> metadata); + + _FinalStage metadata(Map metadata); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements IdStage, NameStage, CreatedAtStage, UpdatedAtStage, _FinalStage { + private String id; + + private String name; + + private OffsetDateTime createdAt; + + private OffsetDateTime updatedAt; + + private Optional> metadata = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(OrganizationProject other) { + id(other.getId()); + name(other.getName()); + metadata(other.getMetadata()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public NameStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public CreatedAtStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("createdAt") + public UpdatedAtStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("updatedAt") + public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { + this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage metadata(Map metadata) { + this.metadata = Optional.ofNullable(metadata); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "metadata", + nulls = Nulls.SKIP + ) + public _FinalStage metadata(Optional> metadata) { + this.metadata = metadata; + return this; + } + + @java.lang.Override + public OrganizationProject build() { + return new OrganizationProject(id, name, metadata, createdAt, updatedAt, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/organizations/types/OrganizationProjectsResponse.java b/src/main/java/com/langfuse/client/resources/organizations/types/OrganizationProjectsResponse.java new file mode 100644 index 0000000..9ac5585 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/organizations/types/OrganizationProjectsResponse.java @@ -0,0 +1,114 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.organizations.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +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 = OrganizationProjectsResponse.Builder.class +) +public final class OrganizationProjectsResponse { + private final List projects; + + private final Map additionalProperties; + + private OrganizationProjectsResponse(List projects, + Map additionalProperties) { + this.projects = projects; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("projects") + public List getProjects() { + return projects; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof OrganizationProjectsResponse && equalTo((OrganizationProjectsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(OrganizationProjectsResponse other) { + return projects.equals(other.projects); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.projects); + } + + @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 List projects = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + public Builder from(OrganizationProjectsResponse other) { + projects(other.getProjects()); + return this; + } + + @JsonSetter( + value = "projects", + nulls = Nulls.SKIP + ) + public Builder projects(List projects) { + this.projects.clear(); + this.projects.addAll(projects); + return this; + } + + public Builder addProjects(OrganizationProject projects) { + this.projects.add(projects); + return this; + } + + public Builder addAllProjects(List projects) { + this.projects.addAll(projects); + return this; + } + + public OrganizationProjectsResponse build() { + return new OrganizationProjectsResponse(projects, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/projects/ProjectsClient.java b/src/main/java/com/langfuse/client/resources/projects/ProjectsClient.java index c0a44a8..f774c40 100644 --- a/src/main/java/com/langfuse/client/resources/projects/ProjectsClient.java +++ b/src/main/java/com/langfuse/client/resources/projects/ProjectsClient.java @@ -8,6 +8,7 @@ import com.langfuse.client.core.ClientOptions; import com.langfuse.client.core.LangfuseClientApiException; import com.langfuse.client.core.LangfuseClientException; +import com.langfuse.client.core.MediaTypes; import com.langfuse.client.core.ObjectMappers; import com.langfuse.client.core.RequestOptions; import java.io.IOException; @@ -17,6 +18,7 @@ import okhttp3.HttpUrl; import okhttp3.OkHttpClient; import okhttp3.Request; +import okhttp3.RequestBody; import okhttp3.Response; import okhttp3.ResponseBody; import com.langfuse.client.resources.commons.errors.AccessDeniedError; @@ -24,6 +26,14 @@ import com.langfuse.client.resources.commons.errors.MethodNotAllowedError; import com.langfuse.client.resources.commons.errors.NotFoundError; import com.langfuse.client.resources.commons.errors.UnauthorizedError; +import com.langfuse.client.resources.projects.requests.CreateApiKeyRequest; +import com.langfuse.client.resources.projects.requests.CreateProjectRequest; +import com.langfuse.client.resources.projects.requests.UpdateProjectRequest; +import com.langfuse.client.resources.projects.types.ApiKeyDeletionResponse; +import com.langfuse.client.resources.projects.types.ApiKeyList; +import com.langfuse.client.resources.projects.types.ApiKeyResponse; +import com.langfuse.client.resources.projects.types.Project; +import com.langfuse.client.resources.projects.types.ProjectDeletionResponse; import com.langfuse.client.resources.projects.types.Projects; public class ProjectsClient { @@ -83,4 +93,350 @@ public Projects get(RequestOptions requestOptions) { throw new LangfuseClientException("Network error executing HTTP request", e); } } + + /** + * Create a new project (requires organization-scoped API key) + */ + public Project create(CreateProjectRequest request) { + return create(request,null); + } + + /** + * Create a new project (requires organization-scoped API key) + */ + public Project create(CreateProjectRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public") + .addPathSegments("projects") + .build(); + RequestBody body; + try { + body = RequestBody.create(ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } + catch(JsonProcessingException e) { + throw new LangfuseClientException("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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Project.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + + /** + * Update a project by ID (requires organization-scoped API key). + */ + public Project update(String projectId, UpdateProjectRequest request) { + return update(projectId,request,null); + } + + /** + * Update a project by ID (requires organization-scoped API key). + */ + public Project update(String projectId, UpdateProjectRequest request, + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public") + .addPathSegments("projects") + .addPathSegment(projectId) + .build(); + RequestBody body; + try { + body = RequestBody.create(ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } + catch(JsonProcessingException e) { + throw new LangfuseClientException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", 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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Project.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + + /** + * Delete a project by ID (requires organization-scoped API key). Project deletion is processed asynchronously. + */ + public ProjectDeletionResponse delete(String projectId) { + return delete(projectId,null); + } + + /** + * Delete a project by ID (requires organization-scoped API key). Project deletion is processed asynchronously. + */ + public ProjectDeletionResponse delete(String projectId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public") + .addPathSegments("projects") + .addPathSegment(projectId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ProjectDeletionResponse.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + + /** + * Get all API keys for a project (requires organization-scoped API key) + */ + public ApiKeyList getApiKeys(String projectId) { + return getApiKeys(projectId,null); + } + + /** + * Get all API keys for a project (requires organization-scoped API key) + */ + public ApiKeyList getApiKeys(String projectId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public") + .addPathSegments("projects") + .addPathSegment(projectId) + .addPathSegments("apiKeys") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ApiKeyList.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + + /** + * Create a new API key for a project (requires organization-scoped API key) + */ + public ApiKeyResponse createApiKey(String projectId) { + return createApiKey(projectId,CreateApiKeyRequest.builder().build()); + } + + /** + * Create a new API key for a project (requires organization-scoped API key) + */ + public ApiKeyResponse createApiKey(String projectId, CreateApiKeyRequest request) { + return createApiKey(projectId,request,null); + } + + /** + * Create a new API key for a project (requires organization-scoped API key) + */ + public ApiKeyResponse createApiKey(String projectId, CreateApiKeyRequest request, + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public") + .addPathSegments("projects") + .addPathSegment(projectId) + .addPathSegments("apiKeys") + .build(); + RequestBody body; + try { + body = RequestBody.create(ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } + catch(JsonProcessingException e) { + throw new LangfuseClientException("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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ApiKeyResponse.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + + /** + * Delete an API key for a project (requires organization-scoped API key) + */ + public ApiKeyDeletionResponse deleteApiKey(String projectId, String apiKeyId) { + return deleteApiKey(projectId,apiKeyId,null); + } + + /** + * Delete an API key for a project (requires organization-scoped API key) + */ + public ApiKeyDeletionResponse deleteApiKey(String projectId, String apiKeyId, + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public") + .addPathSegments("projects") + .addPathSegment(projectId) + .addPathSegments("apiKeys") + .addPathSegment(apiKeyId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ApiKeyDeletionResponse.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } } diff --git a/src/main/java/com/langfuse/client/resources/projects/requests/CreateApiKeyRequest.java b/src/main/java/com/langfuse/client/resources/projects/requests/CreateApiKeyRequest.java new file mode 100644 index 0000000..0ce82e7 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/projects/requests/CreateApiKeyRequest.java @@ -0,0 +1,109 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.projects.requests; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = CreateApiKeyRequest.Builder.class +) +public final class CreateApiKeyRequest { + private final Optional note; + + private final Map additionalProperties; + + private CreateApiKeyRequest(Optional note, Map additionalProperties) { + this.note = note; + this.additionalProperties = additionalProperties; + } + + /** + * @return Optional note for the API key + */ + @JsonProperty("note") + public Optional getNote() { + return note; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateApiKeyRequest && equalTo((CreateApiKeyRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateApiKeyRequest other) { + return note.equals(other.note); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.note); + } + + @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 note = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + public Builder from(CreateApiKeyRequest other) { + note(other.getNote()); + return this; + } + + @JsonSetter( + value = "note", + nulls = Nulls.SKIP + ) + public Builder note(Optional note) { + this.note = note; + return this; + } + + public Builder note(String note) { + this.note = Optional.ofNullable(note); + return this; + } + + public CreateApiKeyRequest build() { + return new CreateApiKeyRequest(note, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/projects/requests/CreateProjectRequest.java b/src/main/java/com/langfuse/client/resources/projects/requests/CreateProjectRequest.java new file mode 100644 index 0000000..0c8da05 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/projects/requests/CreateProjectRequest.java @@ -0,0 +1,180 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.projects.requests; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +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 = CreateProjectRequest.Builder.class +) +public final class CreateProjectRequest { + private final String name; + + private final Optional> metadata; + + private final int retention; + + private final Map additionalProperties; + + private CreateProjectRequest(String name, Optional> metadata, int retention, + Map additionalProperties) { + this.name = name; + this.metadata = metadata; + this.retention = retention; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return Optional metadata for the project + */ + @JsonProperty("metadata") + public Optional> getMetadata() { + return metadata; + } + + /** + * @return Number of days to retain data. Must be 0 or at least 3 days. Requires data-retention entitlement for non-zero values. Optional. + */ + @JsonProperty("retention") + public int getRetention() { + return retention; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateProjectRequest && equalTo((CreateProjectRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateProjectRequest other) { + return name.equals(other.name) && metadata.equals(other.metadata) && retention == other.retention; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.name, this.metadata, this.retention); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + RetentionStage name(@NotNull String name); + + Builder from(CreateProjectRequest other); + } + + public interface RetentionStage { + _FinalStage retention(int retention); + } + + public interface _FinalStage { + CreateProjectRequest build(); + + _FinalStage metadata(Optional> metadata); + + _FinalStage metadata(Map metadata); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements NameStage, RetentionStage, _FinalStage { + private String name; + + private int retention; + + private Optional> metadata = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(CreateProjectRequest other) { + name(other.getName()); + metadata(other.getMetadata()); + retention(other.getRetention()); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public RetentionStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + /** + *

Number of days to retain data. Must be 0 or at least 3 days. Requires data-retention entitlement for non-zero values. Optional.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("retention") + public _FinalStage retention(int retention) { + this.retention = retention; + return this; + } + + /** + *

Optional metadata for the project

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage metadata(Map metadata) { + this.metadata = Optional.ofNullable(metadata); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "metadata", + nulls = Nulls.SKIP + ) + public _FinalStage metadata(Optional> metadata) { + this.metadata = metadata; + return this; + } + + @java.lang.Override + public CreateProjectRequest build() { + return new CreateProjectRequest(name, metadata, retention, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/projects/requests/UpdateProjectRequest.java b/src/main/java/com/langfuse/client/resources/projects/requests/UpdateProjectRequest.java new file mode 100644 index 0000000..48514a8 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/projects/requests/UpdateProjectRequest.java @@ -0,0 +1,180 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.projects.requests; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +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 = UpdateProjectRequest.Builder.class +) +public final class UpdateProjectRequest { + private final String name; + + private final Optional> metadata; + + private final int retention; + + private final Map additionalProperties; + + private UpdateProjectRequest(String name, Optional> metadata, int retention, + Map additionalProperties) { + this.name = name; + this.metadata = metadata; + this.retention = retention; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return Optional metadata for the project + */ + @JsonProperty("metadata") + public Optional> getMetadata() { + return metadata; + } + + /** + * @return Number of days to retain data. Must be 0 or at least 3 days. Requires data-retention entitlement for non-zero values. Optional. + */ + @JsonProperty("retention") + public int getRetention() { + return retention; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateProjectRequest && equalTo((UpdateProjectRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateProjectRequest other) { + return name.equals(other.name) && metadata.equals(other.metadata) && retention == other.retention; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.name, this.metadata, this.retention); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + RetentionStage name(@NotNull String name); + + Builder from(UpdateProjectRequest other); + } + + public interface RetentionStage { + _FinalStage retention(int retention); + } + + public interface _FinalStage { + UpdateProjectRequest build(); + + _FinalStage metadata(Optional> metadata); + + _FinalStage metadata(Map metadata); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements NameStage, RetentionStage, _FinalStage { + private String name; + + private int retention; + + private Optional> metadata = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(UpdateProjectRequest other) { + name(other.getName()); + metadata(other.getMetadata()); + retention(other.getRetention()); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public RetentionStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + /** + *

Number of days to retain data. Must be 0 or at least 3 days. Requires data-retention entitlement for non-zero values. Optional.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("retention") + public _FinalStage retention(int retention) { + this.retention = retention; + return this; + } + + /** + *

Optional metadata for the project

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage metadata(Map metadata) { + this.metadata = Optional.ofNullable(metadata); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "metadata", + nulls = Nulls.SKIP + ) + public _FinalStage metadata(Optional> metadata) { + this.metadata = metadata; + return this; + } + + @java.lang.Override + public UpdateProjectRequest build() { + return new UpdateProjectRequest(name, metadata, retention, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/projects/types/ApiKeyDeletionResponse.java b/src/main/java/com/langfuse/client/resources/projects/types/ApiKeyDeletionResponse.java new file mode 100644 index 0000000..ead19fe --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/projects/types/ApiKeyDeletionResponse.java @@ -0,0 +1,109 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.projects.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = ApiKeyDeletionResponse.Builder.class +) +public final class ApiKeyDeletionResponse { + private final boolean success; + + private final Map additionalProperties; + + private ApiKeyDeletionResponse(boolean success, Map additionalProperties) { + this.success = success; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("success") + public boolean getSuccess() { + return success; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ApiKeyDeletionResponse && equalTo((ApiKeyDeletionResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ApiKeyDeletionResponse other) { + return success == other.success; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.success); + } + + @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(ApiKeyDeletionResponse other); + } + + public interface _FinalStage { + ApiKeyDeletionResponse build(); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements SuccessStage, _FinalStage { + private boolean success; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(ApiKeyDeletionResponse other) { + success(other.getSuccess()); + return this; + } + + @java.lang.Override + @JsonSetter("success") + public _FinalStage success(boolean success) { + this.success = success; + return this; + } + + @java.lang.Override + public ApiKeyDeletionResponse build() { + return new ApiKeyDeletionResponse(success, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/projects/types/ApiKeyList.java b/src/main/java/com/langfuse/client/resources/projects/types/ApiKeyList.java new file mode 100644 index 0000000..9812db6 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/projects/types/ApiKeyList.java @@ -0,0 +1,113 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.projects.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +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 = ApiKeyList.Builder.class +) +public final class ApiKeyList { + private final List apiKeys; + + private final Map additionalProperties; + + private ApiKeyList(List apiKeys, Map additionalProperties) { + this.apiKeys = apiKeys; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("apiKeys") + public List getApiKeys() { + return apiKeys; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ApiKeyList && equalTo((ApiKeyList) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ApiKeyList other) { + return apiKeys.equals(other.apiKeys); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.apiKeys); + } + + @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 List apiKeys = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + public Builder from(ApiKeyList other) { + apiKeys(other.getApiKeys()); + return this; + } + + @JsonSetter( + value = "apiKeys", + nulls = Nulls.SKIP + ) + public Builder apiKeys(List apiKeys) { + this.apiKeys.clear(); + this.apiKeys.addAll(apiKeys); + return this; + } + + public Builder addApiKeys(ApiKeySummary apiKeys) { + this.apiKeys.add(apiKeys); + return this; + } + + public Builder addAllApiKeys(List apiKeys) { + this.apiKeys.addAll(apiKeys); + return this; + } + + public ApiKeyList build() { + return new ApiKeyList(apiKeys, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/projects/types/ApiKeyResponse.java b/src/main/java/com/langfuse/client/resources/projects/types/ApiKeyResponse.java new file mode 100644 index 0000000..574576a --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/projects/types/ApiKeyResponse.java @@ -0,0 +1,233 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.projects.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.time.OffsetDateTime; +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 = ApiKeyResponse.Builder.class +) +public final class ApiKeyResponse { + private final String id; + + private final OffsetDateTime createdAt; + + private final String publicKey; + + private final String secretKey; + + private final String displaySecretKey; + + private final Optional note; + + private final Map additionalProperties; + + private ApiKeyResponse(String id, OffsetDateTime createdAt, String publicKey, String secretKey, + String displaySecretKey, Optional note, Map additionalProperties) { + this.id = id; + this.createdAt = createdAt; + this.publicKey = publicKey; + this.secretKey = secretKey; + this.displaySecretKey = displaySecretKey; + this.note = note; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("createdAt") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("publicKey") + public String getPublicKey() { + return publicKey; + } + + @JsonProperty("secretKey") + public String getSecretKey() { + return secretKey; + } + + @JsonProperty("displaySecretKey") + public String getDisplaySecretKey() { + return displaySecretKey; + } + + @JsonProperty("note") + public Optional getNote() { + return note; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ApiKeyResponse && equalTo((ApiKeyResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ApiKeyResponse other) { + return id.equals(other.id) && createdAt.equals(other.createdAt) && publicKey.equals(other.publicKey) && secretKey.equals(other.secretKey) && displaySecretKey.equals(other.displaySecretKey) && note.equals(other.note); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.createdAt, this.publicKey, this.secretKey, this.displaySecretKey, this.note); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + CreatedAtStage id(@NotNull String id); + + Builder from(ApiKeyResponse other); + } + + public interface CreatedAtStage { + PublicKeyStage createdAt(@NotNull OffsetDateTime createdAt); + } + + public interface PublicKeyStage { + SecretKeyStage publicKey(@NotNull String publicKey); + } + + public interface SecretKeyStage { + DisplaySecretKeyStage secretKey(@NotNull String secretKey); + } + + public interface DisplaySecretKeyStage { + _FinalStage displaySecretKey(@NotNull String displaySecretKey); + } + + public interface _FinalStage { + ApiKeyResponse build(); + + _FinalStage note(Optional note); + + _FinalStage note(String note); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements IdStage, CreatedAtStage, PublicKeyStage, SecretKeyStage, DisplaySecretKeyStage, _FinalStage { + private String id; + + private OffsetDateTime createdAt; + + private String publicKey; + + private String secretKey; + + private String displaySecretKey; + + private Optional note = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(ApiKeyResponse other) { + id(other.getId()); + createdAt(other.getCreatedAt()); + publicKey(other.getPublicKey()); + secretKey(other.getSecretKey()); + displaySecretKey(other.getDisplaySecretKey()); + note(other.getNote()); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public CreatedAtStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("createdAt") + public PublicKeyStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("publicKey") + public SecretKeyStage publicKey(@NotNull String publicKey) { + this.publicKey = Objects.requireNonNull(publicKey, "publicKey must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("secretKey") + public DisplaySecretKeyStage secretKey(@NotNull String secretKey) { + this.secretKey = Objects.requireNonNull(secretKey, "secretKey must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("displaySecretKey") + public _FinalStage displaySecretKey(@NotNull String displaySecretKey) { + this.displaySecretKey = Objects.requireNonNull(displaySecretKey, "displaySecretKey must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage note(String note) { + this.note = Optional.ofNullable(note); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "note", + nulls = Nulls.SKIP + ) + public _FinalStage note(Optional note) { + this.note = note; + return this; + } + + @java.lang.Override + public ApiKeyResponse build() { + return new ApiKeyResponse(id, createdAt, publicKey, secretKey, displaySecretKey, note, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/projects/types/ApiKeySummary.java b/src/main/java/com/langfuse/client/resources/projects/types/ApiKeySummary.java new file mode 100644 index 0000000..22f9c30 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/projects/types/ApiKeySummary.java @@ -0,0 +1,274 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.projects.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.time.OffsetDateTime; +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 = ApiKeySummary.Builder.class +) +public final class ApiKeySummary { + private final String id; + + private final OffsetDateTime createdAt; + + private final Optional expiresAt; + + private final Optional lastUsedAt; + + private final Optional note; + + private final String publicKey; + + private final String displaySecretKey; + + private final Map additionalProperties; + + private ApiKeySummary(String id, OffsetDateTime createdAt, Optional expiresAt, + Optional lastUsedAt, Optional note, String publicKey, + String displaySecretKey, Map additionalProperties) { + this.id = id; + this.createdAt = createdAt; + this.expiresAt = expiresAt; + this.lastUsedAt = lastUsedAt; + this.note = note; + this.publicKey = publicKey; + this.displaySecretKey = displaySecretKey; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("createdAt") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("expiresAt") + public Optional getExpiresAt() { + return expiresAt; + } + + @JsonProperty("lastUsedAt") + public Optional getLastUsedAt() { + return lastUsedAt; + } + + @JsonProperty("note") + public Optional getNote() { + return note; + } + + @JsonProperty("publicKey") + public String getPublicKey() { + return publicKey; + } + + @JsonProperty("displaySecretKey") + public String getDisplaySecretKey() { + return displaySecretKey; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ApiKeySummary && equalTo((ApiKeySummary) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ApiKeySummary other) { + return id.equals(other.id) && createdAt.equals(other.createdAt) && expiresAt.equals(other.expiresAt) && lastUsedAt.equals(other.lastUsedAt) && note.equals(other.note) && publicKey.equals(other.publicKey) && displaySecretKey.equals(other.displaySecretKey); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.createdAt, this.expiresAt, this.lastUsedAt, this.note, this.publicKey, this.displaySecretKey); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + CreatedAtStage id(@NotNull String id); + + Builder from(ApiKeySummary other); + } + + public interface CreatedAtStage { + PublicKeyStage createdAt(@NotNull OffsetDateTime createdAt); + } + + public interface PublicKeyStage { + DisplaySecretKeyStage publicKey(@NotNull String publicKey); + } + + public interface DisplaySecretKeyStage { + _FinalStage displaySecretKey(@NotNull String displaySecretKey); + } + + public interface _FinalStage { + ApiKeySummary build(); + + _FinalStage expiresAt(Optional expiresAt); + + _FinalStage expiresAt(OffsetDateTime expiresAt); + + _FinalStage lastUsedAt(Optional lastUsedAt); + + _FinalStage lastUsedAt(OffsetDateTime lastUsedAt); + + _FinalStage note(Optional note); + + _FinalStage note(String note); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements IdStage, CreatedAtStage, PublicKeyStage, DisplaySecretKeyStage, _FinalStage { + private String id; + + private OffsetDateTime createdAt; + + private String publicKey; + + private String displaySecretKey; + + private Optional note = Optional.empty(); + + private Optional lastUsedAt = Optional.empty(); + + private Optional expiresAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(ApiKeySummary other) { + id(other.getId()); + createdAt(other.getCreatedAt()); + expiresAt(other.getExpiresAt()); + lastUsedAt(other.getLastUsedAt()); + note(other.getNote()); + publicKey(other.getPublicKey()); + displaySecretKey(other.getDisplaySecretKey()); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public CreatedAtStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("createdAt") + public PublicKeyStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("publicKey") + public DisplaySecretKeyStage publicKey(@NotNull String publicKey) { + this.publicKey = Objects.requireNonNull(publicKey, "publicKey must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("displaySecretKey") + public _FinalStage displaySecretKey(@NotNull String displaySecretKey) { + this.displaySecretKey = Objects.requireNonNull(displaySecretKey, "displaySecretKey must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage note(String note) { + this.note = Optional.ofNullable(note); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "note", + nulls = Nulls.SKIP + ) + public _FinalStage note(Optional note) { + this.note = note; + return this; + } + + @java.lang.Override + public _FinalStage lastUsedAt(OffsetDateTime lastUsedAt) { + this.lastUsedAt = Optional.ofNullable(lastUsedAt); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "lastUsedAt", + nulls = Nulls.SKIP + ) + public _FinalStage lastUsedAt(Optional lastUsedAt) { + this.lastUsedAt = lastUsedAt; + return this; + } + + @java.lang.Override + public _FinalStage expiresAt(OffsetDateTime expiresAt) { + this.expiresAt = Optional.ofNullable(expiresAt); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "expiresAt", + nulls = Nulls.SKIP + ) + public _FinalStage expiresAt(Optional expiresAt) { + this.expiresAt = expiresAt; + return this; + } + + @java.lang.Override + public ApiKeySummary build() { + return new ApiKeySummary(id, createdAt, expiresAt, lastUsedAt, note, publicKey, displaySecretKey, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/projects/types/Project.java b/src/main/java/com/langfuse/client/resources/projects/types/Project.java index cd22c35..843ef4b 100644 --- a/src/main/java/com/langfuse/client/resources/projects/types/Project.java +++ b/src/main/java/com/langfuse/client/resources/projects/types/Project.java @@ -10,13 +10,17 @@ 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 com.langfuse.client.core.ObjectMappers; +import java.lang.Integer; import java.lang.Object; import java.lang.String; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; import java.util.Objects; +import java.util.Optional; import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @@ -28,11 +32,18 @@ public final class Project { private final String name; + private final Map metadata; + + private final Optional retentionDays; + private final Map additionalProperties; - private Project(String id, String name, Map additionalProperties) { + private Project(String id, String name, Map metadata, + Optional retentionDays, Map additionalProperties) { this.id = id; this.name = name; + this.metadata = metadata; + this.retentionDays = retentionDays; this.additionalProperties = additionalProperties; } @@ -46,6 +57,22 @@ public String getName() { return name; } + /** + * @return Metadata for the project + */ + @JsonProperty("metadata") + public Map getMetadata() { + return metadata; + } + + /** + * @return Number of days to retain data. Null or 0 means no retention. Omitted if no retention is configured. + */ + @JsonProperty("retentionDays") + public Optional getRetentionDays() { + return retentionDays; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -58,12 +85,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(Project other) { - return id.equals(other.id) && name.equals(other.name); + return id.equals(other.id) && name.equals(other.name) && metadata.equals(other.metadata) && retentionDays.equals(other.retentionDays); } @java.lang.Override public int hashCode() { - return Objects.hash(this.id, this.name); + return Objects.hash(this.id, this.name, this.metadata, this.retentionDays); } @java.lang.Override @@ -87,6 +114,16 @@ public interface NameStage { public interface _FinalStage { Project build(); + + _FinalStage metadata(Map metadata); + + _FinalStage putAllMetadata(Map metadata); + + _FinalStage metadata(String key, Object value); + + _FinalStage retentionDays(Optional retentionDays); + + _FinalStage retentionDays(Integer retentionDays); } @JsonIgnoreProperties( @@ -97,6 +134,10 @@ public static final class Builder implements IdStage, NameStage, _FinalStage { private String name; + private Optional retentionDays = Optional.empty(); + + private Map metadata = new LinkedHashMap<>(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -107,6 +148,8 @@ private Builder() { public Builder from(Project other) { id(other.getId()); name(other.getName()); + metadata(other.getMetadata()); + retentionDays(other.getRetentionDays()); return this; } @@ -124,9 +167,60 @@ public _FinalStage name(@NotNull String name) { return this; } + /** + *

Number of days to retain data. Null or 0 means no retention. Omitted if no retention is configured.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage retentionDays(Integer retentionDays) { + this.retentionDays = Optional.ofNullable(retentionDays); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "retentionDays", + nulls = Nulls.SKIP + ) + public _FinalStage retentionDays(Optional retentionDays) { + this.retentionDays = retentionDays; + return this; + } + + /** + *

Metadata for the project

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage metadata(String key, Object value) { + this.metadata.put(key, value); + return this; + } + + /** + *

Metadata for the project

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage putAllMetadata(Map metadata) { + this.metadata.putAll(metadata); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "metadata", + nulls = Nulls.SKIP + ) + public _FinalStage metadata(Map metadata) { + this.metadata.clear(); + this.metadata.putAll(metadata); + return this; + } + @java.lang.Override public Project build() { - return new Project(id, name, additionalProperties); + return new Project(id, name, metadata, retentionDays, additionalProperties); } } } diff --git a/src/main/java/com/langfuse/client/resources/projects/types/ProjectDeletionResponse.java b/src/main/java/com/langfuse/client/resources/projects/types/ProjectDeletionResponse.java new file mode 100644 index 0000000..d0ffece --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/projects/types/ProjectDeletionResponse.java @@ -0,0 +1,133 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.projects.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = ProjectDeletionResponse.Builder.class +) +public final class ProjectDeletionResponse { + private final boolean success; + + private final String message; + + private final Map additionalProperties; + + private ProjectDeletionResponse(boolean success, String message, + Map additionalProperties) { + this.success = success; + this.message = message; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("success") + public boolean getSuccess() { + return success; + } + + @JsonProperty("message") + public String getMessage() { + return message; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ProjectDeletionResponse && equalTo((ProjectDeletionResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ProjectDeletionResponse other) { + return success == other.success && message.equals(other.message); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.success, this.message); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SuccessStage builder() { + return new Builder(); + } + + public interface SuccessStage { + MessageStage success(boolean success); + + Builder from(ProjectDeletionResponse other); + } + + public interface MessageStage { + _FinalStage message(@NotNull String message); + } + + public interface _FinalStage { + ProjectDeletionResponse build(); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements SuccessStage, MessageStage, _FinalStage { + private boolean success; + + private String message; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(ProjectDeletionResponse other) { + success(other.getSuccess()); + message(other.getMessage()); + return this; + } + + @java.lang.Override + @JsonSetter("success") + public MessageStage success(boolean success) { + this.success = success; + return this; + } + + @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 ProjectDeletionResponse build() { + return new ProjectDeletionResponse(success, message, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/prompts/types/BasePrompt.java b/src/main/java/com/langfuse/client/resources/prompts/types/BasePrompt.java index ff7aa54..1961c41 100644 --- a/src/main/java/com/langfuse/client/resources/prompts/types/BasePrompt.java +++ b/src/main/java/com/langfuse/client/resources/prompts/types/BasePrompt.java @@ -40,16 +40,20 @@ public final class BasePrompt implements IBasePrompt { private final Optional commitMessage; + private final Optional> resolutionGraph; + private final Map additionalProperties; private BasePrompt(String name, int version, Object config, List labels, - List tags, Optional commitMessage, Map additionalProperties) { + List tags, Optional commitMessage, + Optional> resolutionGraph, Map additionalProperties) { this.name = name; this.version = version; this.config = config; this.labels = labels; this.tags = tags; this.commitMessage = commitMessage; + this.resolutionGraph = resolutionGraph; this.additionalProperties = additionalProperties; } @@ -98,6 +102,15 @@ public Optional getCommitMessage() { return commitMessage; } + /** + * @return The dependency resolution graph for the current prompt. Null if prompt has no dependencies. + */ + @JsonProperty("resolutionGraph") + @java.lang.Override + public Optional> getResolutionGraph() { + return resolutionGraph; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -110,12 +123,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(BasePrompt other) { - return name.equals(other.name) && version == other.version && config.equals(other.config) && labels.equals(other.labels) && tags.equals(other.tags) && commitMessage.equals(other.commitMessage); + return name.equals(other.name) && version == other.version && config.equals(other.config) && labels.equals(other.labels) && tags.equals(other.tags) && commitMessage.equals(other.commitMessage) && resolutionGraph.equals(other.resolutionGraph); } @java.lang.Override public int hashCode() { - return Objects.hash(this.name, this.version, this.config, this.labels, this.tags, this.commitMessage); + return Objects.hash(this.name, this.version, this.config, this.labels, this.tags, this.commitMessage, this.resolutionGraph); } @java.lang.Override @@ -159,6 +172,10 @@ public interface _FinalStage { _FinalStage commitMessage(Optional commitMessage); _FinalStage commitMessage(String commitMessage); + + _FinalStage resolutionGraph(Optional> resolutionGraph); + + _FinalStage resolutionGraph(Map resolutionGraph); } @JsonIgnoreProperties( @@ -171,6 +188,8 @@ public static final class Builder implements NameStage, VersionStage, ConfigStag private Object config; + private Optional> resolutionGraph = Optional.empty(); + private Optional commitMessage = Optional.empty(); private List tags = new ArrayList<>(); @@ -191,6 +210,7 @@ public Builder from(BasePrompt other) { labels(other.getLabels()); tags(other.getTags()); commitMessage(other.getCommitMessage()); + resolutionGraph(other.getResolutionGraph()); return this; } @@ -215,6 +235,26 @@ public _FinalStage config(Object config) { return this; } + /** + *

The dependency resolution graph for the current prompt. Null if prompt has no dependencies.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage resolutionGraph(Map resolutionGraph) { + this.resolutionGraph = Optional.ofNullable(resolutionGraph); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "resolutionGraph", + nulls = Nulls.SKIP + ) + public _FinalStage resolutionGraph(Optional> resolutionGraph) { + this.resolutionGraph = resolutionGraph; + return this; + } + /** *

Commit message for this prompt version.

* @return Reference to {@code this} so that method calls can be chained together. @@ -299,7 +339,7 @@ public _FinalStage labels(List labels) { @java.lang.Override public BasePrompt build() { - return new BasePrompt(name, version, config, labels, tags, commitMessage, additionalProperties); + return new BasePrompt(name, version, config, labels, tags, commitMessage, resolutionGraph, additionalProperties); } } } diff --git a/src/main/java/com/langfuse/client/resources/prompts/types/ChatPrompt.java b/src/main/java/com/langfuse/client/resources/prompts/types/ChatPrompt.java index 91b5940..6244390 100644 --- a/src/main/java/com/langfuse/client/resources/prompts/types/ChatPrompt.java +++ b/src/main/java/com/langfuse/client/resources/prompts/types/ChatPrompt.java @@ -40,12 +40,15 @@ public final class ChatPrompt implements IBasePrompt { private final Optional commitMessage; + private final Optional> resolutionGraph; + private final List prompt; private final Map additionalProperties; private ChatPrompt(String name, int version, Object config, List labels, - List tags, Optional commitMessage, List prompt, + List tags, Optional commitMessage, + Optional> resolutionGraph, List prompt, Map additionalProperties) { this.name = name; this.version = version; @@ -53,6 +56,7 @@ private ChatPrompt(String name, int version, Object config, List labels, this.labels = labels; this.tags = tags; this.commitMessage = commitMessage; + this.resolutionGraph = resolutionGraph; this.prompt = prompt; this.additionalProperties = additionalProperties; } @@ -102,6 +106,15 @@ public Optional getCommitMessage() { return commitMessage; } + /** + * @return The dependency resolution graph for the current prompt. Null if prompt has no dependencies. + */ + @JsonProperty("resolutionGraph") + @java.lang.Override + public Optional> getResolutionGraph() { + return resolutionGraph; + } + @JsonProperty("prompt") public List getPrompt() { return prompt; @@ -119,12 +132,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(ChatPrompt other) { - return name.equals(other.name) && version == other.version && config.equals(other.config) && labels.equals(other.labels) && tags.equals(other.tags) && commitMessage.equals(other.commitMessage) && prompt.equals(other.prompt); + return name.equals(other.name) && version == other.version && config.equals(other.config) && labels.equals(other.labels) && tags.equals(other.tags) && commitMessage.equals(other.commitMessage) && resolutionGraph.equals(other.resolutionGraph) && prompt.equals(other.prompt); } @java.lang.Override public int hashCode() { - return Objects.hash(this.name, this.version, this.config, this.labels, this.tags, this.commitMessage, this.prompt); + return Objects.hash(this.name, this.version, this.config, this.labels, this.tags, this.commitMessage, this.resolutionGraph, this.prompt); } @java.lang.Override @@ -169,6 +182,10 @@ public interface _FinalStage { _FinalStage commitMessage(String commitMessage); + _FinalStage resolutionGraph(Optional> resolutionGraph); + + _FinalStage resolutionGraph(Map resolutionGraph); + _FinalStage prompt(List prompt); _FinalStage addPrompt(ChatMessage prompt); @@ -188,6 +205,8 @@ public static final class Builder implements NameStage, VersionStage, ConfigStag private List prompt = new ArrayList<>(); + private Optional> resolutionGraph = Optional.empty(); + private Optional commitMessage = Optional.empty(); private List tags = new ArrayList<>(); @@ -208,6 +227,7 @@ public Builder from(ChatPrompt other) { labels(other.getLabels()); tags(other.getTags()); commitMessage(other.getCommitMessage()); + resolutionGraph(other.getResolutionGraph()); prompt(other.getPrompt()); return this; } @@ -256,6 +276,26 @@ public _FinalStage prompt(List prompt) { return this; } + /** + *

The dependency resolution graph for the current prompt. Null if prompt has no dependencies.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage resolutionGraph(Map resolutionGraph) { + this.resolutionGraph = Optional.ofNullable(resolutionGraph); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "resolutionGraph", + nulls = Nulls.SKIP + ) + public _FinalStage resolutionGraph(Optional> resolutionGraph) { + this.resolutionGraph = resolutionGraph; + return this; + } + /** *

Commit message for this prompt version.

* @return Reference to {@code this} so that method calls can be chained together. @@ -340,7 +380,7 @@ public _FinalStage labels(List labels) { @java.lang.Override public ChatPrompt build() { - return new ChatPrompt(name, version, config, labels, tags, commitMessage, prompt, additionalProperties); + return new ChatPrompt(name, version, config, labels, tags, commitMessage, resolutionGraph, prompt, additionalProperties); } } } diff --git a/src/main/java/com/langfuse/client/resources/prompts/types/IBasePrompt.java b/src/main/java/com/langfuse/client/resources/prompts/types/IBasePrompt.java index ff44d40..22c4587 100644 --- a/src/main/java/com/langfuse/client/resources/prompts/types/IBasePrompt.java +++ b/src/main/java/com/langfuse/client/resources/prompts/types/IBasePrompt.java @@ -7,6 +7,7 @@ import java.lang.Object; import java.lang.String; import java.util.List; +import java.util.Map; import java.util.Optional; public interface IBasePrompt { @@ -21,4 +22,6 @@ public interface IBasePrompt { List getTags(); Optional getCommitMessage(); + + Optional> getResolutionGraph(); } diff --git a/src/main/java/com/langfuse/client/resources/prompts/types/TextPrompt.java b/src/main/java/com/langfuse/client/resources/prompts/types/TextPrompt.java index 5a75008..0a13fc5 100644 --- a/src/main/java/com/langfuse/client/resources/prompts/types/TextPrompt.java +++ b/src/main/java/com/langfuse/client/resources/prompts/types/TextPrompt.java @@ -40,12 +40,15 @@ public final class TextPrompt implements IBasePrompt { private final Optional commitMessage; + private final Optional> resolutionGraph; + private final String prompt; private final Map additionalProperties; private TextPrompt(String name, int version, Object config, List labels, - List tags, Optional commitMessage, String prompt, + List tags, Optional commitMessage, + Optional> resolutionGraph, String prompt, Map additionalProperties) { this.name = name; this.version = version; @@ -53,6 +56,7 @@ private TextPrompt(String name, int version, Object config, List labels, this.labels = labels; this.tags = tags; this.commitMessage = commitMessage; + this.resolutionGraph = resolutionGraph; this.prompt = prompt; this.additionalProperties = additionalProperties; } @@ -102,6 +106,15 @@ public Optional getCommitMessage() { return commitMessage; } + /** + * @return The dependency resolution graph for the current prompt. Null if prompt has no dependencies. + */ + @JsonProperty("resolutionGraph") + @java.lang.Override + public Optional> getResolutionGraph() { + return resolutionGraph; + } + @JsonProperty("prompt") public String getPrompt() { return prompt; @@ -119,12 +132,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(TextPrompt other) { - return name.equals(other.name) && version == other.version && config.equals(other.config) && labels.equals(other.labels) && tags.equals(other.tags) && commitMessage.equals(other.commitMessage) && prompt.equals(other.prompt); + return name.equals(other.name) && version == other.version && config.equals(other.config) && labels.equals(other.labels) && tags.equals(other.tags) && commitMessage.equals(other.commitMessage) && resolutionGraph.equals(other.resolutionGraph) && prompt.equals(other.prompt); } @java.lang.Override public int hashCode() { - return Objects.hash(this.name, this.version, this.config, this.labels, this.tags, this.commitMessage, this.prompt); + return Objects.hash(this.name, this.version, this.config, this.labels, this.tags, this.commitMessage, this.resolutionGraph, this.prompt); } @java.lang.Override @@ -172,6 +185,10 @@ public interface _FinalStage { _FinalStage commitMessage(Optional commitMessage); _FinalStage commitMessage(String commitMessage); + + _FinalStage resolutionGraph(Optional> resolutionGraph); + + _FinalStage resolutionGraph(Map resolutionGraph); } @JsonIgnoreProperties( @@ -186,6 +203,8 @@ public static final class Builder implements NameStage, VersionStage, ConfigStag private String prompt; + private Optional> resolutionGraph = Optional.empty(); + private Optional commitMessage = Optional.empty(); private List tags = new ArrayList<>(); @@ -206,6 +225,7 @@ public Builder from(TextPrompt other) { labels(other.getLabels()); tags(other.getTags()); commitMessage(other.getCommitMessage()); + resolutionGraph(other.getResolutionGraph()); prompt(other.getPrompt()); return this; } @@ -238,6 +258,26 @@ public _FinalStage prompt(@NotNull String prompt) { return this; } + /** + *

The dependency resolution graph for the current prompt. Null if prompt has no dependencies.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage resolutionGraph(Map resolutionGraph) { + this.resolutionGraph = Optional.ofNullable(resolutionGraph); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "resolutionGraph", + nulls = Nulls.SKIP + ) + public _FinalStage resolutionGraph(Optional> resolutionGraph) { + this.resolutionGraph = resolutionGraph; + return this; + } + /** *

Commit message for this prompt version.

* @return Reference to {@code this} so that method calls can be chained together. @@ -322,7 +362,7 @@ public _FinalStage labels(List labels) { @java.lang.Override public TextPrompt build() { - return new TextPrompt(name, version, config, labels, tags, commitMessage, prompt, additionalProperties); + return new TextPrompt(name, version, config, labels, tags, commitMessage, resolutionGraph, prompt, additionalProperties); } } } diff --git a/src/main/java/com/langfuse/client/resources/scim/ScimClient.java b/src/main/java/com/langfuse/client/resources/scim/ScimClient.java new file mode 100644 index 0000000..ad3bf6b --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/scim/ScimClient.java @@ -0,0 +1,425 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.scim; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.langfuse.client.core.ClientOptions; +import com.langfuse.client.core.LangfuseClientApiException; +import com.langfuse.client.core.LangfuseClientException; +import com.langfuse.client.core.MediaTypes; +import com.langfuse.client.core.ObjectMappers; +import com.langfuse.client.core.QueryStringMapper; +import com.langfuse.client.core.RequestOptions; +import java.io.IOException; +import java.lang.Object; +import java.lang.String; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import com.langfuse.client.resources.commons.errors.AccessDeniedError; +import com.langfuse.client.resources.commons.errors.Error; +import com.langfuse.client.resources.commons.errors.MethodNotAllowedError; +import com.langfuse.client.resources.commons.errors.NotFoundError; +import com.langfuse.client.resources.commons.errors.UnauthorizedError; +import com.langfuse.client.resources.scim.requests.CreateUserRequest; +import com.langfuse.client.resources.scim.requests.ListUsersRequest; +import com.langfuse.client.resources.scim.types.EmptyResponse; +import com.langfuse.client.resources.scim.types.ResourceTypesResponse; +import com.langfuse.client.resources.scim.types.SchemasResponse; +import com.langfuse.client.resources.scim.types.ScimUser; +import com.langfuse.client.resources.scim.types.ScimUsersListResponse; +import com.langfuse.client.resources.scim.types.ServiceProviderConfig; + +public class ScimClient { + protected final ClientOptions clientOptions; + + public ScimClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get SCIM Service Provider Configuration (requires organization-scoped API key) + */ + public ServiceProviderConfig getServiceProviderConfig() { + return getServiceProviderConfig(null); + } + + /** + * Get SCIM Service Provider Configuration (requires organization-scoped API key) + */ + public ServiceProviderConfig getServiceProviderConfig(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public/scim") + .addPathSegments("ServiceProviderConfig") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ServiceProviderConfig.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + + /** + * Get SCIM Resource Types (requires organization-scoped API key) + */ + public ResourceTypesResponse getResourceTypes() { + return getResourceTypes(null); + } + + /** + * Get SCIM Resource Types (requires organization-scoped API key) + */ + public ResourceTypesResponse getResourceTypes(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public/scim") + .addPathSegments("ResourceTypes") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ResourceTypesResponse.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + + /** + * Get SCIM Schemas (requires organization-scoped API key) + */ + public SchemasResponse getSchemas() { + return getSchemas(null); + } + + /** + * Get SCIM Schemas (requires organization-scoped API key) + */ + public SchemasResponse getSchemas(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public/scim") + .addPathSegments("Schemas") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SchemasResponse.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + + /** + * List users in the organization (requires organization-scoped API key) + */ + public ScimUsersListResponse listUsers() { + return listUsers(ListUsersRequest.builder().build()); + } + + /** + * List users in the organization (requires organization-scoped API key) + */ + public ScimUsersListResponse listUsers(ListUsersRequest request) { + return listUsers(request,null); + } + + /** + * List users in the organization (requires organization-scoped API key) + */ + public ScimUsersListResponse listUsers(ListUsersRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public/scim") + .addPathSegments("Users");if (request.getFilter().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "filter", request.getFilter().get(), false); + } + if (request.getStartIndex().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "startIndex", request.getStartIndex().get().toString(), false); + } + if (request.getCount().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "count", request.getCount().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ScimUsersListResponse.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + + /** + * Create a new user in the organization (requires organization-scoped API key) + */ + public ScimUser createUser(CreateUserRequest request) { + return createUser(request,null); + } + + /** + * Create a new user in the organization (requires organization-scoped API key) + */ + public ScimUser createUser(CreateUserRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public/scim") + .addPathSegments("Users") + .build(); + RequestBody body; + try { + body = RequestBody.create(ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } + catch(JsonProcessingException e) { + throw new LangfuseClientException("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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ScimUser.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + + /** + * Get a specific user by ID (requires organization-scoped API key) + */ + public ScimUser getUser(String userId) { + return getUser(userId,null); + } + + /** + * Get a specific user by ID (requires organization-scoped API key) + */ + public ScimUser getUser(String userId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public/scim") + .addPathSegments("Users") + .addPathSegment(userId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ScimUser.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + + /** + * Remove a user from the organization (requires organization-scoped API key). Note that this only removes the user from the organization but does not delete the user entity itself. + */ + public EmptyResponse deleteUser(String userId) { + return deleteUser(userId,null); + } + + /** + * Remove a user from the organization (requires organization-scoped API key). Note that this only removes the user from the organization but does not delete the user entity itself. + */ + public EmptyResponse deleteUser(String userId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public/scim") + .addPathSegments("Users") + .addPathSegment(userId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), EmptyResponse.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + } diff --git a/src/main/java/com/langfuse/client/resources/scim/requests/CreateUserRequest.java b/src/main/java/com/langfuse/client/resources/scim/requests/CreateUserRequest.java new file mode 100644 index 0000000..f3dba02 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/scim/requests/CreateUserRequest.java @@ -0,0 +1,268 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.scim.requests; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Boolean; +import java.lang.Object; +import java.lang.String; +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; +import com.langfuse.client.resources.scim.types.ScimEmail; +import com.langfuse.client.resources.scim.types.ScimName; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = CreateUserRequest.Builder.class +) +public final class CreateUserRequest { + private final String userName; + + private final ScimName name; + + private final Optional> emails; + + private final Optional active; + + private final Optional password; + + private final Map additionalProperties; + + private CreateUserRequest(String userName, ScimName name, Optional> emails, + Optional active, Optional password, + Map additionalProperties) { + this.userName = userName; + this.name = name; + this.emails = emails; + this.active = active; + this.password = password; + this.additionalProperties = additionalProperties; + } + + /** + * @return User's email address (required) + */ + @JsonProperty("userName") + public String getUserName() { + return userName; + } + + /** + * @return User's name information + */ + @JsonProperty("name") + public ScimName getName() { + return name; + } + + /** + * @return User's email addresses + */ + @JsonProperty("emails") + public Optional> getEmails() { + return emails; + } + + /** + * @return Whether the user is active + */ + @JsonProperty("active") + public Optional getActive() { + return active; + } + + /** + * @return Initial password for the user + */ + @JsonProperty("password") + public Optional getPassword() { + return password; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateUserRequest && equalTo((CreateUserRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateUserRequest other) { + return userName.equals(other.userName) && name.equals(other.name) && emails.equals(other.emails) && active.equals(other.active) && password.equals(other.password); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.userName, this.name, this.emails, this.active, this.password); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static UserNameStage builder() { + return new Builder(); + } + + public interface UserNameStage { + NameStage userName(@NotNull String userName); + + Builder from(CreateUserRequest other); + } + + public interface NameStage { + _FinalStage name(@NotNull ScimName name); + } + + public interface _FinalStage { + CreateUserRequest build(); + + _FinalStage emails(Optional> emails); + + _FinalStage emails(List emails); + + _FinalStage active(Optional active); + + _FinalStage active(Boolean active); + + _FinalStage password(Optional password); + + _FinalStage password(String password); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements UserNameStage, NameStage, _FinalStage { + private String userName; + + private ScimName name; + + private Optional password = Optional.empty(); + + private Optional active = Optional.empty(); + + private Optional> emails = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(CreateUserRequest other) { + userName(other.getUserName()); + name(other.getName()); + emails(other.getEmails()); + active(other.getActive()); + password(other.getPassword()); + return this; + } + + /** + *

User's email address (required)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("userName") + public NameStage userName(@NotNull String userName) { + this.userName = Objects.requireNonNull(userName, "userName must not be null"); + return this; + } + + /** + *

User's name information

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("name") + public _FinalStage name(@NotNull ScimName name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + /** + *

Initial password for the user

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage password(String password) { + this.password = Optional.ofNullable(password); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "password", + nulls = Nulls.SKIP + ) + public _FinalStage password(Optional password) { + this.password = password; + return this; + } + + /** + *

Whether the user is active

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage active(Boolean active) { + this.active = Optional.ofNullable(active); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "active", + nulls = Nulls.SKIP + ) + public _FinalStage active(Optional active) { + this.active = active; + return this; + } + + /** + *

User's email addresses

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage emails(List emails) { + this.emails = Optional.ofNullable(emails); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "emails", + nulls = Nulls.SKIP + ) + public _FinalStage emails(Optional> emails) { + this.emails = emails; + return this; + } + + @java.lang.Override + public CreateUserRequest build() { + return new CreateUserRequest(userName, name, emails, active, password, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/scim/requests/ListUsersRequest.java b/src/main/java/com/langfuse/client/resources/scim/requests/ListUsersRequest.java new file mode 100644 index 0000000..6d2527c --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/scim/requests/ListUsersRequest.java @@ -0,0 +1,167 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.scim.requests; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Integer; +import java.lang.Object; +import java.lang.String; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = ListUsersRequest.Builder.class +) +public final class ListUsersRequest { + private final Optional filter; + + private final Optional startIndex; + + private final Optional count; + + private final Map additionalProperties; + + private ListUsersRequest(Optional filter, Optional startIndex, + Optional count, Map additionalProperties) { + this.filter = filter; + this.startIndex = startIndex; + this.count = count; + this.additionalProperties = additionalProperties; + } + + /** + * @return Filter expression (e.g. userName eq "value") + */ + @JsonProperty("filter") + public Optional getFilter() { + return filter; + } + + /** + * @return 1-based index of the first result to return (default 1) + */ + @JsonProperty("startIndex") + public Optional getStartIndex() { + return startIndex; + } + + /** + * @return Maximum number of results to return (default 100) + */ + @JsonProperty("count") + public Optional getCount() { + return count; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListUsersRequest && equalTo((ListUsersRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListUsersRequest other) { + return filter.equals(other.filter) && startIndex.equals(other.startIndex) && count.equals(other.count); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.filter, this.startIndex, this.count); + } + + @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 filter = Optional.empty(); + + private Optional startIndex = Optional.empty(); + + private Optional count = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + public Builder from(ListUsersRequest other) { + filter(other.getFilter()); + startIndex(other.getStartIndex()); + count(other.getCount()); + return this; + } + + @JsonSetter( + value = "filter", + nulls = Nulls.SKIP + ) + public Builder filter(Optional filter) { + this.filter = filter; + return this; + } + + public Builder filter(String filter) { + this.filter = Optional.ofNullable(filter); + return this; + } + + @JsonSetter( + value = "startIndex", + nulls = Nulls.SKIP + ) + public Builder startIndex(Optional startIndex) { + this.startIndex = startIndex; + return this; + } + + public Builder startIndex(Integer startIndex) { + this.startIndex = Optional.ofNullable(startIndex); + return this; + } + + @JsonSetter( + value = "count", + nulls = Nulls.SKIP + ) + public Builder count(Optional count) { + this.count = count; + return this; + } + + public Builder count(Integer count) { + this.count = Optional.ofNullable(count); + return this; + } + + public ListUsersRequest build() { + return new ListUsersRequest(filter, startIndex, count, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/scim/types/AuthenticationScheme.java b/src/main/java/com/langfuse/client/resources/scim/types/AuthenticationScheme.java new file mode 100644 index 0000000..8caeee3 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/scim/types/AuthenticationScheme.java @@ -0,0 +1,199 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.scim.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = AuthenticationScheme.Builder.class +) +public final class AuthenticationScheme { + private final String name; + + private final String description; + + private final String specUri; + + private final String type; + + private final boolean primary; + + private final Map additionalProperties; + + private AuthenticationScheme(String name, String description, String specUri, String type, + boolean primary, Map additionalProperties) { + this.name = name; + this.description = description; + this.specUri = specUri; + this.type = type; + this.primary = primary; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("description") + public String getDescription() { + return description; + } + + @JsonProperty("specUri") + public String getSpecUri() { + return specUri; + } + + @JsonProperty("type") + public String getType() { + return type; + } + + @JsonProperty("primary") + public boolean getPrimary() { + return primary; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AuthenticationScheme && equalTo((AuthenticationScheme) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AuthenticationScheme other) { + return name.equals(other.name) && description.equals(other.description) && specUri.equals(other.specUri) && type.equals(other.type) && primary == other.primary; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.name, this.description, this.specUri, this.type, this.primary); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + DescriptionStage name(@NotNull String name); + + Builder from(AuthenticationScheme other); + } + + public interface DescriptionStage { + SpecUriStage description(@NotNull String description); + } + + public interface SpecUriStage { + TypeStage specUri(@NotNull String specUri); + } + + public interface TypeStage { + PrimaryStage type(@NotNull String type); + } + + public interface PrimaryStage { + _FinalStage primary(boolean primary); + } + + public interface _FinalStage { + AuthenticationScheme build(); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements NameStage, DescriptionStage, SpecUriStage, TypeStage, PrimaryStage, _FinalStage { + private String name; + + private String description; + + private String specUri; + + private String type; + + private boolean primary; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(AuthenticationScheme other) { + name(other.getName()); + description(other.getDescription()); + specUri(other.getSpecUri()); + type(other.getType()); + primary(other.getPrimary()); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public DescriptionStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("description") + public SpecUriStage description(@NotNull String description) { + this.description = Objects.requireNonNull(description, "description must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("specUri") + public TypeStage specUri(@NotNull String specUri) { + this.specUri = Objects.requireNonNull(specUri, "specUri must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("type") + public PrimaryStage type(@NotNull String type) { + this.type = Objects.requireNonNull(type, "type must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("primary") + public _FinalStage primary(boolean primary) { + this.primary = primary; + return this; + } + + @java.lang.Override + public AuthenticationScheme build() { + return new AuthenticationScheme(name, description, specUri, type, primary, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/scim/types/BulkConfig.java b/src/main/java/com/langfuse/client/resources/scim/types/BulkConfig.java new file mode 100644 index 0000000..2098a77 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/scim/types/BulkConfig.java @@ -0,0 +1,154 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.scim.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = BulkConfig.Builder.class +) +public final class BulkConfig { + private final boolean supported; + + private final int maxOperations; + + private final int maxPayloadSize; + + private final Map additionalProperties; + + private BulkConfig(boolean supported, int maxOperations, int maxPayloadSize, + Map additionalProperties) { + this.supported = supported; + this.maxOperations = maxOperations; + this.maxPayloadSize = maxPayloadSize; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("supported") + public boolean getSupported() { + return supported; + } + + @JsonProperty("maxOperations") + public int getMaxOperations() { + return maxOperations; + } + + @JsonProperty("maxPayloadSize") + public int getMaxPayloadSize() { + return maxPayloadSize; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BulkConfig && equalTo((BulkConfig) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(BulkConfig other) { + return supported == other.supported && maxOperations == other.maxOperations && maxPayloadSize == other.maxPayloadSize; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.supported, this.maxOperations, this.maxPayloadSize); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SupportedStage builder() { + return new Builder(); + } + + public interface SupportedStage { + MaxOperationsStage supported(boolean supported); + + Builder from(BulkConfig other); + } + + public interface MaxOperationsStage { + MaxPayloadSizeStage maxOperations(int maxOperations); + } + + public interface MaxPayloadSizeStage { + _FinalStage maxPayloadSize(int maxPayloadSize); + } + + public interface _FinalStage { + BulkConfig build(); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements SupportedStage, MaxOperationsStage, MaxPayloadSizeStage, _FinalStage { + private boolean supported; + + private int maxOperations; + + private int maxPayloadSize; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(BulkConfig other) { + supported(other.getSupported()); + maxOperations(other.getMaxOperations()); + maxPayloadSize(other.getMaxPayloadSize()); + return this; + } + + @java.lang.Override + @JsonSetter("supported") + public MaxOperationsStage supported(boolean supported) { + this.supported = supported; + return this; + } + + @java.lang.Override + @JsonSetter("maxOperations") + public MaxPayloadSizeStage maxOperations(int maxOperations) { + this.maxOperations = maxOperations; + return this; + } + + @java.lang.Override + @JsonSetter("maxPayloadSize") + public _FinalStage maxPayloadSize(int maxPayloadSize) { + this.maxPayloadSize = maxPayloadSize; + return this; + } + + @java.lang.Override + public BulkConfig build() { + return new BulkConfig(supported, maxOperations, maxPayloadSize, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/scim/types/EmptyResponse.java b/src/main/java/com/langfuse/client/resources/scim/types/EmptyResponse.java new file mode 100644 index 0000000..4b65fe7 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/scim/types/EmptyResponse.java @@ -0,0 +1,67 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.scim.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = EmptyResponse.Builder.class +) +public final class EmptyResponse { + private final Map additionalProperties; + + private EmptyResponse(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof EmptyResponse; + } + + @JsonAnyGetter + public Map 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 additionalProperties = new HashMap<>(); + + private Builder() { + } + + public Builder from(EmptyResponse other) { + return this; + } + + public EmptyResponse build() { + return new EmptyResponse(additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/scim/types/FilterConfig.java b/src/main/java/com/langfuse/client/resources/scim/types/FilterConfig.java new file mode 100644 index 0000000..0416711 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/scim/types/FilterConfig.java @@ -0,0 +1,132 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.scim.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = FilterConfig.Builder.class +) +public final class FilterConfig { + private final boolean supported; + + private final int maxResults; + + private final Map additionalProperties; + + private FilterConfig(boolean supported, int maxResults, + Map additionalProperties) { + this.supported = supported; + this.maxResults = maxResults; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("supported") + public boolean getSupported() { + return supported; + } + + @JsonProperty("maxResults") + public int getMaxResults() { + return maxResults; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FilterConfig && equalTo((FilterConfig) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FilterConfig other) { + return supported == other.supported && maxResults == other.maxResults; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.supported, this.maxResults); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SupportedStage builder() { + return new Builder(); + } + + public interface SupportedStage { + MaxResultsStage supported(boolean supported); + + Builder from(FilterConfig other); + } + + public interface MaxResultsStage { + _FinalStage maxResults(int maxResults); + } + + public interface _FinalStage { + FilterConfig build(); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements SupportedStage, MaxResultsStage, _FinalStage { + private boolean supported; + + private int maxResults; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(FilterConfig other) { + supported(other.getSupported()); + maxResults(other.getMaxResults()); + return this; + } + + @java.lang.Override + @JsonSetter("supported") + public MaxResultsStage supported(boolean supported) { + this.supported = supported; + return this; + } + + @java.lang.Override + @JsonSetter("maxResults") + public _FinalStage maxResults(int maxResults) { + this.maxResults = maxResults; + return this; + } + + @java.lang.Override + public FilterConfig build() { + return new FilterConfig(supported, maxResults, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/scim/types/ResourceMeta.java b/src/main/java/com/langfuse/client/resources/scim/types/ResourceMeta.java new file mode 100644 index 0000000..26fe4c7 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/scim/types/ResourceMeta.java @@ -0,0 +1,133 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.scim.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = ResourceMeta.Builder.class +) +public final class ResourceMeta { + private final String resourceType; + + private final String location; + + private final Map additionalProperties; + + private ResourceMeta(String resourceType, String location, + Map additionalProperties) { + this.resourceType = resourceType; + this.location = location; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("resourceType") + public String getResourceType() { + return resourceType; + } + + @JsonProperty("location") + public String getLocation() { + return location; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ResourceMeta && equalTo((ResourceMeta) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ResourceMeta other) { + return resourceType.equals(other.resourceType) && location.equals(other.location); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.resourceType, this.location); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ResourceTypeStage builder() { + return new Builder(); + } + + public interface ResourceTypeStage { + LocationStage resourceType(@NotNull String resourceType); + + Builder from(ResourceMeta other); + } + + public interface LocationStage { + _FinalStage location(@NotNull String location); + } + + public interface _FinalStage { + ResourceMeta build(); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements ResourceTypeStage, LocationStage, _FinalStage { + private String resourceType; + + private String location; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(ResourceMeta other) { + resourceType(other.getResourceType()); + location(other.getLocation()); + return this; + } + + @java.lang.Override + @JsonSetter("resourceType") + public LocationStage resourceType(@NotNull String resourceType) { + this.resourceType = Objects.requireNonNull(resourceType, "resourceType must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("location") + public _FinalStage location(@NotNull String location) { + this.location = Objects.requireNonNull(location, "location must not be null"); + return this; + } + + @java.lang.Override + public ResourceMeta build() { + return new ResourceMeta(resourceType, location, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/scim/types/ResourceType.java b/src/main/java/com/langfuse/client/resources/scim/types/ResourceType.java new file mode 100644 index 0000000..5b1321f --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/scim/types/ResourceType.java @@ -0,0 +1,297 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.scim.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +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 = ResourceType.Builder.class +) +public final class ResourceType { + private final Optional> schemas; + + private final String id; + + private final String name; + + private final String endpoint; + + private final String description; + + private final String schema; + + private final List schemaExtensions; + + private final ResourceMeta meta; + + private final Map additionalProperties; + + private ResourceType(Optional> schemas, String id, String name, String endpoint, + String description, String schema, List schemaExtensions, ResourceMeta meta, + Map additionalProperties) { + this.schemas = schemas; + this.id = id; + this.name = name; + this.endpoint = endpoint; + this.description = description; + this.schema = schema; + this.schemaExtensions = schemaExtensions; + this.meta = meta; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("schemas") + public Optional> getSchemas() { + return schemas; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("endpoint") + public String getEndpoint() { + return endpoint; + } + + @JsonProperty("description") + public String getDescription() { + return description; + } + + @JsonProperty("schema") + public String getSchema() { + return schema; + } + + @JsonProperty("schemaExtensions") + public List getSchemaExtensions() { + return schemaExtensions; + } + + @JsonProperty("meta") + public ResourceMeta getMeta() { + return meta; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ResourceType && equalTo((ResourceType) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ResourceType other) { + return schemas.equals(other.schemas) && id.equals(other.id) && name.equals(other.name) && endpoint.equals(other.endpoint) && description.equals(other.description) && schema.equals(other.schema) && schemaExtensions.equals(other.schemaExtensions) && meta.equals(other.meta); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.schemas, this.id, this.name, this.endpoint, this.description, this.schema, this.schemaExtensions, this.meta); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + NameStage id(@NotNull String id); + + Builder from(ResourceType other); + } + + public interface NameStage { + EndpointStage name(@NotNull String name); + } + + public interface EndpointStage { + DescriptionStage endpoint(@NotNull String endpoint); + } + + public interface DescriptionStage { + SchemaStage description(@NotNull String description); + } + + public interface SchemaStage { + MetaStage schema(@NotNull String schema); + } + + public interface MetaStage { + _FinalStage meta(@NotNull ResourceMeta meta); + } + + public interface _FinalStage { + ResourceType build(); + + _FinalStage schemas(Optional> schemas); + + _FinalStage schemas(List schemas); + + _FinalStage schemaExtensions(List schemaExtensions); + + _FinalStage addSchemaExtensions(SchemaExtension schemaExtensions); + + _FinalStage addAllSchemaExtensions(List schemaExtensions); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements IdStage, NameStage, EndpointStage, DescriptionStage, SchemaStage, MetaStage, _FinalStage { + private String id; + + private String name; + + private String endpoint; + + private String description; + + private String schema; + + private ResourceMeta meta; + + private List schemaExtensions = new ArrayList<>(); + + private Optional> schemas = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(ResourceType other) { + schemas(other.getSchemas()); + id(other.getId()); + name(other.getName()); + endpoint(other.getEndpoint()); + description(other.getDescription()); + schema(other.getSchema()); + schemaExtensions(other.getSchemaExtensions()); + meta(other.getMeta()); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public NameStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public EndpointStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("endpoint") + public DescriptionStage endpoint(@NotNull String endpoint) { + this.endpoint = Objects.requireNonNull(endpoint, "endpoint must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("description") + public SchemaStage description(@NotNull String description) { + this.description = Objects.requireNonNull(description, "description must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("schema") + public MetaStage schema(@NotNull String schema) { + this.schema = Objects.requireNonNull(schema, "schema must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("meta") + public _FinalStage meta(@NotNull ResourceMeta meta) { + this.meta = Objects.requireNonNull(meta, "meta must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllSchemaExtensions(List schemaExtensions) { + this.schemaExtensions.addAll(schemaExtensions); + return this; + } + + @java.lang.Override + public _FinalStage addSchemaExtensions(SchemaExtension schemaExtensions) { + this.schemaExtensions.add(schemaExtensions); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "schemaExtensions", + nulls = Nulls.SKIP + ) + public _FinalStage schemaExtensions(List schemaExtensions) { + this.schemaExtensions.clear(); + this.schemaExtensions.addAll(schemaExtensions); + return this; + } + + @java.lang.Override + public _FinalStage schemas(List schemas) { + this.schemas = Optional.ofNullable(schemas); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "schemas", + nulls = Nulls.SKIP + ) + public _FinalStage schemas(Optional> schemas) { + this.schemas = schemas; + return this; + } + + @java.lang.Override + public ResourceType build() { + return new ResourceType(schemas, id, name, endpoint, description, schema, schemaExtensions, meta, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/scim/types/ResourceTypesResponse.java b/src/main/java/com/langfuse/client/resources/scim/types/ResourceTypesResponse.java new file mode 100644 index 0000000..a781ab0 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/scim/types/ResourceTypesResponse.java @@ -0,0 +1,193 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.scim.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +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 = ResourceTypesResponse.Builder.class +) +public final class ResourceTypesResponse { + private final List schemas; + + private final int totalResults; + + private final List resources; + + private final Map additionalProperties; + + private ResourceTypesResponse(List schemas, int totalResults, + List resources, Map additionalProperties) { + this.schemas = schemas; + this.totalResults = totalResults; + this.resources = resources; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("schemas") + public List getSchemas() { + return schemas; + } + + @JsonProperty("totalResults") + public int getTotalResults() { + return totalResults; + } + + @JsonProperty("Resources") + public List getResources() { + return resources; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ResourceTypesResponse && equalTo((ResourceTypesResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ResourceTypesResponse other) { + return schemas.equals(other.schemas) && totalResults == other.totalResults && resources.equals(other.resources); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.schemas, this.totalResults, this.resources); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TotalResultsStage builder() { + return new Builder(); + } + + public interface TotalResultsStage { + _FinalStage totalResults(int totalResults); + + Builder from(ResourceTypesResponse other); + } + + public interface _FinalStage { + ResourceTypesResponse build(); + + _FinalStage schemas(List schemas); + + _FinalStage addSchemas(String schemas); + + _FinalStage addAllSchemas(List schemas); + + _FinalStage resources(List resources); + + _FinalStage addResources(ResourceType resources); + + _FinalStage addAllResources(List resources); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements TotalResultsStage, _FinalStage { + private int totalResults; + + private List resources = new ArrayList<>(); + + private List schemas = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(ResourceTypesResponse other) { + schemas(other.getSchemas()); + totalResults(other.getTotalResults()); + resources(other.getResources()); + return this; + } + + @java.lang.Override + @JsonSetter("totalResults") + public _FinalStage totalResults(int totalResults) { + this.totalResults = totalResults; + return this; + } + + @java.lang.Override + public _FinalStage addAllResources(List resources) { + this.resources.addAll(resources); + return this; + } + + @java.lang.Override + public _FinalStage addResources(ResourceType resources) { + this.resources.add(resources); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "Resources", + nulls = Nulls.SKIP + ) + public _FinalStage resources(List resources) { + this.resources.clear(); + this.resources.addAll(resources); + return this; + } + + @java.lang.Override + public _FinalStage addAllSchemas(List schemas) { + this.schemas.addAll(schemas); + return this; + } + + @java.lang.Override + public _FinalStage addSchemas(String schemas) { + this.schemas.add(schemas); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "schemas", + nulls = Nulls.SKIP + ) + public _FinalStage schemas(List schemas) { + this.schemas.clear(); + this.schemas.addAll(schemas); + return this; + } + + @java.lang.Override + public ResourceTypesResponse build() { + return new ResourceTypesResponse(schemas, totalResults, resources, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/scim/types/SchemaExtension.java b/src/main/java/com/langfuse/client/resources/scim/types/SchemaExtension.java new file mode 100644 index 0000000..f932654 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/scim/types/SchemaExtension.java @@ -0,0 +1,133 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.scim.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = SchemaExtension.Builder.class +) +public final class SchemaExtension { + private final String schema; + + private final boolean required; + + private final Map additionalProperties; + + private SchemaExtension(String schema, boolean required, + Map additionalProperties) { + this.schema = schema; + this.required = required; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("schema") + public String getSchema() { + return schema; + } + + @JsonProperty("required") + public boolean getRequired() { + return required; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SchemaExtension && equalTo((SchemaExtension) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(SchemaExtension other) { + return schema.equals(other.schema) && required == other.required; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.schema, this.required); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SchemaStage builder() { + return new Builder(); + } + + public interface SchemaStage { + RequiredStage schema(@NotNull String schema); + + Builder from(SchemaExtension other); + } + + public interface RequiredStage { + _FinalStage required(boolean required); + } + + public interface _FinalStage { + SchemaExtension build(); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements SchemaStage, RequiredStage, _FinalStage { + private String schema; + + private boolean required; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(SchemaExtension other) { + schema(other.getSchema()); + required(other.getRequired()); + return this; + } + + @java.lang.Override + @JsonSetter("schema") + public RequiredStage schema(@NotNull String schema) { + this.schema = Objects.requireNonNull(schema, "schema must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("required") + public _FinalStage required(boolean required) { + this.required = required; + return this; + } + + @java.lang.Override + public SchemaExtension build() { + return new SchemaExtension(schema, required, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/scim/types/SchemaResource.java b/src/main/java/com/langfuse/client/resources/scim/types/SchemaResource.java new file mode 100644 index 0000000..7b8f88a --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/scim/types/SchemaResource.java @@ -0,0 +1,220 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.scim.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +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 = SchemaResource.Builder.class +) +public final class SchemaResource { + private final String id; + + private final String name; + + private final String description; + + private final List attributes; + + private final ResourceMeta meta; + + private final Map additionalProperties; + + private SchemaResource(String id, String name, String description, List attributes, + ResourceMeta meta, Map additionalProperties) { + this.id = id; + this.name = name; + this.description = description; + this.attributes = attributes; + this.meta = meta; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("description") + public String getDescription() { + return description; + } + + @JsonProperty("attributes") + public List getAttributes() { + return attributes; + } + + @JsonProperty("meta") + public ResourceMeta getMeta() { + return meta; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SchemaResource && equalTo((SchemaResource) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(SchemaResource other) { + return id.equals(other.id) && name.equals(other.name) && description.equals(other.description) && attributes.equals(other.attributes) && meta.equals(other.meta); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.name, this.description, this.attributes, this.meta); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + NameStage id(@NotNull String id); + + Builder from(SchemaResource other); + } + + public interface NameStage { + DescriptionStage name(@NotNull String name); + } + + public interface DescriptionStage { + MetaStage description(@NotNull String description); + } + + public interface MetaStage { + _FinalStage meta(@NotNull ResourceMeta meta); + } + + public interface _FinalStage { + SchemaResource build(); + + _FinalStage attributes(List attributes); + + _FinalStage addAttributes(Object attributes); + + _FinalStage addAllAttributes(List attributes); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements IdStage, NameStage, DescriptionStage, MetaStage, _FinalStage { + private String id; + + private String name; + + private String description; + + private ResourceMeta meta; + + private List attributes = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(SchemaResource other) { + id(other.getId()); + name(other.getName()); + description(other.getDescription()); + attributes(other.getAttributes()); + meta(other.getMeta()); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public NameStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public DescriptionStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("description") + public MetaStage description(@NotNull String description) { + this.description = Objects.requireNonNull(description, "description must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("meta") + public _FinalStage meta(@NotNull ResourceMeta meta) { + this.meta = Objects.requireNonNull(meta, "meta must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllAttributes(List attributes) { + this.attributes.addAll(attributes); + return this; + } + + @java.lang.Override + public _FinalStage addAttributes(Object attributes) { + this.attributes.add(attributes); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "attributes", + nulls = Nulls.SKIP + ) + public _FinalStage attributes(List attributes) { + this.attributes.clear(); + this.attributes.addAll(attributes); + return this; + } + + @java.lang.Override + public SchemaResource build() { + return new SchemaResource(id, name, description, attributes, meta, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/scim/types/SchemasResponse.java b/src/main/java/com/langfuse/client/resources/scim/types/SchemasResponse.java new file mode 100644 index 0000000..2f2839c --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/scim/types/SchemasResponse.java @@ -0,0 +1,193 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.scim.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +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 = SchemasResponse.Builder.class +) +public final class SchemasResponse { + private final List schemas; + + private final int totalResults; + + private final List resources; + + private final Map additionalProperties; + + private SchemasResponse(List schemas, int totalResults, List resources, + Map additionalProperties) { + this.schemas = schemas; + this.totalResults = totalResults; + this.resources = resources; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("schemas") + public List getSchemas() { + return schemas; + } + + @JsonProperty("totalResults") + public int getTotalResults() { + return totalResults; + } + + @JsonProperty("Resources") + public List getResources() { + return resources; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SchemasResponse && equalTo((SchemasResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(SchemasResponse other) { + return schemas.equals(other.schemas) && totalResults == other.totalResults && resources.equals(other.resources); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.schemas, this.totalResults, this.resources); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TotalResultsStage builder() { + return new Builder(); + } + + public interface TotalResultsStage { + _FinalStage totalResults(int totalResults); + + Builder from(SchemasResponse other); + } + + public interface _FinalStage { + SchemasResponse build(); + + _FinalStage schemas(List schemas); + + _FinalStage addSchemas(String schemas); + + _FinalStage addAllSchemas(List schemas); + + _FinalStage resources(List resources); + + _FinalStage addResources(SchemaResource resources); + + _FinalStage addAllResources(List resources); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements TotalResultsStage, _FinalStage { + private int totalResults; + + private List resources = new ArrayList<>(); + + private List schemas = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(SchemasResponse other) { + schemas(other.getSchemas()); + totalResults(other.getTotalResults()); + resources(other.getResources()); + return this; + } + + @java.lang.Override + @JsonSetter("totalResults") + public _FinalStage totalResults(int totalResults) { + this.totalResults = totalResults; + return this; + } + + @java.lang.Override + public _FinalStage addAllResources(List resources) { + this.resources.addAll(resources); + return this; + } + + @java.lang.Override + public _FinalStage addResources(SchemaResource resources) { + this.resources.add(resources); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "Resources", + nulls = Nulls.SKIP + ) + public _FinalStage resources(List resources) { + this.resources.clear(); + this.resources.addAll(resources); + return this; + } + + @java.lang.Override + public _FinalStage addAllSchemas(List schemas) { + this.schemas.addAll(schemas); + return this; + } + + @java.lang.Override + public _FinalStage addSchemas(String schemas) { + this.schemas.add(schemas); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "schemas", + nulls = Nulls.SKIP + ) + public _FinalStage schemas(List schemas) { + this.schemas.clear(); + this.schemas.addAll(schemas); + return this; + } + + @java.lang.Override + public SchemasResponse build() { + return new SchemasResponse(schemas, totalResults, resources, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/scim/types/ScimEmail.java b/src/main/java/com/langfuse/client/resources/scim/types/ScimEmail.java new file mode 100644 index 0000000..4425248 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/scim/types/ScimEmail.java @@ -0,0 +1,155 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.scim.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = ScimEmail.Builder.class +) +public final class ScimEmail { + private final boolean primary; + + private final String value; + + private final String type; + + private final Map additionalProperties; + + private ScimEmail(boolean primary, String value, String type, + Map additionalProperties) { + this.primary = primary; + this.value = value; + this.type = type; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("primary") + public boolean getPrimary() { + return primary; + } + + @JsonProperty("value") + public String getValue() { + return value; + } + + @JsonProperty("type") + public String getType() { + return type; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ScimEmail && equalTo((ScimEmail) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ScimEmail other) { + return primary == other.primary && value.equals(other.value) && type.equals(other.type); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.primary, this.value, this.type); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static PrimaryStage builder() { + return new Builder(); + } + + public interface PrimaryStage { + ValueStage primary(boolean primary); + + Builder from(ScimEmail other); + } + + public interface ValueStage { + TypeStage value(@NotNull String value); + } + + public interface TypeStage { + _FinalStage type(@NotNull String type); + } + + public interface _FinalStage { + ScimEmail build(); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements PrimaryStage, ValueStage, TypeStage, _FinalStage { + private boolean primary; + + private String value; + + private String type; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(ScimEmail other) { + primary(other.getPrimary()); + value(other.getValue()); + type(other.getType()); + return this; + } + + @java.lang.Override + @JsonSetter("primary") + public ValueStage primary(boolean primary) { + this.primary = primary; + return this; + } + + @java.lang.Override + @JsonSetter("value") + public TypeStage value(@NotNull String value) { + this.value = Objects.requireNonNull(value, "value must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("type") + public _FinalStage type(@NotNull String type) { + this.type = Objects.requireNonNull(type, "type must not be null"); + return this; + } + + @java.lang.Override + public ScimEmail build() { + return new ScimEmail(primary, value, type, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/scim/types/ScimFeatureSupport.java b/src/main/java/com/langfuse/client/resources/scim/types/ScimFeatureSupport.java new file mode 100644 index 0000000..d635316 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/scim/types/ScimFeatureSupport.java @@ -0,0 +1,109 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.scim.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = ScimFeatureSupport.Builder.class +) +public final class ScimFeatureSupport { + private final boolean supported; + + private final Map additionalProperties; + + private ScimFeatureSupport(boolean supported, Map additionalProperties) { + this.supported = supported; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("supported") + public boolean getSupported() { + return supported; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ScimFeatureSupport && equalTo((ScimFeatureSupport) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ScimFeatureSupport other) { + return supported == other.supported; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.supported); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SupportedStage builder() { + return new Builder(); + } + + public interface SupportedStage { + _FinalStage supported(boolean supported); + + Builder from(ScimFeatureSupport other); + } + + public interface _FinalStage { + ScimFeatureSupport build(); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements SupportedStage, _FinalStage { + private boolean supported; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(ScimFeatureSupport other) { + supported(other.getSupported()); + return this; + } + + @java.lang.Override + @JsonSetter("supported") + public _FinalStage supported(boolean supported) { + this.supported = supported; + return this; + } + + @java.lang.Override + public ScimFeatureSupport build() { + return new ScimFeatureSupport(supported, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/scim/types/ScimName.java b/src/main/java/com/langfuse/client/resources/scim/types/ScimName.java new file mode 100644 index 0000000..9e69d08 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/scim/types/ScimName.java @@ -0,0 +1,106 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.scim.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = ScimName.Builder.class +) +public final class ScimName { + private final Optional formatted; + + private final Map additionalProperties; + + private ScimName(Optional formatted, Map additionalProperties) { + this.formatted = formatted; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("formatted") + public Optional getFormatted() { + return formatted; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ScimName && equalTo((ScimName) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ScimName other) { + return formatted.equals(other.formatted); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.formatted); + } + + @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 formatted = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + public Builder from(ScimName other) { + formatted(other.getFormatted()); + return this; + } + + @JsonSetter( + value = "formatted", + nulls = Nulls.SKIP + ) + public Builder formatted(Optional formatted) { + this.formatted = formatted; + return this; + } + + public Builder formatted(String formatted) { + this.formatted = Optional.ofNullable(formatted); + return this; + } + + public ScimName build() { + return new ScimName(formatted, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/scim/types/ScimUser.java b/src/main/java/com/langfuse/client/resources/scim/types/ScimUser.java new file mode 100644 index 0000000..2b6f09b --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/scim/types/ScimUser.java @@ -0,0 +1,260 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.scim.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +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 = ScimUser.Builder.class +) +public final class ScimUser { + private final List schemas; + + private final String id; + + private final String userName; + + private final ScimName name; + + private final List emails; + + private final UserMeta meta; + + private final Map additionalProperties; + + private ScimUser(List schemas, String id, String userName, ScimName name, + List emails, UserMeta meta, Map additionalProperties) { + this.schemas = schemas; + this.id = id; + this.userName = userName; + this.name = name; + this.emails = emails; + this.meta = meta; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("schemas") + public List getSchemas() { + return schemas; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("userName") + public String getUserName() { + return userName; + } + + @JsonProperty("name") + public ScimName getName() { + return name; + } + + @JsonProperty("emails") + public List getEmails() { + return emails; + } + + @JsonProperty("meta") + public UserMeta getMeta() { + return meta; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ScimUser && equalTo((ScimUser) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ScimUser other) { + return schemas.equals(other.schemas) && id.equals(other.id) && userName.equals(other.userName) && name.equals(other.name) && emails.equals(other.emails) && meta.equals(other.meta); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.schemas, this.id, this.userName, this.name, this.emails, this.meta); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + UserNameStage id(@NotNull String id); + + Builder from(ScimUser other); + } + + public interface UserNameStage { + NameStage userName(@NotNull String userName); + } + + public interface NameStage { + MetaStage name(@NotNull ScimName name); + } + + public interface MetaStage { + _FinalStage meta(@NotNull UserMeta meta); + } + + public interface _FinalStage { + ScimUser build(); + + _FinalStage schemas(List schemas); + + _FinalStage addSchemas(String schemas); + + _FinalStage addAllSchemas(List schemas); + + _FinalStage emails(List emails); + + _FinalStage addEmails(ScimEmail emails); + + _FinalStage addAllEmails(List emails); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements IdStage, UserNameStage, NameStage, MetaStage, _FinalStage { + private String id; + + private String userName; + + private ScimName name; + + private UserMeta meta; + + private List emails = new ArrayList<>(); + + private List schemas = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(ScimUser other) { + schemas(other.getSchemas()); + id(other.getId()); + userName(other.getUserName()); + name(other.getName()); + emails(other.getEmails()); + meta(other.getMeta()); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public UserNameStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("userName") + public NameStage userName(@NotNull String userName) { + this.userName = Objects.requireNonNull(userName, "userName must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public MetaStage name(@NotNull ScimName name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("meta") + public _FinalStage meta(@NotNull UserMeta meta) { + this.meta = Objects.requireNonNull(meta, "meta must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllEmails(List emails) { + this.emails.addAll(emails); + return this; + } + + @java.lang.Override + public _FinalStage addEmails(ScimEmail emails) { + this.emails.add(emails); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "emails", + nulls = Nulls.SKIP + ) + public _FinalStage emails(List emails) { + this.emails.clear(); + this.emails.addAll(emails); + return this; + } + + @java.lang.Override + public _FinalStage addAllSchemas(List schemas) { + this.schemas.addAll(schemas); + return this; + } + + @java.lang.Override + public _FinalStage addSchemas(String schemas) { + this.schemas.add(schemas); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "schemas", + nulls = Nulls.SKIP + ) + public _FinalStage schemas(List schemas) { + this.schemas.clear(); + this.schemas.addAll(schemas); + return this; + } + + @java.lang.Override + public ScimUser build() { + return new ScimUser(schemas, id, userName, name, emails, meta, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/scim/types/ScimUsersListResponse.java b/src/main/java/com/langfuse/client/resources/scim/types/ScimUsersListResponse.java new file mode 100644 index 0000000..0a42ac5 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/scim/types/ScimUsersListResponse.java @@ -0,0 +1,237 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.scim.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +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 = ScimUsersListResponse.Builder.class +) +public final class ScimUsersListResponse { + private final List schemas; + + private final int totalResults; + + private final int startIndex; + + private final int itemsPerPage; + + private final List resources; + + private final Map additionalProperties; + + private ScimUsersListResponse(List schemas, int totalResults, int startIndex, + int itemsPerPage, List resources, Map additionalProperties) { + this.schemas = schemas; + this.totalResults = totalResults; + this.startIndex = startIndex; + this.itemsPerPage = itemsPerPage; + this.resources = resources; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("schemas") + public List getSchemas() { + return schemas; + } + + @JsonProperty("totalResults") + public int getTotalResults() { + return totalResults; + } + + @JsonProperty("startIndex") + public int getStartIndex() { + return startIndex; + } + + @JsonProperty("itemsPerPage") + public int getItemsPerPage() { + return itemsPerPage; + } + + @JsonProperty("Resources") + public List getResources() { + return resources; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ScimUsersListResponse && equalTo((ScimUsersListResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ScimUsersListResponse other) { + return schemas.equals(other.schemas) && totalResults == other.totalResults && startIndex == other.startIndex && itemsPerPage == other.itemsPerPage && resources.equals(other.resources); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.schemas, this.totalResults, this.startIndex, this.itemsPerPage, this.resources); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TotalResultsStage builder() { + return new Builder(); + } + + public interface TotalResultsStage { + StartIndexStage totalResults(int totalResults); + + Builder from(ScimUsersListResponse other); + } + + public interface StartIndexStage { + ItemsPerPageStage startIndex(int startIndex); + } + + public interface ItemsPerPageStage { + _FinalStage itemsPerPage(int itemsPerPage); + } + + public interface _FinalStage { + ScimUsersListResponse build(); + + _FinalStage schemas(List schemas); + + _FinalStage addSchemas(String schemas); + + _FinalStage addAllSchemas(List schemas); + + _FinalStage resources(List resources); + + _FinalStage addResources(ScimUser resources); + + _FinalStage addAllResources(List resources); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements TotalResultsStage, StartIndexStage, ItemsPerPageStage, _FinalStage { + private int totalResults; + + private int startIndex; + + private int itemsPerPage; + + private List resources = new ArrayList<>(); + + private List schemas = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(ScimUsersListResponse other) { + schemas(other.getSchemas()); + totalResults(other.getTotalResults()); + startIndex(other.getStartIndex()); + itemsPerPage(other.getItemsPerPage()); + resources(other.getResources()); + return this; + } + + @java.lang.Override + @JsonSetter("totalResults") + public StartIndexStage totalResults(int totalResults) { + this.totalResults = totalResults; + return this; + } + + @java.lang.Override + @JsonSetter("startIndex") + public ItemsPerPageStage startIndex(int startIndex) { + this.startIndex = startIndex; + return this; + } + + @java.lang.Override + @JsonSetter("itemsPerPage") + public _FinalStage itemsPerPage(int itemsPerPage) { + this.itemsPerPage = itemsPerPage; + return this; + } + + @java.lang.Override + public _FinalStage addAllResources(List resources) { + this.resources.addAll(resources); + return this; + } + + @java.lang.Override + public _FinalStage addResources(ScimUser resources) { + this.resources.add(resources); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "Resources", + nulls = Nulls.SKIP + ) + public _FinalStage resources(List resources) { + this.resources.clear(); + this.resources.addAll(resources); + return this; + } + + @java.lang.Override + public _FinalStage addAllSchemas(List schemas) { + this.schemas.addAll(schemas); + return this; + } + + @java.lang.Override + public _FinalStage addSchemas(String schemas) { + this.schemas.add(schemas); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "schemas", + nulls = Nulls.SKIP + ) + public _FinalStage schemas(List schemas) { + this.schemas.clear(); + this.schemas.addAll(schemas); + return this; + } + + @java.lang.Override + public ScimUsersListResponse build() { + return new ScimUsersListResponse(schemas, totalResults, startIndex, itemsPerPage, resources, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/scim/types/ServiceProviderConfig.java b/src/main/java/com/langfuse/client/resources/scim/types/ServiceProviderConfig.java new file mode 100644 index 0000000..861c1ab --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/scim/types/ServiceProviderConfig.java @@ -0,0 +1,352 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.scim.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +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 = ServiceProviderConfig.Builder.class +) +public final class ServiceProviderConfig { + private final List schemas; + + private final String documentationUri; + + private final ScimFeatureSupport patch; + + private final BulkConfig bulk; + + private final FilterConfig filter; + + private final ScimFeatureSupport changePassword; + + private final ScimFeatureSupport sort; + + private final ScimFeatureSupport etag; + + private final List authenticationSchemes; + + private final ResourceMeta meta; + + private final Map additionalProperties; + + private ServiceProviderConfig(List schemas, String documentationUri, + ScimFeatureSupport patch, BulkConfig bulk, FilterConfig filter, + ScimFeatureSupport changePassword, ScimFeatureSupport sort, ScimFeatureSupport etag, + List authenticationSchemes, ResourceMeta meta, + Map additionalProperties) { + this.schemas = schemas; + this.documentationUri = documentationUri; + this.patch = patch; + this.bulk = bulk; + this.filter = filter; + this.changePassword = changePassword; + this.sort = sort; + this.etag = etag; + this.authenticationSchemes = authenticationSchemes; + this.meta = meta; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("schemas") + public List getSchemas() { + return schemas; + } + + @JsonProperty("documentationUri") + public String getDocumentationUri() { + return documentationUri; + } + + @JsonProperty("patch") + public ScimFeatureSupport getPatch() { + return patch; + } + + @JsonProperty("bulk") + public BulkConfig getBulk() { + return bulk; + } + + @JsonProperty("filter") + public FilterConfig getFilter() { + return filter; + } + + @JsonProperty("changePassword") + public ScimFeatureSupport getChangePassword() { + return changePassword; + } + + @JsonProperty("sort") + public ScimFeatureSupport getSort() { + return sort; + } + + @JsonProperty("etag") + public ScimFeatureSupport getEtag() { + return etag; + } + + @JsonProperty("authenticationSchemes") + public List getAuthenticationSchemes() { + return authenticationSchemes; + } + + @JsonProperty("meta") + public ResourceMeta getMeta() { + return meta; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ServiceProviderConfig && equalTo((ServiceProviderConfig) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ServiceProviderConfig other) { + return schemas.equals(other.schemas) && documentationUri.equals(other.documentationUri) && patch.equals(other.patch) && bulk.equals(other.bulk) && filter.equals(other.filter) && changePassword.equals(other.changePassword) && sort.equals(other.sort) && etag.equals(other.etag) && authenticationSchemes.equals(other.authenticationSchemes) && meta.equals(other.meta); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.schemas, this.documentationUri, this.patch, this.bulk, this.filter, this.changePassword, this.sort, this.etag, this.authenticationSchemes, this.meta); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DocumentationUriStage builder() { + return new Builder(); + } + + public interface DocumentationUriStage { + PatchStage documentationUri(@NotNull String documentationUri); + + Builder from(ServiceProviderConfig other); + } + + public interface PatchStage { + BulkStage patch(@NotNull ScimFeatureSupport patch); + } + + public interface BulkStage { + FilterStage bulk(@NotNull BulkConfig bulk); + } + + public interface FilterStage { + ChangePasswordStage filter(@NotNull FilterConfig filter); + } + + public interface ChangePasswordStage { + SortStage changePassword(@NotNull ScimFeatureSupport changePassword); + } + + public interface SortStage { + EtagStage sort(@NotNull ScimFeatureSupport sort); + } + + public interface EtagStage { + MetaStage etag(@NotNull ScimFeatureSupport etag); + } + + public interface MetaStage { + _FinalStage meta(@NotNull ResourceMeta meta); + } + + public interface _FinalStage { + ServiceProviderConfig build(); + + _FinalStage schemas(List schemas); + + _FinalStage addSchemas(String schemas); + + _FinalStage addAllSchemas(List schemas); + + _FinalStage authenticationSchemes(List authenticationSchemes); + + _FinalStage addAuthenticationSchemes(AuthenticationScheme authenticationSchemes); + + _FinalStage addAllAuthenticationSchemes(List authenticationSchemes); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements DocumentationUriStage, PatchStage, BulkStage, FilterStage, ChangePasswordStage, SortStage, EtagStage, MetaStage, _FinalStage { + private String documentationUri; + + private ScimFeatureSupport patch; + + private BulkConfig bulk; + + private FilterConfig filter; + + private ScimFeatureSupport changePassword; + + private ScimFeatureSupport sort; + + private ScimFeatureSupport etag; + + private ResourceMeta meta; + + private List authenticationSchemes = new ArrayList<>(); + + private List schemas = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(ServiceProviderConfig other) { + schemas(other.getSchemas()); + documentationUri(other.getDocumentationUri()); + patch(other.getPatch()); + bulk(other.getBulk()); + filter(other.getFilter()); + changePassword(other.getChangePassword()); + sort(other.getSort()); + etag(other.getEtag()); + authenticationSchemes(other.getAuthenticationSchemes()); + meta(other.getMeta()); + return this; + } + + @java.lang.Override + @JsonSetter("documentationUri") + public PatchStage documentationUri(@NotNull String documentationUri) { + this.documentationUri = Objects.requireNonNull(documentationUri, "documentationUri must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("patch") + public BulkStage patch(@NotNull ScimFeatureSupport patch) { + this.patch = Objects.requireNonNull(patch, "patch must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("bulk") + public FilterStage bulk(@NotNull BulkConfig bulk) { + this.bulk = Objects.requireNonNull(bulk, "bulk must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("filter") + public ChangePasswordStage filter(@NotNull FilterConfig filter) { + this.filter = Objects.requireNonNull(filter, "filter must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("changePassword") + public SortStage changePassword(@NotNull ScimFeatureSupport changePassword) { + this.changePassword = Objects.requireNonNull(changePassword, "changePassword must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("sort") + public EtagStage sort(@NotNull ScimFeatureSupport sort) { + this.sort = Objects.requireNonNull(sort, "sort must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("etag") + public MetaStage etag(@NotNull ScimFeatureSupport etag) { + this.etag = Objects.requireNonNull(etag, "etag must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("meta") + public _FinalStage meta(@NotNull ResourceMeta meta) { + this.meta = Objects.requireNonNull(meta, "meta must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllAuthenticationSchemes( + List authenticationSchemes) { + this.authenticationSchemes.addAll(authenticationSchemes); + return this; + } + + @java.lang.Override + public _FinalStage addAuthenticationSchemes(AuthenticationScheme authenticationSchemes) { + this.authenticationSchemes.add(authenticationSchemes); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "authenticationSchemes", + nulls = Nulls.SKIP + ) + public _FinalStage authenticationSchemes(List authenticationSchemes) { + this.authenticationSchemes.clear(); + this.authenticationSchemes.addAll(authenticationSchemes); + return this; + } + + @java.lang.Override + public _FinalStage addAllSchemas(List schemas) { + this.schemas.addAll(schemas); + return this; + } + + @java.lang.Override + public _FinalStage addSchemas(String schemas) { + this.schemas.add(schemas); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "schemas", + nulls = Nulls.SKIP + ) + public _FinalStage schemas(List schemas) { + this.schemas.clear(); + this.schemas.addAll(schemas); + return this; + } + + @java.lang.Override + public ServiceProviderConfig build() { + return new ServiceProviderConfig(schemas, documentationUri, patch, bulk, filter, changePassword, sort, etag, authenticationSchemes, meta, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/scim/types/UserMeta.java b/src/main/java/com/langfuse/client/resources/scim/types/UserMeta.java new file mode 100644 index 0000000..a8fd12d --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/scim/types/UserMeta.java @@ -0,0 +1,175 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.scim.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +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 = UserMeta.Builder.class +) +public final class UserMeta { + private final String resourceType; + + private final Optional created; + + private final Optional lastModified; + + private final Map additionalProperties; + + private UserMeta(String resourceType, Optional created, Optional lastModified, + Map additionalProperties) { + this.resourceType = resourceType; + this.created = created; + this.lastModified = lastModified; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("resourceType") + public String getResourceType() { + return resourceType; + } + + @JsonProperty("created") + public Optional getCreated() { + return created; + } + + @JsonProperty("lastModified") + public Optional getLastModified() { + return lastModified; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UserMeta && equalTo((UserMeta) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UserMeta other) { + return resourceType.equals(other.resourceType) && created.equals(other.created) && lastModified.equals(other.lastModified); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.resourceType, this.created, this.lastModified); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ResourceTypeStage builder() { + return new Builder(); + } + + public interface ResourceTypeStage { + _FinalStage resourceType(@NotNull String resourceType); + + Builder from(UserMeta other); + } + + public interface _FinalStage { + UserMeta build(); + + _FinalStage created(Optional created); + + _FinalStage created(String created); + + _FinalStage lastModified(Optional lastModified); + + _FinalStage lastModified(String lastModified); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements ResourceTypeStage, _FinalStage { + private String resourceType; + + private Optional lastModified = Optional.empty(); + + private Optional created = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(UserMeta other) { + resourceType(other.getResourceType()); + created(other.getCreated()); + lastModified(other.getLastModified()); + return this; + } + + @java.lang.Override + @JsonSetter("resourceType") + public _FinalStage resourceType(@NotNull String resourceType) { + this.resourceType = Objects.requireNonNull(resourceType, "resourceType must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage lastModified(String lastModified) { + this.lastModified = Optional.ofNullable(lastModified); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "lastModified", + nulls = Nulls.SKIP + ) + public _FinalStage lastModified(Optional lastModified) { + this.lastModified = lastModified; + return this; + } + + @java.lang.Override + public _FinalStage created(String created) { + this.created = Optional.ofNullable(created); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "created", + nulls = Nulls.SKIP + ) + public _FinalStage created(Optional created) { + this.created = created; + return this; + } + + @java.lang.Override + public UserMeta build() { + return new UserMeta(resourceType, created, lastModified, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/score/ScoreClient.java b/src/main/java/com/langfuse/client/resources/score/ScoreClient.java index bf37fab..7c16c6c 100644 --- a/src/main/java/com/langfuse/client/resources/score/ScoreClient.java +++ b/src/main/java/com/langfuse/client/resources/score/ScoreClient.java @@ -10,7 +10,6 @@ import com.langfuse.client.core.LangfuseClientException; import com.langfuse.client.core.MediaTypes; import com.langfuse.client.core.ObjectMappers; -import com.langfuse.client.core.QueryStringMapper; import com.langfuse.client.core.RequestOptions; import java.io.IOException; import java.lang.Object; @@ -27,11 +26,8 @@ import com.langfuse.client.resources.commons.errors.MethodNotAllowedError; import com.langfuse.client.resources.commons.errors.NotFoundError; import com.langfuse.client.resources.commons.errors.UnauthorizedError; -import com.langfuse.client.resources.commons.types.Score; -import com.langfuse.client.resources.score.requests.GetScoresRequest; import com.langfuse.client.resources.score.types.CreateScoreRequest; import com.langfuse.client.resources.score.types.CreateScoreResponse; -import com.langfuse.client.resources.score.types.GetScoresResponse; public class ScoreClient { protected final ClientOptions clientOptions; @@ -41,14 +37,14 @@ public ScoreClient(ClientOptions clientOptions) { } /** - * Create a score + * Create a score (supports both trace and session scores) */ public CreateScoreResponse create(CreateScoreRequest request) { return create(request,null); } /** - * Create a score + * Create a score (supports both trace and session scores) */ public CreateScoreResponse create(CreateScoreRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() @@ -99,206 +95,53 @@ public CreateScoreResponse create(CreateScoreRequest request, RequestOptions req } /** - * Get a list of scores + * Delete a score (supports both trace and session scores) */ - public GetScoresResponse get() { - return get(GetScoresRequest.builder().build()); + public void delete(String scoreId) { + delete(scoreId,null); } /** - * Get a list of scores + * Delete a score (supports both trace and session scores) */ - public GetScoresResponse get(GetScoresRequest request) { - return get(request,null); - } - - /** - * Get a list of scores - */ - public GetScoresResponse get(GetScoresRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + public void delete(String scoreId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() .addPathSegments("api/public") - .addPathSegments("scores");if (request.getPage().isPresent()) { - QueryStringMapper.addQueryParameter(httpUrl, "page", request.getPage().get().toString(), false); - } - if (request.getLimit().isPresent()) { - QueryStringMapper.addQueryParameter(httpUrl, "limit", request.getLimit().get().toString(), false); - } - if (request.getUserId().isPresent()) { - QueryStringMapper.addQueryParameter(httpUrl, "userId", request.getUserId().get(), false); - } - if (request.getName().isPresent()) { - QueryStringMapper.addQueryParameter(httpUrl, "name", request.getName().get(), false); - } - if (request.getFromTimestamp().isPresent()) { - QueryStringMapper.addQueryParameter(httpUrl, "fromTimestamp", request.getFromTimestamp().get().toString(), false); - } - if (request.getToTimestamp().isPresent()) { - QueryStringMapper.addQueryParameter(httpUrl, "toTimestamp", request.getToTimestamp().get().toString(), false); - } - if (request.getEnvironment().isPresent()) { - QueryStringMapper.addQueryParameter(httpUrl, "environment", request.getEnvironment().get(), false); - } - if (request.getSource().isPresent()) { - QueryStringMapper.addQueryParameter(httpUrl, "source", request.getSource().get().toString(), false); - } - if (request.getOperator().isPresent()) { - QueryStringMapper.addQueryParameter(httpUrl, "operator", request.getOperator().get(), false); - } - if (request.getValue().isPresent()) { - QueryStringMapper.addQueryParameter(httpUrl, "value", request.getValue().get().toString(), false); - } - if (request.getScoreIds().isPresent()) { - QueryStringMapper.addQueryParameter(httpUrl, "scoreIds", request.getScoreIds().get(), false); - } - if (request.getConfigId().isPresent()) { - QueryStringMapper.addQueryParameter(httpUrl, "configId", request.getConfigId().get(), false); - } - if (request.getQueueId().isPresent()) { - QueryStringMapper.addQueryParameter(httpUrl, "queueId", request.getQueueId().get(), false); - } - if (request.getDataType().isPresent()) { - QueryStringMapper.addQueryParameter(httpUrl, "dataType", request.getDataType().get().toString(), false); - } - if (request.getTraceTags().isPresent()) { - QueryStringMapper.addQueryParameter(httpUrl, "traceTags", request.getTraceTags().get(), false); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetScoresResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } - } - catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } - catch (IOException e) { - throw new LangfuseClientException("Network error executing HTTP request", e); - } - } - - /** - * Get a score - */ - public Score getById(String scoreId) { - return getById(scoreId,null); + .addPathSegments("scores") + .addPathSegment(scoreId) + .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); } - - /** - * Get a score - */ - public Score getById(String scoreId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() - .addPathSegments("api/public") - .addPathSegments("scores") - .addPathSegment(scoreId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return; } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Score.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } - } - catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); } - throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); } - catch (IOException e) { - throw new LangfuseClientException("Network error executing HTTP request", e); + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); } - - /** - * Delete a score - */ - public void delete(String scoreId) { - delete(scoreId,null); - } - - /** - * Delete a score - */ - public void delete(String scoreId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() - .addPathSegments("api/public") - .addPathSegments("scores") - .addPathSegment(scoreId) - .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; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } - } - catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } - catch (IOException e) { - throw new LangfuseClientException("Network error executing HTTP request", e); - } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); } } +} diff --git a/src/main/java/com/langfuse/client/resources/score/types/CreateScoreRequest.java b/src/main/java/com/langfuse/client/resources/score/types/CreateScoreRequest.java index f9b84b0..ffc9023 100644 --- a/src/main/java/com/langfuse/client/resources/score/types/CreateScoreRequest.java +++ b/src/main/java/com/langfuse/client/resources/score/types/CreateScoreRequest.java @@ -30,16 +30,22 @@ public final class CreateScoreRequest { private final Optional id; - private final String traceId; + private final Optional traceId; + + private final Optional sessionId; + + private final Optional observationId; + + private final Optional datasetRunId; private final String name; private final CreateScoreValue value; - private final Optional observationId; - private final Optional comment; + private final Optional metadata; + private final Optional environment; private final Optional dataType; @@ -48,16 +54,20 @@ public final class CreateScoreRequest { private final Map additionalProperties; - private CreateScoreRequest(Optional id, String traceId, String name, - CreateScoreValue value, Optional observationId, Optional comment, + private CreateScoreRequest(Optional id, Optional traceId, + Optional sessionId, Optional observationId, Optional datasetRunId, + String name, CreateScoreValue value, Optional comment, Optional metadata, Optional environment, Optional dataType, Optional configId, Map additionalProperties) { this.id = id; this.traceId = traceId; + this.sessionId = sessionId; + this.observationId = observationId; + this.datasetRunId = datasetRunId; this.name = name; this.value = value; - this.observationId = observationId; this.comment = comment; + this.metadata = metadata; this.environment = environment; this.dataType = dataType; this.configId = configId; @@ -70,10 +80,25 @@ public Optional getId() { } @JsonProperty("traceId") - public String getTraceId() { + public Optional getTraceId() { return traceId; } + @JsonProperty("sessionId") + public Optional getSessionId() { + return sessionId; + } + + @JsonProperty("observationId") + public Optional getObservationId() { + return observationId; + } + + @JsonProperty("datasetRunId") + public Optional getDatasetRunId() { + return datasetRunId; + } + @JsonProperty("name") public String getName() { return name; @@ -87,16 +112,16 @@ public CreateScoreValue getValue() { return value; } - @JsonProperty("observationId") - public Optional getObservationId() { - return observationId; - } - @JsonProperty("comment") public Optional getComment() { return comment; } + @JsonProperty("metadata") + public Optional getMetadata() { + return metadata; + } + /** * @return The environment of the score. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'. */ @@ -133,12 +158,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(CreateScoreRequest other) { - return id.equals(other.id) && traceId.equals(other.traceId) && name.equals(other.name) && value.equals(other.value) && observationId.equals(other.observationId) && comment.equals(other.comment) && environment.equals(other.environment) && dataType.equals(other.dataType) && configId.equals(other.configId); + return id.equals(other.id) && traceId.equals(other.traceId) && sessionId.equals(other.sessionId) && observationId.equals(other.observationId) && datasetRunId.equals(other.datasetRunId) && name.equals(other.name) && value.equals(other.value) && comment.equals(other.comment) && metadata.equals(other.metadata) && environment.equals(other.environment) && dataType.equals(other.dataType) && configId.equals(other.configId); } @java.lang.Override public int hashCode() { - return Objects.hash(this.id, this.traceId, this.name, this.value, this.observationId, this.comment, this.environment, this.dataType, this.configId); + return Objects.hash(this.id, this.traceId, this.sessionId, this.observationId, this.datasetRunId, this.name, this.value, this.comment, this.metadata, this.environment, this.dataType, this.configId); } @java.lang.Override @@ -146,18 +171,14 @@ public String toString() { return ObjectMappers.stringify(this); } - public static TraceIdStage builder() { + public static NameStage builder() { return new Builder(); } - public interface TraceIdStage { - NameStage traceId(@NotNull String traceId); - - Builder from(CreateScoreRequest other); - } - public interface NameStage { ValueStage name(@NotNull String name); + + Builder from(CreateScoreRequest other); } public interface ValueStage { @@ -171,14 +192,30 @@ public interface _FinalStage { _FinalStage id(String id); + _FinalStage traceId(Optional traceId); + + _FinalStage traceId(String traceId); + + _FinalStage sessionId(Optional sessionId); + + _FinalStage sessionId(String sessionId); + _FinalStage observationId(Optional observationId); _FinalStage observationId(String observationId); + _FinalStage datasetRunId(Optional datasetRunId); + + _FinalStage datasetRunId(String datasetRunId); + _FinalStage comment(Optional comment); _FinalStage comment(String comment); + _FinalStage metadata(Optional metadata); + + _FinalStage metadata(Object metadata); + _FinalStage environment(Optional environment); _FinalStage environment(String environment); @@ -195,9 +232,7 @@ public interface _FinalStage { @JsonIgnoreProperties( ignoreUnknown = true ) - public static final class Builder implements TraceIdStage, NameStage, ValueStage, _FinalStage { - private String traceId; - + public static final class Builder implements NameStage, ValueStage, _FinalStage { private String name; private CreateScoreValue value; @@ -208,10 +243,18 @@ public static final class Builder implements TraceIdStage, NameStage, ValueStage private Optional environment = Optional.empty(); + private Optional metadata = Optional.empty(); + private Optional comment = Optional.empty(); + private Optional datasetRunId = Optional.empty(); + private Optional observationId = Optional.empty(); + private Optional sessionId = Optional.empty(); + + private Optional traceId = Optional.empty(); + private Optional id = Optional.empty(); @JsonAnySetter @@ -224,23 +267,19 @@ private Builder() { public Builder from(CreateScoreRequest other) { id(other.getId()); traceId(other.getTraceId()); + sessionId(other.getSessionId()); + observationId(other.getObservationId()); + datasetRunId(other.getDatasetRunId()); name(other.getName()); value(other.getValue()); - observationId(other.getObservationId()); comment(other.getComment()); + metadata(other.getMetadata()); environment(other.getEnvironment()); dataType(other.getDataType()); configId(other.getConfigId()); return this; } - @java.lang.Override - @JsonSetter("traceId") - public NameStage traceId(@NotNull String traceId) { - this.traceId = Objects.requireNonNull(traceId, "traceId must not be null"); - return this; - } - @java.lang.Override @JsonSetter("name") public ValueStage name(@NotNull String name) { @@ -319,6 +358,22 @@ public _FinalStage environment(Optional environment) { return this; } + @java.lang.Override + public _FinalStage metadata(Object metadata) { + this.metadata = Optional.ofNullable(metadata); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "metadata", + nulls = Nulls.SKIP + ) + public _FinalStage metadata(Optional metadata) { + this.metadata = metadata; + return this; + } + @java.lang.Override public _FinalStage comment(String comment) { this.comment = Optional.ofNullable(comment); @@ -335,6 +390,22 @@ public _FinalStage comment(Optional comment) { return this; } + @java.lang.Override + public _FinalStage datasetRunId(String datasetRunId) { + this.datasetRunId = Optional.ofNullable(datasetRunId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "datasetRunId", + nulls = Nulls.SKIP + ) + public _FinalStage datasetRunId(Optional datasetRunId) { + this.datasetRunId = datasetRunId; + return this; + } + @java.lang.Override public _FinalStage observationId(String observationId) { this.observationId = Optional.ofNullable(observationId); @@ -351,6 +422,38 @@ public _FinalStage observationId(Optional observationId) { return this; } + @java.lang.Override + public _FinalStage sessionId(String sessionId) { + this.sessionId = Optional.ofNullable(sessionId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "sessionId", + nulls = Nulls.SKIP + ) + public _FinalStage sessionId(Optional sessionId) { + this.sessionId = sessionId; + return this; + } + + @java.lang.Override + public _FinalStage traceId(String traceId) { + this.traceId = Optional.ofNullable(traceId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "traceId", + nulls = Nulls.SKIP + ) + public _FinalStage traceId(Optional traceId) { + this.traceId = traceId; + return this; + } + @java.lang.Override public _FinalStage id(String id) { this.id = Optional.ofNullable(id); @@ -369,7 +472,7 @@ public _FinalStage id(Optional id) { @java.lang.Override public CreateScoreRequest build() { - return new CreateScoreRequest(id, traceId, name, value, observationId, comment, environment, dataType, configId, additionalProperties); + return new CreateScoreRequest(id, traceId, sessionId, observationId, datasetRunId, name, value, comment, metadata, environment, dataType, configId, additionalProperties); } } } diff --git a/src/main/java/com/langfuse/client/resources/scorev2/ScoreV2Client.java b/src/main/java/com/langfuse/client/resources/scorev2/ScoreV2Client.java new file mode 100644 index 0000000..11f08b3 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/scorev2/ScoreV2Client.java @@ -0,0 +1,191 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.scorev2; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.langfuse.client.core.ClientOptions; +import com.langfuse.client.core.LangfuseClientApiException; +import com.langfuse.client.core.LangfuseClientException; +import com.langfuse.client.core.ObjectMappers; +import com.langfuse.client.core.QueryStringMapper; +import com.langfuse.client.core.RequestOptions; +import java.io.IOException; +import java.lang.Object; +import java.lang.String; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import com.langfuse.client.resources.commons.errors.AccessDeniedError; +import com.langfuse.client.resources.commons.errors.Error; +import com.langfuse.client.resources.commons.errors.MethodNotAllowedError; +import com.langfuse.client.resources.commons.errors.NotFoundError; +import com.langfuse.client.resources.commons.errors.UnauthorizedError; +import com.langfuse.client.resources.commons.types.Score; +import com.langfuse.client.resources.scorev2.requests.GetScoresRequest; +import com.langfuse.client.resources.scorev2.types.GetScoresResponse; + +public class ScoreV2Client { + protected final ClientOptions clientOptions; + + public ScoreV2Client(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get a list of scores (supports both trace and session scores) + */ + public GetScoresResponse get() { + return get(GetScoresRequest.builder().build()); + } + + /** + * Get a list of scores (supports both trace and session scores) + */ + public GetScoresResponse get(GetScoresRequest request) { + return get(request,null); + } + + /** + * Get a list of scores (supports both trace and session scores) + */ + public GetScoresResponse get(GetScoresRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public/v2") + .addPathSegments("scores");if (request.getPage().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "page", request.getPage().get().toString(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "limit", request.getLimit().get().toString(), false); + } + if (request.getUserId().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "userId", request.getUserId().get(), false); + } + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "name", request.getName().get(), false); + } + if (request.getFromTimestamp().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "fromTimestamp", request.getFromTimestamp().get().toString(), false); + } + if (request.getToTimestamp().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "toTimestamp", request.getToTimestamp().get().toString(), false); + } + if (request.getEnvironment().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "environment", request.getEnvironment().get(), false); + } + if (request.getSource().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "source", request.getSource().get().toString(), false); + } + if (request.getOperator().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "operator", request.getOperator().get(), false); + } + if (request.getValue().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "value", request.getValue().get().toString(), false); + } + if (request.getScoreIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "scoreIds", request.getScoreIds().get(), false); + } + if (request.getConfigId().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "configId", request.getConfigId().get(), false); + } + if (request.getQueueId().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "queueId", request.getQueueId().get(), false); + } + if (request.getDataType().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "dataType", request.getDataType().get().toString(), false); + } + if (request.getTraceTags().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "traceTags", request.getTraceTags().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetScoresResponse.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + + /** + * Get a score (supports both trace and session scores) + */ + public Score getById(String scoreId) { + return getById(scoreId,null); + } + + /** + * Get a score (supports both trace and session scores) + */ + public Score getById(String scoreId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder() + .addPathSegments("api/public/v2") + .addPathSegments("scores") + .addPathSegment(scoreId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Score.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } + catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + catch (IOException e) { + throw new LangfuseClientException("Network error executing HTTP request", e); + } + } + } diff --git a/src/main/java/com/langfuse/client/resources/score/requests/GetScoresRequest.java b/src/main/java/com/langfuse/client/resources/scorev2/requests/GetScoresRequest.java similarity index 99% rename from src/main/java/com/langfuse/client/resources/score/requests/GetScoresRequest.java rename to src/main/java/com/langfuse/client/resources/scorev2/requests/GetScoresRequest.java index f9097d5..1cd8c29 100644 --- a/src/main/java/com/langfuse/client/resources/score/requests/GetScoresRequest.java +++ b/src/main/java/com/langfuse/client/resources/scorev2/requests/GetScoresRequest.java @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -package com.langfuse.client.resources.score.requests; +package com.langfuse.client.resources.scorev2.requests; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; diff --git a/src/main/java/com/langfuse/client/resources/score/types/GetScoresResponse.java b/src/main/java/com/langfuse/client/resources/scorev2/types/GetScoresResponse.java similarity index 98% rename from src/main/java/com/langfuse/client/resources/score/types/GetScoresResponse.java rename to src/main/java/com/langfuse/client/resources/scorev2/types/GetScoresResponse.java index 5974bc2..e35b1fa 100644 --- a/src/main/java/com/langfuse/client/resources/score/types/GetScoresResponse.java +++ b/src/main/java/com/langfuse/client/resources/scorev2/types/GetScoresResponse.java @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -package com.langfuse.client.resources.score.types; +package com.langfuse.client.resources.scorev2.types; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; diff --git a/src/main/java/com/langfuse/client/resources/score/types/GetScoresResponseData.java b/src/main/java/com/langfuse/client/resources/scorev2/types/GetScoresResponseData.java similarity index 99% rename from src/main/java/com/langfuse/client/resources/score/types/GetScoresResponseData.java rename to src/main/java/com/langfuse/client/resources/scorev2/types/GetScoresResponseData.java index 9c6c66b..b245504 100644 --- a/src/main/java/com/langfuse/client/resources/score/types/GetScoresResponseData.java +++ b/src/main/java/com/langfuse/client/resources/scorev2/types/GetScoresResponseData.java @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -package com.langfuse.client.resources.score.types; +package com.langfuse.client.resources.scorev2.types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/src/main/java/com/langfuse/client/resources/scorev2/types/GetScoresResponseDataBoolean.java b/src/main/java/com/langfuse/client/resources/scorev2/types/GetScoresResponseDataBoolean.java new file mode 100644 index 0000000..1ea5bbb --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/scorev2/types/GetScoresResponseDataBoolean.java @@ -0,0 +1,670 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.scorev2.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; +import com.langfuse.client.resources.commons.types.IBaseScore; +import com.langfuse.client.resources.commons.types.IBooleanScore; +import com.langfuse.client.resources.commons.types.ScoreSource; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = GetScoresResponseDataBoolean.Builder.class +) +public final class GetScoresResponseDataBoolean implements IBooleanScore, IBaseScore { + private final double value; + + private final String stringValue; + + private final String id; + + private final Optional traceId; + + private final Optional sessionId; + + private final Optional observationId; + + private final Optional datasetRunId; + + private final String name; + + private final ScoreSource source; + + private final OffsetDateTime timestamp; + + private final OffsetDateTime createdAt; + + private final OffsetDateTime updatedAt; + + private final Optional authorUserId; + + private final Optional comment; + + private final Optional metadata; + + private final Optional configId; + + private final Optional queueId; + + private final Optional environment; + + private final Optional trace; + + private final Map additionalProperties; + + private GetScoresResponseDataBoolean(double value, String stringValue, String id, + Optional traceId, Optional sessionId, Optional observationId, + Optional datasetRunId, String name, ScoreSource source, OffsetDateTime timestamp, + OffsetDateTime createdAt, OffsetDateTime updatedAt, Optional authorUserId, + Optional comment, Optional metadata, Optional configId, + Optional queueId, Optional environment, + Optional trace, Map additionalProperties) { + this.value = value; + this.stringValue = stringValue; + this.id = id; + this.traceId = traceId; + this.sessionId = sessionId; + this.observationId = observationId; + this.datasetRunId = datasetRunId; + this.name = name; + this.source = source; + this.timestamp = timestamp; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.authorUserId = authorUserId; + this.comment = comment; + this.metadata = metadata; + this.configId = configId; + this.queueId = queueId; + this.environment = environment; + this.trace = trace; + this.additionalProperties = additionalProperties; + } + + /** + * @return The numeric value of the score. Equals 1 for "True" and 0 for "False" + */ + @JsonProperty("value") + @java.lang.Override + public double getValue() { + return value; + } + + /** + * @return The string representation of the score value. Is inferred from the numeric value and equals "True" or "False" + */ + @JsonProperty("stringValue") + @java.lang.Override + public String getStringValue() { + return stringValue; + } + + @JsonProperty("id") + @java.lang.Override + public String getId() { + return id; + } + + @JsonProperty("traceId") + @java.lang.Override + public Optional getTraceId() { + return traceId; + } + + @JsonProperty("sessionId") + @java.lang.Override + public Optional getSessionId() { + return sessionId; + } + + @JsonProperty("observationId") + @java.lang.Override + public Optional getObservationId() { + return observationId; + } + + @JsonProperty("datasetRunId") + @java.lang.Override + public Optional getDatasetRunId() { + return datasetRunId; + } + + @JsonProperty("name") + @java.lang.Override + public String getName() { + return name; + } + + @JsonProperty("source") + @java.lang.Override + public ScoreSource getSource() { + return source; + } + + @JsonProperty("timestamp") + @java.lang.Override + public OffsetDateTime getTimestamp() { + return timestamp; + } + + @JsonProperty("createdAt") + @java.lang.Override + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("updatedAt") + @java.lang.Override + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @JsonProperty("authorUserId") + @java.lang.Override + public Optional getAuthorUserId() { + return authorUserId; + } + + @JsonProperty("comment") + @java.lang.Override + public Optional getComment() { + return comment; + } + + @JsonProperty("metadata") + @java.lang.Override + public Optional getMetadata() { + return metadata; + } + + /** + * @return Reference a score config on a score. When set, config and score name must be equal and value must comply to optionally defined numerical range + */ + @JsonProperty("configId") + @java.lang.Override + public Optional getConfigId() { + return configId; + } + + /** + * @return Reference an annotation queue on a score. Populated if the score was initially created in an annotation queue. + */ + @JsonProperty("queueId") + @java.lang.Override + public Optional getQueueId() { + return queueId; + } + + /** + * @return The environment from which this score originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'. + */ + @JsonProperty("environment") + @java.lang.Override + public Optional getEnvironment() { + return environment; + } + + @JsonProperty("trace") + public Optional getTrace() { + return trace; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetScoresResponseDataBoolean && equalTo((GetScoresResponseDataBoolean) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetScoresResponseDataBoolean other) { + return value == other.value && stringValue.equals(other.stringValue) && id.equals(other.id) && traceId.equals(other.traceId) && sessionId.equals(other.sessionId) && observationId.equals(other.observationId) && datasetRunId.equals(other.datasetRunId) && name.equals(other.name) && source.equals(other.source) && timestamp.equals(other.timestamp) && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt) && authorUserId.equals(other.authorUserId) && comment.equals(other.comment) && metadata.equals(other.metadata) && configId.equals(other.configId) && queueId.equals(other.queueId) && environment.equals(other.environment) && trace.equals(other.trace); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value, this.stringValue, this.id, this.traceId, this.sessionId, this.observationId, this.datasetRunId, this.name, this.source, this.timestamp, this.createdAt, this.updatedAt, this.authorUserId, this.comment, this.metadata, this.configId, this.queueId, this.environment, this.trace); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ValueStage builder() { + return new Builder(); + } + + public interface ValueStage { + StringValueStage value(double value); + + Builder from(GetScoresResponseDataBoolean other); + } + + public interface StringValueStage { + IdStage stringValue(@NotNull String stringValue); + } + + public interface IdStage { + NameStage id(@NotNull String id); + } + + public interface NameStage { + SourceStage name(@NotNull String name); + } + + public interface SourceStage { + TimestampStage source(@NotNull ScoreSource source); + } + + public interface TimestampStage { + CreatedAtStage timestamp(@NotNull OffsetDateTime timestamp); + } + + public interface CreatedAtStage { + UpdatedAtStage createdAt(@NotNull OffsetDateTime createdAt); + } + + public interface UpdatedAtStage { + _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt); + } + + public interface _FinalStage { + GetScoresResponseDataBoolean build(); + + _FinalStage traceId(Optional traceId); + + _FinalStage traceId(String traceId); + + _FinalStage sessionId(Optional sessionId); + + _FinalStage sessionId(String sessionId); + + _FinalStage observationId(Optional observationId); + + _FinalStage observationId(String observationId); + + _FinalStage datasetRunId(Optional datasetRunId); + + _FinalStage datasetRunId(String datasetRunId); + + _FinalStage authorUserId(Optional authorUserId); + + _FinalStage authorUserId(String authorUserId); + + _FinalStage comment(Optional comment); + + _FinalStage comment(String comment); + + _FinalStage metadata(Optional metadata); + + _FinalStage metadata(Object metadata); + + _FinalStage configId(Optional configId); + + _FinalStage configId(String configId); + + _FinalStage queueId(Optional queueId); + + _FinalStage queueId(String queueId); + + _FinalStage environment(Optional environment); + + _FinalStage environment(String environment); + + _FinalStage trace(Optional trace); + + _FinalStage trace(GetScoresResponseTraceData trace); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements ValueStage, StringValueStage, IdStage, NameStage, SourceStage, TimestampStage, CreatedAtStage, UpdatedAtStage, _FinalStage { + private double value; + + private String stringValue; + + private String id; + + private String name; + + private ScoreSource source; + + private OffsetDateTime timestamp; + + private OffsetDateTime createdAt; + + private OffsetDateTime updatedAt; + + private Optional trace = Optional.empty(); + + private Optional environment = Optional.empty(); + + private Optional queueId = Optional.empty(); + + private Optional configId = Optional.empty(); + + private Optional metadata = Optional.empty(); + + private Optional comment = Optional.empty(); + + private Optional authorUserId = Optional.empty(); + + private Optional datasetRunId = Optional.empty(); + + private Optional observationId = Optional.empty(); + + private Optional sessionId = Optional.empty(); + + private Optional traceId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(GetScoresResponseDataBoolean other) { + value(other.getValue()); + stringValue(other.getStringValue()); + id(other.getId()); + traceId(other.getTraceId()); + sessionId(other.getSessionId()); + observationId(other.getObservationId()); + datasetRunId(other.getDatasetRunId()); + name(other.getName()); + source(other.getSource()); + timestamp(other.getTimestamp()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + authorUserId(other.getAuthorUserId()); + comment(other.getComment()); + metadata(other.getMetadata()); + configId(other.getConfigId()); + queueId(other.getQueueId()); + environment(other.getEnvironment()); + trace(other.getTrace()); + return this; + } + + /** + *

The numeric value of the score. Equals 1 for "True" and 0 for "False"

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("value") + public StringValueStage value(double value) { + this.value = value; + return this; + } + + /** + *

The string representation of the score value. Is inferred from the numeric value and equals "True" or "False"

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("stringValue") + public IdStage stringValue(@NotNull String stringValue) { + this.stringValue = Objects.requireNonNull(stringValue, "stringValue must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public NameStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public SourceStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("source") + public TimestampStage source(@NotNull ScoreSource source) { + this.source = Objects.requireNonNull(source, "source must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("timestamp") + public CreatedAtStage timestamp(@NotNull OffsetDateTime timestamp) { + this.timestamp = Objects.requireNonNull(timestamp, "timestamp must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("createdAt") + public UpdatedAtStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("updatedAt") + public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { + this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage trace(GetScoresResponseTraceData trace) { + this.trace = Optional.ofNullable(trace); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "trace", + nulls = Nulls.SKIP + ) + public _FinalStage trace(Optional trace) { + this.trace = trace; + return this; + } + + /** + *

The environment from which this score originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage environment(String environment) { + this.environment = Optional.ofNullable(environment); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "environment", + nulls = Nulls.SKIP + ) + public _FinalStage environment(Optional environment) { + this.environment = environment; + return this; + } + + /** + *

Reference an annotation queue on a score. Populated if the score was initially created in an annotation queue.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage queueId(String queueId) { + this.queueId = Optional.ofNullable(queueId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "queueId", + nulls = Nulls.SKIP + ) + public _FinalStage queueId(Optional queueId) { + this.queueId = queueId; + return this; + } + + /** + *

Reference a score config on a score. When set, config and score name must be equal and value must comply to optionally defined numerical range

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage configId(String configId) { + this.configId = Optional.ofNullable(configId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "configId", + nulls = Nulls.SKIP + ) + public _FinalStage configId(Optional configId) { + this.configId = configId; + return this; + } + + @java.lang.Override + public _FinalStage metadata(Object metadata) { + this.metadata = Optional.ofNullable(metadata); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "metadata", + nulls = Nulls.SKIP + ) + public _FinalStage metadata(Optional metadata) { + this.metadata = metadata; + return this; + } + + @java.lang.Override + public _FinalStage comment(String comment) { + this.comment = Optional.ofNullable(comment); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "comment", + nulls = Nulls.SKIP + ) + public _FinalStage comment(Optional comment) { + this.comment = comment; + return this; + } + + @java.lang.Override + public _FinalStage authorUserId(String authorUserId) { + this.authorUserId = Optional.ofNullable(authorUserId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "authorUserId", + nulls = Nulls.SKIP + ) + public _FinalStage authorUserId(Optional authorUserId) { + this.authorUserId = authorUserId; + return this; + } + + @java.lang.Override + public _FinalStage datasetRunId(String datasetRunId) { + this.datasetRunId = Optional.ofNullable(datasetRunId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "datasetRunId", + nulls = Nulls.SKIP + ) + public _FinalStage datasetRunId(Optional datasetRunId) { + this.datasetRunId = datasetRunId; + return this; + } + + @java.lang.Override + public _FinalStage observationId(String observationId) { + this.observationId = Optional.ofNullable(observationId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "observationId", + nulls = Nulls.SKIP + ) + public _FinalStage observationId(Optional observationId) { + this.observationId = observationId; + return this; + } + + @java.lang.Override + public _FinalStage sessionId(String sessionId) { + this.sessionId = Optional.ofNullable(sessionId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "sessionId", + nulls = Nulls.SKIP + ) + public _FinalStage sessionId(Optional sessionId) { + this.sessionId = sessionId; + return this; + } + + @java.lang.Override + public _FinalStage traceId(String traceId) { + this.traceId = Optional.ofNullable(traceId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "traceId", + nulls = Nulls.SKIP + ) + public _FinalStage traceId(Optional traceId) { + this.traceId = traceId; + return this; + } + + @java.lang.Override + public GetScoresResponseDataBoolean build() { + return new GetScoresResponseDataBoolean(value, stringValue, id, traceId, sessionId, observationId, datasetRunId, name, source, timestamp, createdAt, updatedAt, authorUserId, comment, metadata, configId, queueId, environment, trace, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/scorev2/types/GetScoresResponseDataCategorical.java b/src/main/java/com/langfuse/client/resources/scorev2/types/GetScoresResponseDataCategorical.java new file mode 100644 index 0000000..e73e55f --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/scorev2/types/GetScoresResponseDataCategorical.java @@ -0,0 +1,680 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.scorev2.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Double; +import java.lang.Object; +import java.lang.String; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; +import com.langfuse.client.resources.commons.types.IBaseScore; +import com.langfuse.client.resources.commons.types.ICategoricalScore; +import com.langfuse.client.resources.commons.types.ScoreSource; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = GetScoresResponseDataCategorical.Builder.class +) +public final class GetScoresResponseDataCategorical implements ICategoricalScore, IBaseScore { + private final Optional value; + + private final String stringValue; + + private final String id; + + private final Optional traceId; + + private final Optional sessionId; + + private final Optional observationId; + + private final Optional datasetRunId; + + private final String name; + + private final ScoreSource source; + + private final OffsetDateTime timestamp; + + private final OffsetDateTime createdAt; + + private final OffsetDateTime updatedAt; + + private final Optional authorUserId; + + private final Optional comment; + + private final Optional metadata; + + private final Optional configId; + + private final Optional queueId; + + private final Optional environment; + + private final Optional trace; + + private final Map additionalProperties; + + private GetScoresResponseDataCategorical(Optional value, String stringValue, String id, + Optional traceId, Optional sessionId, Optional observationId, + Optional datasetRunId, String name, ScoreSource source, OffsetDateTime timestamp, + OffsetDateTime createdAt, OffsetDateTime updatedAt, Optional authorUserId, + Optional comment, Optional metadata, Optional configId, + Optional queueId, Optional environment, + Optional trace, Map additionalProperties) { + this.value = value; + this.stringValue = stringValue; + this.id = id; + this.traceId = traceId; + this.sessionId = sessionId; + this.observationId = observationId; + this.datasetRunId = datasetRunId; + this.name = name; + this.source = source; + this.timestamp = timestamp; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.authorUserId = authorUserId; + this.comment = comment; + this.metadata = metadata; + this.configId = configId; + this.queueId = queueId; + this.environment = environment; + this.trace = trace; + this.additionalProperties = additionalProperties; + } + + /** + * @return Only defined if a config is linked. Represents the numeric category mapping of the stringValue + */ + @JsonProperty("value") + @java.lang.Override + public Optional getValue() { + return value; + } + + /** + * @return The string representation of the score value. If no config is linked, can be any string. Otherwise, must map to a config category + */ + @JsonProperty("stringValue") + @java.lang.Override + public String getStringValue() { + return stringValue; + } + + @JsonProperty("id") + @java.lang.Override + public String getId() { + return id; + } + + @JsonProperty("traceId") + @java.lang.Override + public Optional getTraceId() { + return traceId; + } + + @JsonProperty("sessionId") + @java.lang.Override + public Optional getSessionId() { + return sessionId; + } + + @JsonProperty("observationId") + @java.lang.Override + public Optional getObservationId() { + return observationId; + } + + @JsonProperty("datasetRunId") + @java.lang.Override + public Optional getDatasetRunId() { + return datasetRunId; + } + + @JsonProperty("name") + @java.lang.Override + public String getName() { + return name; + } + + @JsonProperty("source") + @java.lang.Override + public ScoreSource getSource() { + return source; + } + + @JsonProperty("timestamp") + @java.lang.Override + public OffsetDateTime getTimestamp() { + return timestamp; + } + + @JsonProperty("createdAt") + @java.lang.Override + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("updatedAt") + @java.lang.Override + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @JsonProperty("authorUserId") + @java.lang.Override + public Optional getAuthorUserId() { + return authorUserId; + } + + @JsonProperty("comment") + @java.lang.Override + public Optional getComment() { + return comment; + } + + @JsonProperty("metadata") + @java.lang.Override + public Optional getMetadata() { + return metadata; + } + + /** + * @return Reference a score config on a score. When set, config and score name must be equal and value must comply to optionally defined numerical range + */ + @JsonProperty("configId") + @java.lang.Override + public Optional getConfigId() { + return configId; + } + + /** + * @return Reference an annotation queue on a score. Populated if the score was initially created in an annotation queue. + */ + @JsonProperty("queueId") + @java.lang.Override + public Optional getQueueId() { + return queueId; + } + + /** + * @return The environment from which this score originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'. + */ + @JsonProperty("environment") + @java.lang.Override + public Optional getEnvironment() { + return environment; + } + + @JsonProperty("trace") + public Optional getTrace() { + return trace; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetScoresResponseDataCategorical && equalTo((GetScoresResponseDataCategorical) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetScoresResponseDataCategorical other) { + return value.equals(other.value) && stringValue.equals(other.stringValue) && id.equals(other.id) && traceId.equals(other.traceId) && sessionId.equals(other.sessionId) && observationId.equals(other.observationId) && datasetRunId.equals(other.datasetRunId) && name.equals(other.name) && source.equals(other.source) && timestamp.equals(other.timestamp) && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt) && authorUserId.equals(other.authorUserId) && comment.equals(other.comment) && metadata.equals(other.metadata) && configId.equals(other.configId) && queueId.equals(other.queueId) && environment.equals(other.environment) && trace.equals(other.trace); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value, this.stringValue, this.id, this.traceId, this.sessionId, this.observationId, this.datasetRunId, this.name, this.source, this.timestamp, this.createdAt, this.updatedAt, this.authorUserId, this.comment, this.metadata, this.configId, this.queueId, this.environment, this.trace); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static StringValueStage builder() { + return new Builder(); + } + + public interface StringValueStage { + IdStage stringValue(@NotNull String stringValue); + + Builder from(GetScoresResponseDataCategorical other); + } + + public interface IdStage { + NameStage id(@NotNull String id); + } + + public interface NameStage { + SourceStage name(@NotNull String name); + } + + public interface SourceStage { + TimestampStage source(@NotNull ScoreSource source); + } + + public interface TimestampStage { + CreatedAtStage timestamp(@NotNull OffsetDateTime timestamp); + } + + public interface CreatedAtStage { + UpdatedAtStage createdAt(@NotNull OffsetDateTime createdAt); + } + + public interface UpdatedAtStage { + _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt); + } + + public interface _FinalStage { + GetScoresResponseDataCategorical build(); + + _FinalStage value(Optional value); + + _FinalStage value(Double value); + + _FinalStage traceId(Optional traceId); + + _FinalStage traceId(String traceId); + + _FinalStage sessionId(Optional sessionId); + + _FinalStage sessionId(String sessionId); + + _FinalStage observationId(Optional observationId); + + _FinalStage observationId(String observationId); + + _FinalStage datasetRunId(Optional datasetRunId); + + _FinalStage datasetRunId(String datasetRunId); + + _FinalStage authorUserId(Optional authorUserId); + + _FinalStage authorUserId(String authorUserId); + + _FinalStage comment(Optional comment); + + _FinalStage comment(String comment); + + _FinalStage metadata(Optional metadata); + + _FinalStage metadata(Object metadata); + + _FinalStage configId(Optional configId); + + _FinalStage configId(String configId); + + _FinalStage queueId(Optional queueId); + + _FinalStage queueId(String queueId); + + _FinalStage environment(Optional environment); + + _FinalStage environment(String environment); + + _FinalStage trace(Optional trace); + + _FinalStage trace(GetScoresResponseTraceData trace); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements StringValueStage, IdStage, NameStage, SourceStage, TimestampStage, CreatedAtStage, UpdatedAtStage, _FinalStage { + private String stringValue; + + private String id; + + private String name; + + private ScoreSource source; + + private OffsetDateTime timestamp; + + private OffsetDateTime createdAt; + + private OffsetDateTime updatedAt; + + private Optional trace = Optional.empty(); + + private Optional environment = Optional.empty(); + + private Optional queueId = Optional.empty(); + + private Optional configId = Optional.empty(); + + private Optional metadata = Optional.empty(); + + private Optional comment = Optional.empty(); + + private Optional authorUserId = Optional.empty(); + + private Optional datasetRunId = Optional.empty(); + + private Optional observationId = Optional.empty(); + + private Optional sessionId = Optional.empty(); + + private Optional traceId = Optional.empty(); + + private Optional value = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(GetScoresResponseDataCategorical other) { + value(other.getValue()); + stringValue(other.getStringValue()); + id(other.getId()); + traceId(other.getTraceId()); + sessionId(other.getSessionId()); + observationId(other.getObservationId()); + datasetRunId(other.getDatasetRunId()); + name(other.getName()); + source(other.getSource()); + timestamp(other.getTimestamp()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + authorUserId(other.getAuthorUserId()); + comment(other.getComment()); + metadata(other.getMetadata()); + configId(other.getConfigId()); + queueId(other.getQueueId()); + environment(other.getEnvironment()); + trace(other.getTrace()); + return this; + } + + /** + *

The string representation of the score value. If no config is linked, can be any string. Otherwise, must map to a config category

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("stringValue") + public IdStage stringValue(@NotNull String stringValue) { + this.stringValue = Objects.requireNonNull(stringValue, "stringValue must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public NameStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public SourceStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("source") + public TimestampStage source(@NotNull ScoreSource source) { + this.source = Objects.requireNonNull(source, "source must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("timestamp") + public CreatedAtStage timestamp(@NotNull OffsetDateTime timestamp) { + this.timestamp = Objects.requireNonNull(timestamp, "timestamp must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("createdAt") + public UpdatedAtStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("updatedAt") + public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { + this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage trace(GetScoresResponseTraceData trace) { + this.trace = Optional.ofNullable(trace); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "trace", + nulls = Nulls.SKIP + ) + public _FinalStage trace(Optional trace) { + this.trace = trace; + return this; + } + + /** + *

The environment from which this score originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage environment(String environment) { + this.environment = Optional.ofNullable(environment); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "environment", + nulls = Nulls.SKIP + ) + public _FinalStage environment(Optional environment) { + this.environment = environment; + return this; + } + + /** + *

Reference an annotation queue on a score. Populated if the score was initially created in an annotation queue.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage queueId(String queueId) { + this.queueId = Optional.ofNullable(queueId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "queueId", + nulls = Nulls.SKIP + ) + public _FinalStage queueId(Optional queueId) { + this.queueId = queueId; + return this; + } + + /** + *

Reference a score config on a score. When set, config and score name must be equal and value must comply to optionally defined numerical range

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage configId(String configId) { + this.configId = Optional.ofNullable(configId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "configId", + nulls = Nulls.SKIP + ) + public _FinalStage configId(Optional configId) { + this.configId = configId; + return this; + } + + @java.lang.Override + public _FinalStage metadata(Object metadata) { + this.metadata = Optional.ofNullable(metadata); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "metadata", + nulls = Nulls.SKIP + ) + public _FinalStage metadata(Optional metadata) { + this.metadata = metadata; + return this; + } + + @java.lang.Override + public _FinalStage comment(String comment) { + this.comment = Optional.ofNullable(comment); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "comment", + nulls = Nulls.SKIP + ) + public _FinalStage comment(Optional comment) { + this.comment = comment; + return this; + } + + @java.lang.Override + public _FinalStage authorUserId(String authorUserId) { + this.authorUserId = Optional.ofNullable(authorUserId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "authorUserId", + nulls = Nulls.SKIP + ) + public _FinalStage authorUserId(Optional authorUserId) { + this.authorUserId = authorUserId; + return this; + } + + @java.lang.Override + public _FinalStage datasetRunId(String datasetRunId) { + this.datasetRunId = Optional.ofNullable(datasetRunId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "datasetRunId", + nulls = Nulls.SKIP + ) + public _FinalStage datasetRunId(Optional datasetRunId) { + this.datasetRunId = datasetRunId; + return this; + } + + @java.lang.Override + public _FinalStage observationId(String observationId) { + this.observationId = Optional.ofNullable(observationId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "observationId", + nulls = Nulls.SKIP + ) + public _FinalStage observationId(Optional observationId) { + this.observationId = observationId; + return this; + } + + @java.lang.Override + public _FinalStage sessionId(String sessionId) { + this.sessionId = Optional.ofNullable(sessionId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "sessionId", + nulls = Nulls.SKIP + ) + public _FinalStage sessionId(Optional sessionId) { + this.sessionId = sessionId; + return this; + } + + @java.lang.Override + public _FinalStage traceId(String traceId) { + this.traceId = Optional.ofNullable(traceId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "traceId", + nulls = Nulls.SKIP + ) + public _FinalStage traceId(Optional traceId) { + this.traceId = traceId; + return this; + } + + /** + *

Only defined if a config is linked. Represents the numeric category mapping of the stringValue

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage value(Double value) { + this.value = Optional.ofNullable(value); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "value", + nulls = Nulls.SKIP + ) + public _FinalStage value(Optional value) { + this.value = value; + return this; + } + + @java.lang.Override + public GetScoresResponseDataCategorical build() { + return new GetScoresResponseDataCategorical(value, stringValue, id, traceId, sessionId, observationId, datasetRunId, name, source, timestamp, createdAt, updatedAt, authorUserId, comment, metadata, configId, queueId, environment, trace, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/scorev2/types/GetScoresResponseDataNumeric.java b/src/main/java/com/langfuse/client/resources/scorev2/types/GetScoresResponseDataNumeric.java new file mode 100644 index 0000000..8e8dbc5 --- /dev/null +++ b/src/main/java/com/langfuse/client/resources/scorev2/types/GetScoresResponseDataNumeric.java @@ -0,0 +1,640 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package com.langfuse.client.resources.scorev2.types; + +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 com.langfuse.client.core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; +import com.langfuse.client.resources.commons.types.IBaseScore; +import com.langfuse.client.resources.commons.types.INumericScore; +import com.langfuse.client.resources.commons.types.ScoreSource; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = GetScoresResponseDataNumeric.Builder.class +) +public final class GetScoresResponseDataNumeric implements INumericScore, IBaseScore { + private final double value; + + private final String id; + + private final Optional traceId; + + private final Optional sessionId; + + private final Optional observationId; + + private final Optional datasetRunId; + + private final String name; + + private final ScoreSource source; + + private final OffsetDateTime timestamp; + + private final OffsetDateTime createdAt; + + private final OffsetDateTime updatedAt; + + private final Optional authorUserId; + + private final Optional comment; + + private final Optional metadata; + + private final Optional configId; + + private final Optional queueId; + + private final Optional environment; + + private final Optional trace; + + private final Map additionalProperties; + + private GetScoresResponseDataNumeric(double value, String id, Optional traceId, + Optional sessionId, Optional observationId, Optional datasetRunId, + String name, ScoreSource source, OffsetDateTime timestamp, OffsetDateTime createdAt, + OffsetDateTime updatedAt, Optional authorUserId, Optional comment, + Optional metadata, Optional configId, Optional queueId, + Optional environment, Optional trace, + Map additionalProperties) { + this.value = value; + this.id = id; + this.traceId = traceId; + this.sessionId = sessionId; + this.observationId = observationId; + this.datasetRunId = datasetRunId; + this.name = name; + this.source = source; + this.timestamp = timestamp; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.authorUserId = authorUserId; + this.comment = comment; + this.metadata = metadata; + this.configId = configId; + this.queueId = queueId; + this.environment = environment; + this.trace = trace; + this.additionalProperties = additionalProperties; + } + + /** + * @return The numeric value of the score + */ + @JsonProperty("value") + @java.lang.Override + public double getValue() { + return value; + } + + @JsonProperty("id") + @java.lang.Override + public String getId() { + return id; + } + + @JsonProperty("traceId") + @java.lang.Override + public Optional getTraceId() { + return traceId; + } + + @JsonProperty("sessionId") + @java.lang.Override + public Optional getSessionId() { + return sessionId; + } + + @JsonProperty("observationId") + @java.lang.Override + public Optional getObservationId() { + return observationId; + } + + @JsonProperty("datasetRunId") + @java.lang.Override + public Optional getDatasetRunId() { + return datasetRunId; + } + + @JsonProperty("name") + @java.lang.Override + public String getName() { + return name; + } + + @JsonProperty("source") + @java.lang.Override + public ScoreSource getSource() { + return source; + } + + @JsonProperty("timestamp") + @java.lang.Override + public OffsetDateTime getTimestamp() { + return timestamp; + } + + @JsonProperty("createdAt") + @java.lang.Override + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("updatedAt") + @java.lang.Override + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @JsonProperty("authorUserId") + @java.lang.Override + public Optional getAuthorUserId() { + return authorUserId; + } + + @JsonProperty("comment") + @java.lang.Override + public Optional getComment() { + return comment; + } + + @JsonProperty("metadata") + @java.lang.Override + public Optional getMetadata() { + return metadata; + } + + /** + * @return Reference a score config on a score. When set, config and score name must be equal and value must comply to optionally defined numerical range + */ + @JsonProperty("configId") + @java.lang.Override + public Optional getConfigId() { + return configId; + } + + /** + * @return Reference an annotation queue on a score. Populated if the score was initially created in an annotation queue. + */ + @JsonProperty("queueId") + @java.lang.Override + public Optional getQueueId() { + return queueId; + } + + /** + * @return The environment from which this score originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'. + */ + @JsonProperty("environment") + @java.lang.Override + public Optional getEnvironment() { + return environment; + } + + @JsonProperty("trace") + public Optional getTrace() { + return trace; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetScoresResponseDataNumeric && equalTo((GetScoresResponseDataNumeric) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetScoresResponseDataNumeric other) { + return value == other.value && id.equals(other.id) && traceId.equals(other.traceId) && sessionId.equals(other.sessionId) && observationId.equals(other.observationId) && datasetRunId.equals(other.datasetRunId) && name.equals(other.name) && source.equals(other.source) && timestamp.equals(other.timestamp) && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt) && authorUserId.equals(other.authorUserId) && comment.equals(other.comment) && metadata.equals(other.metadata) && configId.equals(other.configId) && queueId.equals(other.queueId) && environment.equals(other.environment) && trace.equals(other.trace); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value, this.id, this.traceId, this.sessionId, this.observationId, this.datasetRunId, this.name, this.source, this.timestamp, this.createdAt, this.updatedAt, this.authorUserId, this.comment, this.metadata, this.configId, this.queueId, this.environment, this.trace); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ValueStage builder() { + return new Builder(); + } + + public interface ValueStage { + IdStage value(double value); + + Builder from(GetScoresResponseDataNumeric other); + } + + public interface IdStage { + NameStage id(@NotNull String id); + } + + public interface NameStage { + SourceStage name(@NotNull String name); + } + + public interface SourceStage { + TimestampStage source(@NotNull ScoreSource source); + } + + public interface TimestampStage { + CreatedAtStage timestamp(@NotNull OffsetDateTime timestamp); + } + + public interface CreatedAtStage { + UpdatedAtStage createdAt(@NotNull OffsetDateTime createdAt); + } + + public interface UpdatedAtStage { + _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt); + } + + public interface _FinalStage { + GetScoresResponseDataNumeric build(); + + _FinalStage traceId(Optional traceId); + + _FinalStage traceId(String traceId); + + _FinalStage sessionId(Optional sessionId); + + _FinalStage sessionId(String sessionId); + + _FinalStage observationId(Optional observationId); + + _FinalStage observationId(String observationId); + + _FinalStage datasetRunId(Optional datasetRunId); + + _FinalStage datasetRunId(String datasetRunId); + + _FinalStage authorUserId(Optional authorUserId); + + _FinalStage authorUserId(String authorUserId); + + _FinalStage comment(Optional comment); + + _FinalStage comment(String comment); + + _FinalStage metadata(Optional metadata); + + _FinalStage metadata(Object metadata); + + _FinalStage configId(Optional configId); + + _FinalStage configId(String configId); + + _FinalStage queueId(Optional queueId); + + _FinalStage queueId(String queueId); + + _FinalStage environment(Optional environment); + + _FinalStage environment(String environment); + + _FinalStage trace(Optional trace); + + _FinalStage trace(GetScoresResponseTraceData trace); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements ValueStage, IdStage, NameStage, SourceStage, TimestampStage, CreatedAtStage, UpdatedAtStage, _FinalStage { + private double value; + + private String id; + + private String name; + + private ScoreSource source; + + private OffsetDateTime timestamp; + + private OffsetDateTime createdAt; + + private OffsetDateTime updatedAt; + + private Optional trace = Optional.empty(); + + private Optional environment = Optional.empty(); + + private Optional queueId = Optional.empty(); + + private Optional configId = Optional.empty(); + + private Optional metadata = Optional.empty(); + + private Optional comment = Optional.empty(); + + private Optional authorUserId = Optional.empty(); + + private Optional datasetRunId = Optional.empty(); + + private Optional observationId = Optional.empty(); + + private Optional sessionId = Optional.empty(); + + private Optional traceId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() { + } + + @java.lang.Override + public Builder from(GetScoresResponseDataNumeric other) { + value(other.getValue()); + id(other.getId()); + traceId(other.getTraceId()); + sessionId(other.getSessionId()); + observationId(other.getObservationId()); + datasetRunId(other.getDatasetRunId()); + name(other.getName()); + source(other.getSource()); + timestamp(other.getTimestamp()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + authorUserId(other.getAuthorUserId()); + comment(other.getComment()); + metadata(other.getMetadata()); + configId(other.getConfigId()); + queueId(other.getQueueId()); + environment(other.getEnvironment()); + trace(other.getTrace()); + return this; + } + + /** + *

The numeric value of the score

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("value") + public IdStage value(double value) { + this.value = value; + return this; + } + + @java.lang.Override + @JsonSetter("id") + public NameStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public SourceStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("source") + public TimestampStage source(@NotNull ScoreSource source) { + this.source = Objects.requireNonNull(source, "source must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("timestamp") + public CreatedAtStage timestamp(@NotNull OffsetDateTime timestamp) { + this.timestamp = Objects.requireNonNull(timestamp, "timestamp must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("createdAt") + public UpdatedAtStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("updatedAt") + public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { + this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage trace(GetScoresResponseTraceData trace) { + this.trace = Optional.ofNullable(trace); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "trace", + nulls = Nulls.SKIP + ) + public _FinalStage trace(Optional trace) { + this.trace = trace; + return this; + } + + /** + *

The environment from which this score originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage environment(String environment) { + this.environment = Optional.ofNullable(environment); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "environment", + nulls = Nulls.SKIP + ) + public _FinalStage environment(Optional environment) { + this.environment = environment; + return this; + } + + /** + *

Reference an annotation queue on a score. Populated if the score was initially created in an annotation queue.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage queueId(String queueId) { + this.queueId = Optional.ofNullable(queueId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "queueId", + nulls = Nulls.SKIP + ) + public _FinalStage queueId(Optional queueId) { + this.queueId = queueId; + return this; + } + + /** + *

Reference a score config on a score. When set, config and score name must be equal and value must comply to optionally defined numerical range

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage configId(String configId) { + this.configId = Optional.ofNullable(configId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "configId", + nulls = Nulls.SKIP + ) + public _FinalStage configId(Optional configId) { + this.configId = configId; + return this; + } + + @java.lang.Override + public _FinalStage metadata(Object metadata) { + this.metadata = Optional.ofNullable(metadata); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "metadata", + nulls = Nulls.SKIP + ) + public _FinalStage metadata(Optional metadata) { + this.metadata = metadata; + return this; + } + + @java.lang.Override + public _FinalStage comment(String comment) { + this.comment = Optional.ofNullable(comment); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "comment", + nulls = Nulls.SKIP + ) + public _FinalStage comment(Optional comment) { + this.comment = comment; + return this; + } + + @java.lang.Override + public _FinalStage authorUserId(String authorUserId) { + this.authorUserId = Optional.ofNullable(authorUserId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "authorUserId", + nulls = Nulls.SKIP + ) + public _FinalStage authorUserId(Optional authorUserId) { + this.authorUserId = authorUserId; + return this; + } + + @java.lang.Override + public _FinalStage datasetRunId(String datasetRunId) { + this.datasetRunId = Optional.ofNullable(datasetRunId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "datasetRunId", + nulls = Nulls.SKIP + ) + public _FinalStage datasetRunId(Optional datasetRunId) { + this.datasetRunId = datasetRunId; + return this; + } + + @java.lang.Override + public _FinalStage observationId(String observationId) { + this.observationId = Optional.ofNullable(observationId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "observationId", + nulls = Nulls.SKIP + ) + public _FinalStage observationId(Optional observationId) { + this.observationId = observationId; + return this; + } + + @java.lang.Override + public _FinalStage sessionId(String sessionId) { + this.sessionId = Optional.ofNullable(sessionId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "sessionId", + nulls = Nulls.SKIP + ) + public _FinalStage sessionId(Optional sessionId) { + this.sessionId = sessionId; + return this; + } + + @java.lang.Override + public _FinalStage traceId(String traceId) { + this.traceId = Optional.ofNullable(traceId); + return this; + } + + @java.lang.Override + @JsonSetter( + value = "traceId", + nulls = Nulls.SKIP + ) + public _FinalStage traceId(Optional traceId) { + this.traceId = traceId; + return this; + } + + @java.lang.Override + public GetScoresResponseDataNumeric build() { + return new GetScoresResponseDataNumeric(value, id, traceId, sessionId, observationId, datasetRunId, name, source, timestamp, createdAt, updatedAt, authorUserId, comment, metadata, configId, queueId, environment, trace, additionalProperties); + } + } +} diff --git a/src/main/java/com/langfuse/client/resources/score/types/GetScoresResponseTraceData.java b/src/main/java/com/langfuse/client/resources/scorev2/types/GetScoresResponseTraceData.java similarity index 98% rename from src/main/java/com/langfuse/client/resources/score/types/GetScoresResponseTraceData.java rename to src/main/java/com/langfuse/client/resources/scorev2/types/GetScoresResponseTraceData.java index 7fe61b4..7eff37b 100644 --- a/src/main/java/com/langfuse/client/resources/score/types/GetScoresResponseTraceData.java +++ b/src/main/java/com/langfuse/client/resources/scorev2/types/GetScoresResponseTraceData.java @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -package com.langfuse.client.resources.score.types; +package com.langfuse.client.resources.scorev2.types; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; diff --git a/src/main/java/com/langfuse/client/resources/trace/TraceClient.java b/src/main/java/com/langfuse/client/resources/trace/TraceClient.java index 4808cc8..535ee30 100644 --- a/src/main/java/com/langfuse/client/resources/trace/TraceClient.java +++ b/src/main/java/com/langfuse/client/resources/trace/TraceClient.java @@ -200,6 +200,9 @@ public Traces list(GetTracesRequest request, RequestOptions requestOptions) { if (request.getEnvironment().isPresent()) { QueryStringMapper.addQueryParameter(httpUrl, "environment", request.getEnvironment().get(), false); } + if (request.getFields().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "fields", request.getFields().get(), false); + } Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl.build()) .method("GET", null) diff --git a/src/main/java/com/langfuse/client/resources/trace/requests/GetTracesRequest.java b/src/main/java/com/langfuse/client/resources/trace/requests/GetTracesRequest.java index 47611c7..a3e0b10 100644 --- a/src/main/java/com/langfuse/client/resources/trace/requests/GetTracesRequest.java +++ b/src/main/java/com/langfuse/client/resources/trace/requests/GetTracesRequest.java @@ -51,13 +51,15 @@ public final class GetTracesRequest { private final Optional environment; + private final Optional fields; + private final Map additionalProperties; private GetTracesRequest(Optional page, Optional limit, Optional userId, Optional name, Optional sessionId, Optional fromTimestamp, Optional toTimestamp, Optional orderBy, Optional tags, Optional version, Optional release, Optional environment, - Map additionalProperties) { + Optional fields, Map additionalProperties) { this.page = page; this.limit = limit; this.userId = userId; @@ -70,6 +72,7 @@ private GetTracesRequest(Optional page, Optional limit, Option this.version = version; this.release = release; this.environment = environment; + this.fields = fields; this.additionalProperties = additionalProperties; } @@ -160,6 +163,14 @@ public Optional getEnvironment() { return environment; } + /** + * @return Comma-separated list of fields to include in the response. Available field groups are 'core' (always included), 'io' (input, output, metadata), 'scores', 'observations', 'metrics'. If not provided, all fields are included. Example: 'core,scores,metrics' + */ + @JsonProperty("fields") + public Optional getFields() { + return fields; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -172,12 +183,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(GetTracesRequest other) { - return page.equals(other.page) && limit.equals(other.limit) && userId.equals(other.userId) && name.equals(other.name) && sessionId.equals(other.sessionId) && fromTimestamp.equals(other.fromTimestamp) && toTimestamp.equals(other.toTimestamp) && orderBy.equals(other.orderBy) && tags.equals(other.tags) && version.equals(other.version) && release.equals(other.release) && environment.equals(other.environment); + return page.equals(other.page) && limit.equals(other.limit) && userId.equals(other.userId) && name.equals(other.name) && sessionId.equals(other.sessionId) && fromTimestamp.equals(other.fromTimestamp) && toTimestamp.equals(other.toTimestamp) && orderBy.equals(other.orderBy) && tags.equals(other.tags) && version.equals(other.version) && release.equals(other.release) && environment.equals(other.environment) && fields.equals(other.fields); } @java.lang.Override public int hashCode() { - return Objects.hash(this.page, this.limit, this.userId, this.name, this.sessionId, this.fromTimestamp, this.toTimestamp, this.orderBy, this.tags, this.version, this.release, this.environment); + return Objects.hash(this.page, this.limit, this.userId, this.name, this.sessionId, this.fromTimestamp, this.toTimestamp, this.orderBy, this.tags, this.version, this.release, this.environment, this.fields); } @java.lang.Override @@ -217,6 +228,8 @@ public static final class Builder { private Optional environment = Optional.empty(); + private Optional fields = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -236,6 +249,7 @@ public Builder from(GetTracesRequest other) { version(other.getVersion()); release(other.getRelease()); environment(other.getEnvironment()); + fields(other.getFields()); return this; } @@ -407,8 +421,22 @@ public Builder environment(String environment) { return this; } + @JsonSetter( + value = "fields", + nulls = Nulls.SKIP + ) + public Builder fields(Optional fields) { + this.fields = fields; + return this; + } + + public Builder fields(String fields) { + this.fields = Optional.ofNullable(fields); + return this; + } + public GetTracesRequest build() { - return new GetTracesRequest(page, limit, userId, name, sessionId, fromTimestamp, toTimestamp, orderBy, tags, version, release, environment, additionalProperties); + return new GetTracesRequest(page, limit, userId, name, sessionId, fromTimestamp, toTimestamp, orderBy, tags, version, release, environment, fields, additionalProperties); } } }