From ba024a835a9c62e65c405c24b54a139bd74ee050 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 1 May 2025 06:32:00 +0000 Subject: [PATCH] CodeGen from PR 34387 in Azure/azure-rest-api-specs Merge ae4b3a321b174b94a0419bc9d2842b8fe89f38c8 into 9f83acd412aa185254294752506dfcf88d401dfd --- eng/versioning/version_client.txt | 1 + sdk/ai/azure-ai-projects/CHANGELOG.md | 16 + sdk/ai/azure-ai-projects/README.md | 78 + sdk/ai/azure-ai-projects/assets.json | 1 + sdk/ai/azure-ai-projects/pom.xml | 71 + .../ai/projects/AIProjectClientBuilder.java | 402 ++++++ .../ai/projects/ConnectionsAsyncClient.java | 286 ++++ .../azure/ai/projects/ConnectionsClient.java | 252 ++++ .../ai/projects/DatasetsAsyncClient.java | 591 ++++++++ .../com/azure/ai/projects/DatasetsClient.java | 533 +++++++ .../ai/projects/DeploymentsAsyncClient.java | 216 +++ .../azure/ai/projects/DeploymentsClient.java | 185 +++ .../azure/ai/projects/IndexesAsyncClient.java | 429 ++++++ .../com/azure/ai/projects/IndexesClient.java | 374 +++++ .../ai/projects/ProjectsServiceVersion.java | 50 + .../implementation/AIProjectClientImpl.java | 197 +++ .../implementation/ConnectionsImpl.java | 650 +++++++++ .../projects/implementation/DatasetsImpl.java | 1249 +++++++++++++++++ .../implementation/DeploymentsImpl.java | 491 +++++++ .../projects/implementation/IndexesImpl.java | 958 +++++++++++++ .../projects/implementation/package-info.java | 10 + .../ai/projects/models/ApiKeyCredentials.java | 98 ++ .../models/AssetCredentialResponse.java | 83 ++ .../projects/models/AzureAISearchIndex.java | 171 +++ .../ai/projects/models/BaseCredentials.java | 114 ++ .../ai/projects/models/BlobReference.java | 128 ++ .../azure/ai/projects/models/Connection.java | 172 +++ .../ai/projects/models/ConnectionType.java | 99 ++ .../ai/projects/models/CosmosDBIndex.java | 217 +++ .../ai/projects/models/CredentialType.java | 75 + .../ai/projects/models/CustomCredential.java | 101 ++ .../azure/ai/projects/models/DatasetType.java | 57 + .../ai/projects/models/DatasetVersion.java | 332 +++++ .../azure/ai/projects/models/Deployment.java | 137 ++ .../ai/projects/models/DeploymentType.java | 51 + .../models/EmbeddingConfiguration.java | 107 ++ .../projects/models/EntraIDCredentials.java | 80 ++ .../projects/models/FileDatasetVersion.java | 137 ++ .../projects/models/FolderDatasetVersion.java | 137 ++ .../models/GetCredentialsRequest.java | 59 + .../com/azure/ai/projects/models/Index.java | 265 ++++ .../azure/ai/projects/models/IndexType.java | 63 + .../models/ManagedAzureAISearchIndex.java | 150 ++ .../ai/projects/models/ModelDeployment.java | 193 +++ .../models/NoAuthenticationCredentials.java | 80 ++ .../projects/models/PendingUploadRequest.java | 142 ++ .../models/PendingUploadResponse.java | 148 ++ .../ai/projects/models/PendingUploadType.java | 57 + .../ai/projects/models/SASCredentials.java | 98 ++ .../ai/projects/models/SasCredential.java | 96 ++ .../com/azure/ai/projects/models/Sku.java | 171 +++ .../ai/projects/models/package-info.java | 10 + .../com/azure/ai/projects/package-info.java | 10 + .../src/main/java/module-info.java | 12 + .../azure-ai-projects_apiview_properties.json | 100 ++ .../resources/azure-ai-projects.properties | 2 + .../com/azure/ai/projects/ReadmeSamples.java | 12 + .../generated/ConnectionsListMaximumSet.java | 25 + .../DatasetsGetCredentialsMaximumSet.java | 25 + .../DatasetsGetCredentialsMinimumSet.java | 25 + ...tsStartPendingUploadVersionMaximumSet.java | 26 + ...tsStartPendingUploadVersionMinimumSet.java | 25 + .../generated/DeploymentsGetMaximumSet.java | 23 + .../generated/DeploymentsListMaximumSet.java | 24 + sdk/ai/azure-ai-projects/tsp-location.yaml | 4 + sdk/ai/ci.yml | 10 +- sdk/ai/pom.xml | 1 + 67 files changed, 11191 insertions(+), 1 deletion(-) create mode 100644 sdk/ai/azure-ai-projects/CHANGELOG.md create mode 100644 sdk/ai/azure-ai-projects/README.md create mode 100644 sdk/ai/azure-ai-projects/assets.json create mode 100644 sdk/ai/azure-ai-projects/pom.xml create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/AIProjectClientBuilder.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/ConnectionsAsyncClient.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/ConnectionsClient.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/DatasetsAsyncClient.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/DatasetsClient.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/DeploymentsAsyncClient.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/DeploymentsClient.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/IndexesAsyncClient.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/IndexesClient.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/ProjectsServiceVersion.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/AIProjectClientImpl.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/ConnectionsImpl.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/DatasetsImpl.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/DeploymentsImpl.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/IndexesImpl.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/package-info.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/ApiKeyCredentials.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/AssetCredentialResponse.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/AzureAISearchIndex.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/BaseCredentials.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/BlobReference.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/Connection.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/ConnectionType.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/CosmosDBIndex.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/CredentialType.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/CustomCredential.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/DatasetType.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/DatasetVersion.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/Deployment.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/DeploymentType.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/EmbeddingConfiguration.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/EntraIDCredentials.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/FileDatasetVersion.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/FolderDatasetVersion.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/GetCredentialsRequest.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/Index.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/IndexType.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/ManagedAzureAISearchIndex.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/ModelDeployment.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/NoAuthenticationCredentials.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/PendingUploadRequest.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/PendingUploadResponse.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/PendingUploadType.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/SASCredentials.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/SasCredential.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/Sku.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/package-info.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/package-info.java create mode 100644 sdk/ai/azure-ai-projects/src/main/java/module-info.java create mode 100644 sdk/ai/azure-ai-projects/src/main/resources/META-INF/azure-ai-projects_apiview_properties.json create mode 100644 sdk/ai/azure-ai-projects/src/main/resources/azure-ai-projects.properties create mode 100644 sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/ReadmeSamples.java create mode 100644 sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/ConnectionsListMaximumSet.java create mode 100644 sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DatasetsGetCredentialsMaximumSet.java create mode 100644 sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DatasetsGetCredentialsMinimumSet.java create mode 100644 sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DatasetsStartPendingUploadVersionMaximumSet.java create mode 100644 sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DatasetsStartPendingUploadVersionMinimumSet.java create mode 100644 sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DeploymentsGetMaximumSet.java create mode 100644 sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DeploymentsListMaximumSet.java create mode 100644 sdk/ai/azure-ai-projects/tsp-location.yaml diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index b04d701dd93c..0ed0344ff11e 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..32e3738e5e38 --- /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.15.4 + 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..dc15b7b7f010 --- /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://cognitiveservices.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 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 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 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..3971823b298f --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/ConnectionsAsyncClient.java @@ -0,0 +1,286 @@ +// 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)
+     *     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 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 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)
+     *     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 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 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
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: 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 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 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 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 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. + * @param top The number of result items to return. + * @param skip The number of result items to skip. + * @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, Integer top, + Integer skip) { + // 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); + } + if (top != null) { + requestOptions.addQueryParam("top", String.valueOf(top), false); + } + if (skip != null) { + requestOptions.addQueryParam("skip", String.valueOf(skip), 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..0d9ddaf3ad46 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/ConnectionsClient.java @@ -0,0 +1,252 @@ +// 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)
+     *     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 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 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)
+     *     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 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 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
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: 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 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 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 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 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. + * @param top The number of result items to return. + * @param skip The number of result items to skip. + * @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, Integer top, + Integer skip) { + // 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); + } + if (top != null) { + requestOptions.addQueryParam("top", String.valueOf(top), false); + } + if (skip != null) { + requestOptions.addQueryParam("skip", String.valueOf(skip), 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..40156ab13089 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/DatasetsAsyncClient.java @@ -0,0 +1,591 @@ +// 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.models.AssetCredentialResponse; +import com.azure.ai.projects.models.DatasetVersion; +import com.azure.ai.projects.models.GetCredentialsRequest; +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. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Required)
+     *     isReference: Boolean (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. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Required)
+     *     isReference: Boolean (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 (Required)
+     *     isReference: Boolean (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 (Required)
+     *     isReference: Boolean (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 (Required)
+     *     isReference: Boolean (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. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     * }
+     * }
+     * 
+ * + *

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 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 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, BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.getCredentialsWithResponseAsync(name, version, body, requestOptions); + } + + /** + * List all versions of the given DatasetVersion. + * + * @param name The name of the resource. + * @param continuationToken Continuation token for pagination. + * @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, String continuationToken) { + // Generated convenience method for listVersions + RequestOptions requestOptions = new RequestOptions(); + if (continuationToken != null) { + requestOptions.addQueryParam("continuationToken", continuationToken, false); + } + 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 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. + * + * @param continuationToken Continuation token for pagination. + * @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 list(String continuationToken) { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + if (continuationToken != null) { + requestOptions.addQueryParam("continuationToken", continuationToken, 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(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(); + return createOrUpdateWithResponse(name, version, BinaryData.fromObject(body), 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. + * @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 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, GetCredentialsRequest body) { + // Generated convenience method for getCredentialsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getCredentialsWithResponse(name, version, BinaryData.fromObject(body), 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..01813bfd1761 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/DatasetsClient.java @@ -0,0 +1,533 @@ +// 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.models.AssetCredentialResponse; +import com.azure.ai.projects.models.DatasetVersion; +import com.azure.ai.projects.models.GetCredentialsRequest; +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. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Required)
+     *     isReference: Boolean (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. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Required)
+     *     isReference: Boolean (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 (Required)
+     *     isReference: Boolean (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 (Required)
+     *     isReference: Boolean (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 (Required)
+     *     isReference: Boolean (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. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     * }
+     * }
+     * 
+ * + *

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 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 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, BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.getCredentialsWithResponse(name, version, body, requestOptions); + } + + /** + * List all versions of the given DatasetVersion. + * + * @param name The name of the resource. + * @param continuationToken Continuation token for pagination. + * @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, String continuationToken) { + // Generated convenience method for listVersions + RequestOptions requestOptions = new RequestOptions(); + if (continuationToken != null) { + requestOptions.addQueryParam("continuationToken", continuationToken, false); + } + return serviceClient.listVersions(name, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(DatasetVersion.class)); + } + + /** + * 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. + * + * @param continuationToken Continuation token for pagination. + * @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 list(String continuationToken) { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + if (continuationToken != null) { + requestOptions.addQueryParam("continuationToken", continuationToken, false); + } + return serviceClient.list(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(); + return createOrUpdateWithResponse(name, version, BinaryData.fromObject(body), 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. + * @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 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, GetCredentialsRequest body) { + // Generated convenience method for getCredentialsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getCredentialsWithResponse(name, version, BinaryData.fromObject(body), 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..656e78b9529d --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/DeploymentsAsyncClient.java @@ -0,0 +1,216 @@ +// 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".
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * 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. + * @param top The number of result items to return. + * @param skip The number of result items to skip. + * @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, + Integer top, Integer skip) { + // 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); + } + if (top != null) { + requestOptions.addQueryParam("top", String.valueOf(top), false); + } + if (skip != null) { + requestOptions.addQueryParam("skip", String.valueOf(skip), 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..fb8446c85887 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/DeploymentsClient.java @@ -0,0 +1,185 @@ +// 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".
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * 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. + * @param top The number of result items to return. + * @param skip The number of result items to skip. + * @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, + Integer top, Integer skip) { + // 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); + } + if (top != null) { + requestOptions.addQueryParam("top", String.valueOf(top), false); + } + if (skip != null) { + requestOptions.addQueryParam("skip", String.valueOf(skip), 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..382873ae358f --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/IndexesAsyncClient.java @@ -0,0 +1,429 @@ +// 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.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. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

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. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

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. + * @param continuationToken Continuation token for pagination. + * @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, String continuationToken) { + // Generated convenience method for listVersions + RequestOptions requestOptions = new RequestOptions(); + if (continuationToken != null) { + requestOptions.addQueryParam("continuationToken", continuationToken, false); + } + 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 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. + * + * @param continuationToken Continuation token for pagination. + * @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 list(String continuationToken) { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + if (continuationToken != null) { + requestOptions.addQueryParam("continuationToken", continuationToken, 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(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(); + return createOrUpdateWithResponse(name, version, BinaryData.fromObject(body), 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..3a2792f60ade --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/IndexesClient.java @@ -0,0 +1,374 @@ +// 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.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. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

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. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

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. + * @param continuationToken Continuation token for pagination. + * @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, String continuationToken) { + // Generated convenience method for listVersions + RequestOptions requestOptions = new RequestOptions(); + if (continuationToken != null) { + requestOptions.addQueryParam("continuationToken", continuationToken, false); + } + return serviceClient.listVersions(name, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(Index.class)); + } + + /** + * 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. + * + * @param continuationToken Continuation token for pagination. + * @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 list(String continuationToken) { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + if (continuationToken != null) { + requestOptions.addQueryParam("continuationToken", continuationToken, false); + } + return serviceClient.list(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(); + return createOrUpdateWithResponse(name, version, BinaryData.fromObject(body), 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..ab091f38401f --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/ConnectionsImpl.java @@ -0,0 +1,650 @@ +// 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 com.azure.core.util.UrlBuilder; +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)
+     *     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 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 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)
+     *     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 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 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)
+     *     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 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 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)
+     *     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 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 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
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: 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
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: 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<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listSinglePageAsync(requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listNextSinglePageAsync(nextLink, requestOptionsLocal); + }); + } + + /** + * 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
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: 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
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: 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<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listSinglePage(requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listNextSinglePage(nextLink, requestOptionsLocal); + }); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: 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)
+     *     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..370e3ab87adc --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/DatasetsImpl.java @@ -0,0 +1,1249 @@ +// 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, + @PathParam("version") String version, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/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, + @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) + 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("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) + Response getCredentialsSync(@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); + + @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. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Required)
+     *     isReference: Boolean (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. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Required)
+     *     isReference: Boolean (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. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Required)
+     *     isReference: Boolean (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. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Required)
+     *     isReference: Boolean (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. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Required)
+     *     isReference: Boolean (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. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Required)
+     *     isReference: Boolean (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. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Required)
+     *     isReference: Boolean (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. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Required)
+     *     isReference: Boolean (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 (Required)
+     *     isReference: Boolean (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 (Required)
+     *     isReference: Boolean (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 (Required)
+     *     isReference: Boolean (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 (Required)
+     *     isReference: Boolean (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/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + name, version, contentType, 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 (Required)
+     *     isReference: Boolean (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 (Required)
+     *     isReference: Boolean (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/json"; + final String accept = "application/json"; + return service.createOrUpdateSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), name, + version, contentType, 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. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     * }
+     * }
+     * 
+ * + *

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 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 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, BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.getCredentials(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + name, version, contentType, accept, body, requestOptions, context)); + } + + /** + * Get the SAS credential to access the storage account associated with a Dataset version. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     * }
+     * }
+     * 
+ * + *

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 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 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, BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.getCredentialsSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), name, + version, contentType, accept, body, requestOptions, Context.NONE); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     type: String(uri_file/uri_folder) (Required)
+     *     dataUri: String (Required)
+     *     isReference: Boolean (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 (Required)
+     *     isReference: Boolean (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 (Required)
+     *     isReference: Boolean (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 (Required)
+     *     isReference: Boolean (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..b56de44a2235 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/DeploymentsImpl.java @@ -0,0 +1,491 @@ +// 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 com.azure.core.util.UrlBuilder; +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".
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * 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".
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * 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<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listSinglePageAsync(requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listNextSinglePageAsync(nextLink, requestOptionsLocal); + }); + } + + /** + * 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".
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * 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".
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * 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<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listSinglePage(requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listNextSinglePage(nextLink, requestOptionsLocal); + }); + } + + /** + * 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..3a2e48ac0761 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/IndexesImpl.java @@ -0,0 +1,958 @@ +// 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, + @PathParam("version") String version, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/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, + @PathParam("version") String version, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/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. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

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. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

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. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

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. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

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. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

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. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

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. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

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. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

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/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + name, version, contentType, 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/json"; + final String accept = "application/json"; + return service.createOrUpdateSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), name, + version, contentType, 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/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..29bbda0e4e32 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/AzureAISearchIndex.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.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.Map; + +/** + * 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 final String connectionName; + + /* + * Name of index in Azure AI Search resource to attach + */ + @Generated + private final String indexName; + + /** + * Creates an instance of AzureAISearchIndex class. + * + * @param connectionName the connectionName value to set. + * @param indexName the indexName value to set. + */ + @Generated + public AzureAISearchIndex(String connectionName, String indexName) { + this.connectionName = connectionName; + this.indexName = indexName; + } + + /** + * 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; + } + + /** + * 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; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public AzureAISearchIndex setDescription(String description) { + super.setDescription(description); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public AzureAISearchIndex setTags(Map tags) { + super.setTags(tags); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("description", getDescription()); + jsonWriter.writeMapField("tags", getTags(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("connectionName", this.connectionName); + jsonWriter.writeStringField("indexName", this.indexName); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + 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 -> { + String name = null; + String version = null; + String id = null; + String description = null; + Map tags = null; + String connectionName = null; + String indexName = null; + IndexType type = IndexType.AZURE_SEARCH; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("version".equals(fieldName)) { + version = reader.getString(); + } else if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("description".equals(fieldName)) { + description = reader.getString(); + } else if ("tags".equals(fieldName)) { + tags = reader.readMap(reader1 -> reader1.getString()); + } else if ("connectionName".equals(fieldName)) { + connectionName = reader.getString(); + } else if ("indexName".equals(fieldName)) { + indexName = reader.getString(); + } else if ("type".equals(fieldName)) { + type = IndexType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + AzureAISearchIndex deserializedAzureAISearchIndex = new AzureAISearchIndex(connectionName, indexName); + deserializedAzureAISearchIndex.setName(name); + deserializedAzureAISearchIndex.setVersion(version); + deserializedAzureAISearchIndex.setId(id); + deserializedAzureAISearchIndex.setDescription(description); + deserializedAzureAISearchIndex.setTags(tags); + deserializedAzureAISearchIndex.type = type; + + 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..175ea59e37da --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/Connection.java @@ -0,0 +1,172 @@ +// 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 name of the resource + */ + @Generated + private String name; + + /* + * 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 name of the resource. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * 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 ("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..8f16a4ec0d2f --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/CosmosDBIndex.java @@ -0,0 +1,217 @@ +// 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.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * 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 final String connectionName; + + /* + * Name of the CosmosDB Database + */ + @Generated + private final String databaseName; + + /* + * Name of CosmosDB Container + */ + @Generated + private final String containerName; + + /* + * Embedding model configuration + */ + @Generated + private final EmbeddingConfiguration embeddingConfiguration; + + /** + * Creates an instance of CosmosDBIndex class. + * + * @param connectionName the connectionName value to set. + * @param databaseName the databaseName value to set. + * @param containerName the containerName value to set. + * @param embeddingConfiguration the embeddingConfiguration value to set. + */ + @Generated + public CosmosDBIndex(String connectionName, String databaseName, String containerName, + EmbeddingConfiguration embeddingConfiguration) { + this.connectionName = connectionName; + this.databaseName = databaseName; + this.containerName = containerName; + this.embeddingConfiguration = embeddingConfiguration; + } + + /** + * 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; + } + + /** + * Get the databaseName property: Name of the CosmosDB Database. + * + * @return the databaseName value. + */ + @Generated + public String getDatabaseName() { + return this.databaseName; + } + + /** + * Get the containerName property: Name of CosmosDB Container. + * + * @return the containerName value. + */ + @Generated + public String getContainerName() { + return this.containerName; + } + + /** + * Get the embeddingConfiguration property: Embedding model configuration. + * + * @return the embeddingConfiguration value. + */ + @Generated + public EmbeddingConfiguration getEmbeddingConfiguration() { + return this.embeddingConfiguration; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public CosmosDBIndex setDescription(String description) { + super.setDescription(description); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public CosmosDBIndex setTags(Map tags) { + super.setTags(tags); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("description", getDescription()); + jsonWriter.writeMapField("tags", getTags(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("connectionName", this.connectionName); + jsonWriter.writeStringField("databaseName", this.databaseName); + jsonWriter.writeStringField("containerName", this.containerName); + jsonWriter.writeJsonField("embeddingConfiguration", this.embeddingConfiguration); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + 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 -> { + String name = null; + String version = null; + String id = null; + String description = null; + Map tags = null; + String connectionName = null; + String databaseName = null; + String containerName = null; + EmbeddingConfiguration embeddingConfiguration = null; + IndexType type = IndexType.COSMOS_DB; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("version".equals(fieldName)) { + version = reader.getString(); + } else if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("description".equals(fieldName)) { + description = reader.getString(); + } else if ("tags".equals(fieldName)) { + tags = reader.readMap(reader1 -> reader1.getString()); + } else if ("connectionName".equals(fieldName)) { + connectionName = reader.getString(); + } else if ("databaseName".equals(fieldName)) { + databaseName = reader.getString(); + } else if ("containerName".equals(fieldName)) { + containerName = reader.getString(); + } else if ("embeddingConfiguration".equals(fieldName)) { + embeddingConfiguration = EmbeddingConfiguration.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = IndexType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + CosmosDBIndex deserializedCosmosDBIndex + = new CosmosDBIndex(connectionName, databaseName, containerName, embeddingConfiguration); + deserializedCosmosDBIndex.setName(name); + deserializedCosmosDBIndex.setVersion(version); + deserializedCosmosDBIndex.setId(id); + deserializedCosmosDBIndex.setDescription(description); + deserializedCosmosDBIndex.setTags(tags); + deserializedCosmosDBIndex.type = type; + + 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..80426bfc37ea --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/DatasetVersion.java @@ -0,0 +1,332 @@ +// 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; +import java.util.Map; + +/** + * 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 final String dataUri; + + /* + * Indicates if dataset is reference only or managed by dataset service. If true, the underlying data will be + * deleted when the dataset version is deleted + */ + @Generated + private Boolean isReference; + + /* + * 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; + + /** + * Creates an instance of DatasetVersion class. + * + * @param dataUri the dataUri value to set. + */ + @Generated + public DatasetVersion(String dataUri) { + this.dataUri = dataUri; + } + + /** + * 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; + } + + /** + * Get the isReference property: Indicates if dataset is reference only or managed by dataset service. If true, the + * underlying data will be deleted when the dataset version is deleted. + * + * @return the isReference value. + */ + @Generated + public Boolean isReference() { + return this.isReference; + } + + /** + * Set the isReference property: Indicates if dataset is reference only or managed by dataset service. If true, the + * underlying data will be deleted when the dataset version is deleted. + * + * @param isReference the isReference value to set. + * @return the DatasetVersion object itself. + */ + @Generated + DatasetVersion setIsReference(Boolean isReference) { + this.isReference = isReference; + 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; + } + + /** + * Set the id property: Asset ID, a unique identifier for the asset. + * + * @param id the id value to set. + * @return the DatasetVersion object itself. + */ + @Generated + DatasetVersion setId(String id) { + this.id = id; + return this; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Set the name property: The name of the resource. + * + * @param name the name value to set. + * @return the DatasetVersion object itself. + */ + @Generated + DatasetVersion setName(String name) { + this.name = name; + return this; + } + + /** + * Get the version property: The version of the resource. + * + * @return the version value. + */ + @Generated + public String getVersion() { + return this.version; + } + + /** + * Set the version property: The version of the resource. + * + * @param version the version value to set. + * @return the DatasetVersion object itself. + */ + @Generated + DatasetVersion setVersion(String version) { + this.version = version; + return this; + } + + /** + * 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; + 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; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("dataUri", this.dataUri); + 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(); + } + + /** + * 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 -> { + String dataUri = null; + String name = null; + String version = null; + DatasetType type = null; + Boolean isReference = null; + String id = null; + String description = null; + Map tags = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("dataUri".equals(fieldName)) { + dataUri = reader.getString(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("version".equals(fieldName)) { + version = reader.getString(); + } else if ("type".equals(fieldName)) { + type = DatasetType.fromString(reader.getString()); + } else if ("isReference".equals(fieldName)) { + isReference = reader.getNullable(JsonReader::getBoolean); + } else if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("description".equals(fieldName)) { + description = reader.getString(); + } else if ("tags".equals(fieldName)) { + tags = reader.readMap(reader1 -> reader1.getString()); + } else { + reader.skipChildren(); + } + } + DatasetVersion deserializedDatasetVersion = new DatasetVersion(dataUri); + deserializedDatasetVersion.name = name; + deserializedDatasetVersion.version = version; + deserializedDatasetVersion.type = type; + deserializedDatasetVersion.isReference = isReference; + deserializedDatasetVersion.id = id; + deserializedDatasetVersion.description = description; + deserializedDatasetVersion.tags = tags; + + 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..7b60dfe36618 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/EmbeddingConfiguration.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.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; + +/** + * Embedding configuration class. + */ +@Immutable +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 final String modelDeploymentName; + + /* + * Embedding field + */ + @Generated + private final String embeddingField; + + /** + * Creates an instance of EmbeddingConfiguration class. + * + * @param modelDeploymentName the modelDeploymentName value to set. + * @param embeddingField the embeddingField value to set. + */ + @Generated + public EmbeddingConfiguration(String modelDeploymentName, String embeddingField) { + this.modelDeploymentName = modelDeploymentName; + this.embeddingField = embeddingField; + } + + /** + * 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; + } + + /** + * Get the embeddingField property: Embedding field. + * + * @return the embeddingField value. + */ + @Generated + public String getEmbeddingField() { + return this.embeddingField; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("modelDeploymentName", this.modelDeploymentName); + 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 IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the EmbeddingConfiguration. + */ + @Generated + public static EmbeddingConfiguration fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String modelDeploymentName = null; + String embeddingField = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("modelDeploymentName".equals(fieldName)) { + modelDeploymentName = reader.getString(); + } else if ("embeddingField".equals(fieldName)) { + embeddingField = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new EmbeddingConfiguration(modelDeploymentName, embeddingField); + }); + } +} 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/FileDatasetVersion.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/FileDatasetVersion.java new file mode 100644 index 000000000000..4772b270f15f --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/FileDatasetVersion.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.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.Map; + +/** + * FileDatasetVersion Definition. + */ +@Fluent +public final class FileDatasetVersion extends DatasetVersion { + /* + * Dataset type + */ + @Generated + private DatasetType type = DatasetType.URI_FILE; + + /** + * Creates an instance of FileDatasetVersion class. + * + * @param dataUri the dataUri value to set. + */ + @Generated + public FileDatasetVersion(String dataUri) { + super(dataUri); + } + + /** + * Get the type property: Dataset type. + * + * @return the type value. + */ + @Generated + @Override + public DatasetType getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public FileDatasetVersion setDescription(String description) { + super.setDescription(description); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public FileDatasetVersion setTags(Map tags) { + super.setTags(tags); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("dataUri", getDataUri()); + 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(); + } + + /** + * 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 -> { + String dataUri = null; + String name = null; + String version = null; + Boolean isReference = null; + String id = null; + String description = null; + Map tags = null; + DatasetType type = DatasetType.URI_FILE; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("dataUri".equals(fieldName)) { + dataUri = reader.getString(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("version".equals(fieldName)) { + version = reader.getString(); + } else if ("isReference".equals(fieldName)) { + isReference = reader.getNullable(JsonReader::getBoolean); + } else if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("description".equals(fieldName)) { + description = reader.getString(); + } else if ("tags".equals(fieldName)) { + tags = reader.readMap(reader1 -> reader1.getString()); + } else if ("type".equals(fieldName)) { + type = DatasetType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + FileDatasetVersion deserializedFileDatasetVersion = new FileDatasetVersion(dataUri); + deserializedFileDatasetVersion.setName(name); + deserializedFileDatasetVersion.setVersion(version); + deserializedFileDatasetVersion.setIsReference(isReference); + deserializedFileDatasetVersion.setId(id); + deserializedFileDatasetVersion.setDescription(description); + deserializedFileDatasetVersion.setTags(tags); + deserializedFileDatasetVersion.type = type; + + 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..e9be671774e2 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/FolderDatasetVersion.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.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.Map; + +/** + * FileDatasetVersion Definition. + */ +@Fluent +public final class FolderDatasetVersion extends DatasetVersion { + /* + * Dataset type + */ + @Generated + private DatasetType type = DatasetType.URI_FOLDER; + + /** + * Creates an instance of FolderDatasetVersion class. + * + * @param dataUri the dataUri value to set. + */ + @Generated + public FolderDatasetVersion(String dataUri) { + super(dataUri); + } + + /** + * Get the type property: Dataset type. + * + * @return the type value. + */ + @Generated + @Override + public DatasetType getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public FolderDatasetVersion setDescription(String description) { + super.setDescription(description); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public FolderDatasetVersion setTags(Map tags) { + super.setTags(tags); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("dataUri", getDataUri()); + 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(); + } + + /** + * 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 -> { + String dataUri = null; + String name = null; + String version = null; + Boolean isReference = null; + String id = null; + String description = null; + Map tags = null; + DatasetType type = DatasetType.URI_FOLDER; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("dataUri".equals(fieldName)) { + dataUri = reader.getString(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("version".equals(fieldName)) { + version = reader.getString(); + } else if ("isReference".equals(fieldName)) { + isReference = reader.getNullable(JsonReader::getBoolean); + } else if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("description".equals(fieldName)) { + description = reader.getString(); + } else if ("tags".equals(fieldName)) { + tags = reader.readMap(reader1 -> reader1.getString()); + } else if ("type".equals(fieldName)) { + type = DatasetType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + FolderDatasetVersion deserializedFolderDatasetVersion = new FolderDatasetVersion(dataUri); + deserializedFolderDatasetVersion.setName(name); + deserializedFolderDatasetVersion.setVersion(version); + deserializedFolderDatasetVersion.setIsReference(isReference); + deserializedFolderDatasetVersion.setId(id); + deserializedFolderDatasetVersion.setDescription(description); + deserializedFolderDatasetVersion.setTags(tags); + deserializedFolderDatasetVersion.type = type; + + return deserializedFolderDatasetVersion; + }); + } +} diff --git a/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/GetCredentialsRequest.java b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/GetCredentialsRequest.java new file mode 100644 index 000000000000..dfafdce62e53 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/GetCredentialsRequest.java @@ -0,0 +1,59 @@ +// 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; + +/** + * The GetCredentialsRequest model. + */ +@Immutable +public final class GetCredentialsRequest implements JsonSerializable { + /** + * Creates an instance of GetCredentialsRequest class. + */ + @Generated + public GetCredentialsRequest() { + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GetCredentialsRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GetCredentialsRequest 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 GetCredentialsRequest. + */ + @Generated + public static GetCredentialsRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + GetCredentialsRequest deserializedGetCredentialsRequest = new GetCredentialsRequest(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + reader.skipChildren(); + } + + return deserializedGetCredentialsRequest; + }); + } +} 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..f09d0a50641a --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/Index.java @@ -0,0 +1,265 @@ +// 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; +import java.util.Map; + +/** + * 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; + + /** + * 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; + } + + /** + * Set the id property: Asset ID, a unique identifier for the asset. + * + * @param id the id value to set. + * @return the Index object itself. + */ + @Generated + Index setId(String id) { + this.id = id; + return this; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Set the name property: The name of the resource. + * + * @param name the name value to set. + * @return the Index object itself. + */ + @Generated + Index setName(String name) { + this.name = name; + return this; + } + + /** + * Get the version property: The version of the resource. + * + * @return the version value. + */ + @Generated + public String getVersion() { + return this.version; + } + + /** + * Set the version property: The version of the resource. + * + * @param version the version value to set. + * @return the Index object itself. + */ + @Generated + Index setVersion(String version) { + this.version = version; + return this; + } + + /** + * 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; + 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; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + 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(); + } + + /** + * 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..081162ac4e54 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/ManagedAzureAISearchIndex.java @@ -0,0 +1,150 @@ +// 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.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * 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 final String vectorStoreId; + + /** + * Creates an instance of ManagedAzureAISearchIndex class. + * + * @param vectorStoreId the vectorStoreId value to set. + */ + @Generated + public ManagedAzureAISearchIndex(String vectorStoreId) { + this.vectorStoreId = vectorStoreId; + } + + /** + * 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; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public ManagedAzureAISearchIndex setDescription(String description) { + super.setDescription(description); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public ManagedAzureAISearchIndex setTags(Map tags) { + super.setTags(tags); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("description", getDescription()); + jsonWriter.writeMapField("tags", getTags(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("vectorStoreId", this.vectorStoreId); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + 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 -> { + String name = null; + String version = null; + String id = null; + String description = null; + Map tags = null; + String vectorStoreId = null; + IndexType type = IndexType.MANAGED_AZURE_SEARCH; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("version".equals(fieldName)) { + version = reader.getString(); + } else if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("description".equals(fieldName)) { + description = reader.getString(); + } else if ("tags".equals(fieldName)) { + tags = reader.readMap(reader1 -> reader1.getString()); + } else if ("vectorStoreId".equals(fieldName)) { + vectorStoreId = reader.getString(); + } else if ("type".equals(fieldName)) { + type = IndexType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + ManagedAzureAISearchIndex deserializedManagedAzureAISearchIndex + = new ManagedAzureAISearchIndex(vectorStoreId); + deserializedManagedAzureAISearchIndex.setName(name); + deserializedManagedAzureAISearchIndex.setVersion(version); + deserializedManagedAzureAISearchIndex.setId(id); + deserializedManagedAzureAISearchIndex.setDescription(description); + deserializedManagedAzureAISearchIndex.setTags(tags); + deserializedManagedAzureAISearchIndex.type = type; + + 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..532db55bcdc7 --- /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; + + /* + * Name of Azure blob storage connection 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: Name of Azure blob storage connection to use for generating temporary SAS token. + * + * @return the connectionName value. + */ + @Generated + public String getConnectionName() { + return this.connectionName; + } + + /** + * Set the connectionName property: Name of Azure blob storage connection 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..67ccd34f9ce8 --- /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.FileDatasetVersion": "Azure.AI.Projects.FileDatasetVersion", + "com.azure.ai.projects.models.FolderDatasetVersion": "Azure.AI.Projects.FolderDatasetVersion", + "com.azure.ai.projects.models.GetCredentialsRequest": "Azure.AI.Projects.getCredentials.Request.anonymous", + "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..dc69828d4d25 --- /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, 6, 12); + // 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..a33d50a0cac4 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DatasetsGetCredentialsMaximumSet.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.AssetCredentialResponse; +import com.azure.ai.projects.models.GetCredentialsRequest; +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", new GetCredentialsRequest()); + // 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..ae574730d7e9 --- /dev/null +++ b/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects/generated/DatasetsGetCredentialsMinimumSet.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.AssetCredentialResponse; +import com.azure.ai.projects.models.GetCredentialsRequest; +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", new GetCredentialsRequest()); + // 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..9a13d29af865 --- /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, 6, 12); + // 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..a4a15c19be0a --- /dev/null +++ b/sdk/ai/azure-ai-projects/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/ai/Azure.AI.Projects +commit: 344628ab8afe090ec1997c84b55954c9d216e9f7 +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