Mizuno scripts. Finished Source & Supplier's removing enrollments from LP.

This commit is contained in:
Norm Rasmussen
2025-02-07 16:09:44 -05:00
parent fb6e6d38db
commit 89a6fd58ee
3 changed files with 52 additions and 2 deletions

View File

@ -4,7 +4,7 @@ from pathlib import Path
import Apikeys
import os
basefile = "/Users/normrasmussen/Downloads/mizuno-completions-dec24.csv"
basefile = "/Users/normrasmussen/Downloads/mizuno-lp-jan25.csv"
api_key = Apikeys.MIZUNO
uuid_url = "https://api.northpass.com/v2/people?filter[email][eq]="
prop_url = "https://api.northpass.com/v2/properties/people/"
@ -51,7 +51,7 @@ def load_file(basefile):
completions = completions[completions["userid"] != "0"]
# completions = completions.iloc[:, 0:]
completions.to_csv(
"/Users/normrasmussen/Downloads/Mizuno-Dec2024-with-PGAID.csv",
"/Users/normrasmussen/Downloads/Mizuno-LP-Jan25-with-PGAID.csv",
index=False,
)

View File

@ -0,0 +1,50 @@
import requests
import Apikeys
import sys
import pprint
pp = pprint.PrettyPrinter(indent=4)
APIKEY = Apikeys.SUPPLIERPROD
LP_UUID = sys.argv[1]
HEADERS = {
"accept": "*/*",
"x-api-key": APIKEY,
"content-type": "application/json",
}
# Category Advisory Services
# 6afe6b7e-088b-4dfa-9a0f-e8aefcd81cdf
# Sandbox - Ascent LP
# 6ef5c9db-81d7-427c-846b-babb9a9a2ad1
def get_enrollments():
page = 0
person_list = []
while True:
page += 1
url = f"https://api2.northpass.com/v2/learning_paths/{LP_UUID}/enrollments?limit=100&page={page}"
response = requests.get(url, headers=HEADERS)
data = response.json()
nextlink = data["links"]
for items in data["data"]:
person_uuid = items["attributes"]["person_id"]
person_list.append(person_uuid)
if "next" not in nextlink:
break
print(person_list)
print(len(person_list))
for person in person_list:
delete_enrollments(person, LP_UUID)
def delete_enrollments(person_uuid, lp_uuid):
url = f"https://api2.northpass.com/v1/people/{person_uuid}/relationships/learning_paths"
payload = { "data": [{ "type": "enrolled-courses", "id": lp_uuid }] }
delsponse = requests.delete(url, headers=HEADERS, json=payload)
print(delsponse.status_code)
if __name__ == "__main__":
get_enrollments()