Last active
November 17, 2020 21:19
-
-
Save parthaa/316b4cdb3b55a09ede2f180a5897edf7 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(org_id, path, metadata_location): | |
return requests.post("http://localhost:3000/katello/api/content_imports/library", auth=HTTPBasicAuth('admin', 'changeme'), json = {'organization_id': org_id, 'path':path, 'metadata': fetch_metadata(metadata_location)}) | |
if len(sys.argv) != 4: | |
print("usage: ", sys.argv[0], '<Org 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