Package com.azure.data.schemaregistry
Class SchemaRegistryAsyncClient
java.lang.Object
com.azure.data.schemaregistry.SchemaRegistryAsyncClient
HTTP-based client that interacts with Azure Schema Registry service to store and retrieve schemas on demand.
Register a schema
Registering a schema returns a unique schema id that can be used to quickly associate payloads with that schema. Reactive operations must be subscribed to; this kicks off the operation.String schema = "{\"type\":\"enum\",\"name\":\"TEST\",\"symbols\":[\"UNIT\",\"INTEGRATION\"]}"; client.registerSchema("{schema-group}", "{schema-name}", schema, SchemaFormat.AVRO) .subscribe(properties -> { System.out.printf("Schema id: %s, schema format: %s%n", properties.getId(), properties.getFormat()); });
Get a schema
client.getSchema("{schema-id}").subscribe(schema -> { System.out.printf("Schema id: %s, schema format: %s%n", schema.getProperties().getId(), schema.getProperties().getFormat()); System.out.println("Schema contents: " + schema.getDefinition()); });
Get a schema's properties
String schema = "{\"type\":\"enum\",\"name\":\"TEST\",\"symbols\":[\"UNIT\",\"INTEGRATION\"]}"; client.getSchemaProperties("{schema-group}", "{schema-name}", schema, SchemaFormat.AVRO).subscribe(properties -> { System.out.println("The schema id: " + properties.getId()); });
-
Method Summary
Modifier and TypeMethodDescriptionGets the fully qualified namespace of the Schema Registry instance.Gets the schema properties of the schema associated with the unique schema id.getSchemaProperties
(String groupName, String name, String schemaDefinition, SchemaFormat format) Gets the schema identifier associated with the given schema.getSchemaPropertiesWithResponse
(String groupName, String name, String schemaDefinition, SchemaFormat format) Gets the schema identifier associated with the given schema.getSchemaWithResponse
(String schemaId) Gets the schema properties of the schema associated with the unique schema id.registerSchema
(String groupName, String name, String schemaDefinition, SchemaFormat format) Registers a new schema in the specified schema group with the given schema name.registerSchemaWithResponse
(String groupName, String name, String schemaDefinition, SchemaFormat format) Registers a new schema in the specified schema group with the given schema name.
-
Method Details
-
getFullyQualifiedNamespace
Gets the fully qualified namespace of the Schema Registry instance.- Returns:
- The fully qualified namespace of the Schema Registry instance.
-
registerSchema
public Mono<SchemaProperties> registerSchema(String groupName, String name, String schemaDefinition, SchemaFormat format) Registers a new schema in the specified schema group with the given schema name. If a schema does not existdoes not exist with the samegroupName
,name
,format
, andschemaDefinition
, it is added to the Schema Registry Instance and assigned a schema id. If a schema exists with a matchinggroupName
,name
,format
, andschemaDefinition
, the id of that schema is returned. If the Schema Registry instance contains an existinggroupName
,name
, andformat
but theschemaDefinition
is different, it is considered a new version, and schema id is assigned to it.- Parameters:
groupName
- The schema group.name
- The schema name.schemaDefinition
- The string representation of the schema.format
- The serialization type of this schema.- Returns:
- The
SchemaProperties
of a successfully registered schema. - Throws:
NullPointerException
- ifgroupName
,name
,format
, orschemaDefinition
are null.HttpResponseException
- if an issue was encountered while registering the schema.
-
registerSchemaWithResponse
public Mono<Response<SchemaProperties>> registerSchemaWithResponse(String groupName, String name, String schemaDefinition, SchemaFormat format) Registers a new schema in the specified schema group with the given schema name. If a schema does not existdoes not exist with the samegroupName
,name
,format
, andschemaDefinition
, it is added to the Schema Registry Instance and assigned a schema id. If a schema exists with a matchinggroupName
,name
,format
, andschemaDefinition
, the id of that schema is returned. If the Schema Registry instance contains an existinggroupName
,name
, andformat
but theschemaDefinition
is different, it is considered a new version, and schema id is assigned to it.- Parameters:
groupName
- The schema group.name
- The schema name.schemaDefinition
- The string representation of the schema.format
- The serialization type of this schema.- Returns:
- The schema properties on successful registration of the schema.
- Throws:
NullPointerException
- ifgroupName
,name
,format
, orschemaDefinition
are null.HttpResponseException
- if an issue was encountered while registering the schema.
-
getSchema
Gets the schema properties of the schema associated with the unique schema id.- Parameters:
schemaId
- The unique identifier of the schema.- Returns:
- The
SchemaProperties
associated with the givenschemaId
. - Throws:
NullPointerException
- ifschemaId
is null.ResourceNotFoundException
- if a schema with the matchingschemaId
could not be found.HttpResponseException
- if an issue was encountered while fetching the schema.
-
getSchemaWithResponse
Gets the schema properties of the schema associated with the unique schema id.- Parameters:
schemaId
- The unique identifier of the schema.- Returns:
- The
SchemaProperties
associated with the givenschemaId
along with the HTTP response. - Throws:
NullPointerException
- ifschemaId
is null.ResourceNotFoundException
- if a schema with the matchingschemaId
could not be found.HttpResponseException
- if an issue was encountered while fetching the schema.
-
getSchemaProperties
public Mono<SchemaProperties> getSchemaProperties(String groupName, String name, String schemaDefinition, SchemaFormat format) Gets the schema identifier associated with the given schema. Gets a cached value if it exists, otherwise makes a call to the service.- Parameters:
groupName
- The schema group.name
- The schema name.schemaDefinition
- The string representation of the schema.format
- The serialization type of this schema.- Returns:
- A mono that completes with the properties for a matching schema.
- Throws:
NullPointerException
- ifgroupName
,name
,schemaDefinition
, orformat
is null.ResourceNotFoundException
- if a schema with matching parameters could not be located.HttpResponseException
- if an issue was encountered while finding a matching schema.
-
getSchemaPropertiesWithResponse
public Mono<Response<SchemaProperties>> getSchemaPropertiesWithResponse(String groupName, String name, String schemaDefinition, SchemaFormat format) Gets the schema identifier associated with the given schema. Always makes a call to the service.- Parameters:
groupName
- The schema group.name
- The schema name.schemaDefinition
- The string representation of the schema.format
- The serialization type of this schema.- Returns:
- A mono that completes with the properties for a matching schema.
- Throws:
NullPointerException
- ifgroupName
,name
,schemaDefinition
, orformat
is null.ResourceNotFoundException
- if a schema with matching parameters could not be located.HttpResponseException
- if an issue was encountered while finding a matching schema.
-