diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 709cec1a3685..890d22219fdd 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -256,6 +256,7 @@ com.azure.spring:spring-cloud-azure-stream-binder-servicebus-core;5.22.0;5.23.0- com.azure.spring:spring-cloud-azure-stream-binder-servicebus;5.22.0;5.23.0-beta.1 com.azure.spring:spring-cloud-azure-testcontainers;5.22.0;5.23.0-beta.1 com.azure:azure-spring-data-cosmos;5.22.0;5.23.0-beta.1 +com.azure:azure-ai-projects;1.0.0-beta.1;1.0.0-beta.1 com.azure.resourcemanager:azure-resourcemanager;2.50.0;2.51.0-beta.1 com.azure.resourcemanager:azure-resourcemanager-appplatform;2.50.0;2.51.0-beta.1 com.azure.resourcemanager:azure-resourcemanager-appservice;2.50.0;2.51.0-beta.1 diff --git a/sdk/ai/azure-ai-projects/CHANGELOG.md b/sdk/ai/azure-ai-projects/CHANGELOG.md new file mode 100644 index 000000000000..d3081f3e3e7d --- /dev/null +++ b/sdk/ai/azure-ai-projects/CHANGELOG.md @@ -0,0 +1,16 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +- Azure Projects client library for Java. This package contains Microsoft Azure Projects client library. + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes +### Features Added + +- Initial release for the azure-ai-projects Java SDK. diff --git a/sdk/ai/azure-ai-projects/README.md b/sdk/ai/azure-ai-projects/README.md new file mode 100644 index 000000000000..6a8d3521adad --- /dev/null +++ b/sdk/ai/azure-ai-projects/README.md @@ -0,0 +1,78 @@ +# Azure Projects client library for Java + +Azure Projects client library for Java. + +This package contains Microsoft Azure Projects client library. + +## Documentation + +Various documentation is available to help you get started + +- [API reference documentation][docs] +- [Product documentation][product_documentation] + +## Getting started + +### Prerequisites + +- [Java Development Kit (JDK)][jdk] with version 8 or above +- [Azure Subscription][azure_subscription] + +### Adding the package to your product + +[//]: # ({x-version-update-start;com.azure:azure-ai-projects;current}) +```xml + + com.azure + azure-ai-projects + 1.0.0-beta.1 + +``` +[//]: # ({x-version-update-end}) + +### Authentication + +[Azure Identity][azure_identity] package provides the default implementation for authenticating the client. + +## Key concepts + +## Examples + +```java com.azure.ai.projects.readme +``` + +### Service API versions + +The client library targets the latest service API version by default. +The service client builder accepts an optional service API version parameter to specify which API version to communicate. + +#### Select a service API version + +You have the flexibility to explicitly select a supported service API version when initializing a service client via the service client builder. +This ensures that the client can communicate with services using the specified API version. + +When selecting an API version, it is important to verify that there are no breaking changes compared to the latest API version. +If there are significant differences, API calls may fail due to incompatibility. + +Always ensure that the chosen API version is fully supported and operational for your specific use case and that it aligns with the service's versioning policy. + +## Troubleshooting + +## Next steps + +## Contributing + +For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md). + +1. Fork it +1. Create your feature branch (`git checkout -b my-new-feature`) +1. Commit your changes (`git commit -am 'Add some feature'`) +1. Push to the branch (`git push origin my-new-feature`) +1. Create new Pull Request + + +[product_documentation]: https://azure.microsoft.com/services/ +[docs]: https://azure.github.io/azure-sdk-for-java/ +[jdk]: https://learn.microsoft.com/azure/developer/java/fundamentals/ +[azure_subscription]: https://azure.microsoft.com/free/ +[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity diff --git a/sdk/ai/azure-ai-projects/assets.json b/sdk/ai/azure-ai-projects/assets.json new file mode 100644 index 000000000000..6218ebb2a369 --- /dev/null +++ b/sdk/ai/azure-ai-projects/assets.json @@ -0,0 +1 @@ +{"AssetsRepo":"Azure/azure-sdk-assets","AssetsRepoPrefixPath":"java","TagPrefix":"java/ai/azure-ai-projects","Tag":""} \ No newline at end of file diff --git a/sdk/ai/azure-ai-projects/pom.xml b/sdk/ai/azure-ai-projects/pom.xml new file mode 100644 index 000000000000..6af06abb80b2 --- /dev/null +++ b/sdk/ai/azure-ai-projects/pom.xml @@ -0,0 +1,71 @@ + + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure + azure-ai-projects + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for Projects + This package contains Microsoft Azure Projects client library. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + + + + com.azure + azure-core + 1.55.3 + + + com.azure + azure-core-http-netty + 1.15.11 + + + com.azure + azure-core-test + 1.27.0-beta.8 + test + + + com.azure + azure-identity + 1.16.0 + test + + + diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/AIProjectClientBuilder.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/AIProjectClientBuilder.java new file mode 100644 index 000000000000..341faad3d1cd --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/AIProjectClientBuilder.java @@ -0,0 +1,402 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects; + +import com.azure.ai.projects.implementation.AIProjectClientImpl; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.client.traits.ConfigurationTrait; +import com.azure.core.client.traits.EndpointTrait; +import com.azure.core.client.traits.HttpTrait; +import com.azure.core.client.traits.TokenCredentialTrait; +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.AddHeadersPolicy; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.util.ClientOptions; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.builder.ClientBuilderUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.serializer.JacksonAdapter; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the AIProjectClient type. + */ +@ServiceClientBuilder( + serviceClients = { + ConnectionsClient.class, + DatasetsClient.class, + IndexesClient.class, + DeploymentsClient.class, + ConnectionsAsyncClient.class, + DatasetsAsyncClient.class, + IndexesAsyncClient.class, + DeploymentsAsyncClient.class }) +public final class AIProjectClientBuilder + implements HttpTrait, ConfigurationTrait, + TokenCredentialTrait, EndpointTrait { + @Generated + private static final String SDK_NAME = "name"; + + @Generated + private static final String SDK_VERSION = "version"; + + @Generated + private static final String[] DEFAULT_SCOPES = new String[] { "https://ai.azure.com/.default" }; + + @Generated + private static final Map PROPERTIES = CoreUtils.getProperties("azure-ai-projects.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the AIProjectClientBuilder. + */ + @Generated + public AIProjectClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AIProjectClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AIProjectClientBuilder pipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AIProjectClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The client options such as application ID and custom headers to set on a request. + */ + @Generated + private ClientOptions clientOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AIProjectClientBuilder clientOptions(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Generated + private RetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AIProjectClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AIProjectClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Generated + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AIProjectClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The TokenCredential used for authentication. + */ + @Generated + private TokenCredential tokenCredential; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AIProjectClientBuilder credential(TokenCredential tokenCredential) { + this.tokenCredential = tokenCredential; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AIProjectClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private ProjectsServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the AIProjectClientBuilder. + */ + @Generated + public AIProjectClientBuilder serviceVersion(ProjectsServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + return this; + } + + /* + * The retry policy that will attempt to retry failed requests, if applicable. + */ + @Generated + private RetryPolicy retryPolicy; + + /** + * Sets The retry policy that will attempt to retry failed requests, if applicable. + * + * @param retryPolicy the retryPolicy value. + * @return the AIProjectClientBuilder. + */ + @Generated + public AIProjectClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of AIProjectClientImpl with the provided parameters. + * + * @return an instance of AIProjectClientImpl. + */ + @Generated + private AIProjectClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + ProjectsServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : ProjectsServiceVersion.getLatest(); + AIProjectClientImpl client = new AIProjectClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, localServiceVersion); + return client; + } + + @Generated + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @Generated + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions; + List policies = new ArrayList<>(); + String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName"); + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + String applicationId = CoreUtils.getApplicationId(localClientOptions, localHttpLogOptions); + policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); + policies.add(new RequestIdPolicy()); + policies.add(new AddHeadersFromContextPolicy()); + HttpHeaders headers = CoreUtils.createHttpHeadersFromClientOptions(localClientOptions); + if (headers != null) { + policies.add(new AddHeadersPolicy(headers)); + } + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .forEach(p -> policies.add(p)); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); + policies.add(new AddDatePolicy()); + if (tokenCredential != null) { + policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, DEFAULT_SCOPES)); + } + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .forEach(p -> policies.add(p)); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) + .httpClient(httpClient) + .clientOptions(localClientOptions) + .build(); + return httpPipeline; + } + + /** + * Builds an instance of ConnectionsAsyncClient class. + * + * @return an instance of ConnectionsAsyncClient. + */ + @Generated + public ConnectionsAsyncClient buildConnectionsAsyncClient() { + return new ConnectionsAsyncClient(buildInnerClient().getConnections()); + } + + /** + * Builds an instance of DatasetsAsyncClient class. + * + * @return an instance of DatasetsAsyncClient. + */ + @Generated + public DatasetsAsyncClient buildDatasetsAsyncClient() { + return new DatasetsAsyncClient(buildInnerClient().getDatasets()); + } + + /** + * Builds an instance of IndexesAsyncClient class. + * + * @return an instance of IndexesAsyncClient. + */ + @Generated + public IndexesAsyncClient buildIndexesAsyncClient() { + return new IndexesAsyncClient(buildInnerClient().getIndexes()); + } + + /** + * Builds an instance of DeploymentsAsyncClient class. + * + * @return an instance of DeploymentsAsyncClient. + */ + @Generated + public DeploymentsAsyncClient buildDeploymentsAsyncClient() { + return new DeploymentsAsyncClient(buildInnerClient().getDeployments()); + } + + /** + * Builds an instance of ConnectionsClient class. + * + * @return an instance of ConnectionsClient. + */ + @Generated + public ConnectionsClient buildConnectionsClient() { + return new ConnectionsClient(buildInnerClient().getConnections()); + } + + /** + * Builds an instance of DatasetsClient class. + * + * @return an instance of DatasetsClient. + */ + @Generated + public DatasetsClient buildDatasetsClient() { + return new DatasetsClient(buildInnerClient().getDatasets()); + } + + /** + * Builds an instance of IndexesClient class. + * + * @return an instance of IndexesClient. + */ + @Generated + public IndexesClient buildIndexesClient() { + return new IndexesClient(buildInnerClient().getIndexes()); + } + + /** + * Builds an instance of DeploymentsClient class. + * + * @return an instance of DeploymentsClient. + */ + @Generated + public DeploymentsClient buildDeploymentsClient() { + return new DeploymentsClient(buildInnerClient().getDeployments()); + } + + private static final ClientLogger LOGGER = new ClientLogger(AIProjectClientBuilder.class); +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/ConnectionsAsyncClient.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/ConnectionsAsyncClient.java new file mode 100644 index 000000000000..c3fbd57cba9e --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/ConnectionsAsyncClient.java @@ -0,0 +1,277 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects; + +import com.azure.ai.projects.implementation.ConnectionsImpl; +import com.azure.ai.projects.models.Connection; +import com.azure.ai.projects.models.ConnectionType; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AIProjectClient type. + */ +@ServiceClient(builder = AIProjectClientBuilder.class, isAsync = true) +public final class ConnectionsAsyncClient { + @Generated + private final ConnectionsImpl serviceClient; + + /** + * Initializes an instance of ConnectionsAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ConnectionsAsyncClient(ConnectionsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get a connection by name, without populating connection credentials. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     id: String (Required)
+     *     type: String(AzureOpenAI/AzureBlob/AzureStorageAccount/CognitiveSearch/CosmosDB/ApiKey/AppConfig/AppInsights/CustomKeys) (Required)
+     *     target: String (Required)
+     *     isDefault: boolean (Required)
+     *     credentials (Required): {
+     *         type: String(ApiKey/AAD/SAS/CustomKeys/None) (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The friendly name of the connection, provided by the user. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a connection by name, without populating connection credentials along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono> getWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(name, requestOptions); + } + + /** + * Get a connection by name, with its connection credentials. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     id: String (Required)
+     *     type: String(AzureOpenAI/AzureBlob/AzureStorageAccount/CognitiveSearch/CosmosDB/ApiKey/AppConfig/AppInsights/CustomKeys) (Required)
+     *     target: String (Required)
+     *     isDefault: boolean (Required)
+     *     credentials (Required): {
+     *         type: String(ApiKey/AAD/SAS/CustomKeys/None) (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The friendly name of the connection, provided by the user. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a connection by name, with its connection credentials along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono> getWithCredentialsWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.getWithCredentialsWithResponseAsync(name, requestOptions); + } + + /** + * List all connections in the project, without populating connection credentials. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
connectionTypeStringNoList connections of this specific type. Allowed values: + * "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", "AppConfig", + * "AppInsights", "CustomKeys".
defaultConnectionBooleanNoList connections that are default + * connections
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     id: String (Required)
+     *     type: String(AzureOpenAI/AzureBlob/AzureStorageAccount/CognitiveSearch/CosmosDB/ApiKey/AppConfig/AppInsights/CustomKeys) (Required)
+     *     target: String (Required)
+     *     isDefault: boolean (Required)
+     *     credentials (Required): {
+     *         type: String(ApiKey/AAD/SAS/CustomKeys/None) (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Connection items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list(RequestOptions requestOptions) { + return this.serviceClient.listAsync(requestOptions); + } + + /** + * Get a connection by name, without populating connection credentials. + * + * @param name The friendly name of the connection, provided by the user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a connection by name, without populating connection credentials on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono get(String name) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(name, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Connection.class)); + } + + /** + * Get a connection by name, with its connection credentials. + * + * @param name The friendly name of the connection, provided by the user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a connection by name, with its connection credentials on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono getWithCredentials(String name) { + // Generated convenience method for getWithCredentialsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithCredentialsWithResponse(name, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Connection.class)); + } + + /** + * List all connections in the project, without populating connection credentials. + * + * @param connectionType List connections of this specific type. + * @param defaultConnection List connections that are default connections. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of Connection items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list(ConnectionType connectionType, Boolean defaultConnection) { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + if (connectionType != null) { + requestOptions.addQueryParam("connectionType", connectionType.toString(), false); + } + if (defaultConnection != null) { + requestOptions.addQueryParam("defaultConnection", String.valueOf(defaultConnection), false); + } + PagedFlux pagedFluxResponse = list(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(Connection.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * List all connections in the project, without populating connection credentials. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of Connection items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list() { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = list(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(Connection.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/ConnectionsClient.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/ConnectionsClient.java new file mode 100644 index 000000000000..2d95252b3713 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/ConnectionsClient.java @@ -0,0 +1,243 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects; + +import com.azure.ai.projects.implementation.ConnectionsImpl; +import com.azure.ai.projects.models.Connection; +import com.azure.ai.projects.models.ConnectionType; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; + +/** + * Initializes a new instance of the synchronous AIProjectClient type. + */ +@ServiceClient(builder = AIProjectClientBuilder.class) +public final class ConnectionsClient { + @Generated + private final ConnectionsImpl serviceClient; + + /** + * Initializes an instance of ConnectionsClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ConnectionsClient(ConnectionsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get a connection by name, without populating connection credentials. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     id: String (Required)
+     *     type: String(AzureOpenAI/AzureBlob/AzureStorageAccount/CognitiveSearch/CosmosDB/ApiKey/AppConfig/AppInsights/CustomKeys) (Required)
+     *     target: String (Required)
+     *     isDefault: boolean (Required)
+     *     credentials (Required): {
+     *         type: String(ApiKey/AAD/SAS/CustomKeys/None) (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The friendly name of the connection, provided by the user. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a connection by name, without populating connection credentials along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(name, requestOptions); + } + + /** + * Get a connection by name, with its connection credentials. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     id: String (Required)
+     *     type: String(AzureOpenAI/AzureBlob/AzureStorageAccount/CognitiveSearch/CosmosDB/ApiKey/AppConfig/AppInsights/CustomKeys) (Required)
+     *     target: String (Required)
+     *     isDefault: boolean (Required)
+     *     credentials (Required): {
+     *         type: String(ApiKey/AAD/SAS/CustomKeys/None) (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The friendly name of the connection, provided by the user. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a connection by name, with its connection credentials along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithCredentialsWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.getWithCredentialsWithResponse(name, requestOptions); + } + + /** + * List all connections in the project, without populating connection credentials. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
connectionTypeStringNoList connections of this specific type. Allowed values: + * "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", "AppConfig", + * "AppInsights", "CustomKeys".
defaultConnectionBooleanNoList connections that are default + * connections
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     id: String (Required)
+     *     type: String(AzureOpenAI/AzureBlob/AzureStorageAccount/CognitiveSearch/CosmosDB/ApiKey/AppConfig/AppInsights/CustomKeys) (Required)
+     *     target: String (Required)
+     *     isDefault: boolean (Required)
+     *     credentials (Required): {
+     *         type: String(ApiKey/AAD/SAS/CustomKeys/None) (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Connection items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(RequestOptions requestOptions) { + return this.serviceClient.list(requestOptions); + } + + /** + * Get a connection by name, without populating connection credentials. + * + * @param name The friendly name of the connection, provided by the user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a connection by name, without populating connection credentials. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Connection get(String name) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(name, requestOptions).getValue().toObject(Connection.class); + } + + /** + * Get a connection by name, with its connection credentials. + * + * @param name The friendly name of the connection, provided by the user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a connection by name, with its connection credentials. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Connection getWithCredentials(String name) { + // Generated convenience method for getWithCredentialsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithCredentialsWithResponse(name, requestOptions).getValue().toObject(Connection.class); + } + + /** + * List all connections in the project, without populating connection credentials. + * + * @param connectionType List connections of this specific type. + * @param defaultConnection List connections that are default connections. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of Connection items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(ConnectionType connectionType, Boolean defaultConnection) { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + if (connectionType != null) { + requestOptions.addQueryParam("connectionType", connectionType.toString(), false); + } + if (defaultConnection != null) { + requestOptions.addQueryParam("defaultConnection", String.valueOf(defaultConnection), false); + } + return serviceClient.list(requestOptions).mapPage(bodyItemValue -> bodyItemValue.toObject(Connection.class)); + } + + /** + * List all connections in the project, without populating connection credentials. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of Connection items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.list(requestOptions).mapPage(bodyItemValue -> bodyItemValue.toObject(Connection.class)); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/DatasetsAsyncClient.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/DatasetsAsyncClient.java new file mode 100644 index 000000000000..517a6ba894ff --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/DatasetsAsyncClient.java @@ -0,0 +1,503 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects; + +import com.azure.ai.projects.implementation.DatasetsImpl; +import com.azure.ai.projects.implementation.JsonMergePatchHelper; +import com.azure.ai.projects.models.AssetCredentialResponse; +import com.azure.ai.projects.models.DatasetVersion; +import com.azure.ai.projects.models.PendingUploadRequest; +import com.azure.ai.projects.models.PendingUploadResponse; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AIProjectClient type. + */ +@ServiceClient(builder = AIProjectClientBuilder.class, isAsync = true) +public final class DatasetsAsyncClient { + @Generated + private final DatasetsImpl serviceClient; + + /** + * Initializes an instance of DatasetsAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DatasetsAsyncClient(DatasetsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * List all versions of the given DatasetVersion. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DatasetVersion items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listVersions(String name, RequestOptions requestOptions) { + return this.serviceClient.listVersionsAsync(name, requestOptions); + } + + /** + * List the latest version of each DatasetVersion. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DatasetVersion items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list(RequestOptions requestOptions) { + return this.serviceClient.listAsync(requestOptions); + } + + /** + * Get the specific version of the DatasetVersion. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param version The specific version id of the DatasetVersion to retrieve. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the specific version of the DatasetVersion along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(String name, String version, RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(name, version, requestOptions); + } + + /** + * Delete the specific version of the DatasetVersion. + * + * @param name The name of the resource. + * @param version The version of the DatasetVersion to delete. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteWithResponse(String name, String version, RequestOptions requestOptions) { + return this.serviceClient.deleteWithResponseAsync(name, version, requestOptions); + } + + /** + * Create a new or update an existing DatasetVersion with the given version id. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param version The specific version id of the DatasetVersion to create or replace. + * @param body The definition of the DatasetVersion to create or update. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return datasetVersion Definition along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createOrUpdateWithResponse(String name, String version, BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.createOrUpdateWithResponseAsync(name, version, body, requestOptions); + } + + /** + * Start a new or get an existing pending upload of a dataset for a specific version. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     pendingUploadId: String (Optional)
+     *     connectionName: String (Optional)
+     *     pendingUploadType: String(None/BlobReference) (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     blobReference (Required): {
+     *         blobUri: String (Required)
+     *         storageAccountArmId: String (Required)
+     *         credential (Required): {
+     *             sasUri: String (Required)
+     *             type: String (Required)
+     *         }
+     *     }
+     *     pendingUploadId: String (Required)
+     *     version: String (Optional)
+     *     pendingUploadType: String(None/BlobReference) (Required)
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param version The specific version id of the DatasetVersion to operate on. + * @param body Parameters for the action. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents the response for a pending upload request along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> pendingUploadWithResponse(String name, String version, BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.pendingUploadWithResponseAsync(name, version, body, requestOptions); + } + + /** + * Get the SAS credential to access the storage account associated with a Dataset version. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     blobReference (Required): {
+     *         blobUri: String (Required)
+     *         storageAccountArmId: String (Required)
+     *         credential (Required): {
+     *             sasUri: String (Required)
+     *             type: String (Required)
+     *         }
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param version The specific version id of the DatasetVersion to operate on. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the SAS credential to access the storage account associated with a Dataset version along with + * {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getCredentialsWithResponse(String name, String version, + RequestOptions requestOptions) { + return this.serviceClient.getCredentialsWithResponseAsync(name, version, requestOptions); + } + + /** + * List all versions of the given DatasetVersion. + * + * @param name The name of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of DatasetVersion items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listVersions(String name) { + // Generated convenience method for listVersions + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listVersions(name, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(DatasetVersion.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * List the latest version of each DatasetVersion. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of DatasetVersion items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list() { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = list(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(DatasetVersion.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Get the specific version of the DatasetVersion. + * + * @param name The name of the resource. + * @param version The specific version id of the DatasetVersion to retrieve. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the specific version of the DatasetVersion on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get(String name, String version) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(name, version, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DatasetVersion.class)); + } + + /** + * Delete the specific version of the DatasetVersion. + * + * @param name The name of the resource. + * @param version The version of the DatasetVersion to delete. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @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 delete(String name, String version) { + // Generated convenience method for deleteWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteWithResponse(name, version, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Create a new or update an existing DatasetVersion with the given version id. + * + * @param name The name of the resource. + * @param version The specific version id of the DatasetVersion to create or replace. + * @param body The definition of the DatasetVersion to create or update. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return datasetVersion Definition on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createOrUpdate(String name, String version, DatasetVersion body) { + // Generated convenience method for createOrUpdateWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getDatasetVersionAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getDatasetVersionAccessor().prepareModelForJsonMergePatch(body, false); + return createOrUpdateWithResponse(name, version, bodyInBinaryData, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DatasetVersion.class)); + } + + /** + * Start a new or get an existing pending upload of a dataset for a specific version. + * + * @param name The name of the resource. + * @param version The specific version id of the DatasetVersion to operate on. + * @param body Parameters for the action. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents the response for a pending upload request on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono pendingUpload(String name, String version, PendingUploadRequest body) { + // Generated convenience method for pendingUploadWithResponse + RequestOptions requestOptions = new RequestOptions(); + return pendingUploadWithResponse(name, version, BinaryData.fromObject(body), requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PendingUploadResponse.class)); + } + + /** + * Get the SAS credential to access the storage account associated with a Dataset version. + * + * @param name The name of the resource. + * @param version The specific version id of the DatasetVersion to operate on. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the SAS credential to access the storage account associated with a Dataset version on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getCredentials(String name, String version) { + // Generated convenience method for getCredentialsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getCredentialsWithResponse(name, version, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(AssetCredentialResponse.class)); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/DatasetsClient.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/DatasetsClient.java new file mode 100644 index 000000000000..e3f82ce74e5a --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/DatasetsClient.java @@ -0,0 +1,468 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects; + +import com.azure.ai.projects.implementation.DatasetsImpl; +import com.azure.ai.projects.implementation.JsonMergePatchHelper; +import com.azure.ai.projects.models.AssetCredentialResponse; +import com.azure.ai.projects.models.DatasetVersion; +import com.azure.ai.projects.models.PendingUploadRequest; +import com.azure.ai.projects.models.PendingUploadResponse; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; + +/** + * Initializes a new instance of the synchronous AIProjectClient type. + */ +@ServiceClient(builder = AIProjectClientBuilder.class) +public final class DatasetsClient { + @Generated + private final DatasetsImpl serviceClient; + + /** + * Initializes an instance of DatasetsClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DatasetsClient(DatasetsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * List all versions of the given DatasetVersion. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DatasetVersion items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listVersions(String name, RequestOptions requestOptions) { + return this.serviceClient.listVersions(name, requestOptions); + } + + /** + * List the latest version of each DatasetVersion. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DatasetVersion items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(RequestOptions requestOptions) { + return this.serviceClient.list(requestOptions); + } + + /** + * Get the specific version of the DatasetVersion. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param version The specific version id of the DatasetVersion to retrieve. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the specific version of the DatasetVersion along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String name, String version, RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(name, version, requestOptions); + } + + /** + * Delete the specific version of the DatasetVersion. + * + * @param name The name of the resource. + * @param version The version of the DatasetVersion to delete. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse(String name, String version, RequestOptions requestOptions) { + return this.serviceClient.deleteWithResponse(name, version, requestOptions); + } + + /** + * Create a new or update an existing DatasetVersion with the given version id. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param version The specific version id of the DatasetVersion to create or replace. + * @param body The definition of the DatasetVersion to create or update. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return datasetVersion Definition along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateWithResponse(String name, String version, BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.createOrUpdateWithResponse(name, version, body, requestOptions); + } + + /** + * Start a new or get an existing pending upload of a dataset for a specific version. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     pendingUploadId: String (Optional)
+     *     connectionName: String (Optional)
+     *     pendingUploadType: String(None/BlobReference) (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     blobReference (Required): {
+     *         blobUri: String (Required)
+     *         storageAccountArmId: String (Required)
+     *         credential (Required): {
+     *             sasUri: String (Required)
+     *             type: String (Required)
+     *         }
+     *     }
+     *     pendingUploadId: String (Required)
+     *     version: String (Optional)
+     *     pendingUploadType: String(None/BlobReference) (Required)
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param version The specific version id of the DatasetVersion to operate on. + * @param body Parameters for the action. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents the response for a pending upload request along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response pendingUploadWithResponse(String name, String version, BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.pendingUploadWithResponse(name, version, body, requestOptions); + } + + /** + * Get the SAS credential to access the storage account associated with a Dataset version. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     blobReference (Required): {
+     *         blobUri: String (Required)
+     *         storageAccountArmId: String (Required)
+     *         credential (Required): {
+     *             sasUri: String (Required)
+     *             type: String (Required)
+     *         }
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param version The specific version id of the DatasetVersion to operate on. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the SAS credential to access the storage account associated with a Dataset version along with + * {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getCredentialsWithResponse(String name, String version, RequestOptions requestOptions) { + return this.serviceClient.getCredentialsWithResponse(name, version, requestOptions); + } + + /** + * List all versions of the given DatasetVersion. + * + * @param name The name of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of DatasetVersion items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listVersions(String name) { + // Generated convenience method for listVersions + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listVersions(name, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(DatasetVersion.class)); + } + + /** + * List the latest version of each DatasetVersion. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of DatasetVersion items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.list(requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(DatasetVersion.class)); + } + + /** + * Get the specific version of the DatasetVersion. + * + * @param name The name of the resource. + * @param version The specific version id of the DatasetVersion to retrieve. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the specific version of the DatasetVersion. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DatasetVersion get(String name, String version) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(name, version, requestOptions).getValue().toObject(DatasetVersion.class); + } + + /** + * Delete the specific version of the DatasetVersion. + * + * @param name The name of the resource. + * @param version The version of the DatasetVersion to delete. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String name, String version) { + // Generated convenience method for deleteWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteWithResponse(name, version, requestOptions).getValue(); + } + + /** + * Create a new or update an existing DatasetVersion with the given version id. + * + * @param name The name of the resource. + * @param version The specific version id of the DatasetVersion to create or replace. + * @param body The definition of the DatasetVersion to create or update. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return datasetVersion Definition. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DatasetVersion createOrUpdate(String name, String version, DatasetVersion body) { + // Generated convenience method for createOrUpdateWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getDatasetVersionAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getDatasetVersionAccessor().prepareModelForJsonMergePatch(body, false); + return createOrUpdateWithResponse(name, version, bodyInBinaryData, requestOptions).getValue() + .toObject(DatasetVersion.class); + } + + /** + * Start a new or get an existing pending upload of a dataset for a specific version. + * + * @param name The name of the resource. + * @param version The specific version id of the DatasetVersion to operate on. + * @param body Parameters for the action. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents the response for a pending upload request. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PendingUploadResponse pendingUpload(String name, String version, PendingUploadRequest body) { + // Generated convenience method for pendingUploadWithResponse + RequestOptions requestOptions = new RequestOptions(); + return pendingUploadWithResponse(name, version, BinaryData.fromObject(body), requestOptions).getValue() + .toObject(PendingUploadResponse.class); + } + + /** + * Get the SAS credential to access the storage account associated with a Dataset version. + * + * @param name The name of the resource. + * @param version The specific version id of the DatasetVersion to operate on. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the SAS credential to access the storage account associated with a Dataset version. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public AssetCredentialResponse getCredentials(String name, String version) { + // Generated convenience method for getCredentialsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getCredentialsWithResponse(name, version, requestOptions).getValue() + .toObject(AssetCredentialResponse.class); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/DeploymentsAsyncClient.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/DeploymentsAsyncClient.java new file mode 100644 index 000000000000..b5b5c7abd685 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/DeploymentsAsyncClient.java @@ -0,0 +1,204 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects; + +import com.azure.ai.projects.implementation.DeploymentsImpl; +import com.azure.ai.projects.models.Deployment; +import com.azure.ai.projects.models.DeploymentType; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AIProjectClient type. + */ +@ServiceClient(builder = AIProjectClientBuilder.class, isAsync = true) +public final class DeploymentsAsyncClient { + @Generated + private final DeploymentsImpl serviceClient; + + /** + * Initializes an instance of DeploymentsAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DeploymentsAsyncClient(DeploymentsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get a deployed model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(ModelDeployment) (Required)
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param name Name of the deployment. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a deployed model along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(name, requestOptions); + } + + /** + * List all deployed models in the project. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
modelPublisherStringNoModel publisher to filter models by
modelNameStringNoModel name (the publisher specific name) to filter models + * by
deploymentTypeStringNoType of deployment to filter list by. Allowed values: + * "ModelDeployment".
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(ModelDeployment) (Required)
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Deployment items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list(RequestOptions requestOptions) { + return this.serviceClient.listAsync(requestOptions); + } + + /** + * Get a deployed model. + * + * @param name Name of the deployment. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a deployed model on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get(String name) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(name, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Deployment.class)); + } + + /** + * List all deployed models in the project. + * + * @param modelPublisher Model publisher to filter models by. + * @param modelName Model name (the publisher specific name) to filter models by. + * @param deploymentType Type of deployment to filter list by. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of Deployment items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list(String modelPublisher, String modelName, DeploymentType deploymentType) { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + if (modelPublisher != null) { + requestOptions.addQueryParam("modelPublisher", modelPublisher, false); + } + if (modelName != null) { + requestOptions.addQueryParam("modelName", modelName, false); + } + if (deploymentType != null) { + requestOptions.addQueryParam("deploymentType", deploymentType.toString(), false); + } + PagedFlux pagedFluxResponse = list(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(Deployment.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * List all deployed models in the project. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of Deployment items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list() { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = list(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(Deployment.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/DeploymentsClient.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/DeploymentsClient.java new file mode 100644 index 000000000000..fd996d97caf3 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/DeploymentsClient.java @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects; + +import com.azure.ai.projects.implementation.DeploymentsImpl; +import com.azure.ai.projects.models.Deployment; +import com.azure.ai.projects.models.DeploymentType; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; + +/** + * Initializes a new instance of the synchronous AIProjectClient type. + */ +@ServiceClient(builder = AIProjectClientBuilder.class) +public final class DeploymentsClient { + @Generated + private final DeploymentsImpl serviceClient; + + /** + * Initializes an instance of DeploymentsClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DeploymentsClient(DeploymentsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get a deployed model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(ModelDeployment) (Required)
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param name Name of the deployment. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a deployed model along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(name, requestOptions); + } + + /** + * List all deployed models in the project. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
modelPublisherStringNoModel publisher to filter models by
modelNameStringNoModel name (the publisher specific name) to filter models + * by
deploymentTypeStringNoType of deployment to filter list by. Allowed values: + * "ModelDeployment".
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(ModelDeployment) (Required)
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Deployment items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(RequestOptions requestOptions) { + return this.serviceClient.list(requestOptions); + } + + /** + * Get a deployed model. + * + * @param name Name of the deployment. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a deployed model. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Deployment get(String name) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(name, requestOptions).getValue().toObject(Deployment.class); + } + + /** + * List all deployed models in the project. + * + * @param modelPublisher Model publisher to filter models by. + * @param modelName Model name (the publisher specific name) to filter models by. + * @param deploymentType Type of deployment to filter list by. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of Deployment items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String modelPublisher, String modelName, DeploymentType deploymentType) { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + if (modelPublisher != null) { + requestOptions.addQueryParam("modelPublisher", modelPublisher, false); + } + if (modelName != null) { + requestOptions.addQueryParam("modelName", modelName, false); + } + if (deploymentType != null) { + requestOptions.addQueryParam("deploymentType", deploymentType.toString(), false); + } + return serviceClient.list(requestOptions).mapPage(bodyItemValue -> bodyItemValue.toObject(Deployment.class)); + } + + /** + * List all deployed models in the project. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of Deployment items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.list(requestOptions).mapPage(bodyItemValue -> bodyItemValue.toObject(Deployment.class)); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/IndexesAsyncClient.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/IndexesAsyncClient.java new file mode 100644 index 000000000000..596f95b98580 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/IndexesAsyncClient.java @@ -0,0 +1,349 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects; + +import com.azure.ai.projects.implementation.IndexesImpl; +import com.azure.ai.projects.implementation.JsonMergePatchHelper; +import com.azure.ai.projects.models.Index; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AIProjectClient type. + */ +@ServiceClient(builder = AIProjectClientBuilder.class, isAsync = true) +public final class IndexesAsyncClient { + @Generated + private final IndexesImpl serviceClient; + + /** + * Initializes an instance of IndexesAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndexesAsyncClient(IndexesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * List all versions of the given Index. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Index items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listVersions(String name, RequestOptions requestOptions) { + return this.serviceClient.listVersionsAsync(name, requestOptions); + } + + /** + * List the latest version of each Index. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Index items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list(RequestOptions requestOptions) { + return this.serviceClient.listAsync(requestOptions); + } + + /** + * Get the specific version of the Index. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param version The specific version id of the Index to retrieve. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the specific version of the Index along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(String name, String version, RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(name, version, requestOptions); + } + + /** + * Delete the specific version of the Index. + * + * @param name The name of the resource. + * @param version The version of the Index to delete. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteWithResponse(String name, String version, RequestOptions requestOptions) { + return this.serviceClient.deleteWithResponseAsync(name, version, requestOptions); + } + + /** + * Create a new or update an existing Index with the given version id. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param version The specific version id of the Index to create or replace. + * @param body The definition of the Index to create or update. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return index resource Definition along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createOrUpdateWithResponse(String name, String version, BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.createOrUpdateWithResponseAsync(name, version, body, requestOptions); + } + + /** + * List all versions of the given Index. + * + * @param name The name of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of Index items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listVersions(String name) { + // Generated convenience method for listVersions + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listVersions(name, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(Index.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * List the latest version of each Index. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of Index items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list() { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = list(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(Index.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Get the specific version of the Index. + * + * @param name The name of the resource. + * @param version The specific version id of the Index to retrieve. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the specific version of the Index on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get(String name, String version) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(name, version, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Index.class)); + } + + /** + * Delete the specific version of the Index. + * + * @param name The name of the resource. + * @param version The version of the Index to delete. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @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 delete(String name, String version) { + // Generated convenience method for deleteWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteWithResponse(name, version, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Create a new or update an existing Index with the given version id. + * + * @param name The name of the resource. + * @param version The specific version id of the Index to create or replace. + * @param body The definition of the Index to create or update. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return index resource Definition on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createOrUpdate(String name, String version, Index body) { + // Generated convenience method for createOrUpdateWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getIndexAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getIndexAccessor().prepareModelForJsonMergePatch(body, false); + return createOrUpdateWithResponse(name, version, bodyInBinaryData, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Index.class)); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/IndexesClient.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/IndexesClient.java new file mode 100644 index 000000000000..7dd6e97c1f90 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/IndexesClient.java @@ -0,0 +1,318 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects; + +import com.azure.ai.projects.implementation.IndexesImpl; +import com.azure.ai.projects.implementation.JsonMergePatchHelper; +import com.azure.ai.projects.models.Index; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; + +/** + * Initializes a new instance of the synchronous AIProjectClient type. + */ +@ServiceClient(builder = AIProjectClientBuilder.class) +public final class IndexesClient { + @Generated + private final IndexesImpl serviceClient; + + /** + * Initializes an instance of IndexesClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndexesClient(IndexesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * List all versions of the given Index. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Index items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listVersions(String name, RequestOptions requestOptions) { + return this.serviceClient.listVersions(name, requestOptions); + } + + /** + * List the latest version of each Index. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Index items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(RequestOptions requestOptions) { + return this.serviceClient.list(requestOptions); + } + + /** + * Get the specific version of the Index. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param version The specific version id of the Index to retrieve. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the specific version of the Index along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String name, String version, RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(name, version, requestOptions); + } + + /** + * Delete the specific version of the Index. + * + * @param name The name of the resource. + * @param version The version of the Index to delete. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse(String name, String version, RequestOptions requestOptions) { + return this.serviceClient.deleteWithResponse(name, version, requestOptions); + } + + /** + * Create a new or update an existing Index with the given version id. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param version The specific version id of the Index to create or replace. + * @param body The definition of the Index to create or update. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return index resource Definition along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateWithResponse(String name, String version, BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.createOrUpdateWithResponse(name, version, body, requestOptions); + } + + /** + * List all versions of the given Index. + * + * @param name The name of the resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of Index items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listVersions(String name) { + // Generated convenience method for listVersions + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listVersions(name, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(Index.class)); + } + + /** + * List the latest version of each Index. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of Index items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.list(requestOptions).mapPage(bodyItemValue -> bodyItemValue.toObject(Index.class)); + } + + /** + * Get the specific version of the Index. + * + * @param name The name of the resource. + * @param version The specific version id of the Index to retrieve. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the specific version of the Index. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Index get(String name, String version) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(name, version, requestOptions).getValue().toObject(Index.class); + } + + /** + * Delete the specific version of the Index. + * + * @param name The name of the resource. + * @param version The version of the Index to delete. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String name, String version) { + // Generated convenience method for deleteWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteWithResponse(name, version, requestOptions).getValue(); + } + + /** + * Create a new or update an existing Index with the given version id. + * + * @param name The name of the resource. + * @param version The specific version id of the Index to create or replace. + * @param body The definition of the Index to create or update. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return index resource Definition. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Index createOrUpdate(String name, String version, Index body) { + // Generated convenience method for createOrUpdateWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getIndexAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getIndexAccessor().prepareModelForJsonMergePatch(body, false); + return createOrUpdateWithResponse(name, version, bodyInBinaryData, requestOptions).getValue() + .toObject(Index.class); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/ProjectsServiceVersion.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/ProjectsServiceVersion.java new file mode 100644 index 000000000000..b076b11f039a --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/ProjectsServiceVersion.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of ProjectsClient. + */ +public enum ProjectsServiceVersion implements ServiceVersion { + /** + * Enum value 2025-05-01. + */ + V2025_05_01("2025-05-01"), + + /** + * Enum value 2025-05-15-preview. + */ + V2025_05_15_PREVIEW("2025-05-15-preview"), + + /** + * Enum value v1. + */ + V1("v1"); + + private final String version; + + ProjectsServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link ProjectsServiceVersion}. + */ + public static ProjectsServiceVersion getLatest() { + return V1; + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/AIProjectClientImpl.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/AIProjectClientImpl.java new file mode 100644 index 000000000000..1e17eb1ec8b6 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/AIProjectClientImpl.java @@ -0,0 +1,197 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.implementation; + +import com.azure.ai.projects.ProjectsServiceVersion; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the AIProjectClient type. + */ +public final class AIProjectClientImpl { + /** + * Project endpoint. In the form + * "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/_project" + * if your Foundry Hub has only one Project, or to use the default Project in your Hub. Or in the form + * "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/<your-project-name>" if + * you want to explicitly + * specify the Foundry Project name. + */ + private final String endpoint; + + /** + * Gets Project endpoint. In the form + * "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/_project" + * if your Foundry Hub has only one Project, or to use the default Project in your Hub. Or in the form + * "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/<your-project-name>" if + * you want to explicitly + * specify the Foundry Project name. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final ProjectsServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public ProjectsServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * The HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The serializer to serialize an object into a string. + */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + public SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * The ConnectionsImpl object to access its operations. + */ + private final ConnectionsImpl connections; + + /** + * Gets the ConnectionsImpl object to access its operations. + * + * @return the ConnectionsImpl object. + */ + public ConnectionsImpl getConnections() { + return this.connections; + } + + /** + * The DatasetsImpl object to access its operations. + */ + private final DatasetsImpl datasets; + + /** + * Gets the DatasetsImpl object to access its operations. + * + * @return the DatasetsImpl object. + */ + public DatasetsImpl getDatasets() { + return this.datasets; + } + + /** + * The IndexesImpl object to access its operations. + */ + private final IndexesImpl indexes; + + /** + * Gets the IndexesImpl object to access its operations. + * + * @return the IndexesImpl object. + */ + public IndexesImpl getIndexes() { + return this.indexes; + } + + /** + * The DeploymentsImpl object to access its operations. + */ + private final DeploymentsImpl deployments; + + /** + * Gets the DeploymentsImpl object to access its operations. + * + * @return the DeploymentsImpl object. + */ + public DeploymentsImpl getDeployments() { + return this.deployments; + } + + /** + * Initializes an instance of AIProjectClient client. + * + * @param endpoint Project endpoint. In the form + * "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/_project" + * if your Foundry Hub has only one Project, or to use the default Project in your Hub. Or in the form + * "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/<your-project-name>" if + * you want to explicitly + * specify the Foundry Project name. + * @param serviceVersion Service version. + */ + public AIProjectClientImpl(String endpoint, ProjectsServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of AIProjectClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Project endpoint. In the form + * "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/_project" + * if your Foundry Hub has only one Project, or to use the default Project in your Hub. Or in the form + * "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/<your-project-name>" if + * you want to explicitly + * specify the Foundry Project name. + * @param serviceVersion Service version. + */ + public AIProjectClientImpl(HttpPipeline httpPipeline, String endpoint, ProjectsServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of AIProjectClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Project endpoint. In the form + * "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/_project" + * if your Foundry Hub has only one Project, or to use the default Project in your Hub. Or in the form + * "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/<your-project-name>" if + * you want to explicitly + * specify the Foundry Project name. + * @param serviceVersion Service version. + */ + public AIProjectClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + ProjectsServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.connections = new ConnectionsImpl(this); + this.datasets = new DatasetsImpl(this); + this.indexes = new IndexesImpl(this); + this.deployments = new DeploymentsImpl(this); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/ConnectionsImpl.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/ConnectionsImpl.java new file mode 100644 index 000000000000..9f8e4be0c178 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/ConnectionsImpl.java @@ -0,0 +1,607 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.implementation; + +import com.azure.ai.projects.ProjectsServiceVersion; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Connections. + */ +public final class ConnectionsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ConnectionsService service; + + /** + * The service client containing this operation class. + */ + private final AIProjectClientImpl client; + + /** + * Initializes an instance of ConnectionsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ConnectionsImpl(AIProjectClientImpl client) { + this.service + = RestProxy.create(ConnectionsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public ProjectsServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for AIProjectClientConnections to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AIProjectClientConne") + public interface ConnectionsService { + @Get("/connections/{name}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/connections/{name}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/connections/{name}/getConnectionWithCredentials") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getWithCredentials(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/connections/{name}/getConnectionWithCredentials") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getWithCredentialsSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/connections") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> list(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/connections") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + } + + /** + * Get a connection by name, without populating connection credentials. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     id: String (Required)
+     *     type: String(AzureOpenAI/AzureBlob/AzureStorageAccount/CognitiveSearch/CosmosDB/ApiKey/AppConfig/AppInsights/CustomKeys) (Required)
+     *     target: String (Required)
+     *     isDefault: boolean (Required)
+     *     credentials (Required): {
+     *         type: String(ApiKey/AAD/SAS/CustomKeys/None) (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The friendly name of the connection, provided by the user. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a connection by name, without populating connection credentials along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), name, accept, requestOptions, context)); + } + + /** + * Get a connection by name, without populating connection credentials. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     id: String (Required)
+     *     type: String(AzureOpenAI/AzureBlob/AzureStorageAccount/CognitiveSearch/CosmosDB/ApiKey/AppConfig/AppInsights/CustomKeys) (Required)
+     *     target: String (Required)
+     *     isDefault: boolean (Required)
+     *     credentials (Required): {
+     *         type: String(ApiKey/AAD/SAS/CustomKeys/None) (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The friendly name of the connection, provided by the user. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a connection by name, without populating connection credentials along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), name, accept, + requestOptions, Context.NONE); + } + + /** + * Get a connection by name, with its connection credentials. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     id: String (Required)
+     *     type: String(AzureOpenAI/AzureBlob/AzureStorageAccount/CognitiveSearch/CosmosDB/ApiKey/AppConfig/AppInsights/CustomKeys) (Required)
+     *     target: String (Required)
+     *     isDefault: boolean (Required)
+     *     credentials (Required): {
+     *         type: String(ApiKey/AAD/SAS/CustomKeys/None) (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The friendly name of the connection, provided by the user. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a connection by name, with its connection credentials along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithCredentialsWithResponseAsync(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getWithCredentials(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), name, accept, requestOptions, context)); + } + + /** + * Get a connection by name, with its connection credentials. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     id: String (Required)
+     *     type: String(AzureOpenAI/AzureBlob/AzureStorageAccount/CognitiveSearch/CosmosDB/ApiKey/AppConfig/AppInsights/CustomKeys) (Required)
+     *     target: String (Required)
+     *     isDefault: boolean (Required)
+     *     credentials (Required): {
+     *         type: String(ApiKey/AAD/SAS/CustomKeys/None) (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The friendly name of the connection, provided by the user. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a connection by name, with its connection credentials along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithCredentialsWithResponse(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getWithCredentialsSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + name, accept, requestOptions, Context.NONE); + } + + /** + * List all connections in the project, without populating connection credentials. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
connectionTypeStringNoList connections of this specific type. Allowed values: + * "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", "AppConfig", + * "AppInsights", "CustomKeys".
defaultConnectionBooleanNoList connections that are default + * connections
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     id: String (Required)
+     *     type: String(AzureOpenAI/AzureBlob/AzureStorageAccount/CognitiveSearch/CosmosDB/ApiKey/AppConfig/AppInsights/CustomKeys) (Required)
+     *     target: String (Required)
+     *     isDefault: boolean (Required)
+     *     credentials (Required): {
+     *         type: String(ApiKey/AAD/SAS/CustomKeys/None) (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Connection items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.list(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List all connections in the project, without populating connection credentials. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
connectionTypeStringNoList connections of this specific type. Allowed values: + * "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", "AppConfig", + * "AppInsights", "CustomKeys".
defaultConnectionBooleanNoList connections that are default + * connections
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     id: String (Required)
+     *     type: String(AzureOpenAI/AzureBlob/AzureStorageAccount/CognitiveSearch/CosmosDB/ApiKey/AppConfig/AppInsights/CustomKeys) (Required)
+     *     target: String (Required)
+     *     isDefault: boolean (Required)
+     *     credentials (Required): {
+     *         type: String(ApiKey/AAD/SAS/CustomKeys/None) (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Connection items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>(() -> listSinglePageAsync(requestOptions), + nextLink -> listNextSinglePageAsync(nextLink, requestOptionsForNextPage)); + } + + /** + * List all connections in the project, without populating connection credentials. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
connectionTypeStringNoList connections of this specific type. Allowed values: + * "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", "AppConfig", + * "AppInsights", "CustomKeys".
defaultConnectionBooleanNoList connections that are default + * connections
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     id: String (Required)
+     *     type: String(AzureOpenAI/AzureBlob/AzureStorageAccount/CognitiveSearch/CosmosDB/ApiKey/AppConfig/AppInsights/CustomKeys) (Required)
+     *     target: String (Required)
+     *     isDefault: boolean (Required)
+     *     credentials (Required): {
+     *         type: String(ApiKey/AAD/SAS/CustomKeys/None) (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Connection items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSinglePage(RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listSync(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * List all connections in the project, without populating connection credentials. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
connectionTypeStringNoList connections of this specific type. Allowed values: + * "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", "AppConfig", + * "AppInsights", "CustomKeys".
defaultConnectionBooleanNoList connections that are default + * connections
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     id: String (Required)
+     *     type: String(AzureOpenAI/AzureBlob/AzureStorageAccount/CognitiveSearch/CosmosDB/ApiKey/AppConfig/AppInsights/CustomKeys) (Required)
+     *     target: String (Required)
+     *     isDefault: boolean (Required)
+     *     credentials (Required): {
+     *         type: String(ApiKey/AAD/SAS/CustomKeys/None) (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Connection items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>(() -> listSinglePage(requestOptions), + nextLink -> listNextSinglePage(nextLink, requestOptionsForNextPage)); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     id: String (Required)
+     *     type: String(AzureOpenAI/AzureBlob/AzureStorageAccount/CognitiveSearch/CosmosDB/ApiKey/AppConfig/AppInsights/CustomKeys) (Required)
+     *     target: String (Required)
+     *     isDefault: boolean (Required)
+     *     credentials (Required): {
+     *         type: String(ApiKey/AAD/SAS/CustomKeys/None) (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Connection items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listNext(nextLink, this.client.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     id: String (Required)
+     *     type: String(AzureOpenAI/AzureBlob/AzureStorageAccount/CognitiveSearch/CosmosDB/ApiKey/AppConfig/AppInsights/CustomKeys) (Required)
+     *     target: String (Required)
+     *     isDefault: boolean (Required)
+     *     credentials (Required): {
+     *         type: String(ApiKey/AAD/SAS/CustomKeys/None) (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Connection items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res + = service.listNextSync(nextLink, this.client.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + private List getValues(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + List values = (List) obj.get(path); + return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); + } catch (RuntimeException e) { + return null; + } + } + + private String getNextLink(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + return (String) obj.get(path); + } catch (RuntimeException e) { + return null; + } + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/DatasetsImpl.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/DatasetsImpl.java new file mode 100644 index 000000000000..3853bc250c25 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/DatasetsImpl.java @@ -0,0 +1,1185 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.implementation; + +import com.azure.ai.projects.ProjectsServiceVersion; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Datasets. + */ +public final class DatasetsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DatasetsService service; + + /** + * The service client containing this operation class. + */ + private final AIProjectClientImpl client; + + /** + * Initializes an instance of DatasetsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DatasetsImpl(AIProjectClientImpl client) { + this.service = RestProxy.create(DatasetsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public ProjectsServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for AIProjectClientDatasets to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AIProjectClientDatas") + public interface DatasetsService { + @Get("/datasets/{name}/versions") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listVersions(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/datasets/{name}/versions") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listVersionsSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/datasets") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> list(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/datasets") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/datasets/{name}/versions/{version}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @PathParam("version") String version, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("/datasets/{name}/versions/{version}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @PathParam("version") String version, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Delete("/datasets/{name}/versions/{version}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @PathParam("version") String version, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Delete("/datasets/{name}/versions/{version}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, + @PathParam("name") String name, @PathParam("version") String version, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Patch("/datasets/{name}/versions/{version}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Content-Type") String contentType, @PathParam("version") String version, + @HeaderParam("Accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Patch("/datasets/{name}/versions/{version}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createOrUpdateSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Content-Type") String contentType, @PathParam("version") String version, + @HeaderParam("Accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/datasets/{name}/versions/{version}/startPendingUpload") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> pendingUpload(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @PathParam("version") String version, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/datasets/{name}/versions/{version}/startPendingUpload") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response pendingUploadSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @PathParam("version") String version, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/datasets/{name}/versions/{version}/credentials") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getCredentials(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @PathParam("version") String version, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Post("/datasets/{name}/versions/{version}/credentials") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getCredentialsSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @PathParam("version") String version, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listVersionsNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listVersionsNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + } + + /** + * List all versions of the given DatasetVersion. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DatasetVersion items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listVersionsSinglePageAsync(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listVersions(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), name, accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List all versions of the given DatasetVersion. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DatasetVersion items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listVersionsAsync(String name, RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>(() -> listVersionsSinglePageAsync(name, requestOptions), + nextLink -> listVersionsNextSinglePageAsync(nextLink, requestOptionsForNextPage)); + } + + /** + * List all versions of the given DatasetVersion. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DatasetVersion items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listVersionsSinglePage(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listVersionsSync(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), name, accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * List all versions of the given DatasetVersion. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DatasetVersion items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listVersions(String name, RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>(() -> listVersionsSinglePage(name, requestOptions), + nextLink -> listVersionsNextSinglePage(nextLink, requestOptionsForNextPage)); + } + + /** + * List the latest version of each DatasetVersion. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DatasetVersion items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.list(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List the latest version of each DatasetVersion. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DatasetVersion items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>(() -> listSinglePageAsync(requestOptions), + nextLink -> listNextSinglePageAsync(nextLink, requestOptionsForNextPage)); + } + + /** + * List the latest version of each DatasetVersion. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DatasetVersion items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSinglePage(RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listSync(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * List the latest version of each DatasetVersion. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DatasetVersion items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>(() -> listSinglePage(requestOptions), + nextLink -> listNextSinglePage(nextLink, requestOptionsForNextPage)); + } + + /** + * Get the specific version of the DatasetVersion. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param version The specific version id of the DatasetVersion to retrieve. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the specific version of the DatasetVersion along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(String name, String version, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), name, version, accept, requestOptions, context)); + } + + /** + * Get the specific version of the DatasetVersion. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param version The specific version id of the DatasetVersion to retrieve. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the specific version of the DatasetVersion along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String name, String version, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), name, version, + accept, requestOptions, Context.NONE); + } + + /** + * Delete the specific version of the DatasetVersion. + * + * @param name The name of the resource. + * @param version The version of the DatasetVersion to delete. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteWithResponseAsync(String name, String version, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.delete(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), name, version, accept, requestOptions, context)); + } + + /** + * Delete the specific version of the DatasetVersion. + * + * @param name The name of the resource. + * @param version The version of the DatasetVersion to delete. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse(String name, String version, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.deleteSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), name, + version, accept, requestOptions, Context.NONE); + } + + /** + * Create a new or update an existing DatasetVersion with the given version id. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param version The specific version id of the DatasetVersion to create or replace. + * @param body The definition of the DatasetVersion to create or update. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return datasetVersion Definition along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createOrUpdateWithResponseAsync(String name, String version, BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + name, contentType, version, accept, body, requestOptions, context)); + } + + /** + * Create a new or update an existing DatasetVersion with the given version id. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param version The specific version id of the DatasetVersion to create or replace. + * @param body The definition of the DatasetVersion to create or update. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return datasetVersion Definition along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateWithResponse(String name, String version, BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + return service.createOrUpdateSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), name, + contentType, version, accept, body, requestOptions, Context.NONE); + } + + /** + * Start a new or get an existing pending upload of a dataset for a specific version. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     pendingUploadId: String (Optional)
+     *     connectionName: String (Optional)
+     *     pendingUploadType: String(None/BlobReference) (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     blobReference (Required): {
+     *         blobUri: String (Required)
+     *         storageAccountArmId: String (Required)
+     *         credential (Required): {
+     *             sasUri: String (Required)
+     *             type: String (Required)
+     *         }
+     *     }
+     *     pendingUploadId: String (Required)
+     *     version: String (Optional)
+     *     pendingUploadType: String(None/BlobReference) (Required)
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param version The specific version id of the DatasetVersion to operate on. + * @param body Parameters for the action. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents the response for a pending upload request along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> pendingUploadWithResponseAsync(String name, String version, BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.pendingUpload(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + name, version, contentType, accept, body, requestOptions, context)); + } + + /** + * Start a new or get an existing pending upload of a dataset for a specific version. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     pendingUploadId: String (Optional)
+     *     connectionName: String (Optional)
+     *     pendingUploadType: String(None/BlobReference) (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     blobReference (Required): {
+     *         blobUri: String (Required)
+     *         storageAccountArmId: String (Required)
+     *         credential (Required): {
+     *             sasUri: String (Required)
+     *             type: String (Required)
+     *         }
+     *     }
+     *     pendingUploadId: String (Required)
+     *     version: String (Optional)
+     *     pendingUploadType: String(None/BlobReference) (Required)
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param version The specific version id of the DatasetVersion to operate on. + * @param body Parameters for the action. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents the response for a pending upload request along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response pendingUploadWithResponse(String name, String version, BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.pendingUploadSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), name, + version, contentType, accept, body, requestOptions, Context.NONE); + } + + /** + * Get the SAS credential to access the storage account associated with a Dataset version. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     blobReference (Required): {
+     *         blobUri: String (Required)
+     *         storageAccountArmId: String (Required)
+     *         credential (Required): {
+     *             sasUri: String (Required)
+     *             type: String (Required)
+     *         }
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param version The specific version id of the DatasetVersion to operate on. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the SAS credential to access the storage account associated with a Dataset version along with + * {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getCredentialsWithResponseAsync(String name, String version, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getCredentials(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), name, version, accept, requestOptions, context)); + } + + /** + * Get the SAS credential to access the storage account associated with a Dataset version. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     blobReference (Required): {
+     *         blobUri: String (Required)
+     *         storageAccountArmId: String (Required)
+     *         credential (Required): {
+     *             sasUri: String (Required)
+     *             type: String (Required)
+     *         }
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param version The specific version id of the DatasetVersion to operate on. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the SAS credential to access the storage account associated with a Dataset version along with + * {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getCredentialsWithResponse(String name, String version, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getCredentialsSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), name, + version, accept, requestOptions, Context.NONE); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DatasetVersion items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listVersionsNextSinglePageAsync(String nextLink, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.listVersionsNext(nextLink, this.client.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DatasetVersion items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listVersionsNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res + = service.listVersionsNextSync(nextLink, this.client.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DatasetVersion items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listNext(nextLink, this.client.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Optional, Required on create)
+     *     isReference: Boolean (Optional)
+     *     connectionName: String (Optional)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DatasetVersion items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res + = service.listNextSync(nextLink, this.client.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + private List getValues(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + List values = (List) obj.get(path); + return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); + } catch (RuntimeException e) { + return null; + } + } + + private String getNextLink(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + return (String) obj.get(path); + } catch (RuntimeException e) { + return null; + } + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/DeploymentsImpl.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/DeploymentsImpl.java new file mode 100644 index 000000000000..badc66d49a4c --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/DeploymentsImpl.java @@ -0,0 +1,438 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.implementation; + +import com.azure.ai.projects.ProjectsServiceVersion; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Deployments. + */ +public final class DeploymentsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DeploymentsService service; + + /** + * The service client containing this operation class. + */ + private final AIProjectClientImpl client; + + /** + * Initializes an instance of DeploymentsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DeploymentsImpl(AIProjectClientImpl client) { + this.service + = RestProxy.create(DeploymentsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public ProjectsServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for AIProjectClientDeployments to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AIProjectClientDeplo") + public interface DeploymentsService { + @Get("/deployments/{name}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/deployments/{name}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/deployments") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> list(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/deployments") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + } + + /** + * Get a deployed model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(ModelDeployment) (Required)
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param name Name of the deployment. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a deployed model along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), name, accept, requestOptions, context)); + } + + /** + * Get a deployed model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(ModelDeployment) (Required)
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param name Name of the deployment. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a deployed model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), name, accept, + requestOptions, Context.NONE); + } + + /** + * List all deployed models in the project. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
modelPublisherStringNoModel publisher to filter models by
modelNameStringNoModel name (the publisher specific name) to filter models + * by
deploymentTypeStringNoType of deployment to filter list by. Allowed values: + * "ModelDeployment".
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(ModelDeployment) (Required)
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Deployment items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.list(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List all deployed models in the project. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
modelPublisherStringNoModel publisher to filter models by
modelNameStringNoModel name (the publisher specific name) to filter models + * by
deploymentTypeStringNoType of deployment to filter list by. Allowed values: + * "ModelDeployment".
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(ModelDeployment) (Required)
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Deployment items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>(() -> listSinglePageAsync(requestOptions), + nextLink -> listNextSinglePageAsync(nextLink, requestOptionsForNextPage)); + } + + /** + * List all deployed models in the project. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
modelPublisherStringNoModel publisher to filter models by
modelNameStringNoModel name (the publisher specific name) to filter models + * by
deploymentTypeStringNoType of deployment to filter list by. Allowed values: + * "ModelDeployment".
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(ModelDeployment) (Required)
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Deployment items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSinglePage(RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listSync(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * List all deployed models in the project. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
modelPublisherStringNoModel publisher to filter models by
modelNameStringNoModel name (the publisher specific name) to filter models + * by
deploymentTypeStringNoType of deployment to filter list by. Allowed values: + * "ModelDeployment".
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(ModelDeployment) (Required)
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Deployment items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>(() -> listSinglePage(requestOptions), + nextLink -> listNextSinglePage(nextLink, requestOptionsForNextPage)); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(ModelDeployment) (Required)
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Deployment items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listNext(nextLink, this.client.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(ModelDeployment) (Required)
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Deployment items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res + = service.listNextSync(nextLink, this.client.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + private List getValues(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + List values = (List) obj.get(path); + return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); + } catch (RuntimeException e) { + return null; + } + } + + private String getNextLink(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + return (String) obj.get(path); + } catch (RuntimeException e) { + return null; + } + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/IndexesImpl.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/IndexesImpl.java new file mode 100644 index 000000000000..f316c3ec8646 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/IndexesImpl.java @@ -0,0 +1,902 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.implementation; + +import com.azure.ai.projects.ProjectsServiceVersion; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Indexes. + */ +public final class IndexesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IndexesService service; + + /** + * The service client containing this operation class. + */ + private final AIProjectClientImpl client; + + /** + * Initializes an instance of IndexesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + IndexesImpl(AIProjectClientImpl client) { + this.service = RestProxy.create(IndexesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public ProjectsServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for AIProjectClientIndexes to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AIProjectClientIndex") + public interface IndexesService { + @Get("/indexes/{name}/versions") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listVersions(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/indexes/{name}/versions") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listVersionsSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/indexes") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> list(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/indexes") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/indexes/{name}/versions/{version}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @PathParam("version") String version, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("/indexes/{name}/versions/{version}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @PathParam("version") String version, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Delete("/indexes/{name}/versions/{version}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @PathParam("version") String version, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Delete("/indexes/{name}/versions/{version}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, + @PathParam("name") String name, @PathParam("version") String version, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Patch("/indexes/{name}/versions/{version}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Content-Type") String contentType, @PathParam("version") String version, + @HeaderParam("Accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Patch("/indexes/{name}/versions/{version}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createOrUpdateSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Content-Type") String contentType, @PathParam("version") String version, + @HeaderParam("Accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listVersionsNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listVersionsNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + } + + /** + * List all versions of the given Index. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Index items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listVersionsSinglePageAsync(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listVersions(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), name, accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List all versions of the given Index. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Index items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listVersionsAsync(String name, RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>(() -> listVersionsSinglePageAsync(name, requestOptions), + nextLink -> listVersionsNextSinglePageAsync(nextLink, requestOptionsForNextPage)); + } + + /** + * List all versions of the given Index. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Index items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listVersionsSinglePage(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listVersionsSync(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), name, accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * List all versions of the given Index. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Index items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listVersions(String name, RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>(() -> listVersionsSinglePage(name, requestOptions), + nextLink -> listVersionsNextSinglePage(nextLink, requestOptionsForNextPage)); + } + + /** + * List the latest version of each Index. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Index items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.list(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List the latest version of each Index. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Index items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>(() -> listSinglePageAsync(requestOptions), + nextLink -> listNextSinglePageAsync(nextLink, requestOptionsForNextPage)); + } + + /** + * List the latest version of each Index. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Index items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSinglePage(RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listSync(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * List the latest version of each Index. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Index items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>(() -> listSinglePage(requestOptions), + nextLink -> listNextSinglePage(nextLink, requestOptionsForNextPage)); + } + + /** + * Get the specific version of the Index. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param version The specific version id of the Index to retrieve. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the specific version of the Index along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(String name, String version, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), name, version, accept, requestOptions, context)); + } + + /** + * Get the specific version of the Index. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param version The specific version id of the Index to retrieve. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the specific version of the Index along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String name, String version, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), name, version, + accept, requestOptions, Context.NONE); + } + + /** + * Delete the specific version of the Index. + * + * @param name The name of the resource. + * @param version The version of the Index to delete. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteWithResponseAsync(String name, String version, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.delete(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), name, version, accept, requestOptions, context)); + } + + /** + * Delete the specific version of the Index. + * + * @param name The name of the resource. + * @param version The version of the Index to delete. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse(String name, String version, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.deleteSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), name, + version, accept, requestOptions, Context.NONE); + } + + /** + * Create a new or update an existing Index with the given version id. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param version The specific version id of the Index to create or replace. + * @param body The definition of the Index to create or update. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return index resource Definition along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createOrUpdateWithResponseAsync(String name, String version, BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + name, contentType, version, accept, body, requestOptions, context)); + } + + /** + * Create a new or update an existing Index with the given version id. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param name The name of the resource. + * @param version The specific version id of the Index to create or replace. + * @param body The definition of the Index to create or update. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return index resource Definition along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateWithResponse(String name, String version, BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + return service.createOrUpdateSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), name, + contentType, version, accept, body, requestOptions, Context.NONE); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Index items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listVersionsNextSinglePageAsync(String nextLink, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.listVersionsNext(nextLink, this.client.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Index items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listVersionsNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res + = service.listVersionsNextSync(nextLink, this.client.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Index items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listNext(nextLink, this.client.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(AzureSearch/CosmosDBNoSqlVectorStore/ManagedAzureSearch) (Required)
+     *     id: String (Optional)
+     *     name: String (Required)
+     *     version: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of Index items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res + = service.listNextSync(nextLink, this.client.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + private List getValues(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + List values = (List) obj.get(path); + return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); + } catch (RuntimeException e) { + return null; + } + } + + private String getNextLink(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + return (String) obj.get(path); + } catch (RuntimeException e) { + return null; + } + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/JsonMergePatchHelper.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/JsonMergePatchHelper.java new file mode 100644 index 000000000000..88f126cae67a --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/JsonMergePatchHelper.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.implementation; + +import com.azure.ai.projects.models.DatasetVersion; +import com.azure.ai.projects.models.EmbeddingConfiguration; +import com.azure.ai.projects.models.FieldMapping; +import com.azure.ai.projects.models.Index; +import java.util.Map; + +/** + * This is the Helper class to enable json merge patch serialization for a model. + */ +public class JsonMergePatchHelper { + private static DatasetVersionAccessor datasetVersionAccessor; + + public interface DatasetVersionAccessor { + DatasetVersion prepareModelForJsonMergePatch(DatasetVersion datasetVersion, boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(DatasetVersion datasetVersion); + + void setDataUri(DatasetVersion datasetVersion, String dataUri); + + void setIsReference(DatasetVersion datasetVersion, Boolean isReference); + + void setConnectionName(DatasetVersion datasetVersion, String connectionName); + + void setId(DatasetVersion datasetVersion, String id); + + void setName(DatasetVersion datasetVersion, String name); + + void setVersion(DatasetVersion datasetVersion, String version); + + void setDescription(DatasetVersion datasetVersion, String description); + + void setTags(DatasetVersion datasetVersion, Map tags); + } + + public static void setDatasetVersionAccessor(DatasetVersionAccessor accessor) { + datasetVersionAccessor = accessor; + } + + public static DatasetVersionAccessor getDatasetVersionAccessor() { + return datasetVersionAccessor; + } + + private static IndexAccessor indexAccessor; + + public interface IndexAccessor { + Index prepareModelForJsonMergePatch(Index index, boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(Index index); + + void setId(Index index, String id); + + void setName(Index index, String name); + + void setVersion(Index index, String version); + + void setDescription(Index index, String description); + + void setTags(Index index, Map tags); + } + + public static void setIndexAccessor(IndexAccessor accessor) { + indexAccessor = accessor; + } + + public static IndexAccessor getIndexAccessor() { + return indexAccessor; + } + + private static FieldMappingAccessor fieldMappingAccessor; + + public interface FieldMappingAccessor { + FieldMapping prepareModelForJsonMergePatch(FieldMapping fieldMapping, boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(FieldMapping fieldMapping); + } + + public static void setFieldMappingAccessor(FieldMappingAccessor accessor) { + fieldMappingAccessor = accessor; + } + + public static FieldMappingAccessor getFieldMappingAccessor() { + return fieldMappingAccessor; + } + + private static EmbeddingConfigurationAccessor embeddingConfigurationAccessor; + + public interface EmbeddingConfigurationAccessor { + EmbeddingConfiguration prepareModelForJsonMergePatch(EmbeddingConfiguration embeddingConfiguration, + boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(EmbeddingConfiguration embeddingConfiguration); + } + + public static void setEmbeddingConfigurationAccessor(EmbeddingConfigurationAccessor accessor) { + embeddingConfigurationAccessor = accessor; + } + + public static EmbeddingConfigurationAccessor getEmbeddingConfigurationAccessor() { + return embeddingConfigurationAccessor; + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/package-info.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/package-info.java new file mode 100644 index 000000000000..36864a6e4a83 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/package-info.java @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * + * Package containing the implementations for Projects. + * + */ +package com.azure.ai.projects.implementation; diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/ApiKeyCredentials.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/ApiKeyCredentials.java new file mode 100644 index 000000000000..e05c99f22e74 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/ApiKeyCredentials.java @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * API Key Credential definition. + */ +@Immutable +public final class ApiKeyCredentials extends BaseCredentials { + /* + * The type of credential used by the connection + */ + @Generated + private CredentialType type = CredentialType.API_KEY; + + /* + * API Key + */ + @Generated + private String apiKey; + + /** + * Creates an instance of ApiKeyCredentials class. + */ + @Generated + private ApiKeyCredentials() { + } + + /** + * Get the type property: The type of credential used by the connection. + * + * @return the type value. + */ + @Generated + @Override + public CredentialType getType() { + return this.type; + } + + /** + * Get the apiKey property: API Key. + * + * @return the apiKey value. + */ + @Generated + public String getApiKey() { + return this.apiKey; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ApiKeyCredentials from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ApiKeyCredentials if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the ApiKeyCredentials. + */ + @Generated + public static ApiKeyCredentials fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ApiKeyCredentials deserializedApiKeyCredentials = new ApiKeyCredentials(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedApiKeyCredentials.type = CredentialType.fromString(reader.getString()); + } else if ("key".equals(fieldName)) { + deserializedApiKeyCredentials.apiKey = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedApiKeyCredentials; + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/AssetCredentialResponse.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/AssetCredentialResponse.java new file mode 100644 index 000000000000..3e790c0318bb --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/AssetCredentialResponse.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents a reference to a blob for consumption. + */ +@Immutable +public final class AssetCredentialResponse implements JsonSerializable { + /* + * Credential info to access the storage account. + */ + @Generated + private final BlobReference blobReference; + + /** + * Creates an instance of AssetCredentialResponse class. + * + * @param blobReference the blobReference value to set. + */ + @Generated + private AssetCredentialResponse(BlobReference blobReference) { + this.blobReference = blobReference; + } + + /** + * Get the blobReference property: Credential info to access the storage account. + * + * @return the blobReference value. + */ + @Generated + public BlobReference getBlobReference() { + return this.blobReference; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("blobReference", this.blobReference); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AssetCredentialResponse from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AssetCredentialResponse if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the AssetCredentialResponse. + */ + @Generated + public static AssetCredentialResponse fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BlobReference blobReference = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("blobReference".equals(fieldName)) { + blobReference = BlobReference.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new AssetCredentialResponse(blobReference); + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/AzureAISearchIndex.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/AzureAISearchIndex.java new file mode 100644 index 000000000000..4ccc1420f355 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/AzureAISearchIndex.java @@ -0,0 +1,280 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.ai.projects.implementation.JsonMergePatchHelper; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * Azure AI Search Index Definition. + */ +@Fluent +public final class AzureAISearchIndex extends Index { + /* + * Type of index + */ + @Generated + private IndexType type = IndexType.AZURE_SEARCH; + + /* + * Name of connection to Azure AI Search + */ + @Generated + private String connectionName; + + /* + * Name of index in Azure AI Search resource to attach + */ + @Generated + private String indexName; + + /* + * Field mapping configuration + */ + @Generated + private FieldMapping fieldMapping; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + /** + * Creates an instance of AzureAISearchIndex class. + */ + @Generated + public AzureAISearchIndex() { + } + + /** + * Get the type property: Type of index. + * + * @return the type value. + */ + @Generated + @Override + public IndexType getType() { + return this.type; + } + + /** + * Get the connectionName property: Name of connection to Azure AI Search. + * + * @return the connectionName value. + */ + @Generated + public String getConnectionName() { + return this.connectionName; + } + + /** + * Set the connectionName property: Name of connection to Azure AI Search. + *

Required when create the resource.

+ * + * @param connectionName the connectionName value to set. + * @return the AzureAISearchIndex object itself. + */ + @Generated + public AzureAISearchIndex setConnectionName(String connectionName) { + this.connectionName = connectionName; + this.updatedProperties.add("connectionName"); + return this; + } + + /** + * Get the indexName property: Name of index in Azure AI Search resource to attach. + * + * @return the indexName value. + */ + @Generated + public String getIndexName() { + return this.indexName; + } + + /** + * Set the indexName property: Name of index in Azure AI Search resource to attach. + *

Required when create the resource.

+ * + * @param indexName the indexName value to set. + * @return the AzureAISearchIndex object itself. + */ + @Generated + public AzureAISearchIndex setIndexName(String indexName) { + this.indexName = indexName; + this.updatedProperties.add("indexName"); + return this; + } + + /** + * Get the fieldMapping property: Field mapping configuration. + * + * @return the fieldMapping value. + */ + @Generated + public FieldMapping getFieldMapping() { + return this.fieldMapping; + } + + /** + * Set the fieldMapping property: Field mapping configuration. + * + * @param fieldMapping the fieldMapping value to set. + * @return the AzureAISearchIndex object itself. + */ + @Generated + public AzureAISearchIndex setFieldMapping(FieldMapping fieldMapping) { + this.fieldMapping = fieldMapping; + this.updatedProperties.add("fieldMapping"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public AzureAISearchIndex setDescription(String description) { + super.setDescription(description); + this.updatedProperties.add("description"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public AzureAISearchIndex setTags(Map tags) { + super.setTags(tags); + this.updatedProperties.add("tags"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (JsonMergePatchHelper.getIndexAccessor().isJsonMergePatch(this)) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("description", getDescription()); + jsonWriter.writeMapField("tags", getTags(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeStringField("connectionName", this.connectionName); + jsonWriter.writeStringField("indexName", this.indexName); + jsonWriter.writeJsonField("fieldMapping", this.fieldMapping); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("description")) { + if (getDescription() == null) { + jsonWriter.writeNullField("description"); + } else { + jsonWriter.writeStringField("description", getDescription()); + } + } + if (updatedProperties.contains("tags")) { + if (getTags() == null) { + jsonWriter.writeNullField("tags"); + } else { + jsonWriter.writeMapField("tags", getTags(), (writer, element) -> { + if (element != null) { + writer.writeString(element); + } else { + writer.writeNull(); + } + }); + } + } + jsonWriter.writeStringField("type", this.type.toString()); + if (updatedProperties.contains("connectionName")) { + if (this.connectionName == null) { + jsonWriter.writeNullField("connectionName"); + } else { + jsonWriter.writeStringField("connectionName", this.connectionName); + } + } + if (updatedProperties.contains("indexName")) { + if (this.indexName == null) { + jsonWriter.writeNullField("indexName"); + } else { + jsonWriter.writeStringField("indexName", this.indexName); + } + } + if (updatedProperties.contains("fieldMapping")) { + if (this.fieldMapping == null) { + jsonWriter.writeNullField("fieldMapping"); + } else { + JsonMergePatchHelper.getFieldMappingAccessor().prepareModelForJsonMergePatch(this.fieldMapping, true); + jsonWriter.writeJsonField("fieldMapping", this.fieldMapping); + JsonMergePatchHelper.getFieldMappingAccessor().prepareModelForJsonMergePatch(this.fieldMapping, false); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AzureAISearchIndex from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AzureAISearchIndex if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the AzureAISearchIndex. + */ + @Generated + public static AzureAISearchIndex fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AzureAISearchIndex deserializedAzureAISearchIndex = new AzureAISearchIndex(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + JsonMergePatchHelper.getIndexAccessor().setName(deserializedAzureAISearchIndex, reader.getString()); + } else if ("version".equals(fieldName)) { + JsonMergePatchHelper.getIndexAccessor() + .setVersion(deserializedAzureAISearchIndex, reader.getString()); + } else if ("id".equals(fieldName)) { + JsonMergePatchHelper.getIndexAccessor().setId(deserializedAzureAISearchIndex, reader.getString()); + } else if ("description".equals(fieldName)) { + JsonMergePatchHelper.getIndexAccessor() + .setDescription(deserializedAzureAISearchIndex, reader.getString()); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + JsonMergePatchHelper.getIndexAccessor().setTags(deserializedAzureAISearchIndex, tags); + } else if ("type".equals(fieldName)) { + deserializedAzureAISearchIndex.type = IndexType.fromString(reader.getString()); + } else if ("connectionName".equals(fieldName)) { + deserializedAzureAISearchIndex.connectionName = reader.getString(); + } else if ("indexName".equals(fieldName)) { + deserializedAzureAISearchIndex.indexName = reader.getString(); + } else if ("fieldMapping".equals(fieldName)) { + deserializedAzureAISearchIndex.fieldMapping = FieldMapping.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedAzureAISearchIndex; + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/BaseCredentials.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/BaseCredentials.java new file mode 100644 index 000000000000..e4aa5cec4921 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/BaseCredentials.java @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A base class for connection credentials. + */ +@Immutable +public class BaseCredentials implements JsonSerializable { + /* + * The type of credential used by the connection + */ + @Generated + private CredentialType type = CredentialType.fromString("BaseCredentials"); + + /** + * Creates an instance of BaseCredentials class. + */ + @Generated + protected BaseCredentials() { + } + + /** + * Get the type property: The type of credential used by the connection. + * + * @return the type value. + */ + @Generated + public CredentialType getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BaseCredentials from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BaseCredentials if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the BaseCredentials. + */ + @Generated + public static BaseCredentials fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("type".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("ApiKey".equals(discriminatorValue)) { + return ApiKeyCredentials.fromJson(readerToUse.reset()); + } else if ("AAD".equals(discriminatorValue)) { + return EntraIDCredentials.fromJson(readerToUse.reset()); + } else if ("CustomKeys".equals(discriminatorValue)) { + return CustomCredential.fromJson(readerToUse.reset()); + } else if ("SAS".equals(discriminatorValue)) { + return SASCredentials.fromJson(readerToUse.reset()); + } else if ("None".equals(discriminatorValue)) { + return NoAuthenticationCredentials.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static BaseCredentials fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BaseCredentials deserializedBaseCredentials = new BaseCredentials(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedBaseCredentials.type = CredentialType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedBaseCredentials; + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/BlobReference.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/BlobReference.java new file mode 100644 index 000000000000..fca46cf4461a --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/BlobReference.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Blob reference details. + */ +@Immutable +public final class BlobReference implements JsonSerializable { + /* + * Blob URI path for client to upload data. Example: https://blob.windows.core.net/Container/Path + */ + @Generated + private final String blobUri; + + /* + * ARM ID of the storage account to use. + */ + @Generated + private final String storageAccountArmId; + + /* + * Credential info to access the storage account. + */ + @Generated + private final SasCredential credential; + + /** + * Creates an instance of BlobReference class. + * + * @param blobUri the blobUri value to set. + * @param storageAccountArmId the storageAccountArmId value to set. + * @param credential the credential value to set. + */ + @Generated + private BlobReference(String blobUri, String storageAccountArmId, SasCredential credential) { + this.blobUri = blobUri; + this.storageAccountArmId = storageAccountArmId; + this.credential = credential; + } + + /** + * Get the blobUri property: Blob URI path for client to upload data. Example: + * https://blob.windows.core.net/Container/Path. + * + * @return the blobUri value. + */ + @Generated + public String getBlobUri() { + return this.blobUri; + } + + /** + * Get the storageAccountArmId property: ARM ID of the storage account to use. + * + * @return the storageAccountArmId value. + */ + @Generated + public String getStorageAccountArmId() { + return this.storageAccountArmId; + } + + /** + * Get the credential property: Credential info to access the storage account. + * + * @return the credential value. + */ + @Generated + public SasCredential getCredential() { + return this.credential; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("blobUri", this.blobUri); + jsonWriter.writeStringField("storageAccountArmId", this.storageAccountArmId); + jsonWriter.writeJsonField("credential", this.credential); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BlobReference from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BlobReference if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the BlobReference. + */ + @Generated + public static BlobReference fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String blobUri = null; + String storageAccountArmId = null; + SasCredential credential = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("blobUri".equals(fieldName)) { + blobUri = reader.getString(); + } else if ("storageAccountArmId".equals(fieldName)) { + storageAccountArmId = reader.getString(); + } else if ("credential".equals(fieldName)) { + credential = SasCredential.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new BlobReference(blobUri, storageAccountArmId, credential); + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/Connection.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/Connection.java new file mode 100644 index 000000000000..5c746ede0fcd --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/Connection.java @@ -0,0 +1,190 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * Response from the list and get connections operations. + */ +@Immutable +public final class Connection implements JsonSerializable { + /* + * The friendly name of the connection, provided by the user. + */ + @Generated + private String name; + + /* + * A unique identifier for the connection, generated by the service + */ + @Generated + private String id; + + /* + * Category of the connection + */ + @Generated + private ConnectionType type; + + /* + * The connection URL to be used for this service + */ + @Generated + private String target; + + /* + * Whether the connection is tagged as the default connection of its type + */ + @Generated + private boolean isDefault; + + /* + * The credentials used by the connection + */ + @Generated + private BaseCredentials credentials; + + /* + * Metadata of the connection + */ + @Generated + private Map metadata; + + /** + * Creates an instance of Connection class. + */ + @Generated + private Connection() { + } + + /** + * Get the name property: The friendly name of the connection, provided by the user. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the id property: A unique identifier for the connection, generated by the service. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the type property: Category of the connection. + * + * @return the type value. + */ + @Generated + public ConnectionType getType() { + return this.type; + } + + /** + * Get the target property: The connection URL to be used for this service. + * + * @return the target value. + */ + @Generated + public String getTarget() { + return this.target; + } + + /** + * Get the isDefault property: Whether the connection is tagged as the default connection of its type. + * + * @return the isDefault value. + */ + @Generated + public boolean isDefault() { + return this.isDefault; + } + + /** + * Get the credentials property: The credentials used by the connection. + * + * @return the credentials value. + */ + @Generated + public BaseCredentials getCredentials() { + return this.credentials; + } + + /** + * Get the metadata property: Metadata of the connection. + * + * @return the metadata value. + */ + @Generated + public Map getMetadata() { + return this.metadata; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Connection from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Connection if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the Connection. + */ + @Generated + public static Connection fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Connection deserializedConnection = new Connection(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedConnection.name = reader.getString(); + } else if ("id".equals(fieldName)) { + deserializedConnection.id = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedConnection.type = ConnectionType.fromString(reader.getString()); + } else if ("target".equals(fieldName)) { + deserializedConnection.target = reader.getString(); + } else if ("isDefault".equals(fieldName)) { + deserializedConnection.isDefault = reader.getBoolean(); + } else if ("credentials".equals(fieldName)) { + deserializedConnection.credentials = BaseCredentials.fromJson(reader); + } else if ("metadata".equals(fieldName)) { + Map metadata = reader.readMap(reader1 -> reader1.getString()); + deserializedConnection.metadata = metadata; + } else { + reader.skipChildren(); + } + } + + return deserializedConnection; + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/ConnectionType.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/ConnectionType.java new file mode 100644 index 000000000000..be779369b14d --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/ConnectionType.java @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The Type (or category) of the connection. + */ +public final class ConnectionType extends ExpandableStringEnum { + /** + * Azure OpenAI Service. + */ + @Generated + public static final ConnectionType AZURE_OPEN_AI = fromString("AzureOpenAI"); + + /** + * Azure Blob Storage, with specified container. + */ + @Generated + public static final ConnectionType AZURE_BLOB_STORAGE = fromString("AzureBlob"); + + /** + * Azure Blob Storage, with container not specified (used by Agents). + */ + @Generated + public static final ConnectionType AZURE_STORAGE_ACCOUNT = fromString("AzureStorageAccount"); + + /** + * Azure AI Search. + */ + @Generated + public static final ConnectionType AZURE_AISEARCH = fromString("CognitiveSearch"); + + /** + * CosmosDB. + */ + @Generated + public static final ConnectionType COSMOS_DB = fromString("CosmosDB"); + + /** + * Generic connection that uses API Key authentication. + */ + @Generated + public static final ConnectionType APIKEY = fromString("ApiKey"); + + /** + * Application Configuration. + */ + @Generated + public static final ConnectionType APPLICATION_CONFIGURATION = fromString("AppConfig"); + + /** + * Application Insights. + */ + @Generated + public static final ConnectionType APPLICATION_INSIGHTS = fromString("AppInsights"); + + /** + * Custom Keys. + */ + @Generated + public static final ConnectionType CUSTOM = fromString("CustomKeys"); + + /** + * Creates a new instance of ConnectionType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public ConnectionType() { + } + + /** + * Creates or finds a ConnectionType from its string representation. + * + * @param name a name to look for. + * @return the corresponding ConnectionType. + */ + @Generated + public static ConnectionType fromString(String name) { + return fromString(name, ConnectionType.class); + } + + /** + * Gets known ConnectionType values. + * + * @return known ConnectionType values. + */ + @Generated + public static Collection values() { + return values(ConnectionType.class); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/CosmosDBIndex.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/CosmosDBIndex.java new file mode 100644 index 000000000000..1dc0fee26d74 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/CosmosDBIndex.java @@ -0,0 +1,364 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.ai.projects.implementation.JsonMergePatchHelper; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * CosmosDB Vector Store Index Definition. + */ +@Fluent +public final class CosmosDBIndex extends Index { + /* + * Type of index + */ + @Generated + private IndexType type = IndexType.COSMOS_DB; + + /* + * Name of connection to CosmosDB + */ + @Generated + private String connectionName; + + /* + * Name of the CosmosDB Database + */ + @Generated + private String databaseName; + + /* + * Name of CosmosDB Container + */ + @Generated + private String containerName; + + /* + * Embedding model configuration + */ + @Generated + private EmbeddingConfiguration embeddingConfiguration; + + /* + * Field mapping configuration + */ + @Generated + private FieldMapping fieldMapping; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + /** + * Creates an instance of CosmosDBIndex class. + */ + @Generated + public CosmosDBIndex() { + } + + /** + * Get the type property: Type of index. + * + * @return the type value. + */ + @Generated + @Override + public IndexType getType() { + return this.type; + } + + /** + * Get the connectionName property: Name of connection to CosmosDB. + * + * @return the connectionName value. + */ + @Generated + public String getConnectionName() { + return this.connectionName; + } + + /** + * Set the connectionName property: Name of connection to CosmosDB. + *

Required when create the resource.

+ * + * @param connectionName the connectionName value to set. + * @return the CosmosDBIndex object itself. + */ + @Generated + public CosmosDBIndex setConnectionName(String connectionName) { + this.connectionName = connectionName; + this.updatedProperties.add("connectionName"); + return this; + } + + /** + * Get the databaseName property: Name of the CosmosDB Database. + * + * @return the databaseName value. + */ + @Generated + public String getDatabaseName() { + return this.databaseName; + } + + /** + * Set the databaseName property: Name of the CosmosDB Database. + *

Required when create the resource.

+ * + * @param databaseName the databaseName value to set. + * @return the CosmosDBIndex object itself. + */ + @Generated + public CosmosDBIndex setDatabaseName(String databaseName) { + this.databaseName = databaseName; + this.updatedProperties.add("databaseName"); + return this; + } + + /** + * Get the containerName property: Name of CosmosDB Container. + * + * @return the containerName value. + */ + @Generated + public String getContainerName() { + return this.containerName; + } + + /** + * Set the containerName property: Name of CosmosDB Container. + *

Required when create the resource.

+ * + * @param containerName the containerName value to set. + * @return the CosmosDBIndex object itself. + */ + @Generated + public CosmosDBIndex setContainerName(String containerName) { + this.containerName = containerName; + this.updatedProperties.add("containerName"); + return this; + } + + /** + * Get the embeddingConfiguration property: Embedding model configuration. + * + * @return the embeddingConfiguration value. + */ + @Generated + public EmbeddingConfiguration getEmbeddingConfiguration() { + return this.embeddingConfiguration; + } + + /** + * Set the embeddingConfiguration property: Embedding model configuration. + *

Required when create the resource.

+ * + * @param embeddingConfiguration the embeddingConfiguration value to set. + * @return the CosmosDBIndex object itself. + */ + @Generated + public CosmosDBIndex setEmbeddingConfiguration(EmbeddingConfiguration embeddingConfiguration) { + this.embeddingConfiguration = embeddingConfiguration; + this.updatedProperties.add("embeddingConfiguration"); + return this; + } + + /** + * Get the fieldMapping property: Field mapping configuration. + * + * @return the fieldMapping value. + */ + @Generated + public FieldMapping getFieldMapping() { + return this.fieldMapping; + } + + /** + * Set the fieldMapping property: Field mapping configuration. + *

Required when create the resource.

+ * + * @param fieldMapping the fieldMapping value to set. + * @return the CosmosDBIndex object itself. + */ + @Generated + public CosmosDBIndex setFieldMapping(FieldMapping fieldMapping) { + this.fieldMapping = fieldMapping; + this.updatedProperties.add("fieldMapping"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public CosmosDBIndex setDescription(String description) { + super.setDescription(description); + this.updatedProperties.add("description"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public CosmosDBIndex setTags(Map tags) { + super.setTags(tags); + this.updatedProperties.add("tags"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (JsonMergePatchHelper.getIndexAccessor().isJsonMergePatch(this)) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("description", getDescription()); + jsonWriter.writeMapField("tags", getTags(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeStringField("connectionName", this.connectionName); + jsonWriter.writeStringField("databaseName", this.databaseName); + jsonWriter.writeStringField("containerName", this.containerName); + jsonWriter.writeJsonField("embeddingConfiguration", this.embeddingConfiguration); + jsonWriter.writeJsonField("fieldMapping", this.fieldMapping); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("description")) { + if (getDescription() == null) { + jsonWriter.writeNullField("description"); + } else { + jsonWriter.writeStringField("description", getDescription()); + } + } + if (updatedProperties.contains("tags")) { + if (getTags() == null) { + jsonWriter.writeNullField("tags"); + } else { + jsonWriter.writeMapField("tags", getTags(), (writer, element) -> { + if (element != null) { + writer.writeString(element); + } else { + writer.writeNull(); + } + }); + } + } + jsonWriter.writeStringField("type", this.type.toString()); + if (updatedProperties.contains("connectionName")) { + if (this.connectionName == null) { + jsonWriter.writeNullField("connectionName"); + } else { + jsonWriter.writeStringField("connectionName", this.connectionName); + } + } + if (updatedProperties.contains("databaseName")) { + if (this.databaseName == null) { + jsonWriter.writeNullField("databaseName"); + } else { + jsonWriter.writeStringField("databaseName", this.databaseName); + } + } + if (updatedProperties.contains("containerName")) { + if (this.containerName == null) { + jsonWriter.writeNullField("containerName"); + } else { + jsonWriter.writeStringField("containerName", this.containerName); + } + } + if (updatedProperties.contains("embeddingConfiguration")) { + if (this.embeddingConfiguration == null) { + jsonWriter.writeNullField("embeddingConfiguration"); + } else { + JsonMergePatchHelper.getEmbeddingConfigurationAccessor() + .prepareModelForJsonMergePatch(this.embeddingConfiguration, true); + jsonWriter.writeJsonField("embeddingConfiguration", this.embeddingConfiguration); + JsonMergePatchHelper.getEmbeddingConfigurationAccessor() + .prepareModelForJsonMergePatch(this.embeddingConfiguration, false); + } + } + if (updatedProperties.contains("fieldMapping")) { + if (this.fieldMapping == null) { + jsonWriter.writeNullField("fieldMapping"); + } else { + JsonMergePatchHelper.getFieldMappingAccessor().prepareModelForJsonMergePatch(this.fieldMapping, true); + jsonWriter.writeJsonField("fieldMapping", this.fieldMapping); + JsonMergePatchHelper.getFieldMappingAccessor().prepareModelForJsonMergePatch(this.fieldMapping, false); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CosmosDBIndex from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CosmosDBIndex if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the CosmosDBIndex. + */ + @Generated + public static CosmosDBIndex fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CosmosDBIndex deserializedCosmosDBIndex = new CosmosDBIndex(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + JsonMergePatchHelper.getIndexAccessor().setName(deserializedCosmosDBIndex, reader.getString()); + } else if ("version".equals(fieldName)) { + JsonMergePatchHelper.getIndexAccessor().setVersion(deserializedCosmosDBIndex, reader.getString()); + } else if ("id".equals(fieldName)) { + JsonMergePatchHelper.getIndexAccessor().setId(deserializedCosmosDBIndex, reader.getString()); + } else if ("description".equals(fieldName)) { + JsonMergePatchHelper.getIndexAccessor() + .setDescription(deserializedCosmosDBIndex, reader.getString()); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + JsonMergePatchHelper.getIndexAccessor().setTags(deserializedCosmosDBIndex, tags); + } else if ("type".equals(fieldName)) { + deserializedCosmosDBIndex.type = IndexType.fromString(reader.getString()); + } else if ("connectionName".equals(fieldName)) { + deserializedCosmosDBIndex.connectionName = reader.getString(); + } else if ("databaseName".equals(fieldName)) { + deserializedCosmosDBIndex.databaseName = reader.getString(); + } else if ("containerName".equals(fieldName)) { + deserializedCosmosDBIndex.containerName = reader.getString(); + } else if ("embeddingConfiguration".equals(fieldName)) { + deserializedCosmosDBIndex.embeddingConfiguration = EmbeddingConfiguration.fromJson(reader); + } else if ("fieldMapping".equals(fieldName)) { + deserializedCosmosDBIndex.fieldMapping = FieldMapping.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedCosmosDBIndex; + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/CredentialType.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/CredentialType.java new file mode 100644 index 000000000000..f820b255fff0 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/CredentialType.java @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The credential type used by the connection. + */ +public final class CredentialType extends ExpandableStringEnum { + /** + * API Key credential. + */ + @Generated + public static final CredentialType API_KEY = fromString("ApiKey"); + + /** + * Entra ID credential (formerly known as AAD). + */ + @Generated + public static final CredentialType ENTRA_ID = fromString("AAD"); + + /** + * Shared Access Signature (SAS) credential. + */ + @Generated + public static final CredentialType SAS = fromString("SAS"); + + /** + * Custom credential. + */ + @Generated + public static final CredentialType CUSTOM = fromString("CustomKeys"); + + /** + * No credential. + */ + @Generated + public static final CredentialType NONE = fromString("None"); + + /** + * Creates a new instance of CredentialType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public CredentialType() { + } + + /** + * Creates or finds a CredentialType from its string representation. + * + * @param name a name to look for. + * @return the corresponding CredentialType. + */ + @Generated + public static CredentialType fromString(String name) { + return fromString(name, CredentialType.class); + } + + /** + * Gets known CredentialType values. + * + * @return known CredentialType values. + */ + @Generated + public static Collection values() { + return values(CredentialType.class); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/CustomCredential.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/CustomCredential.java new file mode 100644 index 000000000000..d5d804c16e4a --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/CustomCredential.java @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * Custom credential definition. + */ +@Immutable +public final class CustomCredential extends BaseCredentials { + /* + * The type of credential used by the connection + */ + @Generated + private CredentialType type = CredentialType.CUSTOM; + + /* + * The credential type + */ + @Generated + private Map keys; + + /** + * Creates an instance of CustomCredential class. + */ + @Generated + private CustomCredential() { + } + + /** + * Get the type property: The type of credential used by the connection. + * + * @return the type value. + */ + @Generated + @Override + public CredentialType getType() { + return this.type; + } + + /** + * Get the keys property: The credential type. + * + * @return the keys value. + */ + @Generated + public Map getKeys() { + return this.keys; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CustomCredential from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CustomCredential if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the CustomCredential. + */ + @Generated + public static CustomCredential fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CustomCredential deserializedCustomCredential = new CustomCredential(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("keys".equals(fieldName)) { + Map keys = reader.readMap(reader1 -> reader1.getString()); + deserializedCustomCredential.keys = keys; + } else if ("type".equals(fieldName)) { + deserializedCustomCredential.type = CredentialType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedCustomCredential; + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/DatasetType.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/DatasetType.java new file mode 100644 index 000000000000..76d560268914 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/DatasetType.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Enum to determine the type of data. + */ +public final class DatasetType extends ExpandableStringEnum { + /** + * URI file. + */ + @Generated + public static final DatasetType URI_FILE = fromString("uri_file"); + + /** + * URI folder. + */ + @Generated + public static final DatasetType URI_FOLDER = fromString("uri_folder"); + + /** + * Creates a new instance of DatasetType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public DatasetType() { + } + + /** + * Creates or finds a DatasetType from its string representation. + * + * @param name a name to look for. + * @return the corresponding DatasetType. + */ + @Generated + public static DatasetType fromString(String name) { + return fromString(name, DatasetType.class); + } + + /** + * Gets known DatasetType values. + * + * @return known DatasetType values. + */ + @Generated + public static Collection values() { + return values(DatasetType.class); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/DatasetVersion.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/DatasetVersion.java new file mode 100644 index 000000000000..1bde442097aa --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/DatasetVersion.java @@ -0,0 +1,434 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.ai.projects.implementation.JsonMergePatchHelper; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * DatasetVersion Definition. + */ +@Fluent +public class DatasetVersion implements JsonSerializable { + /* + * Dataset type + */ + @Generated + private DatasetType type = DatasetType.fromString("DatasetVersion"); + + /* + * URI of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330 + */ + @Generated + private String dataUri; + + /* + * Indicates if the dataset holds a reference to the storage, or the dataset manages storage itself. If true, the + * underlying data will not be deleted when the dataset version is deleted + */ + @Generated + private Boolean isReference; + + /* + * The Azure Storage Account connection name. Required if startPendingUploadVersion was not called before creating + * the Dataset + */ + @Generated + private String connectionName; + + /* + * Asset ID, a unique identifier for the asset + */ + @Generated + private String id; + + /* + * The name of the resource + */ + @Generated + private String name; + + /* + * The version of the resource + */ + @Generated + private String version; + + /* + * The asset description text. + */ + @Generated + private String description; + + /* + * Tag dictionary. Tags can be added, removed, and updated. + */ + @Generated + private Map tags; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setDatasetVersionAccessor(new JsonMergePatchHelper.DatasetVersionAccessor() { + @Override + public DatasetVersion prepareModelForJsonMergePatch(DatasetVersion model, boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(DatasetVersion model) { + return model.jsonMergePatch; + } + + @Override + public void setDataUri(DatasetVersion model, String dataUri) { + model.dataUri = dataUri; + } + + @Override + public void setIsReference(DatasetVersion model, Boolean isReference) { + model.isReference = isReference; + } + + @Override + public void setConnectionName(DatasetVersion model, String connectionName) { + model.connectionName = connectionName; + } + + @Override + public void setId(DatasetVersion model, String id) { + model.id = id; + } + + @Override + public void setName(DatasetVersion model, String name) { + model.name = name; + } + + @Override + public void setVersion(DatasetVersion model, String version) { + model.version = version; + } + + @Override + public void setDescription(DatasetVersion model, String description) { + model.description = description; + } + + @Override + public void setTags(DatasetVersion model, Map tags) { + model.tags = tags; + } + }); + } + + /** + * Creates an instance of DatasetVersion class. + */ + @Generated + public DatasetVersion() { + } + + /** + * Get the type property: Dataset type. + * + * @return the type value. + */ + @Generated + public DatasetType getType() { + return this.type; + } + + /** + * Get the dataUri property: URI of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + * + * @return the dataUri value. + */ + @Generated + public String getDataUri() { + return this.dataUri; + } + + /** + * Set the dataUri property: URI of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + *

Required when create the resource.

+ * + * @param dataUri the dataUri value to set. + * @return the DatasetVersion object itself. + */ + @Generated + public DatasetVersion setDataUri(String dataUri) { + this.dataUri = dataUri; + this.updatedProperties.add("dataUri"); + return this; + } + + /** + * Get the isReference property: Indicates if the dataset holds a reference to the storage, or the dataset manages + * storage itself. If true, the underlying data will not be deleted when the dataset version is deleted. + * + * @return the isReference value. + */ + @Generated + public Boolean isReference() { + return this.isReference; + } + + /** + * Get the connectionName property: The Azure Storage Account connection name. Required if startPendingUploadVersion + * was not called before creating the Dataset. + * + * @return the connectionName value. + */ + @Generated + public String getConnectionName() { + return this.connectionName; + } + + /** + * Set the connectionName property: The Azure Storage Account connection name. Required if startPendingUploadVersion + * was not called before creating the Dataset. + * + * @param connectionName the connectionName value to set. + * @return the DatasetVersion object itself. + */ + @Generated + public DatasetVersion setConnectionName(String connectionName) { + this.connectionName = connectionName; + this.updatedProperties.add("connectionName"); + return this; + } + + /** + * Get the id property: Asset ID, a unique identifier for the asset. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the version property: The version of the resource. + * + * @return the version value. + */ + @Generated + public String getVersion() { + return this.version; + } + + /** + * Get the description property: The asset description text. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: The asset description text. + * + * @param description the description value to set. + * @return the DatasetVersion object itself. + */ + @Generated + public DatasetVersion setDescription(String description) { + this.description = description; + this.updatedProperties.add("description"); + return this; + } + + /** + * Get the tags property: Tag dictionary. Tags can be added, removed, and updated. + * + * @return the tags value. + */ + @Generated + public Map getTags() { + return this.tags; + } + + /** + * Set the tags property: Tag dictionary. Tags can be added, removed, and updated. + * + * @param tags the tags value to set. + * @return the DatasetVersion object itself. + */ + @Generated + public DatasetVersion setTags(Map tags) { + this.tags = tags; + this.updatedProperties.add("tags"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeStringField("dataUri", this.dataUri); + jsonWriter.writeStringField("connectionName", this.connectionName); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeMapField("tags", this.tags, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type.toString()); + if (updatedProperties.contains("dataUri")) { + if (this.dataUri == null) { + jsonWriter.writeNullField("dataUri"); + } else { + jsonWriter.writeStringField("dataUri", this.dataUri); + } + } + if (updatedProperties.contains("connectionName")) { + if (this.connectionName == null) { + jsonWriter.writeNullField("connectionName"); + } else { + jsonWriter.writeStringField("connectionName", this.connectionName); + } + } + if (updatedProperties.contains("description")) { + if (this.description == null) { + jsonWriter.writeNullField("description"); + } else { + jsonWriter.writeStringField("description", this.description); + } + } + if (updatedProperties.contains("tags")) { + if (this.tags == null) { + jsonWriter.writeNullField("tags"); + } else { + jsonWriter.writeMapField("tags", this.tags, (writer, element) -> { + if (element != null) { + writer.writeString(element); + } else { + writer.writeNull(); + } + }); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DatasetVersion from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DatasetVersion if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the DatasetVersion. + */ + @Generated + public static DatasetVersion fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("type".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("uri_file".equals(discriminatorValue)) { + return FileDatasetVersion.fromJson(readerToUse.reset()); + } else if ("uri_folder".equals(discriminatorValue)) { + return FolderDatasetVersion.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static DatasetVersion fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DatasetVersion deserializedDatasetVersion = new DatasetVersion(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedDatasetVersion.name = reader.getString(); + } else if ("version".equals(fieldName)) { + deserializedDatasetVersion.version = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedDatasetVersion.type = DatasetType.fromString(reader.getString()); + } else if ("dataUri".equals(fieldName)) { + deserializedDatasetVersion.dataUri = reader.getString(); + } else if ("isReference".equals(fieldName)) { + deserializedDatasetVersion.isReference = reader.getNullable(JsonReader::getBoolean); + } else if ("connectionName".equals(fieldName)) { + deserializedDatasetVersion.connectionName = reader.getString(); + } else if ("id".equals(fieldName)) { + deserializedDatasetVersion.id = reader.getString(); + } else if ("description".equals(fieldName)) { + deserializedDatasetVersion.description = reader.getString(); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedDatasetVersion.tags = tags; + } else { + reader.skipChildren(); + } + } + + return deserializedDatasetVersion; + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/Deployment.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/Deployment.java new file mode 100644 index 000000000000..cd0cf030b94e --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/Deployment.java @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Model Deployment Definition. + */ +@Immutable +public class Deployment implements JsonSerializable { + /* + * The type of the deployment + */ + @Generated + private DeploymentType type = DeploymentType.fromString("Deployment"); + + /* + * Name of the deployment + */ + @Generated + private String name; + + /** + * Creates an instance of Deployment class. + */ + @Generated + protected Deployment() { + } + + /** + * Get the type property: The type of the deployment. + * + * @return the type value. + */ + @Generated + public DeploymentType getType() { + return this.type; + } + + /** + * Get the name property: Name of the deployment. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Set the name property: Name of the deployment. + * + * @param name the name value to set. + * @return the Deployment object itself. + */ + @Generated + Deployment setName(String name) { + this.name = name; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Deployment from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Deployment if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the Deployment. + */ + @Generated + public static Deployment fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("type".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("ModelDeployment".equals(discriminatorValue)) { + return ModelDeployment.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static Deployment fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Deployment deserializedDeployment = new Deployment(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedDeployment.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedDeployment.type = DeploymentType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedDeployment; + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/DeploymentType.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/DeploymentType.java new file mode 100644 index 000000000000..bb7a65076358 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/DeploymentType.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines values for DeploymentType. + */ +public final class DeploymentType extends ExpandableStringEnum { + /** + * Model deployment. + */ + @Generated + public static final DeploymentType MODEL_DEPLOYMENT = fromString("ModelDeployment"); + + /** + * Creates a new instance of DeploymentType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public DeploymentType() { + } + + /** + * Creates or finds a DeploymentType from its string representation. + * + * @param name a name to look for. + * @return the corresponding DeploymentType. + */ + @Generated + public static DeploymentType fromString(String name) { + return fromString(name, DeploymentType.class); + } + + /** + * Gets known DeploymentType values. + * + * @return known DeploymentType values. + */ + @Generated + public static Collection values() { + return values(DeploymentType.class); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/EmbeddingConfiguration.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/EmbeddingConfiguration.java new file mode 100644 index 000000000000..987a544e8631 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/EmbeddingConfiguration.java @@ -0,0 +1,188 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.ai.projects.implementation.JsonMergePatchHelper; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + * Embedding configuration class. + */ +@Fluent +public final class EmbeddingConfiguration implements JsonSerializable { + /* + * Deployment name of embedding model. It can point to a model deployment either in the parent AIServices or a + * connection. + */ + @Generated + private String modelDeploymentName; + + /* + * Embedding field + */ + @Generated + private String embeddingField; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper + .setEmbeddingConfigurationAccessor(new JsonMergePatchHelper.EmbeddingConfigurationAccessor() { + @Override + public EmbeddingConfiguration prepareModelForJsonMergePatch(EmbeddingConfiguration model, + boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(EmbeddingConfiguration model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of EmbeddingConfiguration class. + */ + @Generated + public EmbeddingConfiguration() { + } + + /** + * Get the modelDeploymentName property: Deployment name of embedding model. It can point to a model deployment + * either in the parent AIServices or a connection. + * + * @return the modelDeploymentName value. + */ + @Generated + public String getModelDeploymentName() { + return this.modelDeploymentName; + } + + /** + * Set the modelDeploymentName property: Deployment name of embedding model. It can point to a model deployment + * either in the parent AIServices or a connection. + *

Required when create the resource.

+ * + * @param modelDeploymentName the modelDeploymentName value to set. + * @return the EmbeddingConfiguration object itself. + */ + @Generated + public EmbeddingConfiguration setModelDeploymentName(String modelDeploymentName) { + this.modelDeploymentName = modelDeploymentName; + this.updatedProperties.add("modelDeploymentName"); + return this; + } + + /** + * Get the embeddingField property: Embedding field. + * + * @return the embeddingField value. + */ + @Generated + public String getEmbeddingField() { + return this.embeddingField; + } + + /** + * Set the embeddingField property: Embedding field. + *

Required when create the resource.

+ * + * @param embeddingField the embeddingField value to set. + * @return the EmbeddingConfiguration object itself. + */ + @Generated + public EmbeddingConfiguration setEmbeddingField(String embeddingField) { + this.embeddingField = embeddingField; + this.updatedProperties.add("embeddingField"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("modelDeploymentName", this.modelDeploymentName); + jsonWriter.writeStringField("embeddingField", this.embeddingField); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("modelDeploymentName")) { + if (this.modelDeploymentName == null) { + jsonWriter.writeNullField("modelDeploymentName"); + } else { + jsonWriter.writeStringField("modelDeploymentName", this.modelDeploymentName); + } + } + if (updatedProperties.contains("embeddingField")) { + if (this.embeddingField == null) { + jsonWriter.writeNullField("embeddingField"); + } else { + jsonWriter.writeStringField("embeddingField", this.embeddingField); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EmbeddingConfiguration from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EmbeddingConfiguration if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the EmbeddingConfiguration. + */ + @Generated + public static EmbeddingConfiguration fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EmbeddingConfiguration deserializedEmbeddingConfiguration = new EmbeddingConfiguration(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("modelDeploymentName".equals(fieldName)) { + deserializedEmbeddingConfiguration.modelDeploymentName = reader.getString(); + } else if ("embeddingField".equals(fieldName)) { + deserializedEmbeddingConfiguration.embeddingField = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedEmbeddingConfiguration; + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/EntraIDCredentials.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/EntraIDCredentials.java new file mode 100644 index 000000000000..77aa107adb06 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/EntraIDCredentials.java @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Entra ID credential definition. + */ +@Immutable +public final class EntraIDCredentials extends BaseCredentials { + /* + * The type of credential used by the connection + */ + @Generated + private CredentialType type = CredentialType.ENTRA_ID; + + /** + * Creates an instance of EntraIDCredentials class. + */ + @Generated + private EntraIDCredentials() { + } + + /** + * Get the type property: The type of credential used by the connection. + * + * @return the type value. + */ + @Generated + @Override + public CredentialType getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EntraIDCredentials from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EntraIDCredentials if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the EntraIDCredentials. + */ + @Generated + public static EntraIDCredentials fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EntraIDCredentials deserializedEntraIDCredentials = new EntraIDCredentials(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedEntraIDCredentials.type = CredentialType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedEntraIDCredentials; + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/FieldMapping.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/FieldMapping.java new file mode 100644 index 000000000000..ac636ab45fde --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/FieldMapping.java @@ -0,0 +1,348 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.ai.projects.implementation.JsonMergePatchHelper; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * Field mapping configuration class. + */ +@Fluent +public final class FieldMapping implements JsonSerializable { + /* + * List of fields with text content + */ + @Generated + private List contentFields; + + /* + * Path of file to be used as a source of text content + */ + @Generated + private String filepathField; + + /* + * Field containing the title of the document + */ + @Generated + private String titleField; + + /* + * Field containing the url of the document + */ + @Generated + private String urlField; + + /* + * List of fields with vector content + */ + @Generated + private List vectorFields; + + /* + * List of fields with metadata content + */ + @Generated + private List metadataFields; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setFieldMappingAccessor(new JsonMergePatchHelper.FieldMappingAccessor() { + @Override + public FieldMapping prepareModelForJsonMergePatch(FieldMapping model, boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(FieldMapping model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of FieldMapping class. + */ + @Generated + public FieldMapping() { + } + + /** + * Get the contentFields property: List of fields with text content. + * + * @return the contentFields value. + */ + @Generated + public List getContentFields() { + return this.contentFields; + } + + /** + * Set the contentFields property: List of fields with text content. + *

Required when create the resource.

+ * + * @param contentFields the contentFields value to set. + * @return the FieldMapping object itself. + */ + @Generated + public FieldMapping setContentFields(List contentFields) { + this.contentFields = contentFields; + this.updatedProperties.add("contentFields"); + return this; + } + + /** + * Get the filepathField property: Path of file to be used as a source of text content. + * + * @return the filepathField value. + */ + @Generated + public String getFilepathField() { + return this.filepathField; + } + + /** + * Set the filepathField property: Path of file to be used as a source of text content. + * + * @param filepathField the filepathField value to set. + * @return the FieldMapping object itself. + */ + @Generated + public FieldMapping setFilepathField(String filepathField) { + this.filepathField = filepathField; + this.updatedProperties.add("filepathField"); + return this; + } + + /** + * Get the titleField property: Field containing the title of the document. + * + * @return the titleField value. + */ + @Generated + public String getTitleField() { + return this.titleField; + } + + /** + * Set the titleField property: Field containing the title of the document. + * + * @param titleField the titleField value to set. + * @return the FieldMapping object itself. + */ + @Generated + public FieldMapping setTitleField(String titleField) { + this.titleField = titleField; + this.updatedProperties.add("titleField"); + return this; + } + + /** + * Get the urlField property: Field containing the url of the document. + * + * @return the urlField value. + */ + @Generated + public String getUrlField() { + return this.urlField; + } + + /** + * Set the urlField property: Field containing the url of the document. + * + * @param urlField the urlField value to set. + * @return the FieldMapping object itself. + */ + @Generated + public FieldMapping setUrlField(String urlField) { + this.urlField = urlField; + this.updatedProperties.add("urlField"); + return this; + } + + /** + * Get the vectorFields property: List of fields with vector content. + * + * @return the vectorFields value. + */ + @Generated + public List getVectorFields() { + return this.vectorFields; + } + + /** + * Set the vectorFields property: List of fields with vector content. + * + * @param vectorFields the vectorFields value to set. + * @return the FieldMapping object itself. + */ + @Generated + public FieldMapping setVectorFields(List vectorFields) { + this.vectorFields = vectorFields; + this.updatedProperties.add("vectorFields"); + return this; + } + + /** + * Get the metadataFields property: List of fields with metadata content. + * + * @return the metadataFields value. + */ + @Generated + public List getMetadataFields() { + return this.metadataFields; + } + + /** + * Set the metadataFields property: List of fields with metadata content. + * + * @param metadataFields the metadataFields value to set. + * @return the FieldMapping object itself. + */ + @Generated + public FieldMapping setMetadataFields(List metadataFields) { + this.metadataFields = metadataFields; + this.updatedProperties.add("metadataFields"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("contentFields", this.contentFields, + (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("filepathField", this.filepathField); + jsonWriter.writeStringField("titleField", this.titleField); + jsonWriter.writeStringField("urlField", this.urlField); + jsonWriter.writeArrayField("vectorFields", this.vectorFields, + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("metadataFields", this.metadataFields, + (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("contentFields")) { + if (this.contentFields == null) { + jsonWriter.writeNullField("contentFields"); + } else { + jsonWriter.writeArrayField("contentFields", this.contentFields, + (writer, element) -> writer.writeString(element)); + } + } + if (updatedProperties.contains("filepathField")) { + if (this.filepathField == null) { + jsonWriter.writeNullField("filepathField"); + } else { + jsonWriter.writeStringField("filepathField", this.filepathField); + } + } + if (updatedProperties.contains("titleField")) { + if (this.titleField == null) { + jsonWriter.writeNullField("titleField"); + } else { + jsonWriter.writeStringField("titleField", this.titleField); + } + } + if (updatedProperties.contains("urlField")) { + if (this.urlField == null) { + jsonWriter.writeNullField("urlField"); + } else { + jsonWriter.writeStringField("urlField", this.urlField); + } + } + if (updatedProperties.contains("vectorFields")) { + if (this.vectorFields == null) { + jsonWriter.writeNullField("vectorFields"); + } else { + jsonWriter.writeArrayField("vectorFields", this.vectorFields, + (writer, element) -> writer.writeString(element)); + } + } + if (updatedProperties.contains("metadataFields")) { + if (this.metadataFields == null) { + jsonWriter.writeNullField("metadataFields"); + } else { + jsonWriter.writeArrayField("metadataFields", this.metadataFields, + (writer, element) -> writer.writeString(element)); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FieldMapping from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FieldMapping if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the FieldMapping. + */ + @Generated + public static FieldMapping fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + FieldMapping deserializedFieldMapping = new FieldMapping(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("contentFields".equals(fieldName)) { + List contentFields = reader.readArray(reader1 -> reader1.getString()); + deserializedFieldMapping.contentFields = contentFields; + } else if ("filepathField".equals(fieldName)) { + deserializedFieldMapping.filepathField = reader.getString(); + } else if ("titleField".equals(fieldName)) { + deserializedFieldMapping.titleField = reader.getString(); + } else if ("urlField".equals(fieldName)) { + deserializedFieldMapping.urlField = reader.getString(); + } else if ("vectorFields".equals(fieldName)) { + List vectorFields = reader.readArray(reader1 -> reader1.getString()); + deserializedFieldMapping.vectorFields = vectorFields; + } else if ("metadataFields".equals(fieldName)) { + List metadataFields = reader.readArray(reader1 -> reader1.getString()); + deserializedFieldMapping.metadataFields = metadataFields; + } else { + reader.skipChildren(); + } + } + + return deserializedFieldMapping; + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/FileDatasetVersion.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/FileDatasetVersion.java new file mode 100644 index 000000000000..024e9bc79713 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/FileDatasetVersion.java @@ -0,0 +1,208 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.ai.projects.implementation.JsonMergePatchHelper; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * FileDatasetVersion Definition. + */ +@Fluent +public final class FileDatasetVersion extends DatasetVersion { + /* + * Dataset type + */ + @Generated + private DatasetType type = DatasetType.URI_FILE; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + /** + * Creates an instance of FileDatasetVersion class. + */ + @Generated + public FileDatasetVersion() { + } + + /** + * Get the type property: Dataset type. + * + * @return the type value. + */ + @Generated + @Override + public DatasetType getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public FileDatasetVersion setDataUri(String dataUri) { + super.setDataUri(dataUri); + this.updatedProperties.add("dataUri"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public FileDatasetVersion setConnectionName(String connectionName) { + super.setConnectionName(connectionName); + this.updatedProperties.add("connectionName"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public FileDatasetVersion setDescription(String description) { + super.setDescription(description); + this.updatedProperties.add("description"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public FileDatasetVersion setTags(Map tags) { + super.setTags(tags); + this.updatedProperties.add("tags"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (JsonMergePatchHelper.getDatasetVersionAccessor().isJsonMergePatch(this)) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("dataUri", getDataUri()); + jsonWriter.writeStringField("connectionName", getConnectionName()); + jsonWriter.writeStringField("description", getDescription()); + jsonWriter.writeMapField("tags", getTags(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("dataUri")) { + if (getDataUri() == null) { + jsonWriter.writeNullField("dataUri"); + } else { + jsonWriter.writeStringField("dataUri", getDataUri()); + } + } + if (updatedProperties.contains("connectionName")) { + if (getConnectionName() == null) { + jsonWriter.writeNullField("connectionName"); + } else { + jsonWriter.writeStringField("connectionName", getConnectionName()); + } + } + if (updatedProperties.contains("description")) { + if (getDescription() == null) { + jsonWriter.writeNullField("description"); + } else { + jsonWriter.writeStringField("description", getDescription()); + } + } + if (updatedProperties.contains("tags")) { + if (getTags() == null) { + jsonWriter.writeNullField("tags"); + } else { + jsonWriter.writeMapField("tags", getTags(), (writer, element) -> { + if (element != null) { + writer.writeString(element); + } else { + writer.writeNull(); + } + }); + } + } + jsonWriter.writeStringField("type", this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FileDatasetVersion from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FileDatasetVersion if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the FileDatasetVersion. + */ + @Generated + public static FileDatasetVersion fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + FileDatasetVersion deserializedFileDatasetVersion = new FileDatasetVersion(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + JsonMergePatchHelper.getDatasetVersionAccessor() + .setName(deserializedFileDatasetVersion, reader.getString()); + } else if ("version".equals(fieldName)) { + JsonMergePatchHelper.getDatasetVersionAccessor() + .setVersion(deserializedFileDatasetVersion, reader.getString()); + } else if ("dataUri".equals(fieldName)) { + JsonMergePatchHelper.getDatasetVersionAccessor() + .setDataUri(deserializedFileDatasetVersion, reader.getString()); + } else if ("isReference".equals(fieldName)) { + JsonMergePatchHelper.getDatasetVersionAccessor() + .setIsReference(deserializedFileDatasetVersion, reader.getNullable(JsonReader::getBoolean)); + } else if ("connectionName".equals(fieldName)) { + JsonMergePatchHelper.getDatasetVersionAccessor() + .setConnectionName(deserializedFileDatasetVersion, reader.getString()); + } else if ("id".equals(fieldName)) { + JsonMergePatchHelper.getDatasetVersionAccessor() + .setId(deserializedFileDatasetVersion, reader.getString()); + } else if ("description".equals(fieldName)) { + JsonMergePatchHelper.getDatasetVersionAccessor() + .setDescription(deserializedFileDatasetVersion, reader.getString()); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + JsonMergePatchHelper.getDatasetVersionAccessor().setTags(deserializedFileDatasetVersion, tags); + } else if ("type".equals(fieldName)) { + deserializedFileDatasetVersion.type = DatasetType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedFileDatasetVersion; + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/FolderDatasetVersion.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/FolderDatasetVersion.java new file mode 100644 index 000000000000..6131ebf2fd32 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/FolderDatasetVersion.java @@ -0,0 +1,208 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.ai.projects.implementation.JsonMergePatchHelper; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * FileDatasetVersion Definition. + */ +@Fluent +public final class FolderDatasetVersion extends DatasetVersion { + /* + * Dataset type + */ + @Generated + private DatasetType type = DatasetType.URI_FOLDER; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + /** + * Creates an instance of FolderDatasetVersion class. + */ + @Generated + public FolderDatasetVersion() { + } + + /** + * Get the type property: Dataset type. + * + * @return the type value. + */ + @Generated + @Override + public DatasetType getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public FolderDatasetVersion setDataUri(String dataUri) { + super.setDataUri(dataUri); + this.updatedProperties.add("dataUri"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public FolderDatasetVersion setConnectionName(String connectionName) { + super.setConnectionName(connectionName); + this.updatedProperties.add("connectionName"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public FolderDatasetVersion setDescription(String description) { + super.setDescription(description); + this.updatedProperties.add("description"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public FolderDatasetVersion setTags(Map tags) { + super.setTags(tags); + this.updatedProperties.add("tags"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (JsonMergePatchHelper.getDatasetVersionAccessor().isJsonMergePatch(this)) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("dataUri", getDataUri()); + jsonWriter.writeStringField("connectionName", getConnectionName()); + jsonWriter.writeStringField("description", getDescription()); + jsonWriter.writeMapField("tags", getTags(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("dataUri")) { + if (getDataUri() == null) { + jsonWriter.writeNullField("dataUri"); + } else { + jsonWriter.writeStringField("dataUri", getDataUri()); + } + } + if (updatedProperties.contains("connectionName")) { + if (getConnectionName() == null) { + jsonWriter.writeNullField("connectionName"); + } else { + jsonWriter.writeStringField("connectionName", getConnectionName()); + } + } + if (updatedProperties.contains("description")) { + if (getDescription() == null) { + jsonWriter.writeNullField("description"); + } else { + jsonWriter.writeStringField("description", getDescription()); + } + } + if (updatedProperties.contains("tags")) { + if (getTags() == null) { + jsonWriter.writeNullField("tags"); + } else { + jsonWriter.writeMapField("tags", getTags(), (writer, element) -> { + if (element != null) { + writer.writeString(element); + } else { + writer.writeNull(); + } + }); + } + } + jsonWriter.writeStringField("type", this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FolderDatasetVersion from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FolderDatasetVersion if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the FolderDatasetVersion. + */ + @Generated + public static FolderDatasetVersion fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + FolderDatasetVersion deserializedFolderDatasetVersion = new FolderDatasetVersion(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + JsonMergePatchHelper.getDatasetVersionAccessor() + .setName(deserializedFolderDatasetVersion, reader.getString()); + } else if ("version".equals(fieldName)) { + JsonMergePatchHelper.getDatasetVersionAccessor() + .setVersion(deserializedFolderDatasetVersion, reader.getString()); + } else if ("dataUri".equals(fieldName)) { + JsonMergePatchHelper.getDatasetVersionAccessor() + .setDataUri(deserializedFolderDatasetVersion, reader.getString()); + } else if ("isReference".equals(fieldName)) { + JsonMergePatchHelper.getDatasetVersionAccessor() + .setIsReference(deserializedFolderDatasetVersion, reader.getNullable(JsonReader::getBoolean)); + } else if ("connectionName".equals(fieldName)) { + JsonMergePatchHelper.getDatasetVersionAccessor() + .setConnectionName(deserializedFolderDatasetVersion, reader.getString()); + } else if ("id".equals(fieldName)) { + JsonMergePatchHelper.getDatasetVersionAccessor() + .setId(deserializedFolderDatasetVersion, reader.getString()); + } else if ("description".equals(fieldName)) { + JsonMergePatchHelper.getDatasetVersionAccessor() + .setDescription(deserializedFolderDatasetVersion, reader.getString()); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + JsonMergePatchHelper.getDatasetVersionAccessor().setTags(deserializedFolderDatasetVersion, tags); + } else if ("type".equals(fieldName)) { + deserializedFolderDatasetVersion.type = DatasetType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedFolderDatasetVersion; + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/Index.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/Index.java new file mode 100644 index 000000000000..fb318b6699f3 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/Index.java @@ -0,0 +1,319 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.ai.projects.implementation.JsonMergePatchHelper; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * Index resource Definition. + */ +@Fluent +public class Index implements JsonSerializable { + /* + * Type of index + */ + @Generated + private IndexType type = IndexType.fromString("Index"); + + /* + * Asset ID, a unique identifier for the asset + */ + @Generated + private String id; + + /* + * The name of the resource + */ + @Generated + private String name; + + /* + * The version of the resource + */ + @Generated + private String version; + + /* + * The asset description text. + */ + @Generated + private String description; + + /* + * Tag dictionary. Tags can be added, removed, and updated. + */ + @Generated + private Map tags; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setIndexAccessor(new JsonMergePatchHelper.IndexAccessor() { + @Override + public Index prepareModelForJsonMergePatch(Index model, boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(Index model) { + return model.jsonMergePatch; + } + + @Override + public void setId(Index model, String id) { + model.id = id; + } + + @Override + public void setName(Index model, String name) { + model.name = name; + } + + @Override + public void setVersion(Index model, String version) { + model.version = version; + } + + @Override + public void setDescription(Index model, String description) { + model.description = description; + } + + @Override + public void setTags(Index model, Map tags) { + model.tags = tags; + } + }); + } + + /** + * Creates an instance of Index class. + */ + @Generated + public Index() { + } + + /** + * Get the type property: Type of index. + * + * @return the type value. + */ + @Generated + public IndexType getType() { + return this.type; + } + + /** + * Get the id property: Asset ID, a unique identifier for the asset. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the version property: The version of the resource. + * + * @return the version value. + */ + @Generated + public String getVersion() { + return this.version; + } + + /** + * Get the description property: The asset description text. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: The asset description text. + * + * @param description the description value to set. + * @return the Index object itself. + */ + @Generated + public Index setDescription(String description) { + this.description = description; + this.updatedProperties.add("description"); + return this; + } + + /** + * Get the tags property: Tag dictionary. Tags can be added, removed, and updated. + * + * @return the tags value. + */ + @Generated + public Map getTags() { + return this.tags; + } + + /** + * Set the tags property: Tag dictionary. Tags can be added, removed, and updated. + * + * @param tags the tags value to set. + * @return the Index object itself. + */ + @Generated + public Index setTags(Map tags) { + this.tags = tags; + this.updatedProperties.add("tags"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeMapField("tags", this.tags, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type.toString()); + if (updatedProperties.contains("description")) { + if (this.description == null) { + jsonWriter.writeNullField("description"); + } else { + jsonWriter.writeStringField("description", this.description); + } + } + if (updatedProperties.contains("tags")) { + if (this.tags == null) { + jsonWriter.writeNullField("tags"); + } else { + jsonWriter.writeMapField("tags", this.tags, (writer, element) -> { + if (element != null) { + writer.writeString(element); + } else { + writer.writeNull(); + } + }); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Index from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Index if the JsonReader was pointing to an instance of it, or null if it was pointing to + * JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the Index. + */ + @Generated + public static Index fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("type".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("AzureSearch".equals(discriminatorValue)) { + return AzureAISearchIndex.fromJson(readerToUse.reset()); + } else if ("ManagedAzureSearch".equals(discriminatorValue)) { + return ManagedAzureAISearchIndex.fromJson(readerToUse.reset()); + } else if ("CosmosDBNoSqlVectorStore".equals(discriminatorValue)) { + return CosmosDBIndex.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static Index fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Index deserializedIndex = new Index(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedIndex.name = reader.getString(); + } else if ("version".equals(fieldName)) { + deserializedIndex.version = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedIndex.type = IndexType.fromString(reader.getString()); + } else if ("id".equals(fieldName)) { + deserializedIndex.id = reader.getString(); + } else if ("description".equals(fieldName)) { + deserializedIndex.description = reader.getString(); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedIndex.tags = tags; + } else { + reader.skipChildren(); + } + } + + return deserializedIndex; + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/IndexType.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/IndexType.java new file mode 100644 index 000000000000..8ceab351133b --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/IndexType.java @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines values for IndexType. + */ +public final class IndexType extends ExpandableStringEnum { + /** + * Azure search. + */ + @Generated + public static final IndexType AZURE_SEARCH = fromString("AzureSearch"); + + /** + * CosmosDB. + */ + @Generated + public static final IndexType COSMOS_DB = fromString("CosmosDBNoSqlVectorStore"); + + /** + * Managed Azure Search. + */ + @Generated + public static final IndexType MANAGED_AZURE_SEARCH = fromString("ManagedAzureSearch"); + + /** + * Creates a new instance of IndexType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public IndexType() { + } + + /** + * Creates or finds a IndexType from its string representation. + * + * @param name a name to look for. + * @return the corresponding IndexType. + */ + @Generated + public static IndexType fromString(String name) { + return fromString(name, IndexType.class); + } + + /** + * Gets known IndexType values. + * + * @return known IndexType values. + */ + @Generated + public static Collection values() { + return values(IndexType.class); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/ManagedAzureAISearchIndex.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/ManagedAzureAISearchIndex.java new file mode 100644 index 000000000000..4750731a8fa7 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/ManagedAzureAISearchIndex.java @@ -0,0 +1,201 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.ai.projects.implementation.JsonMergePatchHelper; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * Managed Azure AI Search Index Definition. + */ +@Fluent +public final class ManagedAzureAISearchIndex extends Index { + /* + * Type of index + */ + @Generated + private IndexType type = IndexType.MANAGED_AZURE_SEARCH; + + /* + * Vector store id of managed index + */ + @Generated + private String vectorStoreId; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + /** + * Creates an instance of ManagedAzureAISearchIndex class. + */ + @Generated + public ManagedAzureAISearchIndex() { + } + + /** + * Get the type property: Type of index. + * + * @return the type value. + */ + @Generated + @Override + public IndexType getType() { + return this.type; + } + + /** + * Get the vectorStoreId property: Vector store id of managed index. + * + * @return the vectorStoreId value. + */ + @Generated + public String getVectorStoreId() { + return this.vectorStoreId; + } + + /** + * Set the vectorStoreId property: Vector store id of managed index. + *

Required when create the resource.

+ * + * @param vectorStoreId the vectorStoreId value to set. + * @return the ManagedAzureAISearchIndex object itself. + */ + @Generated + public ManagedAzureAISearchIndex setVectorStoreId(String vectorStoreId) { + this.vectorStoreId = vectorStoreId; + this.updatedProperties.add("vectorStoreId"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public ManagedAzureAISearchIndex setDescription(String description) { + super.setDescription(description); + this.updatedProperties.add("description"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public ManagedAzureAISearchIndex setTags(Map tags) { + super.setTags(tags); + this.updatedProperties.add("tags"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (JsonMergePatchHelper.getIndexAccessor().isJsonMergePatch(this)) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("description", getDescription()); + jsonWriter.writeMapField("tags", getTags(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeStringField("vectorStoreId", this.vectorStoreId); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("description")) { + if (getDescription() == null) { + jsonWriter.writeNullField("description"); + } else { + jsonWriter.writeStringField("description", getDescription()); + } + } + if (updatedProperties.contains("tags")) { + if (getTags() == null) { + jsonWriter.writeNullField("tags"); + } else { + jsonWriter.writeMapField("tags", getTags(), (writer, element) -> { + if (element != null) { + writer.writeString(element); + } else { + writer.writeNull(); + } + }); + } + } + jsonWriter.writeStringField("type", this.type.toString()); + if (updatedProperties.contains("vectorStoreId")) { + if (this.vectorStoreId == null) { + jsonWriter.writeNullField("vectorStoreId"); + } else { + jsonWriter.writeStringField("vectorStoreId", this.vectorStoreId); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ManagedAzureAISearchIndex from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ManagedAzureAISearchIndex if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ManagedAzureAISearchIndex. + */ + @Generated + public static ManagedAzureAISearchIndex fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ManagedAzureAISearchIndex deserializedManagedAzureAISearchIndex = new ManagedAzureAISearchIndex(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + JsonMergePatchHelper.getIndexAccessor() + .setName(deserializedManagedAzureAISearchIndex, reader.getString()); + } else if ("version".equals(fieldName)) { + JsonMergePatchHelper.getIndexAccessor() + .setVersion(deserializedManagedAzureAISearchIndex, reader.getString()); + } else if ("id".equals(fieldName)) { + JsonMergePatchHelper.getIndexAccessor() + .setId(deserializedManagedAzureAISearchIndex, reader.getString()); + } else if ("description".equals(fieldName)) { + JsonMergePatchHelper.getIndexAccessor() + .setDescription(deserializedManagedAzureAISearchIndex, reader.getString()); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + JsonMergePatchHelper.getIndexAccessor().setTags(deserializedManagedAzureAISearchIndex, tags); + } else if ("type".equals(fieldName)) { + deserializedManagedAzureAISearchIndex.type = IndexType.fromString(reader.getString()); + } else if ("vectorStoreId".equals(fieldName)) { + deserializedManagedAzureAISearchIndex.vectorStoreId = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedManagedAzureAISearchIndex; + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/ModelDeployment.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/ModelDeployment.java new file mode 100644 index 000000000000..740bdd696752 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/ModelDeployment.java @@ -0,0 +1,193 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * Model Deployment Definition. + */ +@Immutable +public final class ModelDeployment extends Deployment { + /* + * The type of the deployment + */ + @Generated + private DeploymentType type = DeploymentType.MODEL_DEPLOYMENT; + + /* + * Publisher-specific name of the deployed model + */ + @Generated + private String modelName; + + /* + * Publisher-specific version of the deployed model + */ + @Generated + private String modelVersion; + + /* + * Name of the deployed model's publisher + */ + @Generated + private String modelPublisher; + + /* + * Capabilities of deployed model + */ + @Generated + private Map capabilities; + + /* + * Sku of the model deployment + */ + @Generated + private Sku sku; + + /* + * Name of the connection the deployment comes from + */ + @Generated + private String connectionName; + + /** + * Creates an instance of ModelDeployment class. + */ + @Generated + private ModelDeployment() { + } + + /** + * Get the type property: The type of the deployment. + * + * @return the type value. + */ + @Generated + @Override + public DeploymentType getType() { + return this.type; + } + + /** + * Get the modelName property: Publisher-specific name of the deployed model. + * + * @return the modelName value. + */ + @Generated + public String getModelName() { + return this.modelName; + } + + /** + * Get the modelVersion property: Publisher-specific version of the deployed model. + * + * @return the modelVersion value. + */ + @Generated + public String getModelVersion() { + return this.modelVersion; + } + + /** + * Get the modelPublisher property: Name of the deployed model's publisher. + * + * @return the modelPublisher value. + */ + @Generated + public String getModelPublisher() { + return this.modelPublisher; + } + + /** + * Get the capabilities property: Capabilities of deployed model. + * + * @return the capabilities value. + */ + @Generated + public Map getCapabilities() { + return this.capabilities; + } + + /** + * Get the sku property: Sku of the model deployment. + * + * @return the sku value. + */ + @Generated + public Sku getSku() { + return this.sku; + } + + /** + * Get the connectionName property: Name of the connection the deployment comes from. + * + * @return the connectionName value. + */ + @Generated + public String getConnectionName() { + return this.connectionName; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ModelDeployment from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ModelDeployment if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ModelDeployment. + */ + @Generated + public static ModelDeployment fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ModelDeployment deserializedModelDeployment = new ModelDeployment(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedModelDeployment.setName(reader.getString()); + } else if ("modelName".equals(fieldName)) { + deserializedModelDeployment.modelName = reader.getString(); + } else if ("modelVersion".equals(fieldName)) { + deserializedModelDeployment.modelVersion = reader.getString(); + } else if ("modelPublisher".equals(fieldName)) { + deserializedModelDeployment.modelPublisher = reader.getString(); + } else if ("capabilities".equals(fieldName)) { + Map capabilities = reader.readMap(reader1 -> reader1.getString()); + deserializedModelDeployment.capabilities = capabilities; + } else if ("sku".equals(fieldName)) { + deserializedModelDeployment.sku = Sku.fromJson(reader); + } else if ("type".equals(fieldName)) { + deserializedModelDeployment.type = DeploymentType.fromString(reader.getString()); + } else if ("connectionName".equals(fieldName)) { + deserializedModelDeployment.connectionName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedModelDeployment; + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/NoAuthenticationCredentials.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/NoAuthenticationCredentials.java new file mode 100644 index 000000000000..001403198b56 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/NoAuthenticationCredentials.java @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Credentials that do not require authentication. + */ +@Immutable +public final class NoAuthenticationCredentials extends BaseCredentials { + /* + * The type of credential used by the connection + */ + @Generated + private CredentialType type = CredentialType.NONE; + + /** + * Creates an instance of NoAuthenticationCredentials class. + */ + @Generated + private NoAuthenticationCredentials() { + } + + /** + * Get the type property: The type of credential used by the connection. + * + * @return the type value. + */ + @Generated + @Override + public CredentialType getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of NoAuthenticationCredentials from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of NoAuthenticationCredentials if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the NoAuthenticationCredentials. + */ + @Generated + public static NoAuthenticationCredentials fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + NoAuthenticationCredentials deserializedNoAuthenticationCredentials = new NoAuthenticationCredentials(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedNoAuthenticationCredentials.type = CredentialType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedNoAuthenticationCredentials; + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/PendingUploadRequest.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/PendingUploadRequest.java new file mode 100644 index 000000000000..f1c25f476885 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/PendingUploadRequest.java @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents a request for a pending upload. + */ +@Fluent +public final class PendingUploadRequest implements JsonSerializable { + /* + * If PendingUploadId is not provided, a random GUID will be used. + */ + @Generated + private String pendingUploadId; + + /* + * Azure Storage Account connection name to use for generating temporary SAS token + */ + @Generated + private String connectionName; + + /* + * BlobReference is the only supported type. + */ + @Generated + private final PendingUploadType pendingUploadType = PendingUploadType.BLOB_REFERENCE; + + /** + * Creates an instance of PendingUploadRequest class. + */ + @Generated + public PendingUploadRequest() { + } + + /** + * Get the pendingUploadId property: If PendingUploadId is not provided, a random GUID will be used. + * + * @return the pendingUploadId value. + */ + @Generated + public String getPendingUploadId() { + return this.pendingUploadId; + } + + /** + * Set the pendingUploadId property: If PendingUploadId is not provided, a random GUID will be used. + * + * @param pendingUploadId the pendingUploadId value to set. + * @return the PendingUploadRequest object itself. + */ + @Generated + public PendingUploadRequest setPendingUploadId(String pendingUploadId) { + this.pendingUploadId = pendingUploadId; + return this; + } + + /** + * Get the connectionName property: Azure Storage Account connection name to use for generating temporary SAS token. + * + * @return the connectionName value. + */ + @Generated + public String getConnectionName() { + return this.connectionName; + } + + /** + * Set the connectionName property: Azure Storage Account connection name to use for generating temporary SAS token. + * + * @param connectionName the connectionName value to set. + * @return the PendingUploadRequest object itself. + */ + @Generated + public PendingUploadRequest setConnectionName(String connectionName) { + this.connectionName = connectionName; + return this; + } + + /** + * Get the pendingUploadType property: BlobReference is the only supported type. + * + * @return the pendingUploadType value. + */ + @Generated + public PendingUploadType getPendingUploadType() { + return this.pendingUploadType; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("pendingUploadType", + this.pendingUploadType == null ? null : this.pendingUploadType.toString()); + jsonWriter.writeStringField("pendingUploadId", this.pendingUploadId); + jsonWriter.writeStringField("connectionName", this.connectionName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PendingUploadRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PendingUploadRequest if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the PendingUploadRequest. + */ + @Generated + public static PendingUploadRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PendingUploadRequest deserializedPendingUploadRequest = new PendingUploadRequest(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("pendingUploadId".equals(fieldName)) { + deserializedPendingUploadRequest.pendingUploadId = reader.getString(); + } else if ("connectionName".equals(fieldName)) { + deserializedPendingUploadRequest.connectionName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedPendingUploadRequest; + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/PendingUploadResponse.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/PendingUploadResponse.java new file mode 100644 index 000000000000..59c20f8fb633 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/PendingUploadResponse.java @@ -0,0 +1,148 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents the response for a pending upload request. + */ +@Immutable +public final class PendingUploadResponse implements JsonSerializable { + /* + * Container-level read, write, list SAS. + */ + @Generated + private final BlobReference blobReference; + + /* + * ID for this upload request. + */ + @Generated + private final String pendingUploadId; + + /* + * Version of asset to be created if user did not specify version when initially creating upload + */ + @Generated + private String version; + + /* + * BlobReference is the only supported type + */ + @Generated + private final PendingUploadType pendingUploadType = PendingUploadType.BLOB_REFERENCE; + + /** + * Creates an instance of PendingUploadResponse class. + * + * @param blobReference the blobReference value to set. + * @param pendingUploadId the pendingUploadId value to set. + */ + @Generated + private PendingUploadResponse(BlobReference blobReference, String pendingUploadId) { + this.blobReference = blobReference; + this.pendingUploadId = pendingUploadId; + } + + /** + * Get the blobReference property: Container-level read, write, list SAS. + * + * @return the blobReference value. + */ + @Generated + public BlobReference getBlobReference() { + return this.blobReference; + } + + /** + * Get the pendingUploadId property: ID for this upload request. + * + * @return the pendingUploadId value. + */ + @Generated + public String getPendingUploadId() { + return this.pendingUploadId; + } + + /** + * Get the version property: Version of asset to be created if user did not specify version when initially creating + * upload. + * + * @return the version value. + */ + @Generated + public String getVersion() { + return this.version; + } + + /** + * Get the pendingUploadType property: BlobReference is the only supported type. + * + * @return the pendingUploadType value. + */ + @Generated + public PendingUploadType getPendingUploadType() { + return this.pendingUploadType; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("blobReference", this.blobReference); + jsonWriter.writeStringField("pendingUploadId", this.pendingUploadId); + jsonWriter.writeStringField("pendingUploadType", + this.pendingUploadType == null ? null : this.pendingUploadType.toString()); + jsonWriter.writeStringField("version", this.version); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PendingUploadResponse from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PendingUploadResponse if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the PendingUploadResponse. + */ + @Generated + public static PendingUploadResponse fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BlobReference blobReference = null; + String pendingUploadId = null; + String version = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("blobReference".equals(fieldName)) { + blobReference = BlobReference.fromJson(reader); + } else if ("pendingUploadId".equals(fieldName)) { + pendingUploadId = reader.getString(); + } else if ("version".equals(fieldName)) { + version = reader.getString(); + } else { + reader.skipChildren(); + } + } + PendingUploadResponse deserializedPendingUploadResponse + = new PendingUploadResponse(blobReference, pendingUploadId); + deserializedPendingUploadResponse.version = version; + + return deserializedPendingUploadResponse; + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/PendingUploadType.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/PendingUploadType.java new file mode 100644 index 000000000000..d0590881d1a6 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/PendingUploadType.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The type of pending upload. + */ +public final class PendingUploadType extends ExpandableStringEnum { + /** + * No pending upload. + */ + @Generated + public static final PendingUploadType NONE = fromString("None"); + + /** + * Blob Reference is the only supported type. + */ + @Generated + public static final PendingUploadType BLOB_REFERENCE = fromString("BlobReference"); + + /** + * Creates a new instance of PendingUploadType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public PendingUploadType() { + } + + /** + * Creates or finds a PendingUploadType from its string representation. + * + * @param name a name to look for. + * @return the corresponding PendingUploadType. + */ + @Generated + public static PendingUploadType fromString(String name) { + return fromString(name, PendingUploadType.class); + } + + /** + * Gets known PendingUploadType values. + * + * @return known PendingUploadType values. + */ + @Generated + public static Collection values() { + return values(PendingUploadType.class); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/SASCredentials.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/SASCredentials.java new file mode 100644 index 000000000000..d9999b6b5c15 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/SASCredentials.java @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Shared Access Signature (SAS) credential definition. + */ +@Immutable +public final class SASCredentials extends BaseCredentials { + /* + * The type of credential used by the connection + */ + @Generated + private CredentialType type = CredentialType.SAS; + + /* + * SAS token + */ + @Generated + private String sasToken; + + /** + * Creates an instance of SASCredentials class. + */ + @Generated + private SASCredentials() { + } + + /** + * Get the type property: The type of credential used by the connection. + * + * @return the type value. + */ + @Generated + @Override + public CredentialType getType() { + return this.type; + } + + /** + * Get the sasToken property: SAS token. + * + * @return the sasToken value. + */ + @Generated + public String getSasToken() { + return this.sasToken; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SASCredentials from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SASCredentials if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the SASCredentials. + */ + @Generated + public static SASCredentials fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SASCredentials deserializedSASCredentials = new SASCredentials(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedSASCredentials.type = CredentialType.fromString(reader.getString()); + } else if ("SAS".equals(fieldName)) { + deserializedSASCredentials.sasToken = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedSASCredentials; + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/SasCredential.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/SasCredential.java new file mode 100644 index 000000000000..f54414c672ba --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/SasCredential.java @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * SAS Credential definition. + */ +@Immutable +public final class SasCredential implements JsonSerializable { + /* + * SAS uri + */ + @Generated + private String sasUri; + + /* + * Type of credential + */ + @Generated + private final String type = "SAS"; + + /** + * Creates an instance of SasCredential class. + */ + @Generated + private SasCredential() { + } + + /** + * Get the sasUri property: SAS uri. + * + * @return the sasUri value. + */ + @Generated + public String getSasUri() { + return this.sasUri; + } + + /** + * Get the type property: Type of credential. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SasCredential from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SasCredential if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the SasCredential. + */ + @Generated + public static SasCredential fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SasCredential deserializedSasCredential = new SasCredential(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("sasUri".equals(fieldName)) { + deserializedSasCredential.sasUri = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedSasCredential; + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/Sku.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/Sku.java new file mode 100644 index 000000000000..649bb29270a3 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/Sku.java @@ -0,0 +1,171 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Sku information. + */ +@Immutable +public final class Sku implements JsonSerializable { + /* + * Sku capacity + */ + @Generated + private final long capacity; + + /* + * Sku family + */ + @Generated + private final String family; + + /* + * Sku name + */ + @Generated + private final String name; + + /* + * Sku size + */ + @Generated + private final String size; + + /* + * Sku tier + */ + @Generated + private final String tier; + + /** + * Creates an instance of Sku class. + * + * @param capacity the capacity value to set. + * @param family the family value to set. + * @param name the name value to set. + * @param size the size value to set. + * @param tier the tier value to set. + */ + @Generated + private Sku(long capacity, String family, String name, String size, String tier) { + this.capacity = capacity; + this.family = family; + this.name = name; + this.size = size; + this.tier = tier; + } + + /** + * Get the capacity property: Sku capacity. + * + * @return the capacity value. + */ + @Generated + public long getCapacity() { + return this.capacity; + } + + /** + * Get the family property: Sku family. + * + * @return the family value. + */ + @Generated + public String getFamily() { + return this.family; + } + + /** + * Get the name property: Sku name. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the size property: Sku size. + * + * @return the size value. + */ + @Generated + public String getSize() { + return this.size; + } + + /** + * Get the tier property: Sku tier. + * + * @return the tier value. + */ + @Generated + public String getTier() { + return this.tier; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeLongField("capacity", this.capacity); + jsonWriter.writeStringField("family", this.family); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("size", this.size); + jsonWriter.writeStringField("tier", this.tier); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Sku from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Sku if the JsonReader was pointing to an instance of it, or null if it was pointing to + * JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the Sku. + */ + @Generated + public static Sku fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + long capacity = 0L; + String family = null; + String name = null; + String size = null; + String tier = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("capacity".equals(fieldName)) { + capacity = reader.getLong(); + } else if ("family".equals(fieldName)) { + family = reader.getString(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("size".equals(fieldName)) { + size = reader.getString(); + } else if ("tier".equals(fieldName)) { + tier = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Sku(capacity, family, name, size, tier); + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/package-info.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/package-info.java new file mode 100644 index 000000000000..8f10e7f3677e --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/package-info.java @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * + * Package containing the data models for Projects. + * + */ +package com.azure.ai.projects.models; diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/package-info.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/package-info.java new file mode 100644 index 000000000000..2b617feda28c --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/package-info.java @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * + * Package containing the classes for Projects. + * + */ +package com.azure.ai.projects; diff --git a/sdk/ai/azure-ai-projects/src/main/java/module-info.java b/sdk/ai/azure-ai-projects/src/main/java/module-info.java new file mode 100644 index 000000000000..487552a5c2e9 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/module-info.java @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +module com.azure.ai.projects { + requires transitive com.azure.core; + + exports com.azure.ai.projects; + exports com.azure.ai.projects.models; + + opens com.azure.ai.projects.models to com.azure.core; +} diff --git a/sdk/ai/azure-ai-projects/src/main/resources/META-INF/azure-ai-projects_apiview_properties.json b/sdk/ai/azure-ai-projects/src/main/resources/META-INF/azure-ai-projects_apiview_properties.json new file mode 100644 index 000000000000..d53061b3afdb --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/resources/META-INF/azure-ai-projects_apiview_properties.json @@ -0,0 +1,100 @@ +{ + "flavor": "azure", + "CrossLanguageDefinitionId": { + "com.azure.ai.projects.AIProjectClientBuilder": "Azure.AI.Projects", + "com.azure.ai.projects.ConnectionsAsyncClient": "Azure.AI.Projects.Connections", + "com.azure.ai.projects.ConnectionsAsyncClient.get": "Azure.AI.Projects.Connections.get", + "com.azure.ai.projects.ConnectionsAsyncClient.getWithCredentials": "Azure.AI.Projects.Connections.getWithCredentials", + "com.azure.ai.projects.ConnectionsAsyncClient.getWithCredentialsWithResponse": "Azure.AI.Projects.Connections.getWithCredentials", + "com.azure.ai.projects.ConnectionsAsyncClient.getWithResponse": "Azure.AI.Projects.Connections.get", + "com.azure.ai.projects.ConnectionsAsyncClient.list": "Azure.AI.Projects.Connections.list", + "com.azure.ai.projects.ConnectionsClient": "Azure.AI.Projects.Connections", + "com.azure.ai.projects.ConnectionsClient.get": "Azure.AI.Projects.Connections.get", + "com.azure.ai.projects.ConnectionsClient.getWithCredentials": "Azure.AI.Projects.Connections.getWithCredentials", + "com.azure.ai.projects.ConnectionsClient.getWithCredentialsWithResponse": "Azure.AI.Projects.Connections.getWithCredentials", + "com.azure.ai.projects.ConnectionsClient.getWithResponse": "Azure.AI.Projects.Connections.get", + "com.azure.ai.projects.ConnectionsClient.list": "Azure.AI.Projects.Connections.list", + "com.azure.ai.projects.DatasetsAsyncClient": "Azure.AI.Projects.Datasets", + "com.azure.ai.projects.DatasetsAsyncClient.createOrUpdate": "Azure.AI.Projects.ServicePatterns.Datasets.createOrUpdateVersion", + "com.azure.ai.projects.DatasetsAsyncClient.createOrUpdateWithResponse": "Azure.AI.Projects.ServicePatterns.Datasets.createOrUpdateVersion", + "com.azure.ai.projects.DatasetsAsyncClient.delete": "Azure.AI.Projects.ServicePatterns.Datasets.deleteVersion", + "com.azure.ai.projects.DatasetsAsyncClient.deleteWithResponse": "Azure.AI.Projects.ServicePatterns.Datasets.deleteVersion", + "com.azure.ai.projects.DatasetsAsyncClient.get": "Azure.AI.Projects.ServicePatterns.Datasets.getVersion", + "com.azure.ai.projects.DatasetsAsyncClient.getCredentials": "Azure.AI.Projects.Datasets.getCredentials", + "com.azure.ai.projects.DatasetsAsyncClient.getCredentialsWithResponse": "Azure.AI.Projects.Datasets.getCredentials", + "com.azure.ai.projects.DatasetsAsyncClient.getWithResponse": "Azure.AI.Projects.ServicePatterns.Datasets.getVersion", + "com.azure.ai.projects.DatasetsAsyncClient.list": "Azure.AI.Projects.ServicePatterns.Datasets.listLatest", + "com.azure.ai.projects.DatasetsAsyncClient.listVersions": "Azure.AI.Projects.ServicePatterns.Datasets.listVersions", + "com.azure.ai.projects.DatasetsAsyncClient.pendingUpload": "Azure.AI.Projects.Datasets.startPendingUploadVersion", + "com.azure.ai.projects.DatasetsAsyncClient.pendingUploadWithResponse": "Azure.AI.Projects.Datasets.startPendingUploadVersion", + "com.azure.ai.projects.DatasetsClient": "Azure.AI.Projects.Datasets", + "com.azure.ai.projects.DatasetsClient.createOrUpdate": "Azure.AI.Projects.ServicePatterns.Datasets.createOrUpdateVersion", + "com.azure.ai.projects.DatasetsClient.createOrUpdateWithResponse": "Azure.AI.Projects.ServicePatterns.Datasets.createOrUpdateVersion", + "com.azure.ai.projects.DatasetsClient.delete": "Azure.AI.Projects.ServicePatterns.Datasets.deleteVersion", + "com.azure.ai.projects.DatasetsClient.deleteWithResponse": "Azure.AI.Projects.ServicePatterns.Datasets.deleteVersion", + "com.azure.ai.projects.DatasetsClient.get": "Azure.AI.Projects.ServicePatterns.Datasets.getVersion", + "com.azure.ai.projects.DatasetsClient.getCredentials": "Azure.AI.Projects.Datasets.getCredentials", + "com.azure.ai.projects.DatasetsClient.getCredentialsWithResponse": "Azure.AI.Projects.Datasets.getCredentials", + "com.azure.ai.projects.DatasetsClient.getWithResponse": "Azure.AI.Projects.ServicePatterns.Datasets.getVersion", + "com.azure.ai.projects.DatasetsClient.list": "Azure.AI.Projects.ServicePatterns.Datasets.listLatest", + "com.azure.ai.projects.DatasetsClient.listVersions": "Azure.AI.Projects.ServicePatterns.Datasets.listVersions", + "com.azure.ai.projects.DatasetsClient.pendingUpload": "Azure.AI.Projects.Datasets.startPendingUploadVersion", + "com.azure.ai.projects.DatasetsClient.pendingUploadWithResponse": "Azure.AI.Projects.Datasets.startPendingUploadVersion", + "com.azure.ai.projects.DeploymentsAsyncClient": "Azure.AI.Projects.Deployments", + "com.azure.ai.projects.DeploymentsAsyncClient.get": "Azure.AI.Projects.Deployments.get", + "com.azure.ai.projects.DeploymentsAsyncClient.getWithResponse": "Azure.AI.Projects.Deployments.get", + "com.azure.ai.projects.DeploymentsAsyncClient.list": "Azure.AI.Projects.Deployments.list", + "com.azure.ai.projects.DeploymentsClient": "Azure.AI.Projects.Deployments", + "com.azure.ai.projects.DeploymentsClient.get": "Azure.AI.Projects.Deployments.get", + "com.azure.ai.projects.DeploymentsClient.getWithResponse": "Azure.AI.Projects.Deployments.get", + "com.azure.ai.projects.DeploymentsClient.list": "Azure.AI.Projects.Deployments.list", + "com.azure.ai.projects.IndexesAsyncClient": "Azure.AI.Projects.Indexes", + "com.azure.ai.projects.IndexesAsyncClient.createOrUpdate": "Azure.AI.Projects.ServicePatterns.Indexes.createOrUpdateVersion", + "com.azure.ai.projects.IndexesAsyncClient.createOrUpdateWithResponse": "Azure.AI.Projects.ServicePatterns.Indexes.createOrUpdateVersion", + "com.azure.ai.projects.IndexesAsyncClient.delete": "Azure.AI.Projects.ServicePatterns.Indexes.deleteVersion", + "com.azure.ai.projects.IndexesAsyncClient.deleteWithResponse": "Azure.AI.Projects.ServicePatterns.Indexes.deleteVersion", + "com.azure.ai.projects.IndexesAsyncClient.get": "Azure.AI.Projects.ServicePatterns.Indexes.getVersion", + "com.azure.ai.projects.IndexesAsyncClient.getWithResponse": "Azure.AI.Projects.ServicePatterns.Indexes.getVersion", + "com.azure.ai.projects.IndexesAsyncClient.list": "Azure.AI.Projects.ServicePatterns.Indexes.listLatest", + "com.azure.ai.projects.IndexesAsyncClient.listVersions": "Azure.AI.Projects.ServicePatterns.Indexes.listVersions", + "com.azure.ai.projects.IndexesClient": "Azure.AI.Projects.Indexes", + "com.azure.ai.projects.IndexesClient.createOrUpdate": "Azure.AI.Projects.ServicePatterns.Indexes.createOrUpdateVersion", + "com.azure.ai.projects.IndexesClient.createOrUpdateWithResponse": "Azure.AI.Projects.ServicePatterns.Indexes.createOrUpdateVersion", + "com.azure.ai.projects.IndexesClient.delete": "Azure.AI.Projects.ServicePatterns.Indexes.deleteVersion", + "com.azure.ai.projects.IndexesClient.deleteWithResponse": "Azure.AI.Projects.ServicePatterns.Indexes.deleteVersion", + "com.azure.ai.projects.IndexesClient.get": "Azure.AI.Projects.ServicePatterns.Indexes.getVersion", + "com.azure.ai.projects.IndexesClient.getWithResponse": "Azure.AI.Projects.ServicePatterns.Indexes.getVersion", + "com.azure.ai.projects.IndexesClient.list": "Azure.AI.Projects.ServicePatterns.Indexes.listLatest", + "com.azure.ai.projects.IndexesClient.listVersions": "Azure.AI.Projects.ServicePatterns.Indexes.listVersions", + "com.azure.ai.projects.models.ApiKeyCredentials": "Azure.AI.Projects.ApiKeyCredentials", + "com.azure.ai.projects.models.AssetCredentialResponse": "Azure.AI.Projects.AssetCredentialResponse", + "com.azure.ai.projects.models.AzureAISearchIndex": "Azure.AI.Projects.AzureAISearchIndex", + "com.azure.ai.projects.models.BaseCredentials": "Azure.AI.Projects.BaseCredentials", + "com.azure.ai.projects.models.BlobReference": "Azure.AI.Projects.BlobReference", + "com.azure.ai.projects.models.Connection": "Azure.AI.Projects.Connection", + "com.azure.ai.projects.models.ConnectionType": "Azure.AI.Projects.ConnectionType", + "com.azure.ai.projects.models.CosmosDBIndex": "Azure.AI.Projects.CosmosDBIndex", + "com.azure.ai.projects.models.CredentialType": "Azure.AI.Projects.CredentialType", + "com.azure.ai.projects.models.CustomCredential": "Azure.AI.Projects.CustomCredential", + "com.azure.ai.projects.models.DatasetType": "Azure.AI.Projects.DatasetType", + "com.azure.ai.projects.models.DatasetVersion": "Azure.AI.Projects.DatasetVersion", + "com.azure.ai.projects.models.Deployment": "Azure.AI.Projects.Deployment", + "com.azure.ai.projects.models.DeploymentType": "Azure.AI.Projects.DeploymentType", + "com.azure.ai.projects.models.EmbeddingConfiguration": "Azure.AI.Projects.EmbeddingConfiguration", + "com.azure.ai.projects.models.EntraIDCredentials": "Azure.AI.Projects.EntraIDCredentials", + "com.azure.ai.projects.models.FieldMapping": "Azure.AI.Projects.FieldMapping", + "com.azure.ai.projects.models.FileDatasetVersion": "Azure.AI.Projects.FileDatasetVersion", + "com.azure.ai.projects.models.FolderDatasetVersion": "Azure.AI.Projects.FolderDatasetVersion", + "com.azure.ai.projects.models.Index": "Azure.AI.Projects.Index", + "com.azure.ai.projects.models.IndexType": "Azure.AI.Projects.IndexType", + "com.azure.ai.projects.models.ManagedAzureAISearchIndex": "Azure.AI.Projects.ManagedAzureAISearchIndex", + "com.azure.ai.projects.models.ModelDeployment": "Azure.AI.Projects.ModelDeployment", + "com.azure.ai.projects.models.NoAuthenticationCredentials": "Azure.AI.Projects.NoAuthenticationCredentials", + "com.azure.ai.projects.models.PendingUploadRequest": "Azure.AI.Projects.PendingUploadRequest", + "com.azure.ai.projects.models.PendingUploadResponse": "Azure.AI.Projects.PendingUploadResponse", + "com.azure.ai.projects.models.PendingUploadType": "Azure.AI.Projects.PendingUploadType", + "com.azure.ai.projects.models.SASCredentials": "Azure.AI.Projects.SASCredentials", + "com.azure.ai.projects.models.SasCredential": "Azure.AI.Projects.SasCredential", + "com.azure.ai.projects.models.Sku": "Azure.AI.Projects.Sku" + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/resources/azure-ai-projects.properties b/sdk/ai/azure-ai-projects/src/main/resources/azure-ai-projects.properties new file mode 100644 index 000000000000..ca812989b4f2 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/resources/azure-ai-projects.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/ReadmeSamples.java b/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/ReadmeSamples.java new file mode 100644 index 000000000000..52d1b33e83df --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/ReadmeSamples.java @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects; + +public final class ReadmeSamples { + public void readmeSamples() { + // BEGIN: com.azure.ai.projects.readme + // END: com.azure.ai.projects.readme + } +} diff --git a/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/ConnectionsListMaximumSet.java b/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/ConnectionsListMaximumSet.java new file mode 100644 index 000000000000..93d2bc485747 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/ConnectionsListMaximumSet.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.generated; + +import com.azure.ai.projects.AIProjectClientBuilder; +import com.azure.ai.projects.ConnectionsClient; +import com.azure.ai.projects.models.Connection; +import com.azure.ai.projects.models.ConnectionType; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class ConnectionsListMaximumSet { + public static void main(String[] args) { + ConnectionsClient connectionsClient + = new AIProjectClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildConnectionsClient(); + // BEGIN:com.azure.ai.projects.generated.connectionslist.connectionslistmaximumset + PagedIterable response = connectionsClient.list(ConnectionType.AZURE_OPEN_AI, true); + // END:com.azure.ai.projects.generated.connectionslist.connectionslistmaximumset + } +} diff --git a/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DatasetsGetCredentialsMaximumSet.java b/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DatasetsGetCredentialsMaximumSet.java new file mode 100644 index 000000000000..1c80d0bb6e16 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DatasetsGetCredentialsMaximumSet.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.generated; + +import com.azure.ai.projects.AIProjectClientBuilder; +import com.azure.ai.projects.DatasetsClient; +import com.azure.ai.projects.models.AssetCredentialResponse; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class DatasetsGetCredentialsMaximumSet { + public static void main(String[] args) { + DatasetsClient datasetsClient + = new AIProjectClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildDatasetsClient(); + // BEGIN:com.azure.ai.projects.generated.datasetsgetcredentials.datasetsgetcredentialsmaximumset + AssetCredentialResponse response = datasetsClient.getCredentials("hpvjnkljsuospxwrypot", "rlf"); + // END:com.azure.ai.projects.generated.datasetsgetcredentials.datasetsgetcredentialsmaximumset + } +} diff --git a/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DatasetsGetCredentialsMinimumSet.java b/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DatasetsGetCredentialsMinimumSet.java new file mode 100644 index 000000000000..5f49aed6c230 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DatasetsGetCredentialsMinimumSet.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.generated; + +import com.azure.ai.projects.AIProjectClientBuilder; +import com.azure.ai.projects.DatasetsClient; +import com.azure.ai.projects.models.AssetCredentialResponse; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class DatasetsGetCredentialsMinimumSet { + public static void main(String[] args) { + DatasetsClient datasetsClient + = new AIProjectClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildDatasetsClient(); + // BEGIN:com.azure.ai.projects.generated.datasetsgetcredentials.datasetsgetcredentialsminimumset + AssetCredentialResponse response = datasetsClient.getCredentials("udrhdaxbjptksqqwztnfswzku", "ytogupzn"); + // END:com.azure.ai.projects.generated.datasetsgetcredentials.datasetsgetcredentialsminimumset + } +} diff --git a/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DatasetsStartPendingUploadVersionMaximumSet.java b/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DatasetsStartPendingUploadVersionMaximumSet.java new file mode 100644 index 000000000000..d7b8c25dd922 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DatasetsStartPendingUploadVersionMaximumSet.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.generated; + +import com.azure.ai.projects.AIProjectClientBuilder; +import com.azure.ai.projects.DatasetsClient; +import com.azure.ai.projects.models.PendingUploadRequest; +import com.azure.ai.projects.models.PendingUploadResponse; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class DatasetsStartPendingUploadVersionMaximumSet { + public static void main(String[] args) { + DatasetsClient datasetsClient + = new AIProjectClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildDatasetsClient(); + // BEGIN:com.azure.ai.projects.generated.datasetspendingupload.datasetsstartpendinguploadversionmaximumset + PendingUploadResponse response = datasetsClient.pendingUpload("cncrcmiaksswirlujwcptxeaef", "jkqqzmj", + new PendingUploadRequest().setPendingUploadId("gxuutkdhlygsmsbtszqzx") + .setConnectionName("hsgskbhwucytwglwlm")); + // END:com.azure.ai.projects.generated.datasetspendingupload.datasetsstartpendinguploadversionmaximumset + } +} diff --git a/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DatasetsStartPendingUploadVersionMinimumSet.java b/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DatasetsStartPendingUploadVersionMinimumSet.java new file mode 100644 index 000000000000..7a3d0bc82f38 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DatasetsStartPendingUploadVersionMinimumSet.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.generated; + +import com.azure.ai.projects.AIProjectClientBuilder; +import com.azure.ai.projects.DatasetsClient; +import com.azure.ai.projects.models.PendingUploadRequest; +import com.azure.ai.projects.models.PendingUploadResponse; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class DatasetsStartPendingUploadVersionMinimumSet { + public static void main(String[] args) { + DatasetsClient datasetsClient + = new AIProjectClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildDatasetsClient(); + // BEGIN:com.azure.ai.projects.generated.datasetspendingupload.datasetsstartpendinguploadversionminimumset + PendingUploadResponse response = datasetsClient.pendingUpload("atopkjwxsjtforndczju", "yftpnjxwjylhixypopcytxd", + new PendingUploadRequest()); + // END:com.azure.ai.projects.generated.datasetspendingupload.datasetsstartpendinguploadversionminimumset + } +} diff --git a/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DeploymentsGetMaximumSet.java b/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DeploymentsGetMaximumSet.java new file mode 100644 index 000000000000..bc5454d9a559 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DeploymentsGetMaximumSet.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.generated; + +import com.azure.ai.projects.AIProjectClientBuilder; +import com.azure.ai.projects.DeploymentsClient; +import com.azure.ai.projects.models.Deployment; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class DeploymentsGetMaximumSet { + public static void main(String[] args) { + DeploymentsClient deploymentsClient + = new AIProjectClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildDeploymentsClient(); + // BEGIN:com.azure.ai.projects.generated.deploymentsget.deploymentsgetmaximumset + Deployment response = deploymentsClient.get("ft"); + // END:com.azure.ai.projects.generated.deploymentsget.deploymentsgetmaximumset + } +} diff --git a/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DeploymentsListMaximumSet.java b/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DeploymentsListMaximumSet.java new file mode 100644 index 000000000000..211bdbaba60e --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DeploymentsListMaximumSet.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.projects.generated; + +import com.azure.ai.projects.AIProjectClientBuilder; +import com.azure.ai.projects.DeploymentsClient; +import com.azure.ai.projects.models.Deployment; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class DeploymentsListMaximumSet { + public static void main(String[] args) { + DeploymentsClient deploymentsClient + = new AIProjectClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildDeploymentsClient(); + // BEGIN:com.azure.ai.projects.generated.deploymentslist.deploymentslistmaximumset + PagedIterable response = deploymentsClient.list("tb", "xdlvjxymsmdnebesolv", null); + // END:com.azure.ai.projects.generated.deploymentslist.deploymentslistmaximumset + } +} diff --git a/sdk/ai/azure-ai-projects/tsp-location.yaml b/sdk/ai/azure-ai-projects/tsp-location.yaml new file mode 100644 index 000000000000..995b770264e2 --- /dev/null +++ b/sdk/ai/azure-ai-projects/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/ai/Azure.AI.Projects +commit: ff3b3c214e6fe5043a772cfdc2a528a4fdcaba9f +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/ai/ci.yml b/sdk/ai/ci.yml index c52361cf6f1b..6771cbfada5d 100644 --- a/sdk/ai/ci.yml +++ b/sdk/ai/ci.yml @@ -31,7 +31,11 @@ pr: parameters: - name: release_azureaiinference - displayName: 'azure-ai-inference' + displayName: azure-ai-inference + type: boolean + default: true + - name: release_azureaiprojects + displayName: azure-ai-projects type: boolean default: true @@ -44,3 +48,7 @@ extends: groupId: com.azure safeName: azureaiinference releaseInBatch: ${{ parameters.release_azureaiinference }} + - name: azure-ai-projects + groupId: com.azure + safeName: azureaiprojects + releaseInBatch: ${{ parameters.release_azureaiprojects }} diff --git a/sdk/ai/pom.xml b/sdk/ai/pom.xml index 14915ac80174..5f1e5086b12f 100644 --- a/sdk/ai/pom.xml +++ b/sdk/ai/pom.xml @@ -11,5 +11,6 @@ azure-ai-inference + azure-ai-projects