Started the migration tool scripts. Finished Karbon's script for mass delete and re-addition. Other small things.
This commit is contained in:
1
Scripts/Migration_tool/Apikeys.py
Normal file
1
Scripts/Migration_tool/Apikeys.py
Normal file
@ -0,0 +1 @@
|
||||
SANDBOX = "SlpQlju219WnWogn94dQUT6Yt"
|
||||
BIN
Scripts/Migration_tool/__pycache__/Apikeys.cpython-310.pyc
Normal file
BIN
Scripts/Migration_tool/__pycache__/Apikeys.cpython-310.pyc
Normal file
Binary file not shown.
51
Scripts/Migration_tool/create_project.py
Normal file
51
Scripts/Migration_tool/create_project.py
Normal file
@ -0,0 +1,51 @@
|
||||
import requests
|
||||
import Apikeys
|
||||
import pprint
|
||||
|
||||
PP = pprint.PrettyPrinter(indent=4)
|
||||
APIKEY = Apikeys.SANDBOX
|
||||
HEADERS = {"content-type": "application/json", "X-Api-Key": APIKEY}
|
||||
BASEURL = "https://api.northpass.com/v2/migration"
|
||||
|
||||
def create_project():
|
||||
"""
|
||||
Function to create a project with just a name. While ID is in the example payload, it isn't needed.
|
||||
Will generate a project ID for you in the return that you can use to transfer everything.
|
||||
Note that it will not give you an error if a project already exists with that name!
|
||||
"""
|
||||
payload = { "data": {
|
||||
"type": "migration_projects",
|
||||
"attributes": {
|
||||
"name": "My Second Migration Project"
|
||||
},
|
||||
} }
|
||||
create_req = requests.post(f"{BASEURL}/projects", headers=HEADERS, json=payload)
|
||||
print(payload)
|
||||
print(create_req.status_code)
|
||||
print(create_req.text)
|
||||
|
||||
|
||||
def get_all_projects():
|
||||
"""
|
||||
Returns all projects. Leverage PrettyPrint or uncomment the name to just return names and ids.
|
||||
"""
|
||||
get_proj = requests.get(f"{BASEURL}/projects", headers=HEADERS)
|
||||
print(get_proj.status_code)
|
||||
# PP.pprint(get_proj.json())
|
||||
|
||||
for items in get_proj.json()['data']:
|
||||
print(f"{ items['attributes']['name'] } -- { items['id'] }")
|
||||
|
||||
def get_specific_project():
|
||||
"""
|
||||
Returns results from a specific project.
|
||||
"""
|
||||
proj_id = "13aa7aed-3fb5-4488-9185-3befd0c1ae86"
|
||||
get_spec_proj = requests.get(f"{BASEURL}/projects/{proj_id}", headers=HEADERS)
|
||||
print(get_spec_proj.status_code)
|
||||
PP.pprint(get_spec_proj.json())
|
||||
|
||||
if __name__ == "__main__":
|
||||
# create_project()
|
||||
# get_all_projects()
|
||||
get_specific_project()
|
||||
Reference in New Issue
Block a user