> 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