Created
August 7, 2019 18:28
-
-
Save blackknight36/f853f414be6554d0bb570c2ec8ba72fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import json | |
import requests | |
import sys | |
def main(): | |
if len(sys.argv) < 3: | |
print("usage: deprecate_module.py <module_name> <replacement_module>") | |
else: | |
update_record(sys.argv[1], sys.argv[2]) | |
def update_record(old, new): | |
baseurl = 'https://forgeapi.puppet.com/v3/modules/%s' %old | |
headers = {'Content-Type': 'application/json', 'Authorization': 'Bearer xxxxx'} | |
payload = {'action': 'deprecate', 'params': {"reason": "No longer maintained.", "replacement_slug": new}} | |
r = requests.patch(baseurl, headers=headers, data=json.dumps(payload)) | |
if r.status_code == 200: | |
return json.loads(r.text) | |
else: | |
raise RuntimeError( | |
u"Error loading data from stand: HTTP {} - {} ({})".format( | |
r.status_code, r.text, baseurl)) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment