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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions src/main/java/com/google/genai/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.google.genai.gaos.Webhooks;
import com.google.genai.gaos.utils.HTTPClient;
import com.google.genai.gaos.utils.Headers;
import com.google.genai.gaos.utils.RetryConfig;
import com.google.genai.gaos.utils.transport.HttpBody;
import com.google.genai.gaos.utils.transport.HttpRequest;
import com.google.genai.gaos.utils.transport.HttpResponse;
Expand Down Expand Up @@ -417,6 +418,7 @@ private Client(
gaosBuilder = gaosBuilder.userProject(apiClient.credentials().getQuotaProjectId());
}
gaosBuilder = gaosBuilder.client(new GenAiGaosHttpClient(this.apiClient));
gaosBuilder = gaosBuilder.retryConfig(RetryConfig.noRetries());
if (asyncRetryScheduler.isPresent()) {
gaosBuilder = gaosBuilder.asyncRetryScheduler(asyncRetryScheduler.get());
}
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/google/genai/errors/ApiException.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ public ApiException(int code, String status, String message) {
this.message = message;
}

/**
* Creates a new ApiException carrying the originating cause (e.g. a reparented gaos error). Lets
* translated interaction errors keep their original stack/message.
*/
public ApiException(int code, String status, String message, Throwable cause) {
super(String.format("%d %s. %s", code, status, message), cause);
this.code = code;
this.status = status;
this.message = message;
}


