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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class AgentsCustomizations extends Customization {
public void customize(LibraryCustomization libraryCustomization, Logger logger) {
renameImageGenToolSize(libraryCustomization, logger);
modifyPollingStrategies(libraryCustomization, logger);
addToolboxesV1PreviewEnumValue(libraryCustomization, logger);
}

private void renameImageGenToolSize(LibraryCustomization customization, Logger logger) {
Expand Down Expand Up @@ -53,4 +54,22 @@ private void modifyPollingStrategies(LibraryCustomization customization, Logger
clazz.addMember(StaticJavaParser.parseMethodDeclaration("@Override public PollResponse<T> poll(PollingContext<T> pollingContext, TypeReference<T> pollResponseType) { return AgentsServicePollUtils.remapStatus(super.poll(pollingContext, pollResponseType)); }"));
}));
}

/**
* Adds TOOLBOXES_V1_PREVIEW enum value to FoundryFeaturesOptInKeys.
*/
private void addToolboxesV1PreviewEnumValue(LibraryCustomization customization, Logger logger) {
customization.getClass("com.azure.ai.agents.models", "FoundryFeaturesOptInKeys")
.customizeAst(ast -> ast.getEnumByName("FoundryFeaturesOptInKeys")
.ifPresent(clazz -> {
// Check if already present
boolean exists = clazz.getEntries().stream()
.anyMatch(entry -> "TOOLBOXES_V1_PREVIEW".equals(entry.getName().getIdentifier()));
if (!exists) {
clazz.addEnumConstant("TOOLBOXES_V1_PREVIEW")
.addArgument(StaticJavaParser.parseExpression("\"Toolboxes=V1Preview\""))
.setJavadocComment("Enum value Toolboxes=V1Preview.");
}
}));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.azure.ai.agents.implementation.ToolboxesImpl;
import com.azure.ai.agents.implementation.models.CreateToolboxVersionRequest;
import com.azure.ai.agents.implementation.models.UpdateToolboxRequest;
import com.azure.ai.agents.models.FoundryFeaturesOptInKeys;
import com.azure.ai.agents.models.PageOrder;
import com.azure.ai.agents.models.Tool;
import com.azure.ai.agents.models.ToolboxDetails;
Expand All @@ -19,6 +20,7 @@
import com.azure.core.exception.HttpResponseException;
import com.azure.core.exception.ResourceModifiedException;
import com.azure.core.exception.ResourceNotFoundException;
import com.azure.core.http.HttpHeaderName;
import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.PagedResponseBase;
Expand Down Expand Up @@ -397,12 +399,14 @@ public Mono<Response<Void>> deleteToolboxVersionWithResponse(String name, String
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a specific version of a toolbox on successful completion of {@link Mono}.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<ToolboxVersionDetails> createToolboxVersion(String name, List<Tool> tools, String description,
Map<String, String> metadata, ToolboxPolicies policies) {
Map<String, String> metadata, ToolboxPolicies policies, FoundryFeaturesOptInKeys foundryFeatures) {
// Generated convenience method for createToolboxVersionWithResponse
RequestOptions requestOptions = new RequestOptions();
if (foundryFeatures != null) {
requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString());
}
CreateToolboxVersionRequest createToolboxVersionRequestObj
= new CreateToolboxVersionRequest(tools).setDescription(description)
.setMetadata(metadata)
Expand All @@ -426,11 +430,14 @@ public Mono<ToolboxVersionDetails> createToolboxVersion(String name, List<Tool>
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a specific version of a toolbox on successful completion of {@link Mono}.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<ToolboxVersionDetails> createToolboxVersion(String name, List<Tool> tools) {
public Mono<ToolboxVersionDetails> createToolboxVersion(String name, List<Tool> tools,
FoundryFeaturesOptInKeys foundryFeatures) {
// Generated convenience method for createToolboxVersionWithResponse
RequestOptions requestOptions = new RequestOptions();
if (foundryFeatures != null) {
requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString());
}
CreateToolboxVersionRequest createToolboxVersionRequestObj = new CreateToolboxVersionRequest(tools);
BinaryData createToolboxVersionRequest = BinaryData.fromObject(createToolboxVersionRequestObj);
return createToolboxVersionWithResponse(name, createToolboxVersionRequest, requestOptions)
Expand All @@ -450,11 +457,13 @@ public Mono<ToolboxVersionDetails> createToolboxVersion(String name, List<Tool>
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a toolbox that stores reusable tool definitions for agents on successful completion of {@link Mono}.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<ToolboxDetails> getToolbox(String name) {
public Mono<ToolboxDetails> getToolbox(String name, FoundryFeaturesOptInKeys foundryFeatures) {
// Generated convenience method for getToolboxWithResponse
RequestOptions requestOptions = new RequestOptions();
if (foundryFeatures != null) {
requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString());
}
return getToolboxWithResponse(name, requestOptions).flatMap(FluxUtil::toMono)
.map(protocolMethodData -> protocolMethodData.toObject(ToolboxDetails.class));
}
Expand All @@ -480,11 +489,14 @@ public Mono<ToolboxDetails> getToolbox(String name) {
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the response data for a requested list of items as paginated response with {@link PagedFlux}.
*/
@Generated
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<ToolboxDetails> listToolboxes(Integer limit, PageOrder order, String after, String before) {
public PagedFlux<ToolboxDetails> listToolboxes(FoundryFeaturesOptInKeys foundryFeatures, Integer limit,
PageOrder order, String after, String before) {
// Generated convenience method for listToolboxes
RequestOptions requestOptions = new RequestOptions();
if (foundryFeatures != null) {
requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString());
}
if (limit != null) {
requestOptions.addQueryParam("limit", String.valueOf(limit), false);
}
Expand Down Expand Up @@ -522,11 +534,13 @@ public PagedFlux<ToolboxDetails> listToolboxes(Integer limit, PageOrder order, S
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the response data for a requested list of items as paginated response with {@link PagedFlux}.
*/
@Generated
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<ToolboxDetails> listToolboxes() {
public PagedFlux<ToolboxDetails> listToolboxes(FoundryFeaturesOptInKeys foundryFeatures) {
// Generated convenience method for listToolboxes
RequestOptions requestOptions = new RequestOptions();
if (foundryFeatures != null) {
requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString());
}
PagedFlux<BinaryData> pagedFluxResponse = listToolboxes(requestOptions);
return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> {
Flux<PagedResponse<BinaryData>> flux = (continuationTokenParam == null)
Expand Down Expand Up @@ -564,12 +578,14 @@ public PagedFlux<ToolboxDetails> listToolboxes() {
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the response data for a requested list of items as paginated response with {@link PagedFlux}.
*/
@Generated
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<ToolboxVersionDetails> listToolboxVersions(String name, Integer limit, PageOrder order,
String after, String before) {
public PagedFlux<ToolboxVersionDetails> listToolboxVersions(String name, FoundryFeaturesOptInKeys foundryFeatures,
Integer limit, PageOrder order, String after, String before) {
// Generated convenience method for listToolboxVersions
RequestOptions requestOptions = new RequestOptions();
if (foundryFeatures != null) {
requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString());
}
if (limit != null) {
requestOptions.addQueryParam("limit", String.valueOf(limit), false);
}
Expand Down Expand Up @@ -610,11 +626,13 @@ public PagedFlux<ToolboxVersionDetails> listToolboxVersions(String name, Integer
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the response data for a requested list of items as paginated response with {@link PagedFlux}.
*/
@Generated
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<ToolboxVersionDetails> listToolboxVersions(String name) {
public PagedFlux<ToolboxVersionDetails> listToolboxVersions(String name, FoundryFeaturesOptInKeys foundryFeatures) {
// Generated convenience method for listToolboxVersions
RequestOptions requestOptions = new RequestOptions();
if (foundryFeatures != null) {
requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString());
}
PagedFlux<BinaryData> pagedFluxResponse = listToolboxVersions(name, requestOptions);
return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> {
Flux<PagedResponse<BinaryData>> flux = (continuationTokenParam == null)
Expand Down Expand Up @@ -644,11 +662,14 @@ public PagedFlux<ToolboxVersionDetails> listToolboxVersions(String name) {
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a specific version of a toolbox on successful completion of {@link Mono}.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<ToolboxVersionDetails> getToolboxVersion(String name, String version) {
public Mono<ToolboxVersionDetails> getToolboxVersion(String name, String version,
FoundryFeaturesOptInKeys foundryFeatures) {
// Generated convenience method for getToolboxVersionWithResponse
RequestOptions requestOptions = new RequestOptions();
if (foundryFeatures != null) {
requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString());
}
return getToolboxVersionWithResponse(name, version, requestOptions).flatMap(FluxUtil::toMono)
.map(protocolMethodData -> protocolMethodData.toObject(ToolboxVersionDetails.class));
}
Expand All @@ -667,11 +688,14 @@ public Mono<ToolboxVersionDetails> getToolboxVersion(String name, String version
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a toolbox that stores reusable tool definitions for agents on successful completion of {@link Mono}.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<ToolboxDetails> updateToolbox(String name, String defaultVersion) {
public Mono<ToolboxDetails> updateToolbox(String name, String defaultVersion,
FoundryFeaturesOptInKeys foundryFeatures) {
// Generated convenience method for updateToolboxWithResponse
RequestOptions requestOptions = new RequestOptions();
if (foundryFeatures != null) {
requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString());
}
UpdateToolboxRequest updateToolboxRequestObj = new UpdateToolboxRequest(defaultVersion);
BinaryData updateToolboxRequest = BinaryData.fromObject(updateToolboxRequestObj);
return updateToolboxWithResponse(name, updateToolboxRequest, requestOptions).flatMap(FluxUtil::toMono)
Expand All @@ -690,11 +714,13 @@ public Mono<ToolboxDetails> updateToolbox(String name, String defaultVersion) {
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return A {@link Mono} that completes when a successful response is received.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Void> deleteToolbox(String name) {
public Mono<Void> deleteToolbox(String name, FoundryFeaturesOptInKeys foundryFeatures) {
// Generated convenience method for deleteToolboxWithResponse
RequestOptions requestOptions = new RequestOptions();
if (foundryFeatures != null) {
requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString());
}
return deleteToolboxWithResponse(name, requestOptions).flatMap(FluxUtil::toMono);
}

Expand All @@ -711,11 +737,13 @@ public Mono<Void> deleteToolbox(String name) {
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return A {@link Mono} that completes when a successful response is received.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Void> deleteToolboxVersion(String name, String version) {
public Mono<Void> deleteToolboxVersion(String name, String version, FoundryFeaturesOptInKeys foundryFeatures) {
// Generated convenience method for deleteToolboxVersionWithResponse
RequestOptions requestOptions = new RequestOptions();
if (foundryFeatures != null) {
requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString());
}
return deleteToolboxVersionWithResponse(name, version, requestOptions).flatMap(FluxUtil::toMono);
}
}
Loading