From 6a805d709f8fdee54273e8f4f207661e55716abb Mon Sep 17 00:00:00 2001
From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com>
Date: Wed, 4 Mar 2026 20:43:00 +0000
Subject: [PATCH 1/7] SDK regeneration
Unable to analyze changes with AI, incrementing PATCH version.
---
build.gradle | 4 +-
changelog.md | 4 +
reference.md | 77 ++++++
sample-app/src/main/java/sample/App.java | 2 +-
.../java/com/phenoml/api/AsyncClient.java | 38 ---
...ncPhenoML.java => AsyncPhenomlClient.java} | 8 +-
...er.java => AsyncPhenomlClientBuilder.java} | 51 ++--
src/main/java/com/phenoml/api/Client.java | 38 ---
.../api/{PhenoML.java => PhenomlClient.java} | 8 +-
...Builder.java => PhenomlClientBuilder.java} | 51 ++--
.../com/phenoml/api/core/ClientOptions.java | 4 +-
.../phenoml/api/core/OAuthTokenSupplier.java | 54 ++++
...on.java => PhenomlClientApiException.java} | 10 +-
...ption.java => PhenomlClientException.java} | 6 +-
...se.java => PhenomlClientHttpResponse.java} | 4 +-
.../com/phenoml/api/core/RequestOptions.java | 16 +-
.../resources/agent/AsyncRawAgentClient.java | 141 +++++-----
.../api/resources/agent/RawAgentClient.java | 105 ++++----
.../agent/errors/BadRequestError.java | 4 +-
.../agent/errors/ForbiddenError.java | 4 +-
.../agent/errors/InternalServerError.java | 4 +-
.../resources/agent/errors/NotFoundError.java | 4 +-
.../agent/errors/UnauthorizedError.java | 4 +-
.../agent/prompts/AsyncRawPromptsClient.java | 114 ++++----
.../agent/prompts/RawPromptsClient.java | 84 +++---
.../authtoken/auth/AsyncAuthClient.java | 32 +++
.../authtoken/auth/AsyncRawAuthClient.java | 142 ++++++++--
.../resources/authtoken/auth/AuthClient.java | 32 +++
.../authtoken/auth/RawAuthClient.java | 118 ++++++--
.../requests/ClientCredentialsRequest.java | 163 +++++++++++
.../authtoken/errors/BadRequestError.java | 4 +-
.../authtoken/errors/InternalServerError.java | 32 +++
.../authtoken/errors/UnauthorizedError.java | 4 +-
.../resources/authtoken/types/OAuthError.java | 254 ++++++++++++++++++
.../authtoken/types/TokenResponse.java | 182 +++++++++++++
.../cohort/AsyncRawCohortClient.java | 22 +-
.../api/resources/cohort/RawCohortClient.java | 18 +-
.../cohort/errors/BadRequestError.java | 4 +-
.../cohort/errors/InternalServerError.java | 4 +-
.../cohort/errors/UnauthorizedError.java | 4 +-
.../construe/AsyncRawConstrueClient.java | 181 +++++++------
.../resources/construe/RawConstrueClient.java | 133 ++++-----
.../construe/errors/BadRequestError.java | 4 +-
.../construe/errors/ConflictError.java | 4 +-
.../errors/FailedDependencyError.java | 4 +-
.../construe/errors/ForbiddenError.java | 4 +-
.../construe/errors/GatewayTimeoutError.java | 4 +-
.../construe/errors/InternalServerError.java | 4 +-
.../construe/errors/NotFoundError.java | 4 +-
.../construe/errors/NotImplementedError.java | 4 +-
.../errors/ServiceUnavailableError.java | 4 +-
.../construe/errors/UnauthorizedError.java | 4 +-
.../resources/fhir/AsyncRawFhirClient.java | 96 +++----
.../api/resources/fhir/RawFhirClient.java | 74 ++---
.../fhir/errors/BadGatewayError.java | 4 +-
.../fhir/errors/BadRequestError.java | 4 +-
.../fhir/errors/InternalServerError.java | 4 +-
.../resources/fhir/errors/NotFoundError.java | 4 +-
.../fhir/errors/UnauthorizedError.java | 4 +-
.../AsyncRawFhirProviderClient.java | 114 ++++----
.../fhirprovider/RawFhirProviderClient.java | 84 +++---
.../fhirprovider/errors/BadRequestError.java | 4 +-
.../fhirprovider/errors/ForbiddenError.java | 4 +-
.../errors/InternalServerError.java | 4 +-
.../fhirprovider/errors/NotFoundError.java | 4 +-
.../errors/UnauthorizedError.java | 4 +-
.../lang2fhir/AsyncRawLang2FhirClient.java | 102 +++----
.../lang2fhir/RawLang2FhirClient.java | 79 +++---
.../lang2fhir/errors/BadRequestError.java | 4 +-
.../errors/FailedDependencyError.java | 4 +-
.../lang2fhir/errors/ForbiddenError.java | 4 +-
.../lang2fhir/errors/InternalServerError.java | 4 +-
.../lang2fhir/errors/UnauthorizedError.java | 4 +-
.../errors/UnprocessableEntityError.java | 4 +-
.../summary/AsyncRawSummaryClient.java | 96 +++----
.../resources/summary/RawSummaryClient.java | 74 ++---
.../summary/errors/BadRequestError.java | 4 +-
.../summary/errors/ForbiddenError.java | 4 +-
.../summary/errors/InternalServerError.java | 4 +-
.../summary/errors/NotFoundError.java | 4 +-
.../summary/errors/UnauthorizedError.java | 4 +-
.../resources/tools/AsyncRawToolsClient.java | 63 ++---
.../api/resources/tools/RawToolsClient.java | 48 ++--
.../tools/errors/BadRequestError.java | 4 +-
.../tools/errors/FailedDependencyError.java | 4 +-
.../tools/errors/ForbiddenError.java | 4 +-
.../tools/errors/InternalServerError.java | 4 +-
.../tools/errors/UnauthorizedError.java | 4 +-
.../mcpserver/AsyncRawMcpServerClient.java | 64 ++---
.../tools/mcpserver/RawMcpServerClient.java | 48 ++--
.../mcpserver/tools/AsyncRawToolsClient.java | 64 ++---
.../tools/mcpserver/tools/RawToolsClient.java | 49 ++--
.../workflows/AsyncRawWorkflowsClient.java | 97 +++----
.../workflows/RawWorkflowsClient.java | 72 ++---
.../workflows/errors/BadRequestError.java | 4 +-
.../workflows/errors/ForbiddenError.java | 4 +-
.../workflows/errors/InternalServerError.java | 4 +-
.../workflows/errors/NotFoundError.java | 4 +-
.../workflows/errors/UnauthorizedError.java | 4 +-
.../api/wrapper/AsyncPhenoMLClient.java | 119 --------
.../phenoml/api/wrapper/PhenoMLClient.java | 89 ------
101 files changed, 2272 insertions(+), 1492 deletions(-)
delete mode 100644 src/main/java/com/phenoml/api/AsyncClient.java
rename src/main/java/com/phenoml/api/{AsyncPhenoML.java => AsyncPhenomlClient.java} (94%)
rename src/main/java/com/phenoml/api/{PhenoMLBuilder.java => AsyncPhenomlClientBuilder.java} (77%)
delete mode 100644 src/main/java/com/phenoml/api/Client.java
rename src/main/java/com/phenoml/api/{PhenoML.java => PhenomlClient.java} (94%)
rename src/main/java/com/phenoml/api/{AsyncPhenoMLBuilder.java => PhenomlClientBuilder.java} (78%)
create mode 100644 src/main/java/com/phenoml/api/core/OAuthTokenSupplier.java
rename src/main/java/com/phenoml/api/core/{PhenoMLApiException.java => PhenomlClientApiException.java} (78%)
rename src/main/java/com/phenoml/api/core/{PhenoMLException.java => PhenomlClientException.java} (57%)
rename src/main/java/com/phenoml/api/core/{PhenoMLHttpResponse.java => PhenomlClientHttpResponse.java} (87%)
create mode 100644 src/main/java/com/phenoml/api/resources/authtoken/auth/requests/ClientCredentialsRequest.java
create mode 100644 src/main/java/com/phenoml/api/resources/authtoken/errors/InternalServerError.java
create mode 100644 src/main/java/com/phenoml/api/resources/authtoken/types/OAuthError.java
create mode 100644 src/main/java/com/phenoml/api/resources/authtoken/types/TokenResponse.java
delete mode 100644 src/main/java/com/phenoml/api/wrapper/AsyncPhenoMLClient.java
delete mode 100644 src/main/java/com/phenoml/api/wrapper/PhenoMLClient.java
diff --git a/build.gradle b/build.gradle
index 8a2cc7d..491bbb6 100644
--- a/build.gradle
+++ b/build.gradle
@@ -47,7 +47,7 @@ java {
group = 'com.phenoml.maven'
-version = '8.3.0'
+version = '8.3.1'
jar {
dependsOn(":generatePomFileForMavenPublication")
@@ -78,7 +78,7 @@ publishing {
maven(MavenPublication) {
groupId = 'com.phenoml.maven'
artifactId = 'phenoml-java-sdk'
- version = '8.3.0'
+ version = '8.3.1'
from components.java
pom {
name = 'phenoml'
diff --git a/changelog.md b/changelog.md
index 78e9267..03372f5 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,3 +1,7 @@
+## 8.3.1 - 2026-03-04
+* SDK regeneration
+* Unable to analyze changes with AI, incrementing PATCH version.
+
## 8.3.0 - 2026-03-03
* feat: add document multi-resource extraction endpoint
* Add a new endpoint for extracting multiple FHIR resources from documents (PDF/images).
diff --git a/reference.md b/reference.md
index ed64d80..844429b 100644
--- a/reference.md
+++ b/reference.md
@@ -1252,6 +1252,83 @@ client.authtoken().auth().generateToken(
+
+
+
+
+client.authtoken.auth.getToken(request) -> TokenResponse
+
+-
+
+#### ๐ Description
+
+
+-
+
+
+-
+
+OAuth 2.0 client credentials token endpoint (RFC 6749 ยง4.4).
+Accepts client_id and client_secret in the request body (JSON or
+form-encoded) or via Basic Auth header (RFC 6749 ยง2.3.1), and
+returns an access token with expiration information.
+
+
+
+
+
+#### ๐ Usage
+
+
+-
+
+
+-
+
+```java
+client.authtoken().auth().getToken(
+ ClientCredentialsRequest
+ .builder()
+ .build()
+);
+```
+
+
+
+
+
+#### โ๏ธ Parameters
+
+
+-
+
+
+-
+
+**grantType:** `Optional` โ Must be "client_credentials" if provided
+
+
+
+
+
+-
+
+**clientId:** `Optional` โ The client ID (credential username)
+
+
+
+
+
+-
+
+**clientSecret:** `Optional` โ The client secret (credential password)
+
+
+
+
+
+
+
diff --git a/sample-app/src/main/java/sample/App.java b/sample-app/src/main/java/sample/App.java
index 9f6d674..c5ad4d0 100644
--- a/sample-app/src/main/java/sample/App.java
+++ b/sample-app/src/main/java/sample/App.java
@@ -8,6 +8,6 @@
public final class App {
public static void main(String[] args) {
- // import com.phenoml.api.AsyncPhenoML
+ // import com.phenoml.api.AsyncPhenomlClient
}
}
diff --git a/src/main/java/com/phenoml/api/AsyncClient.java b/src/main/java/com/phenoml/api/AsyncClient.java
deleted file mode 100644
index a98cae6..0000000
--- a/src/main/java/com/phenoml/api/AsyncClient.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.phenoml.api;
-
-import com.phenoml.api.wrapper.AsyncPhenoMLClient;
-
-/**
- * Simple convenience class for the PhenoML async wrapper client.
- *
- * Usage:
- *
{@code
- * // With username/password
- * AsyncClient client = AsyncClient.withCredentials("user", "pass", "https://api.example.com");
- *
- * // With token
- * AsyncClient client = AsyncClient.withToken("your-token", "https://api.example.com");
- * }
- */
-public class AsyncClient extends AsyncPhenoMLClient {
-
- private AsyncClient(com.phenoml.api.core.ClientOptions clientOptions) {
- super(clientOptions);
- }
-
- /**
- * Create an async client with username/password authentication.
- */
- public static AsyncClient withCredentials(String username, String password, String baseUrl) {
- AsyncPhenoMLClient client = AsyncPhenoMLClient.withCredentials(username, password, baseUrl);
- return new AsyncClient(client.clientOptions);
- }
-
- /**
- * Create an async client with direct token authentication.
- */
- public static AsyncClient withToken(String token, String baseUrl) {
- AsyncPhenoMLClient client = AsyncPhenoMLClient.withToken(token, baseUrl);
- return new AsyncClient(client.clientOptions);
- }
-}
diff --git a/src/main/java/com/phenoml/api/AsyncPhenoML.java b/src/main/java/com/phenoml/api/AsyncPhenomlClient.java
similarity index 94%
rename from src/main/java/com/phenoml/api/AsyncPhenoML.java
rename to src/main/java/com/phenoml/api/AsyncPhenomlClient.java
index c45c781..69faace 100644
--- a/src/main/java/com/phenoml/api/AsyncPhenoML.java
+++ b/src/main/java/com/phenoml/api/AsyncPhenomlClient.java
@@ -17,7 +17,7 @@
import com.phenoml.api.resources.workflows.AsyncWorkflowsClient;
import java.util.function.Supplier;
-public class AsyncPhenoML {
+public class AsyncPhenomlClient {
protected final ClientOptions clientOptions;
protected final Supplier agentClient;
@@ -40,7 +40,7 @@ public class AsyncPhenoML {
protected final Supplier workflowsClient;
- public AsyncPhenoML(ClientOptions clientOptions) {
+ public AsyncPhenomlClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.agentClient = Suppliers.memoize(() -> new AsyncAgentClient(clientOptions));
this.authtokenClient = Suppliers.memoize(() -> new AsyncAuthtokenClient(clientOptions));
@@ -94,7 +94,7 @@ public AsyncWorkflowsClient workflows() {
return this.workflowsClient.get();
}
- public static AsyncPhenoMLBuilder builder() {
- return new AsyncPhenoMLBuilder();
+ public static AsyncPhenomlClientBuilder builder() {
+ return new AsyncPhenomlClientBuilder();
}
}
diff --git a/src/main/java/com/phenoml/api/PhenoMLBuilder.java b/src/main/java/com/phenoml/api/AsyncPhenomlClientBuilder.java
similarity index 77%
rename from src/main/java/com/phenoml/api/PhenoMLBuilder.java
rename to src/main/java/com/phenoml/api/AsyncPhenomlClientBuilder.java
index 7b73974..9beceb0 100644
--- a/src/main/java/com/phenoml/api/PhenoMLBuilder.java
+++ b/src/main/java/com/phenoml/api/AsyncPhenomlClientBuilder.java
@@ -5,38 +5,52 @@
import com.phenoml.api.core.ClientOptions;
import com.phenoml.api.core.Environment;
+import com.phenoml.api.core.OAuthTokenSupplier;
+import com.phenoml.api.resources.authtoken.auth.AuthClient;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import okhttp3.OkHttpClient;
-public class PhenoMLBuilder {
+public class AsyncPhenomlClientBuilder {
private Optional timeout = Optional.empty();
private Optional maxRetries = Optional.empty();
private final Map customHeaders = new HashMap<>();
- private String token = null;
+ private String clientId = System.getenv("PHENOML_CLIENT_ID");
+
+ private String clientSecret = System.getenv("PHENOML_CLIENT_SECRET");
private Environment environment = Environment.DEFAULT;
private OkHttpClient httpClient;
/**
- * Sets token
+ * Sets clientId.
+ * Defaults to the PHENOML_CLIENT_ID environment variable.
*/
- public PhenoMLBuilder token(String token) {
- this.token = token;
+ public AsyncPhenomlClientBuilder clientId(String clientId) {
+ this.clientId = clientId;
return this;
}
- public PhenoMLBuilder environment(Environment environment) {
+ /**
+ * Sets clientSecret.
+ * Defaults to the PHENOML_CLIENT_SECRET environment variable.
+ */
+ public AsyncPhenomlClientBuilder clientSecret(String clientSecret) {
+ this.clientSecret = clientSecret;
+ return this;
+ }
+
+ public AsyncPhenomlClientBuilder environment(Environment environment) {
this.environment = environment;
return this;
}
- public PhenoMLBuilder url(String url) {
+ public AsyncPhenomlClientBuilder url(String url) {
this.environment = Environment.custom(url);
return this;
}
@@ -44,7 +58,7 @@ public PhenoMLBuilder url(String url) {
/**
* Sets the timeout (in seconds) for the client. Defaults to 60 seconds.
*/
- public PhenoMLBuilder timeout(int timeout) {
+ public AsyncPhenomlClientBuilder timeout(int timeout) {
this.timeout = Optional.of(timeout);
return this;
}
@@ -52,7 +66,7 @@ public PhenoMLBuilder timeout(int timeout) {
/**
* Sets the maximum number of retries for the client. Defaults to 2 retries.
*/
- public PhenoMLBuilder maxRetries(int maxRetries) {
+ public AsyncPhenomlClientBuilder maxRetries(int maxRetries) {
this.maxRetries = Optional.of(maxRetries);
return this;
}
@@ -60,7 +74,7 @@ public PhenoMLBuilder maxRetries(int maxRetries) {
/**
* Sets the underlying OkHttp client
*/
- public PhenoMLBuilder httpClient(OkHttpClient httpClient) {
+ public AsyncPhenomlClientBuilder httpClient(OkHttpClient httpClient) {
this.httpClient = httpClient;
return this;
}
@@ -73,7 +87,7 @@ public PhenoMLBuilder httpClient(OkHttpClient httpClient) {
* @param value The header value
* @return This builder for method chaining
*/
- public PhenoMLBuilder addHeader(String name, String value) {
+ public AsyncPhenomlClientBuilder addHeader(String name, String value) {
this.customHeaders.put(name, value);
return this;
}
@@ -118,8 +132,12 @@ protected void setEnvironment(ClientOptions.Builder builder) {
* }
*/
protected void setAuthentication(ClientOptions.Builder builder) {
- if (this.token != null) {
- builder.addHeader("Authorization", "Bearer " + this.token);
+ if (this.clientId != null && this.clientSecret != null) {
+ AuthClient authClient = new AuthClient(
+ ClientOptions.builder().environment(this.environment).build());
+ OAuthTokenSupplier oAuthTokenSupplier =
+ new OAuthTokenSupplier(this.clientId, this.clientSecret, authClient);
+ builder.addHeader("Authorization", oAuthTokenSupplier);
}
}
@@ -195,11 +213,8 @@ protected void setAdditional(ClientOptions.Builder builder) {}
*/
protected void validateConfiguration() {}
- public PhenoML build() {
- if (token == null) {
- throw new RuntimeException("Please provide token");
- }
+ public AsyncPhenomlClient build() {
validateConfiguration();
- return new PhenoML(buildClientOptions());
+ return new AsyncPhenomlClient(buildClientOptions());
}
}
diff --git a/src/main/java/com/phenoml/api/Client.java b/src/main/java/com/phenoml/api/Client.java
deleted file mode 100644
index 40d962c..0000000
--- a/src/main/java/com/phenoml/api/Client.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.phenoml.api;
-
-import com.phenoml.api.wrapper.PhenoMLClient;
-
-/**
- * Simple convenience class for the PhenoML wrapper client.
- *
- * Usage:
- * {@code
- * // With username/password
- * Client client = Client.withCredentials("user", "pass", "https://api.example.com");
- *
- * // With token
- * Client client = Client.withToken("your-token", "https://api.example.com");
- * }
- */
-public class Client extends PhenoMLClient {
-
- private Client(com.phenoml.api.core.ClientOptions clientOptions) {
- super(clientOptions);
- }
-
- /**
- * Create a client with username/password authentication.
- */
- public static Client withCredentials(String username, String password, String baseUrl) {
- PhenoMLClient client = PhenoMLClient.withCredentials(username, password, baseUrl);
- return new Client(client.clientOptions);
- }
-
- /**
- * Create a client with direct token authentication.
- */
- public static Client withToken(String token, String baseUrl) {
- PhenoMLClient client = PhenoMLClient.withToken(token, baseUrl);
- return new Client(client.clientOptions);
- }
-}
diff --git a/src/main/java/com/phenoml/api/PhenoML.java b/src/main/java/com/phenoml/api/PhenomlClient.java
similarity index 94%
rename from src/main/java/com/phenoml/api/PhenoML.java
rename to src/main/java/com/phenoml/api/PhenomlClient.java
index a882f6b..1b6ae23 100644
--- a/src/main/java/com/phenoml/api/PhenoML.java
+++ b/src/main/java/com/phenoml/api/PhenomlClient.java
@@ -17,7 +17,7 @@
import com.phenoml.api.resources.workflows.WorkflowsClient;
import java.util.function.Supplier;
-public class PhenoML {
+public class PhenomlClient {
protected final ClientOptions clientOptions;
protected final Supplier agentClient;
@@ -40,7 +40,7 @@ public class PhenoML {
protected final Supplier workflowsClient;
- public PhenoML(ClientOptions clientOptions) {
+ public PhenomlClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.agentClient = Suppliers.memoize(() -> new AgentClient(clientOptions));
this.authtokenClient = Suppliers.memoize(() -> new AuthtokenClient(clientOptions));
@@ -94,7 +94,7 @@ public WorkflowsClient workflows() {
return this.workflowsClient.get();
}
- public static PhenoMLBuilder builder() {
- return new PhenoMLBuilder();
+ public static PhenomlClientBuilder builder() {
+ return new PhenomlClientBuilder();
}
}
diff --git a/src/main/java/com/phenoml/api/AsyncPhenoMLBuilder.java b/src/main/java/com/phenoml/api/PhenomlClientBuilder.java
similarity index 78%
rename from src/main/java/com/phenoml/api/AsyncPhenoMLBuilder.java
rename to src/main/java/com/phenoml/api/PhenomlClientBuilder.java
index 9d31754..147d7b5 100644
--- a/src/main/java/com/phenoml/api/AsyncPhenoMLBuilder.java
+++ b/src/main/java/com/phenoml/api/PhenomlClientBuilder.java
@@ -5,38 +5,52 @@
import com.phenoml.api.core.ClientOptions;
import com.phenoml.api.core.Environment;
+import com.phenoml.api.core.OAuthTokenSupplier;
+import com.phenoml.api.resources.authtoken.auth.AuthClient;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import okhttp3.OkHttpClient;
-public class AsyncPhenoMLBuilder {
+public class PhenomlClientBuilder {
private Optional timeout = Optional.empty();
private Optional maxRetries = Optional.empty();
private final Map customHeaders = new HashMap<>();
- private String token = null;
+ private String clientId = System.getenv("PHENOML_CLIENT_ID");
+
+ private String clientSecret = System.getenv("PHENOML_CLIENT_SECRET");
private Environment environment = Environment.DEFAULT;
private OkHttpClient httpClient;
/**
- * Sets token
+ * Sets clientId.
+ * Defaults to the PHENOML_CLIENT_ID environment variable.
*/
- public AsyncPhenoMLBuilder token(String token) {
- this.token = token;
+ public PhenomlClientBuilder clientId(String clientId) {
+ this.clientId = clientId;
return this;
}
- public AsyncPhenoMLBuilder environment(Environment environment) {
+ /**
+ * Sets clientSecret.
+ * Defaults to the PHENOML_CLIENT_SECRET environment variable.
+ */
+ public PhenomlClientBuilder clientSecret(String clientSecret) {
+ this.clientSecret = clientSecret;
+ return this;
+ }
+
+ public PhenomlClientBuilder environment(Environment environment) {
this.environment = environment;
return this;
}
- public AsyncPhenoMLBuilder url(String url) {
+ public PhenomlClientBuilder url(String url) {
this.environment = Environment.custom(url);
return this;
}
@@ -44,7 +58,7 @@ public AsyncPhenoMLBuilder url(String url) {
/**
* Sets the timeout (in seconds) for the client. Defaults to 60 seconds.
*/
- public AsyncPhenoMLBuilder timeout(int timeout) {
+ public PhenomlClientBuilder timeout(int timeout) {
this.timeout = Optional.of(timeout);
return this;
}
@@ -52,7 +66,7 @@ public AsyncPhenoMLBuilder timeout(int timeout) {
/**
* Sets the maximum number of retries for the client. Defaults to 2 retries.
*/
- public AsyncPhenoMLBuilder maxRetries(int maxRetries) {
+ public PhenomlClientBuilder maxRetries(int maxRetries) {
this.maxRetries = Optional.of(maxRetries);
return this;
}
@@ -60,7 +74,7 @@ public AsyncPhenoMLBuilder maxRetries(int maxRetries) {
/**
* Sets the underlying OkHttp client
*/
- public AsyncPhenoMLBuilder httpClient(OkHttpClient httpClient) {
+ public PhenomlClientBuilder httpClient(OkHttpClient httpClient) {
this.httpClient = httpClient;
return this;
}
@@ -73,7 +87,7 @@ public AsyncPhenoMLBuilder httpClient(OkHttpClient httpClient) {
* @param value The header value
* @return This builder for method chaining
*/
- public AsyncPhenoMLBuilder addHeader(String name, String value) {
+ public PhenomlClientBuilder addHeader(String name, String value) {
this.customHeaders.put(name, value);
return this;
}
@@ -118,8 +132,12 @@ protected void setEnvironment(ClientOptions.Builder builder) {
* }
*/
protected void setAuthentication(ClientOptions.Builder builder) {
- if (this.token != null) {
- builder.addHeader("Authorization", "Bearer " + this.token);
+ if (this.clientId != null && this.clientSecret != null) {
+ AuthClient authClient = new AuthClient(
+ ClientOptions.builder().environment(this.environment).build());
+ OAuthTokenSupplier oAuthTokenSupplier =
+ new OAuthTokenSupplier(this.clientId, this.clientSecret, authClient);
+ builder.addHeader("Authorization", oAuthTokenSupplier);
}
}
@@ -195,11 +213,8 @@ protected void setAdditional(ClientOptions.Builder builder) {}
*/
protected void validateConfiguration() {}
- public AsyncPhenoML build() {
- if (token == null) {
- throw new RuntimeException("Please provide token");
- }
+ public PhenomlClient build() {
validateConfiguration();
- return new AsyncPhenoML(buildClientOptions());
+ return new PhenomlClient(buildClientOptions());
}
}
diff --git a/src/main/java/com/phenoml/api/core/ClientOptions.java b/src/main/java/com/phenoml/api/core/ClientOptions.java
index b4167d8..9a81db2 100644
--- a/src/main/java/com/phenoml/api/core/ClientOptions.java
+++ b/src/main/java/com/phenoml/api/core/ClientOptions.java
@@ -32,10 +32,10 @@ private ClientOptions(
this.headers.putAll(headers);
this.headers.putAll(new HashMap() {
{
- put("User-Agent", "com.phenoml.maven:phenoml-java-sdk/8.3.0");
+ put("User-Agent", "com.phenoml.maven:phenoml-java-sdk/8.3.1");
put("X-Fern-Language", "JAVA");
put("X-Fern-SDK-Name", "com.phenoml.fern:api-sdk");
- put("X-Fern-SDK-Version", "8.3.0");
+ put("X-Fern-SDK-Version", "8.3.1");
}
});
this.headerSuppliers = headerSuppliers;
diff --git a/src/main/java/com/phenoml/api/core/OAuthTokenSupplier.java b/src/main/java/com/phenoml/api/core/OAuthTokenSupplier.java
new file mode 100644
index 0000000..1895140
--- /dev/null
+++ b/src/main/java/com/phenoml/api/core/OAuthTokenSupplier.java
@@ -0,0 +1,54 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.phenoml.api.core;
+
+import com.phenoml.api.resources.authtoken.auth.AuthClient;
+import com.phenoml.api.resources.authtoken.auth.requests.ClientCredentialsRequest;
+import com.phenoml.api.resources.authtoken.types.TokenResponse;
+import java.time.Instant;
+import java.time.temporal.ChronoUnit;
+import java.util.function.Supplier;
+
+public final class OAuthTokenSupplier implements Supplier {
+ private static final long BUFFER_IN_MINUTES = 2;
+
+ private final String clientId;
+
+ private final String clientSecret;
+
+ private final AuthClient authClient;
+
+ private String accessToken;
+
+ private Instant expiresAt;
+
+ public OAuthTokenSupplier(String clientId, String clientSecret, AuthClient authClient) {
+ this.clientId = clientId;
+ this.clientSecret = clientSecret;
+ this.authClient = authClient;
+ this.expiresAt = Instant.now();
+ }
+
+ public TokenResponse fetchToken() {
+ ClientCredentialsRequest getTokenRequest = ClientCredentialsRequest.builder()
+ .clientId(clientId)
+ .clientSecret(clientSecret)
+ .build();
+ return authClient.getToken(getTokenRequest);
+ }
+
+ @java.lang.Override
+ public String get() {
+ if (accessToken == null || expiresAt.isBefore(Instant.now())) {
+ TokenResponse authResponse = fetchToken();
+ this.accessToken = authResponse.getAccessToken();
+ this.expiresAt = getExpiresAt(authResponse.getExpiresIn());
+ }
+ return "Bearer " + accessToken;
+ }
+
+ private Instant getExpiresAt(long expiresInSeconds) {
+ return Instant.now().plus(expiresInSeconds, ChronoUnit.SECONDS).minus(BUFFER_IN_MINUTES, ChronoUnit.MINUTES);
+ }
+}
diff --git a/src/main/java/com/phenoml/api/core/PhenoMLApiException.java b/src/main/java/com/phenoml/api/core/PhenomlClientApiException.java
similarity index 78%
rename from src/main/java/com/phenoml/api/core/PhenoMLApiException.java
rename to src/main/java/com/phenoml/api/core/PhenomlClientApiException.java
index 84e5c0d..7ceb3e3 100644
--- a/src/main/java/com/phenoml/api/core/PhenoMLApiException.java
+++ b/src/main/java/com/phenoml/api/core/PhenomlClientApiException.java
@@ -12,7 +12,7 @@
/**
* This exception type will be thrown for any non-2XX API responses.
*/
-public class PhenoMLApiException extends PhenoMLException {
+public class PhenomlClientApiException extends PhenomlClientException {
/**
* The error code of the response that triggered the exception.
*/
@@ -25,14 +25,14 @@ public class PhenoMLApiException extends PhenoMLException {
private final Map> headers;
- public PhenoMLApiException(String message, int statusCode, Object body) {
+ public PhenomlClientApiException(String message, int statusCode, Object body) {
super(message);
this.statusCode = statusCode;
this.body = body;
this.headers = new HashMap<>();
}
- public PhenoMLApiException(String message, int statusCode, Object body, Response rawResponse) {
+ public PhenomlClientApiException(String message, int statusCode, Object body, Response rawResponse) {
super(message);
this.statusCode = statusCode;
this.body = body;
@@ -67,7 +67,7 @@ public Map> headers() {
@java.lang.Override
public String toString() {
- return "PhenoMLApiException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: " + body
- + "}";
+ return "PhenomlClientApiException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: "
+ + body + "}";
}
}
diff --git a/src/main/java/com/phenoml/api/core/PhenoMLException.java b/src/main/java/com/phenoml/api/core/PhenomlClientException.java
similarity index 57%
rename from src/main/java/com/phenoml/api/core/PhenoMLException.java
rename to src/main/java/com/phenoml/api/core/PhenomlClientException.java
index 63658fc..c50b75a 100644
--- a/src/main/java/com/phenoml/api/core/PhenoMLException.java
+++ b/src/main/java/com/phenoml/api/core/PhenomlClientException.java
@@ -6,12 +6,12 @@
/**
* This class serves as the base exception for all errors in the SDK.
*/
-public class PhenoMLException extends RuntimeException {
- public PhenoMLException(String message) {
+public class PhenomlClientException extends RuntimeException {
+ public PhenomlClientException(String message) {
super(message);
}
- public PhenoMLException(String message, Exception e) {
+ public PhenomlClientException(String message, Exception e) {
super(message, e);
}
}
diff --git a/src/main/java/com/phenoml/api/core/PhenoMLHttpResponse.java b/src/main/java/com/phenoml/api/core/PhenomlClientHttpResponse.java
similarity index 87%
rename from src/main/java/com/phenoml/api/core/PhenoMLHttpResponse.java
rename to src/main/java/com/phenoml/api/core/PhenomlClientHttpResponse.java
index 1ae28a9..5f3d3d4 100644
--- a/src/main/java/com/phenoml/api/core/PhenoMLHttpResponse.java
+++ b/src/main/java/com/phenoml/api/core/PhenomlClientHttpResponse.java
@@ -9,13 +9,13 @@
import java.util.Map;
import okhttp3.Response;
-public final class PhenoMLHttpResponse {
+public final class PhenomlClientHttpResponse {
private final T body;
private final Map> headers;
- public PhenoMLHttpResponse(T body, Response rawResponse) {
+ public PhenomlClientHttpResponse(T body, Response rawResponse) {
this.body = body;
Map> headers = new HashMap<>();
diff --git a/src/main/java/com/phenoml/api/core/RequestOptions.java b/src/main/java/com/phenoml/api/core/RequestOptions.java
index 712f469..c0b50d3 100644
--- a/src/main/java/com/phenoml/api/core/RequestOptions.java
+++ b/src/main/java/com/phenoml/api/core/RequestOptions.java
@@ -10,8 +10,6 @@
import java.util.function.Supplier;
public final class RequestOptions {
- private final String token;
-
private final Optional timeout;
private final TimeUnit timeoutTimeUnit;
@@ -21,12 +19,10 @@ public final class RequestOptions {
private final Map> headerSuppliers;
private RequestOptions(
- String token,
Optional timeout,
TimeUnit timeoutTimeUnit,
Map headers,
Map> headerSuppliers) {
- this.token = token;
this.timeout = timeout;
this.timeoutTimeUnit = timeoutTimeUnit;
this.headers = headers;
@@ -43,9 +39,6 @@ public TimeUnit getTimeoutTimeUnit() {
public Map getHeaders() {
Map headers = new HashMap<>();
- if (this.token != null) {
- headers.put("Authorization", "Bearer " + this.token);
- }
headers.putAll(this.headers);
this.headerSuppliers.forEach((key, supplier) -> {
headers.put(key, supplier.get());
@@ -58,8 +51,6 @@ public static Builder builder() {
}
public static class Builder {
- private String token = null;
-
private Optional timeout = Optional.empty();
private TimeUnit timeoutTimeUnit = TimeUnit.SECONDS;
@@ -68,11 +59,6 @@ public static class Builder {
private final Map> headerSuppliers = new HashMap<>();
- public Builder token(String token) {
- this.token = token;
- return this;
- }
-
public Builder timeout(Integer timeout) {
this.timeout = Optional.of(timeout);
return this;
@@ -95,7 +81,7 @@ public Builder addHeader(String key, Supplier value) {
}
public RequestOptions build() {
- return new RequestOptions(token, timeout, timeoutTimeUnit, headers, headerSuppliers);
+ return new RequestOptions(timeout, timeoutTimeUnit, headers, headerSuppliers);
}
}
}
diff --git a/src/main/java/com/phenoml/api/resources/agent/AsyncRawAgentClient.java b/src/main/java/com/phenoml/api/resources/agent/AsyncRawAgentClient.java
index f847b85..7065a18 100644
--- a/src/main/java/com/phenoml/api/resources/agent/AsyncRawAgentClient.java
+++ b/src/main/java/com/phenoml/api/resources/agent/AsyncRawAgentClient.java
@@ -7,9 +7,9 @@
import com.phenoml.api.core.ClientOptions;
import com.phenoml.api.core.MediaTypes;
import com.phenoml.api.core.ObjectMappers;
-import com.phenoml.api.core.PhenoMLApiException;
-import com.phenoml.api.core.PhenoMLException;
-import com.phenoml.api.core.PhenoMLHttpResponse;
+import com.phenoml.api.core.PhenomlClientApiException;
+import com.phenoml.api.core.PhenomlClientException;
+import com.phenoml.api.core.PhenomlClientHttpResponse;
import com.phenoml.api.core.QueryStringMapper;
import com.phenoml.api.core.RequestOptions;
import com.phenoml.api.core.ResponseBodyReader;
@@ -58,14 +58,14 @@ public AsyncRawAgentClient(ClientOptions clientOptions) {
/**
* Creates a new PhenoAgent with specified configuration
*/
- public CompletableFuture> create(AgentCreateRequest request) {
+ public CompletableFuture> create(AgentCreateRequest request) {
return create(request, null);
}
/**
* Creates a new PhenoAgent with specified configuration
*/
- public CompletableFuture> create(
+ public CompletableFuture> create(
AgentCreateRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
@@ -76,7 +76,7 @@ public CompletableFuture> create(
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (JsonProcessingException e) {
- throw new PhenoMLException("Failed to serialize request", e);
+ throw new PhenomlClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
@@ -89,13 +89,13 @@ public CompletableFuture> create(
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
- CompletableFuture> future = new CompletableFuture<>();
+ CompletableFuture> future = new CompletableFuture<>();
client.newCall(okhttpRequest).enqueue(new Callback() {
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
if (response.isSuccessful()) {
- future.complete(new PhenoMLHttpResponse<>(
+ future.complete(new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AgentResponse.class),
response));
return;
@@ -127,20 +127,20 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- future.completeExceptionally(new PhenoMLApiException(
+ future.completeExceptionally(new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
});
return future;
@@ -149,21 +149,21 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
/**
* Retrieves a list of PhenoAgents belonging to the authenticated user
*/
- public CompletableFuture> list() {
+ public CompletableFuture> list() {
return list(AgentListRequest.builder().build());
}
/**
* Retrieves a list of PhenoAgents belonging to the authenticated user
*/
- public CompletableFuture> list(AgentListRequest request) {
+ public CompletableFuture> list(AgentListRequest request) {
return list(request, null);
}
/**
* Retrieves a list of PhenoAgents belonging to the authenticated user
*/
- public CompletableFuture> list(
+ public CompletableFuture> list(
AgentListRequest request, RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
@@ -182,13 +182,13 @@ public CompletableFuture> list(
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
- CompletableFuture> future = new CompletableFuture<>();
+ CompletableFuture> future = new CompletableFuture<>();
client.newCall(okhttpRequest).enqueue(new Callback() {
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
if (response.isSuccessful()) {
- future.complete(new PhenoMLHttpResponse<>(
+ future.complete(new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AgentListResponse.class),
response));
return;
@@ -215,20 +215,20 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- future.completeExceptionally(new PhenoMLApiException(
+ future.completeExceptionally(new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
});
return future;
@@ -237,14 +237,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
/**
* Retrieves a specific agent by its ID
*/
- public CompletableFuture> get(String id) {
+ public CompletableFuture> get(String id) {
return get(id, null);
}
/**
* Retrieves a specific agent by its ID
*/
- public CompletableFuture> get(String id, RequestOptions requestOptions) {
+ public CompletableFuture> get(String id, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("agent")
@@ -260,13 +260,13 @@ public CompletableFuture> get(String id, Requ
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
- CompletableFuture> future = new CompletableFuture<>();
+ CompletableFuture> future = new CompletableFuture<>();
client.newCall(okhttpRequest).enqueue(new Callback() {
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
if (response.isSuccessful()) {
- future.complete(new PhenoMLHttpResponse<>(
+ future.complete(new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AgentResponse.class),
response));
return;
@@ -298,20 +298,20 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- future.completeExceptionally(new PhenoMLApiException(
+ future.completeExceptionally(new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
});
return future;
@@ -320,14 +320,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
/**
* Updates an existing agent's configuration
*/
- public CompletableFuture> update(String id, AgentCreateRequest request) {
+ public CompletableFuture> update(String id, AgentCreateRequest request) {
return update(id, request, null);
}
/**
* Updates an existing agent's configuration
*/
- public CompletableFuture> update(
+ public CompletableFuture> update(
String id, AgentCreateRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
@@ -339,7 +339,7 @@ public CompletableFuture> update(
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (JsonProcessingException e) {
- throw new PhenoMLException("Failed to serialize request", e);
+ throw new PhenomlClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
@@ -352,13 +352,13 @@ public CompletableFuture> update(
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
- CompletableFuture> future = new CompletableFuture<>();
+ CompletableFuture> future = new CompletableFuture<>();
client.newCall(okhttpRequest).enqueue(new Callback() {
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
if (response.isSuccessful()) {
- future.complete(new PhenoMLHttpResponse<>(
+ future.complete(new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AgentResponse.class),
response));
return;
@@ -395,20 +395,20 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- future.completeExceptionally(new PhenoMLApiException(
+ future.completeExceptionally(new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
});
return future;
@@ -417,14 +417,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
/**
* Deletes an existing agent
*/
- public CompletableFuture> delete(String id) {
+ public CompletableFuture> delete(String id) {
return delete(id, null);
}
/**
* Deletes an existing agent
*/
- public CompletableFuture> delete(
+ public CompletableFuture> delete(
String id, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
@@ -441,13 +441,13 @@ public CompletableFuture> delete(
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
- CompletableFuture> future = new CompletableFuture<>();
+ CompletableFuture> future = new CompletableFuture<>();
client.newCall(okhttpRequest).enqueue(new Callback() {
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
if (response.isSuccessful()) {
- future.complete(new PhenoMLHttpResponse<>(
+ future.complete(new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AgentDeleteResponse.class),
response));
return;
@@ -479,20 +479,20 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- future.completeExceptionally(new PhenoMLApiException(
+ future.completeExceptionally(new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
});
return future;
@@ -501,14 +501,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
/**
* Patches an existing agent's configuration
*/
- public CompletableFuture> patch(String id, List request) {
+ public CompletableFuture> patch(
+ String id, List request) {
return patch(id, request, null);
}
/**
* Patches an existing agent's configuration
*/
- public CompletableFuture> patch(
+ public CompletableFuture> patch(
String id, List request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
@@ -520,7 +521,7 @@ public CompletableFuture> patch(
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json+patch"));
} catch (JsonProcessingException e) {
- throw new PhenoMLException("Failed to serialize request", e);
+ throw new PhenomlClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
@@ -533,13 +534,13 @@ public CompletableFuture> patch(
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
- CompletableFuture> future = new CompletableFuture<>();
+ CompletableFuture> future = new CompletableFuture<>();
client.newCall(okhttpRequest).enqueue(new Callback() {
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
if (response.isSuccessful()) {
- future.complete(new PhenoMLHttpResponse<>(
+ future.complete(new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AgentResponse.class),
response));
return;
@@ -576,20 +577,20 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- future.completeExceptionally(new PhenoMLApiException(
+ future.completeExceptionally(new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
});
return future;
@@ -598,14 +599,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
/**
* Send a message to an agent and receive a JSON response.
*/
- public CompletableFuture> chat(AgentChatRequest request) {
+ public CompletableFuture> chat(AgentChatRequest request) {
return chat(request, null);
}
/**
* Send a message to an agent and receive a JSON response.
*/
- public CompletableFuture> chat(
+ public CompletableFuture> chat(
AgentChatRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
@@ -649,13 +650,13 @@ public CompletableFuture> chat(
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
- CompletableFuture> future = new CompletableFuture<>();
+ CompletableFuture> future = new CompletableFuture<>();
client.newCall(okhttpRequest).enqueue(new Callback() {
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
if (response.isSuccessful()) {
- future.complete(new PhenoMLHttpResponse<>(
+ future.complete(new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AgentChatResponse.class),
response));
return;
@@ -687,20 +688,20 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- future.completeExceptionally(new PhenoMLApiException(
+ future.completeExceptionally(new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
});
return future;
@@ -711,7 +712,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
* (SSE) stream. Events include message_start, content_delta, tool_use,
* tool_result, message_end, and error.
*/
- public CompletableFuture>> streamChat(
+ public CompletableFuture>> streamChat(
AgentStreamChatRequest request) {
return streamChat(request, null);
}
@@ -721,7 +722,7 @@ public CompletableFuture>> st
* (SSE) stream. Events include message_start, content_delta, tool_use,
* tool_result, message_end, and error.
*/
- public CompletableFuture>> streamChat(
+ public CompletableFuture>> streamChat(
AgentStreamChatRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
@@ -765,14 +766,14 @@ public CompletableFuture>> st
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
- CompletableFuture>> future = new CompletableFuture<>();
+ CompletableFuture>> future = new CompletableFuture<>();
client.newCall(okhttpRequest).enqueue(new Callback() {
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
- future.complete(new PhenoMLHttpResponse<>(
+ future.complete(new PhenomlClientHttpResponse<>(
Stream.fromSse(AgentChatStreamEvent.class, new ResponseBodyReader(response)),
response));
return;
@@ -804,20 +805,20 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- future.completeExceptionally(new PhenoMLApiException(
+ future.completeExceptionally(new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
});
return future;
@@ -826,7 +827,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
/**
* Retrieves a list of chat messages for a given chat session
*/
- public CompletableFuture> getChatMessages(
+ public CompletableFuture> getChatMessages(
AgentGetChatMessagesRequest request) {
return getChatMessages(request, null);
}
@@ -834,7 +835,7 @@ public CompletableFuture> getC
/**
* Retrieves a list of chat messages for a given chat session
*/
- public CompletableFuture> getChatMessages(
+ public CompletableFuture> getChatMessages(
AgentGetChatMessagesRequest request, RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
@@ -862,13 +863,13 @@ public CompletableFuture> getC
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
- CompletableFuture> future = new CompletableFuture<>();
+ CompletableFuture> future = new CompletableFuture<>();
client.newCall(okhttpRequest).enqueue(new Callback() {
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
if (response.isSuccessful()) {
- future.complete(new PhenoMLHttpResponse<>(
+ future.complete(new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(
responseBody.string(), AgentGetChatMessagesResponse.class),
response));
@@ -896,20 +897,20 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- future.completeExceptionally(new PhenoMLApiException(
+ future.completeExceptionally(new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
});
return future;
diff --git a/src/main/java/com/phenoml/api/resources/agent/RawAgentClient.java b/src/main/java/com/phenoml/api/resources/agent/RawAgentClient.java
index e5fc851..22a8af5 100644
--- a/src/main/java/com/phenoml/api/resources/agent/RawAgentClient.java
+++ b/src/main/java/com/phenoml/api/resources/agent/RawAgentClient.java
@@ -7,9 +7,9 @@
import com.phenoml.api.core.ClientOptions;
import com.phenoml.api.core.MediaTypes;
import com.phenoml.api.core.ObjectMappers;
-import com.phenoml.api.core.PhenoMLApiException;
-import com.phenoml.api.core.PhenoMLException;
-import com.phenoml.api.core.PhenoMLHttpResponse;
+import com.phenoml.api.core.PhenomlClientApiException;
+import com.phenoml.api.core.PhenomlClientException;
+import com.phenoml.api.core.PhenomlClientHttpResponse;
import com.phenoml.api.core.QueryStringMapper;
import com.phenoml.api.core.RequestOptions;
import com.phenoml.api.core.ResponseBodyReader;
@@ -54,14 +54,14 @@ public RawAgentClient(ClientOptions clientOptions) {
/**
* Creates a new PhenoAgent with specified configuration
*/
- public PhenoMLHttpResponse create(AgentCreateRequest request) {
+ public PhenomlClientHttpResponse create(AgentCreateRequest request) {
return create(request, null);
}
/**
* Creates a new PhenoAgent with specified configuration
*/
- public PhenoMLHttpResponse create(AgentCreateRequest request, RequestOptions requestOptions) {
+ public PhenomlClientHttpResponse create(AgentCreateRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("agent/create")
@@ -71,7 +71,7 @@ public PhenoMLHttpResponse create(AgentCreateRequest request, Req
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (JsonProcessingException e) {
- throw new PhenoMLException("Failed to serialize request", e);
+ throw new PhenomlClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
@@ -87,7 +87,7 @@ public PhenoMLHttpResponse create(AgentCreateRequest request, Req
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
- return new PhenoMLHttpResponse<>(
+ return new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AgentResponse.class), response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
@@ -109,34 +109,34 @@ public PhenoMLHttpResponse create(AgentCreateRequest request, Req
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- throw new PhenoMLApiException(
+ throw new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
- throw new PhenoMLException("Network error executing HTTP request", e);
+ throw new PhenomlClientException("Network error executing HTTP request", e);
}
}
/**
* Retrieves a list of PhenoAgents belonging to the authenticated user
*/
- public PhenoMLHttpResponse list() {
+ public PhenomlClientHttpResponse list() {
return list(AgentListRequest.builder().build());
}
/**
* Retrieves a list of PhenoAgents belonging to the authenticated user
*/
- public PhenoMLHttpResponse list(AgentListRequest request) {
+ public PhenomlClientHttpResponse list(AgentListRequest request) {
return list(request, null);
}
/**
* Retrieves a list of PhenoAgents belonging to the authenticated user
*/
- public PhenoMLHttpResponse list(AgentListRequest request, RequestOptions requestOptions) {
+ public PhenomlClientHttpResponse list(AgentListRequest request, RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("agent/list");
@@ -157,7 +157,7 @@ public PhenoMLHttpResponse list(AgentListRequest request, Req
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
- return new PhenoMLHttpResponse<>(
+ return new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AgentListResponse.class), response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
@@ -176,27 +176,27 @@ public PhenoMLHttpResponse list(AgentListRequest request, Req
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- throw new PhenoMLApiException(
+ throw new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
- throw new PhenoMLException("Network error executing HTTP request", e);
+ throw new PhenomlClientException("Network error executing HTTP request", e);
}
}
/**
* Retrieves a specific agent by its ID
*/
- public PhenoMLHttpResponse get(String id) {
+ public PhenomlClientHttpResponse get(String id) {
return get(id, null);
}
/**
* Retrieves a specific agent by its ID
*/
- public PhenoMLHttpResponse get(String id, RequestOptions requestOptions) {
+ public PhenomlClientHttpResponse get(String id, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("agent")
@@ -215,7 +215,7 @@ public PhenoMLHttpResponse get(String id, RequestOptions requestO
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
- return new PhenoMLHttpResponse<>(
+ return new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AgentResponse.class), response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
@@ -237,27 +237,27 @@ public PhenoMLHttpResponse get(String id, RequestOptions requestO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- throw new PhenoMLApiException(
+ throw new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
- throw new PhenoMLException("Network error executing HTTP request", e);
+ throw new PhenomlClientException("Network error executing HTTP request", e);
}
}
/**
* Updates an existing agent's configuration
*/
- public PhenoMLHttpResponse update(String id, AgentCreateRequest request) {
+ public PhenomlClientHttpResponse update(String id, AgentCreateRequest request) {
return update(id, request, null);
}
/**
* Updates an existing agent's configuration
*/
- public PhenoMLHttpResponse update(
+ public PhenomlClientHttpResponse update(
String id, AgentCreateRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
@@ -269,7 +269,7 @@ public PhenoMLHttpResponse update(
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (JsonProcessingException e) {
- throw new PhenoMLException("Failed to serialize request", e);
+ throw new PhenomlClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
@@ -285,7 +285,7 @@ public PhenoMLHttpResponse update(
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
- return new PhenoMLHttpResponse<>(
+ return new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AgentResponse.class), response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
@@ -310,27 +310,27 @@ public PhenoMLHttpResponse update(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- throw new PhenoMLApiException(
+ throw new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
- throw new PhenoMLException("Network error executing HTTP request", e);
+ throw new PhenomlClientException("Network error executing HTTP request", e);
}
}
/**
* Deletes an existing agent
*/
- public PhenoMLHttpResponse delete(String id) {
+ public PhenomlClientHttpResponse delete(String id) {
return delete(id, null);
}
/**
* Deletes an existing agent
*/
- public PhenoMLHttpResponse delete(String id, RequestOptions requestOptions) {
+ public PhenomlClientHttpResponse delete(String id, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("agent")
@@ -349,7 +349,7 @@ public PhenoMLHttpResponse delete(String id, RequestOptions
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
- return new PhenoMLHttpResponse<>(
+ return new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AgentDeleteResponse.class),
response);
}
@@ -372,27 +372,27 @@ public PhenoMLHttpResponse delete(String id, RequestOptions
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- throw new PhenoMLApiException(
+ throw new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
- throw new PhenoMLException("Network error executing HTTP request", e);
+ throw new PhenomlClientException("Network error executing HTTP request", e);
}
}
/**
* Patches an existing agent's configuration
*/
- public PhenoMLHttpResponse patch(String id, List request) {
+ public PhenomlClientHttpResponse patch(String id, List request) {
return patch(id, request, null);
}
/**
* Patches an existing agent's configuration
*/
- public PhenoMLHttpResponse patch(
+ public PhenomlClientHttpResponse patch(
String id, List request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
@@ -404,7 +404,7 @@ public PhenoMLHttpResponse patch(
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json+patch"));
} catch (JsonProcessingException e) {
- throw new PhenoMLException("Failed to serialize request", e);
+ throw new PhenomlClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
@@ -420,7 +420,7 @@ public PhenoMLHttpResponse patch(
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
- return new PhenoMLHttpResponse<>(
+ return new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AgentResponse.class), response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
@@ -445,27 +445,27 @@ public PhenoMLHttpResponse patch(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- throw new PhenoMLApiException(
+ throw new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
- throw new PhenoMLException("Network error executing HTTP request", e);
+ throw new PhenomlClientException("Network error executing HTTP request", e);
}
}
/**
* Send a message to an agent and receive a JSON response.
*/
- public PhenoMLHttpResponse chat(AgentChatRequest request) {
+ public PhenomlClientHttpResponse chat(AgentChatRequest request) {
return chat(request, null);
}
/**
* Send a message to an agent and receive a JSON response.
*/
- public PhenoMLHttpResponse chat(AgentChatRequest request, RequestOptions requestOptions) {
+ public PhenomlClientHttpResponse chat(AgentChatRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("agent/chat")
@@ -511,7 +511,7 @@ public PhenoMLHttpResponse chat(AgentChatRequest request, Req
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
- return new PhenoMLHttpResponse<>(
+ return new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AgentChatResponse.class), response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
@@ -533,13 +533,13 @@ public PhenoMLHttpResponse chat(AgentChatRequest request, Req
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- throw new PhenoMLApiException(
+ throw new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
- throw new PhenoMLException("Network error executing HTTP request", e);
+ throw new PhenomlClientException("Network error executing HTTP request", e);
}
}
@@ -548,7 +548,7 @@ public PhenoMLHttpResponse chat(AgentChatRequest request, Req
* (SSE) stream. Events include message_start, content_delta, tool_use,
* tool_result, message_end, and error.
*/
- public PhenoMLHttpResponse> streamChat(AgentStreamChatRequest request) {
+ public PhenomlClientHttpResponse> streamChat(AgentStreamChatRequest request) {
return streamChat(request, null);
}
@@ -557,7 +557,7 @@ public PhenoMLHttpResponse> streamChat(AgentStrea
* (SSE) stream. Events include message_start, content_delta, tool_use,
* tool_result, message_end, and error.
*/
- public PhenoMLHttpResponse> streamChat(
+ public PhenomlClientHttpResponse> streamChat(
AgentStreamChatRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
@@ -605,7 +605,7 @@ public PhenoMLHttpResponse> streamChat(
Response response = client.newCall(okhttpRequest).execute();
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
- return new PhenoMLHttpResponse<>(
+ return new PhenomlClientHttpResponse<>(
Stream.fromSse(AgentChatStreamEvent.class, new ResponseBodyReader(response)), response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
@@ -627,27 +627,28 @@ public PhenoMLHttpResponse> streamChat(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- throw new PhenoMLApiException(
+ throw new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
- throw new PhenoMLException("Network error executing HTTP request", e);
+ throw new PhenomlClientException("Network error executing HTTP request", e);
}
}
/**
* Retrieves a list of chat messages for a given chat session
*/
- public PhenoMLHttpResponse getChatMessages(AgentGetChatMessagesRequest request) {
+ public PhenomlClientHttpResponse getChatMessages(
+ AgentGetChatMessagesRequest request) {
return getChatMessages(request, null);
}
/**
* Retrieves a list of chat messages for a given chat session
*/
- public PhenoMLHttpResponse getChatMessages(
+ public PhenomlClientHttpResponse getChatMessages(
AgentGetChatMessagesRequest request, RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
@@ -678,7 +679,7 @@ public PhenoMLHttpResponse getChatMessages(
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
- return new PhenoMLHttpResponse<>(
+ return new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AgentGetChatMessagesResponse.class),
response);
}
@@ -698,13 +699,13 @@ public PhenoMLHttpResponse getChatMessages(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- throw new PhenoMLApiException(
+ throw new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
- throw new PhenoMLException("Network error executing HTTP request", e);
+ throw new PhenomlClientException("Network error executing HTTP request", e);
}
}
}
diff --git a/src/main/java/com/phenoml/api/resources/agent/errors/BadRequestError.java b/src/main/java/com/phenoml/api/resources/agent/errors/BadRequestError.java
index 44f8bf1..54352d6 100644
--- a/src/main/java/com/phenoml/api/resources/agent/errors/BadRequestError.java
+++ b/src/main/java/com/phenoml/api/resources/agent/errors/BadRequestError.java
@@ -3,10 +3,10 @@
*/
package com.phenoml.api.resources.agent.errors;
-import com.phenoml.api.core.PhenoMLApiException;
+import com.phenoml.api.core.PhenomlClientApiException;
import okhttp3.Response;
-public final class BadRequestError extends PhenoMLApiException {
+public final class BadRequestError extends PhenomlClientApiException {
/**
* The body of the response that triggered the exception.
*/
diff --git a/src/main/java/com/phenoml/api/resources/agent/errors/ForbiddenError.java b/src/main/java/com/phenoml/api/resources/agent/errors/ForbiddenError.java
index ff1368d..26aaba7 100644
--- a/src/main/java/com/phenoml/api/resources/agent/errors/ForbiddenError.java
+++ b/src/main/java/com/phenoml/api/resources/agent/errors/ForbiddenError.java
@@ -3,10 +3,10 @@
*/
package com.phenoml.api.resources.agent.errors;
-import com.phenoml.api.core.PhenoMLApiException;
+import com.phenoml.api.core.PhenomlClientApiException;
import okhttp3.Response;
-public final class ForbiddenError extends PhenoMLApiException {
+public final class ForbiddenError extends PhenomlClientApiException {
/**
* The body of the response that triggered the exception.
*/
diff --git a/src/main/java/com/phenoml/api/resources/agent/errors/InternalServerError.java b/src/main/java/com/phenoml/api/resources/agent/errors/InternalServerError.java
index 4056eca..253a810 100644
--- a/src/main/java/com/phenoml/api/resources/agent/errors/InternalServerError.java
+++ b/src/main/java/com/phenoml/api/resources/agent/errors/InternalServerError.java
@@ -3,10 +3,10 @@
*/
package com.phenoml.api.resources.agent.errors;
-import com.phenoml.api.core.PhenoMLApiException;
+import com.phenoml.api.core.PhenomlClientApiException;
import okhttp3.Response;
-public final class InternalServerError extends PhenoMLApiException {
+public final class InternalServerError extends PhenomlClientApiException {
/**
* The body of the response that triggered the exception.
*/
diff --git a/src/main/java/com/phenoml/api/resources/agent/errors/NotFoundError.java b/src/main/java/com/phenoml/api/resources/agent/errors/NotFoundError.java
index e0ba0d1..4602a5c 100644
--- a/src/main/java/com/phenoml/api/resources/agent/errors/NotFoundError.java
+++ b/src/main/java/com/phenoml/api/resources/agent/errors/NotFoundError.java
@@ -3,10 +3,10 @@
*/
package com.phenoml.api.resources.agent.errors;
-import com.phenoml.api.core.PhenoMLApiException;
+import com.phenoml.api.core.PhenomlClientApiException;
import okhttp3.Response;
-public final class NotFoundError extends PhenoMLApiException {
+public final class NotFoundError extends PhenomlClientApiException {
/**
* The body of the response that triggered the exception.
*/
diff --git a/src/main/java/com/phenoml/api/resources/agent/errors/UnauthorizedError.java b/src/main/java/com/phenoml/api/resources/agent/errors/UnauthorizedError.java
index 1e48856..52459ba 100644
--- a/src/main/java/com/phenoml/api/resources/agent/errors/UnauthorizedError.java
+++ b/src/main/java/com/phenoml/api/resources/agent/errors/UnauthorizedError.java
@@ -3,10 +3,10 @@
*/
package com.phenoml.api.resources.agent.errors;
-import com.phenoml.api.core.PhenoMLApiException;
+import com.phenoml.api.core.PhenomlClientApiException;
import okhttp3.Response;
-public final class UnauthorizedError extends PhenoMLApiException {
+public final class UnauthorizedError extends PhenomlClientApiException {
/**
* The body of the response that triggered the exception.
*/
diff --git a/src/main/java/com/phenoml/api/resources/agent/prompts/AsyncRawPromptsClient.java b/src/main/java/com/phenoml/api/resources/agent/prompts/AsyncRawPromptsClient.java
index 6f64419..641af94 100644
--- a/src/main/java/com/phenoml/api/resources/agent/prompts/AsyncRawPromptsClient.java
+++ b/src/main/java/com/phenoml/api/resources/agent/prompts/AsyncRawPromptsClient.java
@@ -7,9 +7,9 @@
import com.phenoml.api.core.ClientOptions;
import com.phenoml.api.core.MediaTypes;
import com.phenoml.api.core.ObjectMappers;
-import com.phenoml.api.core.PhenoMLApiException;
-import com.phenoml.api.core.PhenoMLException;
-import com.phenoml.api.core.PhenoMLHttpResponse;
+import com.phenoml.api.core.PhenomlClientApiException;
+import com.phenoml.api.core.PhenomlClientException;
+import com.phenoml.api.core.PhenomlClientHttpResponse;
import com.phenoml.api.core.RequestOptions;
import com.phenoml.api.resources.agent.errors.BadRequestError;
import com.phenoml.api.resources.agent.errors.ForbiddenError;
@@ -48,14 +48,15 @@ public AsyncRawPromptsClient(ClientOptions clientOptions) {
/**
* Creates a new agent prompt
*/
- public CompletableFuture> create(AgentPromptsCreateRequest request) {
+ public CompletableFuture> create(
+ AgentPromptsCreateRequest request) {
return create(request, null);
}
/**
* Creates a new agent prompt
*/
- public CompletableFuture> create(
+ public CompletableFuture> create(
AgentPromptsCreateRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
@@ -66,7 +67,7 @@ public CompletableFuture> create(
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (JsonProcessingException e) {
- throw new PhenoMLException("Failed to serialize request", e);
+ throw new PhenomlClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
@@ -79,13 +80,13 @@ public CompletableFuture> create(
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
- CompletableFuture> future = new CompletableFuture<>();
+ CompletableFuture> future = new CompletableFuture<>();
client.newCall(okhttpRequest).enqueue(new Callback() {
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
if (response.isSuccessful()) {
- future.complete(new PhenoMLHttpResponse<>(
+ future.complete(new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AgentPromptsResponse.class),
response));
return;
@@ -117,20 +118,20 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- future.completeExceptionally(new PhenoMLApiException(
+ future.completeExceptionally(new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
});
return future;
@@ -139,14 +140,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
/**
* Retrieves a list of agent prompts belonging to the authenticated user
*/
- public CompletableFuture> list() {
+ public CompletableFuture> list() {
return list(null);
}
/**
* Retrieves a list of agent prompts belonging to the authenticated user
*/
- public CompletableFuture> list(RequestOptions requestOptions) {
+ public CompletableFuture> list(RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("agent/prompts/list")
@@ -161,13 +162,13 @@ public CompletableFuture> list(RequestO
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
- CompletableFuture> future = new CompletableFuture<>();
+ CompletableFuture> future = new CompletableFuture<>();
client.newCall(okhttpRequest).enqueue(new Callback() {
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
if (response.isSuccessful()) {
- future.complete(new PhenoMLHttpResponse<>(
+ future.complete(new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PromptsListResponse.class),
response));
return;
@@ -194,20 +195,20 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- future.completeExceptionally(new PhenoMLApiException(
+ future.completeExceptionally(new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
});
return future;
@@ -216,14 +217,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
/**
* Retrieves a specific prompt by its ID
*/
- public CompletableFuture> get(String id) {
+ public CompletableFuture> get(String id) {
return get(id, null);
}
/**
* Retrieves a specific prompt by its ID
*/
- public CompletableFuture> get(String id, RequestOptions requestOptions) {
+ public CompletableFuture> get(
+ String id, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("agent/prompts")
@@ -239,13 +241,13 @@ public CompletableFuture> get(String i
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
- CompletableFuture> future = new CompletableFuture<>();
+ CompletableFuture> future = new CompletableFuture<>();
client.newCall(okhttpRequest).enqueue(new Callback() {
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
if (response.isSuccessful()) {
- future.complete(new PhenoMLHttpResponse<>(
+ future.complete(new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AgentPromptsResponse.class),
response));
return;
@@ -277,20 +279,20 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- future.completeExceptionally(new PhenoMLApiException(
+ future.completeExceptionally(new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
});
return future;
@@ -299,14 +301,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
/**
* Updates an existing prompt
*/
- public CompletableFuture> update(String id) {
+ public CompletableFuture> update(String id) {
return update(id, AgentPromptsUpdateRequest.builder().build());
}
/**
* Updates an existing prompt
*/
- public CompletableFuture> update(
+ public CompletableFuture> update(
String id, AgentPromptsUpdateRequest request) {
return update(id, request, null);
}
@@ -314,7 +316,7 @@ public CompletableFuture> update(
/**
* Updates an existing prompt
*/
- public CompletableFuture> update(
+ public CompletableFuture> update(
String id, AgentPromptsUpdateRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
@@ -326,7 +328,7 @@ public CompletableFuture> update(
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (JsonProcessingException e) {
- throw new PhenoMLException("Failed to serialize request", e);
+ throw new PhenomlClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
@@ -339,13 +341,13 @@ public CompletableFuture> update(
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
- CompletableFuture> future = new CompletableFuture<>();
+ CompletableFuture> future = new CompletableFuture<>();
client.newCall(okhttpRequest).enqueue(new Callback() {
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
if (response.isSuccessful()) {
- future.complete(new PhenoMLHttpResponse<>(
+ future.complete(new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AgentPromptsResponse.class),
response));
return;
@@ -382,20 +384,20 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- future.completeExceptionally(new PhenoMLApiException(
+ future.completeExceptionally(new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
});
return future;
@@ -404,14 +406,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
/**
* Deletes a prompt
*/
- public CompletableFuture> delete(String id) {
+ public CompletableFuture> delete(String id) {
return delete(id, null);
}
/**
* Deletes a prompt
*/
- public CompletableFuture> delete(
+ public CompletableFuture> delete(
String id, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
@@ -428,13 +430,13 @@ public CompletableFuture> delete(
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
- CompletableFuture> future = new CompletableFuture<>();
+ CompletableFuture> future = new CompletableFuture<>();
client.newCall(okhttpRequest).enqueue(new Callback() {
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
if (response.isSuccessful()) {
- future.complete(new PhenoMLHttpResponse<>(
+ future.complete(new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PromptsDeleteResponse.class),
response));
return;
@@ -466,20 +468,20 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- future.completeExceptionally(new PhenoMLApiException(
+ future.completeExceptionally(new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
});
return future;
@@ -488,7 +490,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
/**
* Patches an existing prompt
*/
- public CompletableFuture> patch(
+ public CompletableFuture> patch(
String id, List request) {
return patch(id, request, null);
}
@@ -496,7 +498,7 @@ public CompletableFuture> patch(
/**
* Patches an existing prompt
*/
- public CompletableFuture> patch(
+ public CompletableFuture> patch(
String id, List request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
@@ -508,7 +510,7 @@ public CompletableFuture> patch(
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json+patch"));
} catch (JsonProcessingException e) {
- throw new PhenoMLException("Failed to serialize request", e);
+ throw new PhenomlClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
@@ -521,13 +523,13 @@ public CompletableFuture> patch(
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
- CompletableFuture> future = new CompletableFuture<>();
+ CompletableFuture> future = new CompletableFuture<>();
client.newCall(okhttpRequest).enqueue(new Callback() {
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
if (response.isSuccessful()) {
- future.complete(new PhenoMLHttpResponse<>(
+ future.complete(new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AgentPromptsResponse.class),
response));
return;
@@ -564,20 +566,20 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- future.completeExceptionally(new PhenoMLApiException(
+ future.completeExceptionally(new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
});
return future;
@@ -586,14 +588,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
/**
* Loads default agent prompts for the authenticated user
*/
- public CompletableFuture> loadDefaults() {
+ public CompletableFuture> loadDefaults() {
return loadDefaults(null);
}
/**
* Loads default agent prompts for the authenticated user
*/
- public CompletableFuture> loadDefaults(RequestOptions requestOptions) {
+ public CompletableFuture> loadDefaults(RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("agent/prompts/load-defaults")
@@ -608,13 +610,13 @@ public CompletableFuture> loadDefaults(Requ
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
- CompletableFuture> future = new CompletableFuture<>();
+ CompletableFuture> future = new CompletableFuture<>();
client.newCall(okhttpRequest).enqueue(new Callback() {
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
if (response.isSuccessful()) {
- future.complete(new PhenoMLHttpResponse<>(
+ future.complete(new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SuccessResponse.class),
response));
return;
@@ -641,20 +643,20 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- future.completeExceptionally(new PhenoMLApiException(
+ future.completeExceptionally(new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
}
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
- future.completeExceptionally(new PhenoMLException("Network error executing HTTP request", e));
+ future.completeExceptionally(new PhenomlClientException("Network error executing HTTP request", e));
}
});
return future;
diff --git a/src/main/java/com/phenoml/api/resources/agent/prompts/RawPromptsClient.java b/src/main/java/com/phenoml/api/resources/agent/prompts/RawPromptsClient.java
index 9d1bb7f..429912b 100644
--- a/src/main/java/com/phenoml/api/resources/agent/prompts/RawPromptsClient.java
+++ b/src/main/java/com/phenoml/api/resources/agent/prompts/RawPromptsClient.java
@@ -7,9 +7,9 @@
import com.phenoml.api.core.ClientOptions;
import com.phenoml.api.core.MediaTypes;
import com.phenoml.api.core.ObjectMappers;
-import com.phenoml.api.core.PhenoMLApiException;
-import com.phenoml.api.core.PhenoMLException;
-import com.phenoml.api.core.PhenoMLHttpResponse;
+import com.phenoml.api.core.PhenomlClientApiException;
+import com.phenoml.api.core.PhenomlClientException;
+import com.phenoml.api.core.PhenomlClientHttpResponse;
import com.phenoml.api.core.RequestOptions;
import com.phenoml.api.resources.agent.errors.BadRequestError;
import com.phenoml.api.resources.agent.errors.ForbiddenError;
@@ -44,14 +44,14 @@ public RawPromptsClient(ClientOptions clientOptions) {
/**
* Creates a new agent prompt
*/
- public PhenoMLHttpResponse create(AgentPromptsCreateRequest request) {
+ public PhenomlClientHttpResponse create(AgentPromptsCreateRequest request) {
return create(request, null);
}
/**
* Creates a new agent prompt
*/
- public PhenoMLHttpResponse create(
+ public PhenomlClientHttpResponse create(
AgentPromptsCreateRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
@@ -62,7 +62,7 @@ public PhenoMLHttpResponse create(
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (JsonProcessingException e) {
- throw new PhenoMLException("Failed to serialize request", e);
+ throw new PhenomlClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
@@ -78,7 +78,7 @@ public PhenoMLHttpResponse create(
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
- return new PhenoMLHttpResponse<>(
+ return new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AgentPromptsResponse.class),
response);
}
@@ -101,27 +101,27 @@ public PhenoMLHttpResponse create(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- throw new PhenoMLApiException(
+ throw new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
- throw new PhenoMLException("Network error executing HTTP request", e);
+ throw new PhenomlClientException("Network error executing HTTP request", e);
}
}
/**
* Retrieves a list of agent prompts belonging to the authenticated user
*/
- public PhenoMLHttpResponse list() {
+ public PhenomlClientHttpResponse list() {
return list(null);
}
/**
* Retrieves a list of agent prompts belonging to the authenticated user
*/
- public PhenoMLHttpResponse list(RequestOptions requestOptions) {
+ public PhenomlClientHttpResponse list(RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("agent/prompts/list")
@@ -139,7 +139,7 @@ public PhenoMLHttpResponse list(RequestOptions requestOptio
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
- return new PhenoMLHttpResponse<>(
+ return new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PromptsListResponse.class),
response);
}
@@ -159,27 +159,27 @@ public PhenoMLHttpResponse list(RequestOptions requestOptio
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- throw new PhenoMLApiException(
+ throw new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
- throw new PhenoMLException("Network error executing HTTP request", e);
+ throw new PhenomlClientException("Network error executing HTTP request", e);
}
}
/**
* Retrieves a specific prompt by its ID
*/
- public PhenoMLHttpResponse get(String id) {
+ public PhenomlClientHttpResponse get(String id) {
return get(id, null);
}
/**
* Retrieves a specific prompt by its ID
*/
- public PhenoMLHttpResponse get(String id, RequestOptions requestOptions) {
+ public PhenomlClientHttpResponse get(String id, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("agent/prompts")
@@ -198,7 +198,7 @@ public PhenoMLHttpResponse get(String id, RequestOptions r
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
- return new PhenoMLHttpResponse<>(
+ return new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AgentPromptsResponse.class),
response);
}
@@ -221,34 +221,34 @@ public PhenoMLHttpResponse get(String id, RequestOptions r
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- throw new PhenoMLApiException(
+ throw new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
- throw new PhenoMLException("Network error executing HTTP request", e);
+ throw new PhenomlClientException("Network error executing HTTP request", e);
}
}
/**
* Updates an existing prompt
*/
- public PhenoMLHttpResponse update(String id) {
+ public PhenomlClientHttpResponse update(String id) {
return update(id, AgentPromptsUpdateRequest.builder().build());
}
/**
* Updates an existing prompt
*/
- public PhenoMLHttpResponse update(String id, AgentPromptsUpdateRequest request) {
+ public PhenomlClientHttpResponse update(String id, AgentPromptsUpdateRequest request) {
return update(id, request, null);
}
/**
* Updates an existing prompt
*/
- public PhenoMLHttpResponse update(
+ public PhenomlClientHttpResponse update(
String id, AgentPromptsUpdateRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
@@ -260,7 +260,7 @@ public PhenoMLHttpResponse update(
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (JsonProcessingException e) {
- throw new PhenoMLException("Failed to serialize request", e);
+ throw new PhenomlClientException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
@@ -276,7 +276,7 @@ public PhenoMLHttpResponse update(
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
- return new PhenoMLHttpResponse<>(
+ return new PhenomlClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AgentPromptsResponse.class),
response);
}
@@ -302,27 +302,27 @@ public PhenoMLHttpResponse update(
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
- throw new PhenoMLApiException(
+ throw new PhenomlClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
- throw new PhenoMLException("Network error executing HTTP request", e);
+ throw new PhenomlClientException("Network error executing HTTP request", e);
}
}
/**
* Deletes a prompt
*/
- public PhenoMLHttpResponse delete(String id) {
+ public PhenomlClientHttpResponse delete(String id) {
return delete(id, null);
}
/**
* Deletes a prompt
*/
- public PhenoMLHttpResponse