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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Build

on:
pull_request:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: '23'
distribution: 'temurin'

- name: Build with Maven
run: mvn clean package
2 changes: 1 addition & 1 deletion src/main/java/com/langfuse/client/core/ClientOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private ClientOptions(Environment environment, Map<String, String> headers,
this.environment = environment;
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.headers.putAll(new HashMap<String,String>() {{put("X-Fern-Language", "JAVA");put("X-Fern-SDK-Name", "com.langfuse.fern:langfuse-sdk");put("X-Fern-SDK-Version", "0.0.120");}});
this.headers.putAll(new HashMap<String,String>() {{put("X-Fern-Language", "JAVA");put("X-Fern-SDK-Name", "com.langfuse.fern:langfuse-sdk");put("X-Fern-SDK-Version", "0.0.169");}});
this.headerSuppliers = headerSuppliers;
this.httpClient = httpClient;
this.timeout = timeout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.langfuse.client.resources.commons.types.DatasetItem;
import com.langfuse.client.resources.datasetitems.requests.GetDatasetItemsRequest;
import com.langfuse.client.resources.datasetitems.types.CreateDatasetItemRequest;
import com.langfuse.client.resources.datasetitems.types.DeleteDatasetItemResponse;
import com.langfuse.client.resources.datasetitems.types.PaginatedDatasetItems;

public class DatasetItemsClient {
Expand Down Expand Up @@ -219,4 +220,56 @@ public PaginatedDatasetItems list(GetDatasetItemsRequest request, RequestOptions
throw new LangfuseClientException("Network error executing HTTP request", e);
}
}

/**
* Delete a dataset item and all its run items. This action is irreversible.
*/
public DeleteDatasetItemResponse delete(String id) {
return delete(id,null);
}

/**
* Delete a dataset item and all its run items. This action is irreversible.
*/
public DeleteDatasetItemResponse delete(String id, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder()
.addPathSegments("api/public")
.addPathSegments("dataset-items")
.addPathSegment(id)
.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(), DeleteDatasetItemResponse.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);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

package com.langfuse.client.resources.datasetitems.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 = DeleteDatasetItemResponse.Builder.class
)
public final class DeleteDatasetItemResponse {
private final String message;

private final Map<String, Object> additionalProperties;

private DeleteDatasetItemResponse(String message, Map<String, Object> additionalProperties) {
this.message = message;
this.additionalProperties = additionalProperties;
}

/**
* @return Success message after deletion
*/
@JsonProperty("message")
public String getMessage() {
return message;
}

@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof DeleteDatasetItemResponse && equalTo((DeleteDatasetItemResponse) other);
}

@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}

private boolean equalTo(DeleteDatasetItemResponse other) {
return message.equals(other.message);
}

@java.lang.Override
public int hashCode() {
return Objects.hash(this.message);
}

@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}

public static MessageStage builder() {
return new Builder();
}

public interface MessageStage {
_FinalStage message(@NotNull String message);

Builder from(DeleteDatasetItemResponse other);
}

public interface _FinalStage {
DeleteDatasetItemResponse build();
}

@JsonIgnoreProperties(
ignoreUnknown = true
)
public static final class Builder implements MessageStage, _FinalStage {
private String message;

@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();

private Builder() {
}

@java.lang.Override
public Builder from(DeleteDatasetItemResponse other) {
message(other.getMessage());
return this;
}

/**
* <p>Success message after deletion</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
@JsonSetter("message")
public _FinalStage message(@NotNull String message) {
this.message = Objects.requireNonNull(message, "message must not be null");
return this;
}

@java.lang.Override
public DeleteDatasetItemResponse build() {
return new DeleteDatasetItemResponse(message, additionalProperties);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.langfuse.client.resources.datasets.requests.GetDatasetRunsRequest;
import com.langfuse.client.resources.datasets.requests.GetDatasetsRequest;
import com.langfuse.client.resources.datasets.types.CreateDatasetRequest;
import com.langfuse.client.resources.datasets.types.DeleteDatasetRunResponse;
import com.langfuse.client.resources.datasets.types.PaginatedDatasetRuns;
import com.langfuse.client.resources.datasets.types.PaginatedDatasets;

Expand Down Expand Up @@ -269,6 +270,61 @@ public DatasetRunWithItems getRun(String datasetName, String runName,
}
}

/**
* Delete a dataset run and all its run items. This action is irreversible.
*/
public DeleteDatasetRunResponse deleteRun(String datasetName, String runName) {
return deleteRun(datasetName,runName,null);
}

/**
* Delete a dataset run and all its run items. This action is irreversible.
*/
public DeleteDatasetRunResponse deleteRun(String datasetName, String runName,
RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder()
.addPathSegments("api/public")
.addPathSegments("datasets")
.addPathSegment(datasetName)
.addPathSegments("runs")
.addPathSegment(runName)
.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(), DeleteDatasetRunResponse.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 dataset runs
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

package com.langfuse.client.resources.datasets.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 = DeleteDatasetRunResponse.Builder.class
)
public final class DeleteDatasetRunResponse {
private final String message;

private final Map<String, Object> additionalProperties;

private DeleteDatasetRunResponse(String message, Map<String, Object> additionalProperties) {
this.message = message;
this.additionalProperties = additionalProperties;
}

@JsonProperty("message")
public String getMessage() {
return message;
}

@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof DeleteDatasetRunResponse && equalTo((DeleteDatasetRunResponse) other);
}

@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}

private boolean equalTo(DeleteDatasetRunResponse other) {
return message.equals(other.message);
}

@java.lang.Override
public int hashCode() {
return Objects.hash(this.message);
}

@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}

public static MessageStage builder() {
return new Builder();
}

public interface MessageStage {
_FinalStage message(@NotNull String message);

Builder from(DeleteDatasetRunResponse other);
}

public interface _FinalStage {
DeleteDatasetRunResponse build();
}

@JsonIgnoreProperties(
ignoreUnknown = true
)
public static final class Builder implements MessageStage, _FinalStage {
private String message;

@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();

private Builder() {
}

@java.lang.Override
public Builder from(DeleteDatasetRunResponse other) {
message(other.getMessage());
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 DeleteDatasetRunResponse build() {
return new DeleteDatasetRunResponse(message, additionalProperties);
}
}
}
Loading