Skip to content

Instantly share code, notes, and snippets.

@christophschubert
Last active June 7, 2021 04:41
Show Gist options
  • Save christophschubert/32d764fcfc1d06b3dc2b2a29aa9dec4c to your computer and use it in GitHub Desktop.
Save christophschubert/32d764fcfc1d06b3dc2b2a29aa9dec4c to your computer and use it in GitHub Desktop.
Confluent schema registry below version 6.1 does not provide any endpoint to count the total number of schema versions in the SR.
# Get basic summary of versions in Confluent Cloud schema registry.
# You need to provide the SR url as well as SR apikey and api secret (lines 6 - 8 below).
import requests
from requests.auth import HTTPBasicAuth
sr_apikey = ''
sr_apisecret = ''
sr_url = ''
auth = HTTPBasicAuth(sr_apikey, sr_apisecret)
r = requests.get(sr_url + '/subjects', auth=auth)
subjects = r.json()
print("Found %d subjects" % len(subjects))
count = 0
print('Subject\tversions')
for subject in subjects:
r = requests.get('%s/subjects/%s/versions' % (sr_url, subject), auth=auth)
versions = r.json()
print('%s\t\t%s' % (subject, versions))
count += len(versions)
print('Total %d versions' % count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment