Last active
November 17, 2020 21:08
-
-
Save parthaa/e7d76f4dcf604931853c493b5069c580 to your computer and use it in GitHub Desktop.
This file contains 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
#!/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