Skip to content

Instantly share code, notes, and snippets.

@parthaa
Last active November 17, 2020 21:08
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 parthaa/e7d76f4dcf604931853c493b5069c580 to your computer and use it in GitHub Desktop.
Save parthaa/e7d76f4dcf604931853c493b5069c580 to your computer and use it in GitHub Desktop.
#!/bin/env python
import json
import requests
import sys
from requests.auth import HTTPBasicAuth
from pprint import pprint
def fetch_metadata(fl):
with open(fl, "r") as content:
data = json.load(content)
return data
def do_import(cv_id, path, metadata_location):
return requests.post("http://localhost:3000/katello/api/content_imports/version", auth=HTTPBasicAuth('admin', 'changeme'), json = {'content_view_id': cv_id, 'path':path, 'metadata': fetch_metadata(metadata_location)})
if len(sys.argv) != 4:
print("usage: ", sys.argv[0], '<Content View Id> <path> <metadata_file_location>')
sys.exit(-1)
pprint(do_import(*sys.argv[1:]).json())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment