Skip to content

Instantly share code, notes, and snippets.

@alces
Created September 19, 2019 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alces/dc9904376e1cac2336276599c57f6120 to your computer and use it in GitHub Desktop.
Save alces/dc9904376e1cac2336276599c57f6120 to your computer and use it in GitHub Desktop.
Remove old schemes from Confluent Schema Registry
#!/usr/bin/env python
# Cleanup old schemas from schema registry
import httplib
import json
import re
DELETE_REGEX = 'IT6[0-6][0-9]-'
con = httplib.HTTPConnection('127.0.0.1', 8081)
con.request('GET', '/subjects')
rsp = con.getresponse()
subjects = json.loads(rsp.read())
con.close()
for subj in subjects:
if re.search(DELETE_REGEX, subj):
con = httplib.HTTPConnection('127.0.0.1', 8081)
con.request('DELETE', '/subjects/%s' % subj)
rsp = con.getresponse()
print 'Delete %s status %d' % (subj, rsp.status)
con.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment