Skip to main content

versions

Creates, updates, deletes, gets or lists a versions resource.

Overview

Nameversions
TypeResource
Idconfluent.schema_registry.versions

Fields

The following fields are returned by SELECT queries:

The schema.

NameDatatypeDescription
idinteger (int32)Globally unique identifier of the schema
metadataobjectUser-defined metadata
referencesarrayReferences to other schemas
ruleSetobjectSchema rule set
schemastringSchema definition string (example: {"schema": "{"type": "string"}"})
schemaTagsarraySchema tags
schemaTypestringSchema type (example: AVRO)
subjectstringName of the subject (example: User)
versioninteger (int32)Version number

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_schema_by_versionselectsubject, versionformat, deletedRetrieves a specific version of the schema registered under this subject.
get_versionsselectidsubject, deleted, offset, limitGet all the subject-version pairs associated with the input ID.
list_versionsselectsubjectdeleted, deletedOnly, offset, limitRetrieves a list of versions registered under the specified subject.
registerinsertsubjectnormalize, formatRegister a new schema under the specified subject. If successfully registered, this returns the unique identifier of this schema in the registry. The returned identifier should be used to retrieve this schema from the schemas resource and is different from the schema's version which is associated with the subject. If the same schema is registered under a different subject, the same identifier will be returned. However, the version of the schema may be different under different subjects.
A schema should be compatible with the previously registered schema or schemas (if there are any) as per the configured compatibility level. The configured compatibility level can be obtained by issuing a GET http:get:: /config/(string: subject). If that returns null, then GET http:get:: /config
When there are multiple instances of Schema Registry running in the same cluster, the schema registration request will be forwarded to one of the instances designated as the primary. If the primary is not available, the client will get an error code indicating that the forwarding has failed.
delete_schema_versiondeletesubject, versionpermanentDeletes a specific version of the schema registered under this subject. This only deletes the version and the schema ID remains intact making it still possible to decode data using the schema ID. This API is recommended to be used only in development environments or under extreme circumstances where-in, its required to delete a previously registered schema for compatibility purposes or re-register previously registered schema.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
idinteger (int32)Globally unique identifier of the schema
subjectstringName of the subject
versionstringVersion of the schema to be returned. Valid values for versionId are between [1,2^31-1] or the string "latest". "latest" returns the last registered schema under the specified subject. Note that there may be a new latest schema that gets registered right after this request is served.
deletedbooleanWhether to include deleted schemas
deletedOnlybooleanWhether to return deleted schemas only
formatstringDesired output format, dependent on schema type. For AVRO schemas, valid values are: " " (default) or "resolved". For PROTOBUF schemas, valid values are: " " (default), "ignore_extensions", or "serialized" (The parameter does not apply to JSON schemas.)
limitinteger (int32)Pagination size for results. Ignored if negative
normalizebooleanWhether to register the normalized schema
offsetinteger (int32)Pagination offset for results
permanentbooleanWhether to perform a permanent delete
subjectstringFilters results by the respective subject

SELECT examples

Retrieves a specific version of the schema registered under this subject.

SELECT
id,
metadata,
references,
ruleSet,
schema,
schemaTags,
schemaType,
subject,
version
FROM confluent.schema_registry.versions
WHERE subject = '{{ subject }}' -- required
AND version = '{{ version }}' -- required
AND format = '{{ format }}'
AND deleted = '{{ deleted }}'
;

INSERT examples

Register a new schema under the specified subject. If successfully registered, this returns the unique identifier of this schema in the registry. The returned identifier should be used to retrieve this schema from the schemas resource and is different from the schema's version which is associated with the subject. If the same schema is registered under a different subject, the same identifier will be returned. However, the version of the schema may be different under different subjects.
A schema should be compatible with the previously registered schema or schemas (if there are any) as per the configured compatibility level. The configured compatibility level can be obtained by issuing a GET http:get:: /config/(string: subject). If that returns null, then GET http:get:: /config
When there are multiple instances of Schema Registry running in the same cluster, the schema registration request will be forwarded to one of the instances designated as the primary. If the primary is not available, the client will get an error code indicating that the forwarding has failed.

INSERT INTO confluent.schema_registry.versions (
version,
id,
schemaType,
references,
schema,
metadata,
ruleSet,
schemaTagsToAdd,
schemaTagsToRemove,
propagateSchemaTags,
subject,
normalize,
format
)
SELECT
{{ version }},
{{ id }},
'{{ schemaType }}',
'{{ references }}',
'{{ schema }}',
'{{ metadata }}',
'{{ ruleSet }}',
'{{ schemaTagsToAdd }}',
'{{ schemaTagsToRemove }}',
{{ propagateSchemaTags }},
'{{ subject }}',
'{{ normalize }}',
'{{ format }}'
RETURNING
id
;

DELETE examples

Deletes a specific version of the schema registered under this subject. This only deletes the version and the schema ID remains intact making it still possible to decode data using the schema ID. This API is recommended to be used only in development environments or under extreme circumstances where-in, its required to delete a previously registered schema for compatibility purposes or re-register previously registered schema.

DELETE FROM confluent.schema_registry.versions
WHERE subject = '{{ subject }}' --required
AND version = '{{ version }}' --required
AND permanent = '{{ permanent }}'
;