/**
* Throws an ApiException from the response if the response is not a OK status.
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/google/genai/errors/ClientException.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@
package com.google.genai.errors;

/** Client exception raised by the GenAI API. */
public final class ClientException extends ApiException {
public class ClientException extends ApiException {

/** Creates a new ClientException with the specified message. */
public ClientException(int code, String status, String message) {
super(code, status, message);
}

/** Creates a new ClientException carrying the originating cause. */
public ClientException(int code, String status, String message, Throwable cause) {
super(code, status, message, cause);
}
}
7 changes: 6 additions & 1 deletion src/main/java/com/google/genai/errors/ServerException.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@
package com.google.genai.errors;

/** Server exception raised by the GenAI API. */
public final class ServerException extends ApiException {
public class ServerException extends ApiException {

/** Creates a new ServerException with the specified message. */
public ServerException(int code, String status, String message) {
super(code, status, message);
}

/** Creates a new ServerException carrying the originating cause. */
public ServerException(int code, String status, String message, Throwable cause) {
super(code, status, message, cause);
}
}
83 changes: 37 additions & 46 deletions src/main/java/com/google/genai/gaos/Agents.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import java.lang.Integer;
import java.lang.String;


public class Agents {
private static final Headers _headers = Headers.EMPTY;
private final SDKConfiguration sdkConfiguration;
Expand All @@ -58,7 +57,7 @@ public class Agents {

/**
* Switches to the async SDK.
*
*
* @return The async SDK
*/
public AsyncAgents async() {
Expand All @@ -67,7 +66,7 @@ public AsyncAgents async() {

/**
* Creates a new Agent (Typed version for SDK).
*
*
* @return The call builder
*/
public CreateAgentRequestBuilder create() {
Expand All @@ -76,7 +75,7 @@ public CreateAgentRequestBuilder create() {

/**
* Creates a new Agent (Typed version for SDK).
*
*
* @param body An agent definition for the CreateAgent API.
* This message is the target for annotation-parser-based JSON parsing.
* New format:
Expand All @@ -96,7 +95,7 @@ public CreateAgentResponse create(@Nonnull Agent body) {

/**
* Creates a new Agent (Typed version for SDK).
*
*
* @param apiVersion Which version of the API to use.
* @param body An agent definition for the CreateAgent API.
* This message is the target for annotation-parser-based JSON parsing.
Expand All @@ -112,18 +111,16 @@ public CreateAgentResponse create(@Nonnull Agent body) {
* @return The response from the API call
* @throws RuntimeException subclass if the API call fails
*/
public CreateAgentResponse create(
@Nullable String apiVersion, @Nonnull Agent body,
@Nullable Options options) {
public CreateAgentResponse create(@Nullable String apiVersion, @Nonnull Agent body, @Nullable Options options) {
CreateAgentRequest request = new CreateAgentRequest(apiVersion, body);
RequestOperation<CreateAgentRequest, CreateAgentResponse> operation
= new CreateAgent.Sync(sdkConfiguration, options, _headers);
RequestOperation<CreateAgentRequest, CreateAgentResponse> operation =
new CreateAgent.Sync(sdkConfiguration, options, _headers);
return operation.handleResponse(operation.doRequest(request));
}

/**
* Lists all Agents.
*
*
* @return The call builder
*/
public ListAgentsRequestBuilder list() {
Expand All @@ -132,41 +129,40 @@ public ListAgentsRequestBuilder list() {

/**
* Lists all Agents.
*
*
* @return The response from the API call
* @throws RuntimeException subclass if the API call fails
*/
public ListAgentsResponse listDirect() {
return list(null, null, null,
null, null);
return list(null, null, null, null, null);
}

/**
* Lists all Agents.
*
*
* @param apiVersion Which version of the API to use.
* @param pageSize
* @param pageToken
* @param parent
* @param pageSize
* @param pageToken
* @param parent
* @param options additional options
* @return The response from the API call
* @throws RuntimeException subclass if the API call fails
*/
public ListAgentsResponse list(
@Nullable String apiVersion, @Nullable Integer pageSize,
@Nullable String pageToken, @Nullable String parent,
@Nullable String apiVersion,
@Nullable Integer pageSize,
@Nullable String pageToken,
@Nullable String parent,
@Nullable Options options) {
ListAgentsRequest request = new ListAgentsRequest(
apiVersion, pageSize, pageToken,
parent);
RequestOperation<ListAgentsRequest, ListAgentsResponse> operation
= new ListAgents.Sync(sdkConfiguration, options, _headers);
ListAgentsRequest request = new ListAgentsRequest(apiVersion, pageSize, pageToken, parent);
RequestOperation<ListAgentsRequest, ListAgentsResponse> operation =
new ListAgents.Sync(sdkConfiguration, options, _headers);
return operation.handleResponse(operation.doRequest(request));
}

/**
* Gets a specific Agent.
*
*
* @return The call builder
*/
public GetAgentRequestBuilder get() {
Expand All @@ -175,8 +171,8 @@ public GetAgentRequestBuilder get() {

/**
* Gets a specific Agent.
*
* @param id
*
* @param id
* @return The response from the API call
* @throws RuntimeException subclass if the API call fails
*/
Expand All @@ -186,25 +182,23 @@ public GetAgentResponse get(@Nonnull String id) {

/**
* Gets a specific Agent.
*
*
* @param apiVersion Which version of the API to use.
* @param id
* @param id
* @param options additional options
* @return The response from the API call
* @throws RuntimeException subclass if the API call fails
*/
public GetAgentResponse get(
@Nullable String apiVersion, @Nonnull String id,
@Nullable Options options) {
public GetAgentResponse get(@Nullable String apiVersion, @Nonnull String id, @Nullable Options options) {
GetAgentRequest request = new GetAgentRequest(apiVersion, id);
RequestOperation<GetAgentRequest, GetAgentResponse> operation
= new GetAgent.Sync(sdkConfiguration, options, _headers);
RequestOperation<GetAgentRequest, GetAgentResponse> operation =
new GetAgent.Sync(sdkConfiguration, options, _headers);
return operation.handleResponse(operation.doRequest(request));
}

/**
* Deletes an Agent.
*
*
* @return The call builder
*/
public DeleteAgentRequestBuilder delete() {
Expand All @@ -213,8 +207,8 @@ public DeleteAgentRequestBuilder delete() {

/**
* Deletes an Agent.
*
* @param id
*
* @param id
* @return The response from the API call
* @throws RuntimeException subclass if the API call fails
*/
Expand All @@ -224,20 +218,17 @@ public DeleteAgentResponse delete(@Nonnull String id) {

/**
* Deletes an Agent.
*
*
* @param apiVersion Which version of the API to use.
* @param id
* @param id
* @param options additional options
* @return The response from the API call
* @throws RuntimeException subclass if the API call fails
*/
public DeleteAgentResponse delete(
@Nullable String apiVersion, @Nonnull String id,
@Nullable Options options) {
public DeleteAgentResponse delete(@Nullable String apiVersion, @Nonnull String id, @Nullable Options options) {
DeleteAgentRequest request = new DeleteAgentRequest(apiVersion, id);
RequestOperation<DeleteAgentRequest, DeleteAgentResponse> operation
= new DeleteAgent.Sync(sdkConfiguration, options, _headers);
RequestOperation<DeleteAgentRequest, DeleteAgentResponse> operation =
new DeleteAgent.Sync(sdkConfiguration, options, _headers);
return operation.handleResponse(operation.doRequest(request));
}

}
Loading