You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
127 lines
3.0 KiB
127 lines
3.0 KiB
{ |
|
"cells": [ |
|
{ |
|
"cell_type": "code", |
|
"execution_count": null, |
|
"id": "2bec1b04-f1ab-4165-a4ea-cc890cc9e5ec", |
|
"metadata": {}, |
|
"outputs": [], |
|
"source": [ |
|
"!python -m pip install gql" |
|
] |
|
}, |
|
{ |
|
"cell_type": "code", |
|
"execution_count": null, |
|
"id": "dca88210-18db-45ee-9949-7010b92dbae7", |
|
"metadata": {}, |
|
"outputs": [], |
|
"source": [ |
|
"import json\n", |
|
"import os\n", |
|
"import pprint\n", |
|
"\n", |
|
"import requests\n", |
|
"from gql import Client, gql\n", |
|
"from gql.transport.requests import RequestsHTTPTransport\n", |
|
"\n", |
|
"cwd = os.getcwd()\n", |
|
"print(cwd)" |
|
] |
|
}, |
|
{ |
|
"cell_type": "code", |
|
"execution_count": null, |
|
"id": "7374f89e-23f8-407d-967b-c76e7d6d93a2", |
|
"metadata": { |
|
"scrolled": true, |
|
"tags": [] |
|
}, |
|
"outputs": [], |
|
"source": [ |
|
"with open(\"/home/jovyan/code/directus/docker.json\") as f:\n", |
|
" scrubbed_records = json.load(f)\n", |
|
"\n", |
|
"# print(scrubbed_records[0])\n", |
|
"item = scrubbed_records[0]\n", |
|
"name = item[\"Name\"]\n", |
|
"image = item[\"Config\"][\"Image\"]\n", |
|
"# print(name)\n", |
|
"# print(image)\n", |
|
"image = image.replace(\":latest\", \"\")\n", |
|
"name = name.replace(\"/\", \"\")\n", |
|
"print(name)\n", |
|
"print(image)" |
|
] |
|
}, |
|
{ |
|
"cell_type": "code", |
|
"execution_count": null, |
|
"id": "f2b300a9-f7c0-4863-9696-29e92e6cedc8", |
|
"metadata": { |
|
"scrolled": true, |
|
"tags": [] |
|
}, |
|
"outputs": [], |
|
"source": [ |
|
"for x in scrubbed_records:\n", |
|
" # pprint.pprint(x)\n", |
|
" item = x\n", |
|
" name = item[\"Name\"]\n", |
|
" image = item[\"Config\"][\"Image\"]\n", |
|
" image = image.replace(\":latest\", \"\")\n", |
|
" name = name.replace(\"/\", \"\")\n", |
|
" print(name)\n", |
|
" print(image)\n", |
|
" input_set = {\"id\": name, \"image\": image, \"name\": name, \"raw\": item}\n", |
|
"\n", |
|
" my_headers = {\n", |
|
" \"Authorization\": os.getenv(directus_token),\n", |
|
" \"Content-Type\": \"application/json\",\n", |
|
" }\n", |
|
" response = requests.post(\n", |
|
" \"https://cms.donavanaldrich.com/items/containers\",\n", |
|
" headers=my_headers,\n", |
|
" json=(input_set),\n", |
|
" )\n", |
|
" print(response.json())" |
|
] |
|
} |
|
], |
|
"metadata": { |
|
"kernelspec": { |
|
"display_name": "Python 3.10.4 64-bit", |
|
"language": "python", |
|
"name": "python3" |
|
}, |
|
"language_info": { |
|
"codemirror_mode": { |
|
"name": "ipython", |
|
"version": 3 |
|
}, |
|
"file_extension": ".py", |
|
"mimetype": "text/x-python", |
|
"name": "python", |
|
"nbconvert_exporter": "python", |
|
"pygments_lexer": "ipython3", |
|
"version": "3.10.4" |
|
}, |
|
"toc-autonumbering": false, |
|
"toc-showcode": false, |
|
"toc-showtags": false, |
|
"vscode": { |
|
"interpreter": { |
|
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6" |
|
} |
|
}, |
|
"widgets": { |
|
"application/vnd.jupyter.widget-state+json": { |
|
"state": {}, |
|
"version_major": 2, |
|
"version_minor": 0 |
|
} |
|
} |
|
}, |
|
"nbformat": 4, |
|
"nbformat_minor": 5 |
|
}
|
|
|