diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml index 90518ee2490f1..414279269571e 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml @@ -47,7 +47,7 @@ com.azure azure-core - 1.32.0 + 1.33.0-beta.1 com.azure diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryAsyncClientTests.getSchemaByGroupNameVersion.json b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryAsyncClientTests.getSchemaByGroupNameVersion.json new file mode 100644 index 0000000000000..0967ef424bce6 --- /dev/null +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryAsyncClientTests.getSchemaByGroupNameVersion.json @@ -0,0 +1 @@ +{} diff --git a/sdk/schemaregistry/azure-data-schemaregistry/CHANGELOG.md b/sdk/schemaregistry/azure-data-schemaregistry/CHANGELOG.md index 618d77af01930..f340637ff4226 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry/CHANGELOG.md +++ b/sdk/schemaregistry/azure-data-schemaregistry/CHANGELOG.md @@ -4,6 +4,14 @@ ### Features Added +- Added `getVersion` to `SchemaProperties`. +- Added the following methods in `SchemaRegistryAsyncClient`: + - `Mono getSchema(String groupName, String schemaName, int schemaVersion)` + - `Mono> getSchemaWithResponse(String groupName, String schemaName, int schemaVersion)` +- Added the following methods in `SchemaRegistryClient`: + - `SchemaRegistrySchema getSchema(String groupName, String schemaName, int schemaVersion)` + - `Response getSchemaWithResponse(String groupName, String schemaName, int schemaVersion, Context context)` + ### Breaking Changes ### Bugs Fixed diff --git a/sdk/schemaregistry/azure-data-schemaregistry/pom.xml b/sdk/schemaregistry/azure-data-schemaregistry/pom.xml index 23906a86bd6b2..bf00f827c0fe4 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry/pom.xml +++ b/sdk/schemaregistry/azure-data-schemaregistry/pom.xml @@ -39,7 +39,10 @@ + --add-opens com.azure.core/com.azure.core.implementation.util=ALL-UNNAMED --add-opens com.azure.data.schemaregistry/com.azure.data.schemaregistry=ALL-UNNAMED + + --add-exports com.azure.core/com.azure.core.implementation.util=ALL-UNNAMED --add-exports com.azure.data.schemaregistry/com.azure.data.schemaregistry.implementation.models=ALL-UNNAMED **/implementation/**/*.java @@ -49,7 +52,7 @@ com.azure azure-core - 1.32.0 + 1.33.0-beta.1 com.azure diff --git a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/SchemaRegistryAsyncClient.java b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/SchemaRegistryAsyncClient.java index 2250d72e46020..61dd48fb48fad 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/SchemaRegistryAsyncClient.java +++ b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/SchemaRegistryAsyncClient.java @@ -10,18 +10,23 @@ import com.azure.core.exception.ResourceNotFoundException; import com.azure.core.http.rest.Response; import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.BinaryData; import com.azure.core.util.Context; import com.azure.core.util.FluxUtil; import com.azure.core.util.logging.ClientLogger; import com.azure.data.schemaregistry.implementation.AzureSchemaRegistryImpl; import com.azure.data.schemaregistry.implementation.SchemaRegistryHelper; import com.azure.data.schemaregistry.implementation.models.ErrorException; -import com.azure.data.schemaregistry.implementation.models.SchemasQueryIdByContentHeaders; import com.azure.data.schemaregistry.models.SchemaFormat; import com.azure.data.schemaregistry.models.SchemaProperties; import com.azure.data.schemaregistry.models.SchemaRegistrySchema; import reactor.core.publisher.Mono; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.UncheckedIOException; import java.nio.charset.StandardCharsets; import java.util.Objects; @@ -160,9 +165,10 @@ Mono> registerSchemaWithResponse(String groupName, St logger.verbose("Registering schema. Group: '{}', name: '{}', serialization type: '{}', payload: '{}'", groupName, name, format, schemaDefinition); - final String contentType = getContentType(format); + final BinaryData binaryData = BinaryData.fromString(schemaDefinition); - return restService.getSchemas().registerWithResponseAsync(groupName, name, schemaDefinition, contentType, context) + return restService.getSchemas().registerWithResponseAsync(groupName, name, binaryData, binaryData.getLength(), + context) .map(response -> { final SchemaProperties registered = SchemaRegistryHelper.getSchemaProperties(response); @@ -177,33 +183,77 @@ Mono> registerSchemaWithResponse(String groupName, St * * @param schemaId The unique identifier of the schema. * - * @return The {@link SchemaProperties} associated with the given {@code schemaId}. + * @return The {@link SchemaRegistrySchema} associated with the given {@code schemaId}. * * @throws NullPointerException if {@code schemaId} is null. * @throws ResourceNotFoundException if a schema with the matching {@code schemaId} could not be found. * @throws HttpResponseException if an issue was encountered while fetching the schema. + * @throws UncheckedIOException if an error occurred while deserializing response. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono getSchema(String schemaId) { return getSchemaWithResponse(schemaId).map(Response::getValue); } + /** + * Gets the schema properties of the schema associated with the group name, schema name, and schema version. + * + * @param groupName Group name for the schema + * @param schemaName Name of the schema + * @param schemaVersion Version of schema + * + * @return The {@link SchemaRegistrySchema} matching the parameters. + * + * @throws NullPointerException if {@code groupName} or {@code schemaName} is null. + * @throws ResourceNotFoundException if a schema with the matching {@code groupName} or {@code schemaName} could + * not be found. + * @throws HttpResponseException if an issue was encountered while fetching the schema. + * @throws UncheckedIOException if an error occurred while deserializing response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getSchema(String groupName, String schemaName, int schemaVersion) { + return getSchemaWithResponse(groupName, schemaName, schemaVersion).map(Response::getValue); + } + /** * Gets the schema properties of the schema associated with the unique schema id. * * @param schemaId The unique identifier of the schema. * - * @return The {@link SchemaProperties} associated with the given {@code schemaId} along with the HTTP response. + * @return The {@link SchemaRegistrySchema} associated with the given {@code schemaId} along with the HTTP response. * * @throws NullPointerException if {@code schemaId} is null. * @throws ResourceNotFoundException if a schema with the matching {@code schemaId} could not be found. * @throws HttpResponseException if an issue was encountered while fetching the schema. + * @throws UncheckedIOException if an error occurred while deserializing response. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getSchemaWithResponse(String schemaId) { return FluxUtil.withContext(context -> getSchemaWithResponse(schemaId, context)); } + /** + * Gets the schema properties of the schema associated with the group name, schema name, and schema version. + * + * @param groupName Group name for the schema + * @param schemaName Name of the schema + * @param schemaVersion Version of schema + * + * @return The {@link SchemaRegistrySchema} matching the parameters. + * + * @throws NullPointerException if {@code groupName} or {@code schemaName} is null. + * @throws ResourceNotFoundException if a schema with the matching {@code groupName} or {@code schemaName} could + * not be found. + * @throws HttpResponseException if an issue was encountered while fetching the schema. + * @throws UncheckedIOException if an error occurred while deserializing response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getSchemaWithResponse(String groupName, String schemaName, + int schemaVersion) { + + return FluxUtil.withContext(context -> getSchemaWithResponse(groupName, schemaName, schemaVersion, context)); + } + Mono> getSchemaWithResponse(String schemaId, Context context) { if (Objects.isNull(schemaId)) { return monoError(logger, new NullPointerException("'schemaId' should not be null.")); @@ -211,13 +261,58 @@ Mono> getSchemaWithResponse(String schemaId, Cont return this.restService.getSchemas().getByIdWithResponseAsync(schemaId, context) .onErrorMap(ErrorException.class, SchemaRegistryAsyncClient::remapError) - .map(response -> { + .handle((response, sink) -> { final SchemaProperties schemaObject = SchemaRegistryHelper.getSchemaProperties(response); - final String schema = new String(response.getValue(), StandardCharsets.UTF_8); + final String schema; - return new SimpleResponse<>( + try { + schema = convertToString(response.getValue()); + } catch (UncheckedIOException e) { + sink.error(e); + return; + } + + sink.next(new SimpleResponse<>( + response.getRequest(), response.getStatusCode(), + response.getHeaders(), new SchemaRegistrySchema(schemaObject, schema))); + sink.complete(); + }); + } + + Mono> getSchemaWithResponse(String groupName, String schemaName, int schemaVersion, + Context context) { + + if (Objects.isNull(groupName)) { + return monoError(logger, new NullPointerException("'groupName' should not be null.")); + } + + return this.restService.getSchemas().getSchemaVersionWithResponseAsync(groupName, schemaName, schemaVersion, + context) + .onErrorMap(ErrorException.class, SchemaRegistryAsyncClient::remapError) + .handle((response, sink) -> { + final InputStream schemaInputStream = response.getValue(); + final SchemaProperties schemaObject = SchemaRegistryHelper.getSchemaProperties(response); + final String schema; + + if (schemaInputStream == null) { + sink.error(new IllegalArgumentException(String.format( + "Schema definition should not be null. Group Name: %s. Schema Name: %s. Version: %d", + groupName, schemaName, schemaVersion))); + + return; + } + + try { + schema = convertToString(schemaInputStream); + } catch (UncheckedIOException e) { + sink.error(e); + return; + } + + sink.next(new SimpleResponse<>( response.getRequest(), response.getStatusCode(), - response.getHeaders(), new SchemaRegistrySchema(schemaObject, schema)); + response.getHeaders(), new SchemaRegistrySchema(schemaObject, schema))); + sink.complete(); }); } @@ -232,8 +327,8 @@ Mono> getSchemaWithResponse(String schemaId, Cont * * @return A mono that completes with the properties for a matching schema. * - * @throws NullPointerException if {@code groupName}, {@code name}, {@code schemaDefinition}, or {@code format} is - * null. + * @throws NullPointerException if {@code groupName}, {@code name}, {@code schemaDefinition}, or {@code format} + * is null. * @throws ResourceNotFoundException if a schema with matching parameters could not be located. * @throws HttpResponseException if an issue was encountered while finding a matching schema. */ @@ -255,8 +350,8 @@ public Mono getSchemaProperties(String groupName, String name, * * @return A mono that completes with the properties for a matching schema. * - * @throws NullPointerException if {@code groupName}, {@code name}, {@code schemaDefinition}, or {@code format} is - * null. + * @throws NullPointerException if {@code groupName}, {@code name}, {@code schemaDefinition}, or {@code format} + * is null. * @throws ResourceNotFoundException if a schema with matching parameters could not be located. * @throws HttpResponseException if an issue was encountered while finding a matching schema. */ @@ -279,8 +374,8 @@ public Mono> getSchemaPropertiesWithResponse(String g * * @return A mono that completes with the properties for a matching schema. * - * @throws NullPointerException if {@code groupName}, {@code name}, {@code schemaDefinition}, or {@code format} is - * null. + * @throws NullPointerException if {@code groupName}, {@code name}, {@code schemaDefinition}, or {@code format} + * is null. * @throws ResourceNotFoundException if a schema with matching parameters could not be located. * @throws HttpResponseException if an issue was encountered while finding a matching schema. */ @@ -301,13 +396,12 @@ Mono> getSchemaPropertiesWithResponse(String groupNam context = Context.NONE; } - final String contentType = getContentType(format); + final BinaryData binaryData = BinaryData.fromString(schemaDefinition); return restService.getSchemas() - .queryIdByContentWithResponseAsync(groupName, name, schemaDefinition, contentType, context) + .queryIdByContentWithResponseAsync(groupName, name, binaryData, binaryData.getLength(), context) .onErrorMap(ErrorException.class, SchemaRegistryAsyncClient::remapError) .map(response -> { - final SchemasQueryIdByContentHeaders deserializedHeaders = response.getDeserializedHeaders(); final SchemaProperties properties = SchemaRegistryHelper.getSchemaProperties(response); return new SimpleResponse<>( @@ -338,7 +432,30 @@ private static Throwable remapError(ErrorException error) { return error; } - private static String getContentType(SchemaFormat schemaFormat) { - return "application/json; serialization=" + schemaFormat; + /** + * Converts an input stream into its string representation. + * + * @param inputStream Input stream. + * + * @return A string representation. + * + * @throws UncheckedIOException if an {@link IOException} is thrown when creating the readers. + */ + private static String convertToString(InputStream inputStream) { + final StringBuilder builder = new StringBuilder(); + try (BufferedReader reader = new BufferedReader( + new InputStreamReader(inputStream, StandardCharsets.UTF_8))) { + + String str; + + while ((str = reader.readLine()) != null) { + builder.append(str); + } + + } catch (IOException exception) { + throw new UncheckedIOException("Error occurred while deserializing schemaContent.", exception); + } + + return builder.toString(); } } diff --git a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/SchemaRegistryClient.java b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/SchemaRegistryClient.java index 03f36b4b9692b..8fb045ebfdfd5 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/SchemaRegistryClient.java +++ b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/SchemaRegistryClient.java @@ -14,6 +14,8 @@ import com.azure.data.schemaregistry.models.SchemaProperties; import com.azure.data.schemaregistry.models.SchemaRegistrySchema; +import java.io.UncheckedIOException; + /** * HTTP-based client that interacts with Azure Schema Registry service to store and retrieve schemas on demand. * @@ -129,34 +131,78 @@ public Response registerSchemaWithResponse(String groupName, S * * @param schemaId The unique identifier of the schema. * - * @return The {@link SchemaProperties} associated with the given {@code schemaId}. + * @return The {@link SchemaRegistrySchema} associated with the given {@code schemaId}. * * @throws NullPointerException if {@code schemaId} is null. * @throws ResourceNotFoundException if a schema with the matching {@code schemaId} could not be found. * @throws HttpResponseException if an issue was encountered while fetching the schema. + * @throws UncheckedIOException if an error occurred while deserializing response. */ @ServiceMethod(returns = ReturnType.SINGLE) public SchemaRegistrySchema getSchema(String schemaId) { return this.asyncClient.getSchema(schemaId).block(); } + /** + * Gets the schema properties of the schema associated with the group name, schema name, and schema version. + * + * @param groupName Group name for the schema + * @param schemaName Name of the schema + * @param schemaVersion Version of schema + * + * @return The {@link SchemaRegistrySchema} matching the parameters. + * + * @throws NullPointerException if {@code groupName} or {@code schemaName} is null. + * @throws ResourceNotFoundException if a schema with the matching {@code groupName} or {@code schemaName} could + * not be found. + * @throws HttpResponseException if an issue was encountered while fetching the schema. + * @throws UncheckedIOException if an error occurred while deserializing response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SchemaRegistrySchema getSchema(String groupName, String schemaName, int schemaVersion) { + return this.asyncClient.getSchema(groupName, schemaName, schemaVersion).block(); + } + /** * Gets the schema properties of the schema associated with the unique schema id. * * @param schemaId The unique identifier of the schema. * @param context The context to pass to the Http pipeline. * - * @return The {@link SchemaProperties} associated with the given {@code schemaId} and its HTTP response. + * @return The {@link SchemaRegistrySchema} associated with the given {@code schemaId} and its HTTP response. * * @throws NullPointerException if {@code schemaId} is null. * @throws ResourceNotFoundException if a schema with the matching {@code schemaId} could not be found. * @throws HttpResponseException if an issue was encountered while fetching the schema. + * @throws UncheckedIOException if an error occurred while deserializing response. */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getSchemaWithResponse(String schemaId, Context context) { return this.asyncClient.getSchemaWithResponse(schemaId, context).block(); } + /** + * Gets the schema properties of the schema associated with the group name, schema name, and schema version. + * + * @param groupName Group name for the schema + * @param schemaName Name of the schema + * @param schemaVersion Version of schema + * @param context The context to pass to the Http pipeline. + * + * @return The {@link SchemaRegistrySchema} matching the parameters. + * + * @throws NullPointerException if {@code groupName} or {@code schemaName} is null. + * @throws ResourceNotFoundException if a schema with the matching {@code groupName} or {@code schemaName} could + * not be found. + * @throws HttpResponseException if an issue was encountered while fetching the schema. + * @throws UncheckedIOException if an error occurred while deserializing response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getSchemaWithResponse(String groupName, String schemaName, + int schemaVersion, Context context) { + return this.asyncClient.getSchemaWithResponse(groupName, schemaName, schemaVersion, context).block(); + } + /** * Gets schema properties for a schema with matching {@code groupName}, {@code name}, {@code schemaDefinition}, and * {@code format}. diff --git a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/AzureSchemaRegistryImplBuilder.java b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/AzureSchemaRegistryImplBuilder.java index 8d100c061310a..6985850a6c4a8 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/AzureSchemaRegistryImplBuilder.java +++ b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/AzureSchemaRegistryImplBuilder.java @@ -4,205 +4,207 @@ package com.azure.data.schemaregistry.implementation; +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.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.CookiePolicy; 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.serializer.JacksonAdapter; import com.azure.core.util.serializer.SerializerAdapter; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** A builder for creating a new instance of the AzureSchemaRegistry type. */ @ServiceClientBuilder(serviceClients = {AzureSchemaRegistryImpl.class}) -public final class AzureSchemaRegistryImplBuilder { - private static final String SDK_NAME = "name"; +public final class AzureSchemaRegistryImplBuilder + implements HttpTrait, + ConfigurationTrait, + EndpointTrait { + @Generated private static final String SDK_NAME = "name"; + + @Generated private static final String SDK_VERSION = "version"; - private static final String SDK_VERSION = "version"; + @Generated private final Map properties = new HashMap<>(); - private final Map properties = new HashMap<>(); + @Generated private final List pipelinePolicies; /** Create an instance of the AzureSchemaRegistryImplBuilder. */ + @Generated public AzureSchemaRegistryImplBuilder() { this.pipelinePolicies = new ArrayList<>(); } /* - * The Schema Registry service endpoint, for example - * my-namespace.servicebus.windows.net. + * The HTTP pipeline to send requests through. */ - private String endpoint; + @Generated private HttpPipeline pipeline; - /** - * Sets The Schema Registry service endpoint, for example my-namespace.servicebus.windows.net. - * - * @param endpoint the endpoint value. - * @return the AzureSchemaRegistryImplBuilder. - */ - public AzureSchemaRegistryImplBuilder endpoint(String endpoint) { - this.endpoint = endpoint; + /** {@inheritDoc}. */ + @Generated + @Override + public AzureSchemaRegistryImplBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; return this; } /* - * Api Version + * The HTTP client used to send the request. */ - private String apiVersion; + @Generated private HttpClient httpClient; - /** - * Sets Api Version. - * - * @param apiVersion the apiVersion value. - * @return the AzureSchemaRegistryImplBuilder. - */ - public AzureSchemaRegistryImplBuilder apiVersion(String apiVersion) { - this.apiVersion = apiVersion; + /** {@inheritDoc}. */ + @Generated + @Override + public AzureSchemaRegistryImplBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; return this; } /* - * The HTTP pipeline to send requests through + * The logging configuration for HTTP requests and responses. */ - private HttpPipeline pipeline; + @Generated private HttpLogOptions httpLogOptions; - /** - * Sets The HTTP pipeline to send requests through. - * - * @param pipeline the pipeline value. - * @return the AzureSchemaRegistryImplBuilder. - */ - public AzureSchemaRegistryImplBuilder pipeline(HttpPipeline pipeline) { - this.pipeline = pipeline; + /** {@inheritDoc}. */ + @Generated + @Override + public AzureSchemaRegistryImplBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; return this; } /* - * The serializer to serialize an object into a string + * The client options such as application ID and custom headers to set on a request. */ - private SerializerAdapter serializerAdapter; + @Generated private ClientOptions clientOptions; - /** - * Sets The serializer to serialize an object into a string. - * - * @param serializerAdapter the serializerAdapter value. - * @return the AzureSchemaRegistryImplBuilder. - */ - public AzureSchemaRegistryImplBuilder serializerAdapter(SerializerAdapter serializerAdapter) { - this.serializerAdapter = serializerAdapter; + /** {@inheritDoc}. */ + @Generated + @Override + public AzureSchemaRegistryImplBuilder clientOptions(ClientOptions clientOptions) { + this.clientOptions = clientOptions; return this; } /* - * The HTTP client used to send the request. + * The retry options to configure retry policy for failed requests. */ - private HttpClient httpClient; + @Generated private RetryOptions retryOptions; - /** - * Sets The HTTP client used to send the request. - * - * @param httpClient the httpClient value. - * @return the AzureSchemaRegistryImplBuilder. - */ - public AzureSchemaRegistryImplBuilder httpClient(HttpClient httpClient) { - this.httpClient = httpClient; + /** {@inheritDoc}. */ + @Generated + @Override + public AzureSchemaRegistryImplBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** {@inheritDoc}. */ + @Generated + @Override + public AzureSchemaRegistryImplBuilder addPolicy(HttpPipelinePolicy customPolicy) { + pipelinePolicies.add(customPolicy); return this; } /* - * The configuration store that is used during construction of the service - * client. + * The configuration store that is used during construction of the service client. */ - private Configuration configuration; + @Generated private Configuration configuration; - /** - * Sets The configuration store that is used during construction of the service client. - * - * @param configuration the configuration value. - * @return the AzureSchemaRegistryImplBuilder. - */ + /** {@inheritDoc}. */ + @Generated + @Override public AzureSchemaRegistryImplBuilder configuration(Configuration configuration) { this.configuration = configuration; return this; } /* - * The logging configuration for HTTP requests and responses. + * The service endpoint */ - private HttpLogOptions httpLogOptions; + @Generated private String endpoint; - /** - * Sets The logging configuration for HTTP requests and responses. - * - * @param httpLogOptions the httpLogOptions value. - * @return the AzureSchemaRegistryImplBuilder. - */ - public AzureSchemaRegistryImplBuilder httpLogOptions(HttpLogOptions httpLogOptions) { - this.httpLogOptions = httpLogOptions; + /** {@inheritDoc}. */ + @Generated + @Override + public AzureSchemaRegistryImplBuilder endpoint(String endpoint) { + this.endpoint = endpoint; return this; } /* - * The retry policy that will attempt to retry failed requests, if - * applicable. + * Api Version */ - private RetryPolicy retryPolicy; + @Generated private String apiVersion; /** - * Sets The retry policy that will attempt to retry failed requests, if applicable. + * Sets Api Version. * - * @param retryPolicy the retryPolicy value. + * @param apiVersion the apiVersion value. * @return the AzureSchemaRegistryImplBuilder. */ - public AzureSchemaRegistryImplBuilder retryPolicy(RetryPolicy retryPolicy) { - this.retryPolicy = retryPolicy; + @Generated + public AzureSchemaRegistryImplBuilder apiVersion(String apiVersion) { + this.apiVersion = apiVersion; return this; } /* - * The list of Http pipeline policies to add. - */ - private final List pipelinePolicies; - - /* - * The client options such as application ID and custom headers to set on a - * request. + * The serializer to serialize an object into a string */ - private ClientOptions clientOptions; + @Generated private SerializerAdapter serializerAdapter; /** - * Sets The client options such as application ID and custom headers to set on a request. + * Sets The serializer to serialize an object into a string. * - * @param clientOptions the clientOptions value. + * @param serializerAdapter the serializerAdapter value. * @return the AzureSchemaRegistryImplBuilder. */ - public AzureSchemaRegistryImplBuilder clientOptions(ClientOptions clientOptions) { - this.clientOptions = clientOptions; + @Generated + public AzureSchemaRegistryImplBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; return this; } + /* + * The retry policy that will attempt to retry failed requests, if applicable. + */ + @Generated private RetryPolicy retryPolicy; + /** - * Adds a custom Http pipeline policy. + * Sets The retry policy that will attempt to retry failed requests, if applicable. * - * @param customPolicy The custom Http pipeline policy to add. + * @param retryPolicy the retryPolicy value. * @return the AzureSchemaRegistryImplBuilder. */ - public AzureSchemaRegistryImplBuilder addPolicy(HttpPipelinePolicy customPolicy) { - pipelinePolicies.add(customPolicy); + @Generated + public AzureSchemaRegistryImplBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; return this; } @@ -211,20 +213,18 @@ public AzureSchemaRegistryImplBuilder addPolicy(HttpPipelinePolicy customPolicy) * * @return an instance of AzureSchemaRegistryImpl. */ + @Generated public AzureSchemaRegistryImpl buildClient() { - if (apiVersion == null) { - this.apiVersion = "2021-10"; - } - if (pipeline == null) { - this.pipeline = createHttpPipeline(); - } - if (serializerAdapter == null) { - this.serializerAdapter = JacksonAdapter.createDefaultSerializerAdapter(); - } - AzureSchemaRegistryImpl client = new AzureSchemaRegistryImpl(pipeline, serializerAdapter, endpoint, apiVersion); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localApiVersion = (apiVersion != null) ? apiVersion : "2021-10"; + SerializerAdapter localSerializerAdapter = + (serializerAdapter != null) ? serializerAdapter : JacksonAdapter.createDefaultSerializerAdapter(); + AzureSchemaRegistryImpl client = + new AzureSchemaRegistryImpl(localPipeline, localSerializerAdapter, endpoint, localApiVersion); return client; } + @Generated private HttpPipeline createHttpPipeline() { Configuration buildConfiguration = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; @@ -239,21 +239,32 @@ private HttpPipeline createHttpPipeline() { String clientVersion = properties.getOrDefault(SDK_VERSION, "UnknownVersion"); String applicationId = CoreUtils.getApplicationId(clientOptions, httpLogOptions); policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); + policies.add(new RequestIdPolicy()); + policies.add(new AddHeadersFromContextPolicy()); HttpHeaders headers = new HttpHeaders(); clientOptions.getHeaders().forEach(header -> headers.set(header.getName(), header.getValue())); if (headers.getSize() > 0) { policies.add(new AddHeadersPolicy(headers)); } + policies.addAll( + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .collect(Collectors.toList())); HttpPolicyProviders.addBeforeRetryPolicies(policies); - policies.add(retryPolicy == null ? new RetryPolicy() : retryPolicy); + policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); + policies.add(new AddDatePolicy()); policies.add(new CookiePolicy()); - policies.addAll(this.pipelinePolicies); + policies.addAll( + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .collect(Collectors.toList())); HttpPolicyProviders.addAfterRetryPolicies(policies); policies.add(new HttpLoggingPolicy(httpLogOptions)); HttpPipeline httpPipeline = new HttpPipelineBuilder() .policies(policies.toArray(new HttpPipelinePolicy[0])) .httpClient(httpClient) + .clientOptions(clientOptions) .build(); return httpPipeline; } diff --git a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/SchemaGroupsOperationsImpl.java b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/SchemaGroupsOperationsImpl.java index f88d8c23647e1..fafbf4c937430 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/SchemaGroupsOperationsImpl.java +++ b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/SchemaGroupsOperationsImpl.java @@ -58,13 +58,16 @@ Mono> list( } /** - * Gets the list of schema groups user is authorized to access. + * Get list of schema groups. + * + *

Gets the list of schema groups user is authorized to access. * * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of schema groups user is authorized to access. + * @return the list of schema groups user is authorized to access along with {@link Response} on successful + * completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> listWithResponseAsync(Context context) { diff --git a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/SchemaRegistryHelper.java b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/SchemaRegistryHelper.java index 599d2914689cf..289333f6e9c98 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/SchemaRegistryHelper.java +++ b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/SchemaRegistryHelper.java @@ -4,6 +4,8 @@ import com.azure.data.schemaregistry.implementation.models.SchemasGetByIdHeaders; import com.azure.data.schemaregistry.implementation.models.SchemasGetByIdResponse; +import com.azure.data.schemaregistry.implementation.models.SchemasGetSchemaVersionHeaders; +import com.azure.data.schemaregistry.implementation.models.SchemasGetSchemaVersionResponse; import com.azure.data.schemaregistry.implementation.models.SchemasQueryIdByContentHeaders; import com.azure.data.schemaregistry.implementation.models.SchemasQueryIdByContentResponse; import com.azure.data.schemaregistry.implementation.models.SchemasRegisterHeaders; @@ -23,7 +25,8 @@ public final class SchemaRegistryHelper { * Accessor interface. */ public interface SchemaRegistryModelsAccessor { - SchemaProperties getSchemaProperties(String id, SchemaFormat format, String groupName, String name); + SchemaProperties getSchemaProperties(String id, SchemaFormat format, String groupName, String name, + int version); } /** @@ -39,21 +42,29 @@ public static SchemaProperties getSchemaProperties(SchemasRegisterResponse respo final SchemasRegisterHeaders headers = response.getDeserializedHeaders(); return accessor.getSchemaProperties(headers.getSchemaId(), SchemaFormat.AVRO, headers.getSchemaGroupName(), - headers.getSchemaName()); + headers.getSchemaName(), headers.getSchemaVersion()); } public static SchemaProperties getSchemaProperties(SchemasGetByIdResponse response) { final SchemasGetByIdHeaders headers = response.getDeserializedHeaders(); return accessor.getSchemaProperties(headers.getSchemaId(), SchemaFormat.AVRO, headers.getSchemaGroupName(), - headers.getSchemaName()); + headers.getSchemaName(), headers.getSchemaVersion()); } public static SchemaProperties getSchemaProperties(SchemasQueryIdByContentResponse response) { final SchemasQueryIdByContentHeaders headers = response.getDeserializedHeaders(); return accessor.getSchemaProperties(headers.getSchemaId(), SchemaFormat.AVRO, headers.getSchemaGroupName(), - headers.getSchemaName()); + headers.getSchemaName(), headers.getSchemaVersion()); } + + public static SchemaProperties getSchemaProperties(SchemasGetSchemaVersionResponse response) { + final SchemasGetSchemaVersionHeaders headers = response.getDeserializedHeaders(); + + return accessor.getSchemaProperties(headers.getSchemaId(), SchemaFormat.AVRO, headers.getSchemaGroupName(), + headers.getSchemaName(), headers.getSchemaVersion()); + } + } diff --git a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/SchemasImpl.java b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/SchemasImpl.java index 6b73c5465d657..309267d3348ce 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/SchemasImpl.java +++ b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/SchemasImpl.java @@ -20,12 +20,16 @@ import com.azure.core.annotation.UnexpectedResponseExceptionType; 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.data.schemaregistry.implementation.models.ErrorException; import com.azure.data.schemaregistry.implementation.models.SchemaVersions; import com.azure.data.schemaregistry.implementation.models.SchemasGetByIdResponse; +import com.azure.data.schemaregistry.implementation.models.SchemasGetSchemaVersionResponse; import com.azure.data.schemaregistry.implementation.models.SchemasQueryIdByContentResponse; import com.azure.data.schemaregistry.implementation.models.SchemasRegisterResponse; +import java.nio.ByteBuffer; +import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; /** An instance of this class provides access to all the operations defined in Schemas. */ @@ -74,6 +78,18 @@ Mono> getVersions( @HeaderParam("Accept") String accept, Context context); + @Get("/$schemaGroups/{groupName}/schemas/{schemaName}/versions/{schemaVersion}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ErrorException.class) + Mono getSchemaVersion( + @HostParam("endpoint") String endpoint, + @PathParam("groupName") String groupName, + @PathParam("schemaName") String schemaName, + @PathParam("schemaVersion") int schemaVersion, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + @Post("/$schemaGroups/{groupName}/schemas/{schemaName}:get-id") @ExpectedResponses({204}) @UnexpectedResponseExceptionType( @@ -85,8 +101,24 @@ Mono queryIdByContent( @PathParam("groupName") String groupName, @PathParam("schemaName") String schemaName, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json; serialization=Avro") String schemaContent, - @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json; serialization=Avro") Flux schemaContent, + @HeaderParam("Content-Length") long contentLength, + @HeaderParam("Accept") String accept, + Context context); + + @Post("/$schemaGroups/{groupName}/schemas/{schemaName}:get-id") + @ExpectedResponses({204}) + @UnexpectedResponseExceptionType( + value = ErrorException.class, + code = {415}) + @UnexpectedResponseExceptionType(ErrorException.class) + Mono queryIdByContent( + @HostParam("endpoint") String endpoint, + @PathParam("groupName") String groupName, + @PathParam("schemaName") String schemaName, + @QueryParam("api-version") String apiVersion, + @BodyParam("application/json; serialization=Avro") BinaryData schemaContent, + @HeaderParam("Content-Length") long contentLength, @HeaderParam("Accept") String accept, Context context); @@ -101,40 +133,61 @@ Mono register( @PathParam("groupName") String groupName, @PathParam("schemaName") String schemaName, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json; serialization=Avro") String schemaContent, - @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json; serialization=Avro") Flux schemaContent, + @HeaderParam("Content-Length") long contentLength, + @HeaderParam("Accept") String accept, + Context context); + + @Put("/$schemaGroups/{groupName}/schemas/{schemaName}") + @ExpectedResponses({204}) + @UnexpectedResponseExceptionType( + value = ErrorException.class, + code = {415}) + @UnexpectedResponseExceptionType(ErrorException.class) + Mono register( + @HostParam("endpoint") String endpoint, + @PathParam("groupName") String groupName, + @PathParam("schemaName") String schemaName, + @QueryParam("api-version") String apiVersion, + @BodyParam("application/json; serialization=Avro") BinaryData schemaContent, + @HeaderParam("Content-Length") long contentLength, @HeaderParam("Accept") String accept, Context context); } /** - * Gets a registered schema by its unique ID. Azure Schema Registry guarantees that ID is unique within a namespace. - * Operation response type is based on serialization of schema requested. + * Get a registered schema by its unique ID reference. + * + *

Gets a registered schema by its unique ID. Azure Schema Registry guarantees that ID is unique within a + * namespace. Operation response type is based on serialization of schema requested. * * @param id References specific schema in registry namespace. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a registered schema by its unique ID. + * @return a registered schema by its unique ID on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono getByIdWithResponseAsync(String id, Context context) { - final String accept = "application/json; serialization=avro"; + final String accept = "application/json; serialization=Avro"; return service.getById(this.client.getEndpoint(), id, this.client.getApiVersion(), accept, context); } /** - * Gets the list of all versions of one schema. + * Get list schema versions. + * + *

Gets the list of all versions of one schema. * * @param groupName Schema group under which schema is registered. Group's serialization type should match the * serialization type specified in the request. - * @param schemaName Name of schema being registered. + * @param schemaName Name of schema. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of all versions of one schema. + * @return the list of all versions of one schema along with {@link Response} on successful completion of {@link + * Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getVersionsWithResponseAsync( @@ -145,25 +198,90 @@ public Mono> getVersionsWithResponseAsync( } /** - * Gets the ID referencing an existing schema within the specified schema group, as matched by schema content + * Get specific schema versions. + * + *

Gets one specific version of one schema. + * + * @param groupName Schema group under which schema is registered. Group's serialization type should match the + * serialization type specified in the request. + * @param schemaName Name of schema. + * @param schemaVersion Version number of specific schema. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return one specific version of one schema on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getSchemaVersionWithResponseAsync( + String groupName, String schemaName, int schemaVersion, Context context) { + final String accept = "application/json"; + return service.getSchemaVersion( + this.client.getEndpoint(), + groupName, + schemaName, + schemaVersion, + this.client.getApiVersion(), + accept, + context); + } + + /** + * Get ID for existing schema. + * + *

Gets the ID referencing an existing schema within the specified schema group, as matched by schema content + * comparison. + * + * @param groupName Schema group under which schema is registered. Group's serialization type should match the + * serialization type specified in the request. + * @param schemaName Name of schema. + * @param schemaContent String representation (UTF-8) of the registered schema. + * @param contentLength The Content-Length header for the request. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorException thrown if the request is rejected by server. + * @throws ErrorException thrown if the request is rejected by server on status code 415. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the ID referencing an existing schema within the specified schema group, as matched by schema content + * comparison on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono queryIdByContentWithResponseAsync( + String groupName, String schemaName, Flux schemaContent, long contentLength, Context context) { + final String accept = "application/json"; + return service.queryIdByContent( + this.client.getEndpoint(), + groupName, + schemaName, + this.client.getApiVersion(), + schemaContent, + contentLength, + accept, + context); + } + + /** + * Get ID for existing schema. + * + *

Gets the ID referencing an existing schema within the specified schema group, as matched by schema content * comparison. * * @param groupName Schema group under which schema is registered. Group's serialization type should match the * serialization type specified in the request. - * @param schemaName Name of requested schema. + * @param schemaName Name of schema. * @param schemaContent String representation (UTF-8) of the registered schema. - * @param contentType The contentType parameter. + * @param contentLength The Content-Length header for the request. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorException thrown if the request is rejected by server. * @throws ErrorException thrown if the request is rejected by server on status code 415. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the ID referencing an existing schema within the specified schema group, as matched by schema content - * comparison. + * comparison on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono queryIdByContentWithResponseAsync( - String groupName, String schemaName, String schemaContent, String contentType, Context context) { + String groupName, String schemaName, BinaryData schemaContent, long contentLength, Context context) { final String accept = "application/json"; return service.queryIdByContent( this.client.getEndpoint(), @@ -171,29 +289,67 @@ public Mono queryIdByContentWithResponseAsync( schemaName, this.client.getApiVersion(), schemaContent, - contentType, + contentLength, + accept, + context); + } + + /** + * Register new schema + * + *

Register new schema. If schema of specified name does not exist in specified group, schema is created at + * version 1. If schema of specified name exists already in specified group, schema is created at latest version + + * 1. + * + * @param groupName Schema group under which schema should be registered. Group's serialization type should match + * the serialization type specified in the request. + * @param schemaName Name of schema. + * @param schemaContent String representation (UTF-8) of the schema being registered. + * @param contentLength The Content-Length header for the request. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorException thrown if the request is rejected by server. + * @throws ErrorException thrown if the request is rejected by server on status code 415. + * @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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono registerWithResponseAsync( + String groupName, String schemaName, Flux schemaContent, long contentLength, Context context) { + final String accept = "application/json"; + return service.register( + this.client.getEndpoint(), + groupName, + schemaName, + this.client.getApiVersion(), + schemaContent, + contentLength, accept, context); } /** - * Register new schema. If schema of specified name does not exist in specified group, schema is created at version - * 1. If schema of specified name exists already in specified group, schema is created at latest version + 1. + * Register new schema + * + *

Register new schema. If schema of specified name does not exist in specified group, schema is created at + * version 1. If schema of specified name exists already in specified group, schema is created at latest version + + * 1. * * @param groupName Schema group under which schema should be registered. Group's serialization type should match * the serialization type specified in the request. - * @param schemaName Name of schema being registered. + * @param schemaName Name of schema. * @param schemaContent String representation (UTF-8) of the schema being registered. + * @param contentLength The Content-Length header for the request. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ErrorException thrown if the request is rejected by server. * @throws ErrorException thrown if the request is rejected by server on status code 415. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the completion. + * @return A {@link Mono} that completes when a successful response is received. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono registerWithResponseAsync( - String groupName, String schemaName, String schemaContent, String contentType, Context context) { + String groupName, String schemaName, BinaryData schemaContent, long contentLength, Context context) { final String accept = "application/json"; return service.register( this.client.getEndpoint(), @@ -201,7 +357,7 @@ public Mono registerWithResponseAsync( schemaName, this.client.getApiVersion(), schemaContent, - contentType, + contentLength, accept, context); } diff --git a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/ErrorDetail.java b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/ErrorDetail.java index d2090704a6ed6..c1cec549d4170 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/ErrorDetail.java +++ b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/ErrorDetail.java @@ -6,7 +6,6 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; - import java.util.List; /** Error response returned from Azure Schema Registry service. */ diff --git a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/ErrorException.java b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/ErrorException.java index 1e48076d522df..331ace0b96d24 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/ErrorException.java +++ b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/ErrorException.java @@ -30,6 +30,7 @@ public ErrorException(String message, HttpResponse response, Error value) { super(message, response, value); } + /** {@inheritDoc} */ @Override public Error getValue() { return (Error) super.getValue(); diff --git a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/SchemaGroups.java b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/SchemaGroups.java index 380a81a791024..e7de5f685e384 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/SchemaGroups.java +++ b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/SchemaGroups.java @@ -6,7 +6,6 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; - import java.util.List; /** Array received from the registry containing the list of schema groups. */ diff --git a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/SchemaVersions.java b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/SchemaVersions.java index c046ebfcfdf58..d981a6636e3b4 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/SchemaVersions.java +++ b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/SchemaVersions.java @@ -6,7 +6,6 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; - import java.util.List; /** Array received from the registry containing the list of versions for specific schema. */ diff --git a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/SchemasGetByIdHeaders.java b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/SchemasGetByIdHeaders.java index ed6a9bd4cbbbd..2db54c3b8d083 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/SchemasGetByIdHeaders.java +++ b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/SchemasGetByIdHeaders.java @@ -5,6 +5,7 @@ package com.azure.data.schemaregistry.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.http.HttpHeaders; import com.fasterxml.jackson.annotation.JsonProperty; /** The SchemasGetByIdHeaders model. */ @@ -52,6 +53,22 @@ public final class SchemasGetByIdHeaders { @JsonProperty(value = "Content-Type") private String contentType; + // HttpHeaders containing the raw property values. + /** + * Creates an instance of SchemasGetByIdHeaders class. + * + * @param rawHeaders The raw HttpHeaders that will be used to create the property values. + */ + public SchemasGetByIdHeaders(HttpHeaders rawHeaders) { + this.schemaVersion = Integer.parseInt(rawHeaders.getValue("Schema-Version")); + this.schemaId = rawHeaders.getValue("Schema-Id"); + this.schemaGroupName = rawHeaders.getValue("Schema-Group-Name"); + this.schemaName = rawHeaders.getValue("Schema-Name"); + this.schemaIdLocation = rawHeaders.getValue("Schema-Id-Location"); + this.location = rawHeaders.getValue("Location"); + this.contentType = rawHeaders.getValue("Content-Type"); + } + /** * Get the schemaVersion property: The Schema-Version property. * diff --git a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/SchemasGetByIdResponse.java b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/SchemasGetByIdResponse.java index 9813cb4658af9..19fd11da5bb9c 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/SchemasGetByIdResponse.java +++ b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/SchemasGetByIdResponse.java @@ -7,11 +7,10 @@ import com.azure.core.http.HttpHeaders; import com.azure.core.http.HttpRequest; import com.azure.core.http.rest.ResponseBase; - -import java.nio.ByteBuffer; +import java.io.InputStream; /** Contains all response data for the getById operation. */ -public final class SchemasGetByIdResponse extends ResponseBase { +public final class SchemasGetByIdResponse extends ResponseBase { /** * Creates an instance of SchemasGetByIdResponse. * @@ -22,7 +21,21 @@ public final class SchemasGetByIdResponse extends ResponseBase { + /** + * Creates an instance of SchemasGetSchemaVersionResponse. + * + * @param request the request which resulted in this SchemasGetSchemaVersionResponse. + * @param statusCode the status code of the HTTP response. + * @param rawHeaders the raw headers of the HTTP response. + * @param value the deserialized value of the HTTP response. + * @param headers the deserialized headers of the HTTP response. + */ + public SchemasGetSchemaVersionResponse( + HttpRequest request, + int statusCode, + HttpHeaders rawHeaders, + InputStream value, + SchemasGetSchemaVersionHeaders headers) { + super(request, statusCode, rawHeaders, value, headers); + } + + /** + * Gets the deserialized response body. + * + * @return the deserialized response body. + */ + @Override + public InputStream getValue() { + return super.getValue(); + } +} diff --git a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/SchemasQueryIdByContentHeaders.java b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/SchemasQueryIdByContentHeaders.java index a79313098ce50..09f21395c1736 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/SchemasQueryIdByContentHeaders.java +++ b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/SchemasQueryIdByContentHeaders.java @@ -5,6 +5,7 @@ package com.azure.data.schemaregistry.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.http.HttpHeaders; import com.fasterxml.jackson.annotation.JsonProperty; /** The SchemasQueryIdByContentHeaders model. */ @@ -46,6 +47,21 @@ public final class SchemasQueryIdByContentHeaders { @JsonProperty(value = "Location") private String location; + // HttpHeaders containing the raw property values. + /** + * Creates an instance of SchemasQueryIdByContentHeaders class. + * + * @param rawHeaders The raw HttpHeaders that will be used to create the property values. + */ + public SchemasQueryIdByContentHeaders(HttpHeaders rawHeaders) { + this.schemaVersion = Integer.parseInt(rawHeaders.getValue("Schema-Version")); + this.schemaId = rawHeaders.getValue("Schema-Id"); + this.schemaGroupName = rawHeaders.getValue("Schema-Group-Name"); + this.schemaName = rawHeaders.getValue("Schema-Name"); + this.schemaIdLocation = rawHeaders.getValue("Schema-Id-Location"); + this.location = rawHeaders.getValue("Location"); + } + /** * Get the schemaVersion property: The Schema-Version property. * diff --git a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/SchemasRegisterHeaders.java b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/SchemasRegisterHeaders.java index 8bceceafbbc27..5bec46ebb9837 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/SchemasRegisterHeaders.java +++ b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/implementation/models/SchemasRegisterHeaders.java @@ -5,6 +5,7 @@ package com.azure.data.schemaregistry.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.http.HttpHeaders; import com.fasterxml.jackson.annotation.JsonProperty; /** The SchemasRegisterHeaders model. */ @@ -46,6 +47,21 @@ public final class SchemasRegisterHeaders { @JsonProperty(value = "Location") private String location; + // HttpHeaders containing the raw property values. + /** + * Creates an instance of SchemasRegisterHeaders class. + * + * @param rawHeaders The raw HttpHeaders that will be used to create the property values. + */ + public SchemasRegisterHeaders(HttpHeaders rawHeaders) { + this.schemaVersion = Integer.parseInt(rawHeaders.getValue("Schema-Version")); + this.schemaId = rawHeaders.getValue("Schema-Id"); + this.schemaGroupName = rawHeaders.getValue("Schema-Group-Name"); + this.schemaName = rawHeaders.getValue("Schema-Name"); + this.schemaIdLocation = rawHeaders.getValue("Schema-Id-Location"); + this.location = rawHeaders.getValue("Location"); + } + /** * Get the schemaVersion property: The Schema-Version property. * diff --git a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/models/SchemaProperties.java b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/models/SchemaProperties.java index 848de66f6d4e4..177ac3907ac08 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/models/SchemaProperties.java +++ b/sdk/schemaregistry/azure-data-schemaregistry/src/main/java/com/azure/data/schemaregistry/models/SchemaProperties.java @@ -21,12 +21,14 @@ public final class SchemaProperties { private final SchemaFormat format; private final String groupName; private final String name; + private final int version; static { SchemaRegistryHelper.setAccessor(new SchemaRegistryHelper.SchemaRegistryModelsAccessor() { @Override - public SchemaProperties getSchemaProperties(String id, SchemaFormat format, String groupName, String name) { - return new SchemaProperties(id, format, groupName, name); + public SchemaProperties getSchemaProperties(String id, SchemaFormat format, String groupName, String name, + int version) { + return new SchemaProperties(id, format, groupName, name, version); } }); } @@ -38,7 +40,7 @@ public SchemaProperties getSchemaProperties(String id, SchemaFormat format, Stri * @param format The type of schema, e.g. avro, json. */ public SchemaProperties(String id, SchemaFormat format) { - this(id, format, null, null); + this(id, format, null, null, -1); } /** @@ -49,11 +51,12 @@ public SchemaProperties(String id, SchemaFormat format) { * @param groupName The schema group for this schema. * @param name The name of the schema. */ - SchemaProperties(String id, SchemaFormat format, String groupName, String name) { + SchemaProperties(String id, SchemaFormat format, String groupName, String name, int version) { this.id = id; this.format = format; this.groupName = groupName; this.name = name; + this.version = version; } /** @@ -90,4 +93,13 @@ public String getGroupName() { public String getName() { return name; } + + /** + * Gets the version of the schema. + * + * @return The version of the schema. + */ + public int getVersion() { + return version; + } } diff --git a/sdk/schemaregistry/azure-data-schemaregistry/src/test/java/com/azure/data/schemaregistry/SchemaRegistryAsyncClientTests.java b/sdk/schemaregistry/azure-data-schemaregistry/src/test/java/com/azure/data/schemaregistry/SchemaRegistryAsyncClientTests.java index 9114d69cfcdd7..15c0a0ea3aa8b 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry/src/test/java/com/azure/data/schemaregistry/SchemaRegistryAsyncClientTests.java +++ b/sdk/schemaregistry/azure-data-schemaregistry/src/test/java/com/azure/data/schemaregistry/SchemaRegistryAsyncClientTests.java @@ -191,6 +191,7 @@ public void registerAndGetSchemaId() { StepVerifier.create(client1.registerSchema(schemaGroup, schemaName, SCHEMA_CONTENT, SchemaFormat.AVRO)) .assertNext(response -> { assertSchemaProperties(response, null, SchemaFormat.AVRO, schemaGroup, schemaName); + assertEquals(1, response.getVersion()); schemaId.set(response.getId()); }).verifyComplete(); @@ -203,6 +204,9 @@ public void registerAndGetSchemaId() { StepVerifier.create(client2.getSchemaProperties(schemaGroup, schemaName, SCHEMA_CONTENT, SchemaFormat.AVRO)) .assertNext(schema -> { assertSchemaProperties(schema, schemaIdToGet, SchemaFormat.AVRO, schemaGroup, schemaName); + + // Should be the same version since we did not register a new one. + assertEquals(1, schema.getVersion()); }) .verifyComplete(); } @@ -309,6 +313,33 @@ public void getSchemaIdDoesNotExist() { .verify(); } + @Test + public void getSchemaByGroupNameVersion() { + // Arrange + final SchemaRegistryAsyncClient client1 = builder.buildAsyncClient(); + final String schemaName = testResourceNamer.randomName("sch", RESOURCE_LENGTH); + + // Register a schema first. + final SchemaProperties registeredSchema = client1.registerSchema(schemaGroup, schemaName, SCHEMA_CONTENT, + SchemaFormat.AVRO).block(Duration.ofSeconds(10)); + + assertNotNull(registeredSchema); + + // Act & Assert + StepVerifier.create(client1.getSchema(schemaGroup, schemaName, registeredSchema.getVersion())) + .assertNext(actual -> { + SchemaProperties properties = actual.getProperties(); + assertNotNull(properties); + + assertEquals(registeredSchema.getVersion(), properties.getVersion()); + assertEquals(schemaGroup, registeredSchema.getGroupName()); + assertEquals(schemaName, registeredSchema.getName()); + assertEquals(registeredSchema.getId(), registeredSchema.getId()); + }) + .expectComplete() + .verify(); + } + static void assertSchemaRegistrySchema(SchemaRegistrySchema actual, String expectedSchemaId, SchemaFormat format, String expectedContents) { diff --git a/sdk/schemaregistry/azure-data-schemaregistry/src/test/java/com/azure/data/schemaregistry/SchemaRegistryClientTests.java b/sdk/schemaregistry/azure-data-schemaregistry/src/test/java/com/azure/data/schemaregistry/SchemaRegistryClientTests.java index 84f3ddc828bdc..2d32584359520 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry/src/test/java/com/azure/data/schemaregistry/SchemaRegistryClientTests.java +++ b/sdk/schemaregistry/azure-data-schemaregistry/src/test/java/com/azure/data/schemaregistry/SchemaRegistryClientTests.java @@ -246,4 +246,31 @@ public void getSchemaIdDoesNotExist() { assertEquals(404, error.getResponse().getStatusCode()); } + + @Test + public void getSchemaByGroupNameVersion() { + // Arrange + final SchemaRegistryClient client1 = builder.buildClient(); + final String schemaName = testResourceNamer.randomName("sch", RESOURCE_LENGTH); + + // Register a schema first. + final SchemaProperties registeredSchema = client1.registerSchema(schemaGroup, schemaName, SCHEMA_CONTENT, + SchemaFormat.AVRO); + + assertNotNull(registeredSchema); + + // Act + final SchemaRegistrySchema actual = client1.getSchema(schemaGroup, schemaName, registeredSchema.getVersion()); + + // Assert + assertNotNull(schemaName); + + final SchemaProperties properties = actual.getProperties(); + assertNotNull(properties); + + assertEquals(registeredSchema.getVersion(), properties.getVersion()); + assertEquals(schemaGroup, registeredSchema.getGroupName()); + assertEquals(schemaName, registeredSchema.getName()); + assertEquals(registeredSchema.getId(), registeredSchema.getId()); + } } diff --git a/sdk/schemaregistry/azure-data-schemaregistry/src/test/resources/session-records/SchemaRegistryAsyncClientTests.getSchemaByGroupNameVersion.json b/sdk/schemaregistry/azure-data-schemaregistry/src/test/resources/session-records/SchemaRegistryAsyncClientTests.getSchemaByGroupNameVersion.json new file mode 100644 index 0000000000000..ec3d27ca88fdd --- /dev/null +++ b/sdk/schemaregistry/azure-data-schemaregistry/src/test/resources/session-records/SchemaRegistryAsyncClientTests.getSchemaByGroupNameVersion.json @@ -0,0 +1,53 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.servicebus.windows.net/$schemaGroups/mygroup/schemas/sch439370379?api-version=2021-10", + "Headers" : { + "User-Agent" : "azsdk-java-azure-data-schemaregistry/1.3.0-beta.1 (11.0.5; Windows 10; 10.0)", + "x-ms-client-request-id" : "899445ce-8e18-4cf3-90fe-ee4fb5ef49ea", + "Content-Type" : "application/json; serialization=Avro" + }, + "Response" : { + "content-length" : "0", + "Schema-Version" : "1", + "Server" : "Microsoft-HTTPAPI/2.0", + "Schema-Name" : "sch439370379", + "retry-after" : "0", + "Schema-Id-Location" : "https://conniey.servicebus.windows.net:443/$schemagroups/$schemas/b5e21f8bdb234cceb2ba558935f56704?api-version=2021-10", + "StatusCode" : "204", + "Date" : "Tue, 27 Sep 2022 07:29:56 GMT", + "Strict-Transport-Security" : "max-age=31536000", + "Schema-Id" : "b5e21f8bdb234cceb2ba558935f56704", + "Schema-Group-Name" : "mygroup", + "Location" : "https://conniey.servicebus.windows.net:443/$schemagroups/mygroup/schemas/sch439370379/versions/1?api-version=2021-10", + "Schema-Versions-Location" : "https://conniey.servicebus.windows.net:443/$schemagroups/mygroup/schemas/sch439370379/versions?api-version=2021-10" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://REDACTED.servicebus.windows.net/$schemaGroups/mygroup/schemas/sch439370379/versions/1?api-version=2021-10", + "Headers" : { + "User-Agent" : "azsdk-java-azure-data-schemaregistry/1.3.0-beta.1 (11.0.5; Windows 10; 10.0)", + "x-ms-client-request-id" : "d4f429db-d225-4fbe-92ee-b69fcbadffd2" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "Schema-Version" : "1", + "Server" : "Microsoft-HTTPAPI/2.0", + "Schema-Name" : "sch439370379", + "retry-after" : "0", + "Schema-Id-Location" : "https://conniey.servicebus.windows.net:443/$schemagroups/$schemas/b5e21f8bdb234cceb2ba558935f56704?api-version=2021-10", + "StatusCode" : "200", + "Date" : "Tue, 27 Sep 2022 07:29:56 GMT", + "Strict-Transport-Security" : "max-age=31536000", + "Schema-Id" : "b5e21f8bdb234cceb2ba558935f56704", + "Schema-Group-Name" : "mygroup", + "Body" : "{\"type\":\"record\",\"namespace\":\"TestSchema\",\"name\":\"Employee\",\"fields\":[{\"name\":\"Name\",\"type\":\"string\"},{\"name\":\"Age\",\"type\":\"int\"}]}", + "Content-Type" : "application/json;serialization=Avro", + "Location" : "https://conniey.servicebus.windows.net:443/$schemagroups/mygroup/schemas/sch439370379/versions/1?api-version=2021-10", + "Schema-Versions-Location" : "https://conniey.servicebus.windows.net:443/$schemagroups/mygroup/schemas/sch439370379/versions?api-version=2021-10" + }, + "Exception" : null + } ], + "variables" : [ "sch439370379" ] +} \ No newline at end of file diff --git a/sdk/schemaregistry/azure-data-schemaregistry/src/test/resources/session-records/SchemaRegistryClientTests.getSchemaByGroupNameVersion.json b/sdk/schemaregistry/azure-data-schemaregistry/src/test/resources/session-records/SchemaRegistryClientTests.getSchemaByGroupNameVersion.json new file mode 100644 index 0000000000000..263cf25845914 --- /dev/null +++ b/sdk/schemaregistry/azure-data-schemaregistry/src/test/resources/session-records/SchemaRegistryClientTests.getSchemaByGroupNameVersion.json @@ -0,0 +1,53 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.servicebus.windows.net/$schemaGroups/mygroup/schemas/sch55155bad7?api-version=2021-10", + "Headers" : { + "User-Agent" : "azsdk-java-azure-data-schemaregistry/1.3.0-beta.1 (11.0.5; Windows 10; 10.0)", + "x-ms-client-request-id" : "86a13e8e-095c-4e47-b126-3ed3e438223f", + "Content-Type" : "application/json; serialization=Avro" + }, + "Response" : { + "content-length" : "0", + "Schema-Version" : "1", + "Server" : "Microsoft-HTTPAPI/2.0", + "Schema-Name" : "sch55155bad7", + "retry-after" : "0", + "Schema-Id-Location" : "https://conniey.servicebus.windows.net:443/$schemagroups/$schemas/dc0c992aa2a742c38487671446b3a973?api-version=2021-10", + "StatusCode" : "204", + "Date" : "Tue, 27 Sep 2022 07:33:53 GMT", + "Strict-Transport-Security" : "max-age=31536000", + "Schema-Id" : "dc0c992aa2a742c38487671446b3a973", + "Schema-Group-Name" : "mygroup", + "Location" : "https://conniey.servicebus.windows.net:443/$schemagroups/mygroup/schemas/sch55155bad7/versions/1?api-version=2021-10", + "Schema-Versions-Location" : "https://conniey.servicebus.windows.net:443/$schemagroups/mygroup/schemas/sch55155bad7/versions?api-version=2021-10" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://REDACTED.servicebus.windows.net/$schemaGroups/mygroup/schemas/sch55155bad7/versions/1?api-version=2021-10", + "Headers" : { + "User-Agent" : "azsdk-java-azure-data-schemaregistry/1.3.0-beta.1 (11.0.5; Windows 10; 10.0)", + "x-ms-client-request-id" : "7ef4e984-4e89-4253-9dcc-8827908af106" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "Schema-Version" : "1", + "Server" : "Microsoft-HTTPAPI/2.0", + "Schema-Name" : "sch55155bad7", + "retry-after" : "0", + "Schema-Id-Location" : "https://conniey.servicebus.windows.net:443/$schemagroups/$schemas/dc0c992aa2a742c38487671446b3a973?api-version=2021-10", + "StatusCode" : "200", + "Date" : "Tue, 27 Sep 2022 07:33:53 GMT", + "Strict-Transport-Security" : "max-age=31536000", + "Schema-Id" : "dc0c992aa2a742c38487671446b3a973", + "Schema-Group-Name" : "mygroup", + "Body" : "{\"type\":\"record\",\"namespace\":\"TestSchema\",\"name\":\"Employee\",\"fields\":[{\"name\":\"Name\",\"type\":\"string\"},{\"name\":\"Age\",\"type\":\"int\"}]}", + "Content-Type" : "application/json;serialization=Avro", + "Location" : "https://conniey.servicebus.windows.net:443/$schemagroups/mygroup/schemas/sch55155bad7/versions/1?api-version=2021-10", + "Schema-Versions-Location" : "https://conniey.servicebus.windows.net:443/$schemagroups/mygroup/schemas/sch55155bad7/versions?api-version=2021-10" + }, + "Exception" : null + } ], + "variables" : [ "sch55155bad7" ] +} diff --git a/sdk/schemaregistry/azure-data-schemaregistry/swagger/README.md b/sdk/schemaregistry/azure-data-schemaregistry/swagger/README.md index 88239cb3432ee..2b4dd6ab4ef6c 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry/swagger/README.md +++ b/sdk/schemaregistry/azure-data-schemaregistry/swagger/README.md @@ -16,7 +16,7 @@ autorest --java --use:@autorest/java@4.0.x ### Code generation settings ``` yaml -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/77ace2a6387b5a210f6b822262bc68cffa55499d/specification/schemaregistry/data-plane/Microsoft.EventHub/stable/2021-10/schemaregistry.json +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/a31ffeca96db3901c77b7dabbb8f224f226e78b9/specification/schemaregistry/data-plane/Microsoft.EventHub/stable/2021-10/schemaregistry.json java: true output-folder: ../ namespace: com.azure.data.schemaregistry