Organized anthology scripts and wrote a new one for their knowledgestate ppl. updated project files for scripts to better interact with neovim.
This commit is contained in:
@ -1,104 +0,0 @@
|
||||
import pandas as pd
|
||||
import requests
|
||||
import Apikeys
|
||||
|
||||
MASTER = "~/Downloads/Anthology-Master-CSV-FirstChanges.csv"
|
||||
BASEURL = "https://api.northpass.com/v2/people"
|
||||
APIKEY = Apikeys.ANTHOLOGY
|
||||
HEADERS = {
|
||||
"accept": "*/*",
|
||||
"X-Api-Key": APIKEY,
|
||||
"content-type": "application/json",
|
||||
}
|
||||
KNOWLEDGEGROUPS = [
|
||||
]
|
||||
|
||||
KNOWLEDGEPROPS = "Anthology Academic Economics: Essential, Anthology Academic Economics: Enhanced, Anthology Accreditation: Essential, Anthology Accreditation: Enhanced, Anthology 101: Essential, Anthology Baseline: Essential, Anthology Baseline: Enhanced, Anthology Beacon: Essential, Anthology Course Evaluations: Essential, Anthology Course Evaluations: Enhanced, Anthology Digital Assistant: Essential, Anthology Digital Assistant: Enhanced, Anthology Encompass: Essential, Anthology Encompass: Enhanced, Anthology Encompass: Enhanced+, Anthology Engage: Essential, Anthology Engage: Enhanced, Anthology Engage: Enhanced+, Anthology Evaluate: Essential, Anthology Evaluate: Enhanced, Anthology Finance & HCM: Essential, Anthology Finance & HCM: Enhanced, Anthology Finance & HCM: Enhanced+, Anthology Insight: Essential, Anthology Insight: Enhanced, Blackboard Learn: Essential, Anthology Milestone: Essential, Anthology Milestone: Enhanced, Outcomes: Essential, Outcomes: Enhanced, Anthology Payroll: Essential, Anthology Payroll: Enhanced, Anthology Planning: Essential, Anthology Planning: Enhanced, Anthology Portfolio: Essential, Anthology Portfolio: Enhanced, Power BI: Essential, Power BI: Enhanced, Anthology Program Review: Essential, Anthology Program Review: Enhanced, Anthology Raise: Essential, Anthology Raise: Enhanced, Anthology Raise: Enhanced+, Anthology Reach: Essential, Anthology Reach: Enhanced, Anthology Reach: Enhanced+, Anthology Student: Essential, Anthology Student: Enhanced, Ally - (T1), Ally - (T2), Ally - (T3)"
|
||||
|
||||
|
||||
def groups():
|
||||
for row in df.itertuples():
|
||||
domain = row[1]
|
||||
groups = row[2:]
|
||||
# groups = list(groups)
|
||||
tmplist = []
|
||||
for group in groups:
|
||||
group = str(group)
|
||||
if "nan" not in group:
|
||||
# Grab Group UUIDs
|
||||
url = f"https://api.northpass.com/v2/groups?filter[name][eq]={group}"
|
||||
response = requests.get(url, headers=HEADERS)
|
||||
response = response.json()
|
||||
data = response["data"]
|
||||
for name in data:
|
||||
id = name["id"]
|
||||
tmplist.append(id)
|
||||
rowdict = {domain: tmplist}
|
||||
|
||||
# Grab all people
|
||||
personlist = []
|
||||
COUNT += 1
|
||||
url = BASEURL + f"?filter[email][cont]={domain}&limit=100"
|
||||
response = requests.get(url, headers=HEADERS)
|
||||
response = response.json()
|
||||
nextlink = response["links"]
|
||||
|
||||
for data in response["data"]:
|
||||
person = data["id"]
|
||||
personlist.append(person)
|
||||
|
||||
# if "next" not in nextlink:
|
||||
# break
|
||||
|
||||
# Construct Payload for Bulk API
|
||||
payload = {"payload": {"person_ids": personlist, "group_ids": tmplist}}
|
||||
print(payload)
|
||||
|
||||
|
||||
def props():
|
||||
person_id_list = []
|
||||
count = 0
|
||||
while True:
|
||||
count += 1
|
||||
url = (
|
||||
BASEURL
|
||||
+ f"?filter[email][cont]=%40knowledgestate.edu&limit=100&page={count}"
|
||||
)
|
||||
response = requests.get(url, headers=HEADERS)
|
||||
response = response.json()
|
||||
nextlink = response["links"]
|
||||
|
||||
for data in response["data"]:
|
||||
person_name = data["attributes"]["name"]
|
||||
person = data["id"]
|
||||
print(f"Adding {person_name}'s id to list. ID: {person}")
|
||||
person_id_list.append(person)
|
||||
|
||||
if "next" not in nextlink:
|
||||
break
|
||||
|
||||
print(f"Cycling through {len(person_id_list)} people and adding their properties.")
|
||||
for person_id in person_id_list:
|
||||
propsurl = "https://api.northpass.com/v2/properties/people/bulk"
|
||||
payload = {
|
||||
"data": [
|
||||
{
|
||||
"attributes": {
|
||||
"properties": {"subscription_levels": KNOWLEDGEPROPS}
|
||||
},
|
||||
"id": person_id,
|
||||
"type": "person_properties",
|
||||
}
|
||||
]
|
||||
}
|
||||
prop_response = requests.post(propsurl, headers=HEADERS, json=payload)
|
||||
print(f"{person_id}'s status code is {prop_response.status_code}'")
|
||||
if prop_response.status_code != 200:
|
||||
print(
|
||||
f"There is a non-200 status code. The code was {prop_response.status_code}. Here's the text:"
|
||||
)
|
||||
print(f"{response.text}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
props()
|
||||
@ -1,52 +0,0 @@
|
||||
import pandas as pd
|
||||
import requests
|
||||
import Apikeys
|
||||
|
||||
MASTER = "~/Downloads/Anthology-Master-CSV-FirstChanges.csv"
|
||||
BASEURL = "https://api.northpass.com/v2/people"
|
||||
APIKEY = Apikeys.ANTHOLOGY
|
||||
HEADERS = {
|
||||
"accept": "*/*",
|
||||
"X-Api-Key": APIKEY,
|
||||
"content-type": "application/json",
|
||||
}
|
||||
df = pd.read_csv(MASTER)
|
||||
df.dropna(how="all", axis=0, inplace=True)
|
||||
COUNT = 0
|
||||
|
||||
for row in df.itertuples():
|
||||
domain = row[1]
|
||||
groups = row[2:]
|
||||
# groups = list(groups)
|
||||
tmplist = []
|
||||
for group in groups:
|
||||
group = str(group)
|
||||
if "nan" not in group:
|
||||
# Grab Group UUIDs
|
||||
url = f"https://api.northpass.com/v2/groups?filter[name][eq]={group}"
|
||||
response = requests.get(url, headers=HEADERS)
|
||||
response = response.json()
|
||||
data = response["data"]
|
||||
for name in data:
|
||||
id = name["id"]
|
||||
tmplist.append(id)
|
||||
rowdict = {domain: tmplist}
|
||||
|
||||
# Grab all people
|
||||
personlist = []
|
||||
COUNT += 1
|
||||
url = BASEURL + f"?filter[email][cont]={domain}&limit=100"
|
||||
response = requests.get(url, headers=HEADERS)
|
||||
response = response.json()
|
||||
nextlink = response["links"]
|
||||
|
||||
for data in response["data"]:
|
||||
person = data["id"]
|
||||
personlist.append(person)
|
||||
|
||||
# if "next" not in nextlink:
|
||||
# break
|
||||
|
||||
# Construct Payload for Bulk API
|
||||
payload = {"payload": {"person_ids": personlist, "group_ids": tmplist}}
|
||||
print(payload)
|
||||
@ -1,178 +0,0 @@
|
||||
import requests
|
||||
import json
|
||||
import Apikeys
|
||||
import pandas as pd
|
||||
|
||||
BASEURL = "https://api.northpass.com"
|
||||
APIKEY = Apikeys.ANTHOLOGY
|
||||
HEADERS = {
|
||||
"accept": "*/*",
|
||||
"X-Api-Key": APIKEY,
|
||||
"content-type": "application/json",
|
||||
}
|
||||
BASEFILE = "~/Downloads/Anthology-DomainMaster-forWorkato - Sheet1.csv"
|
||||
|
||||
|
||||
def get_ppl():
|
||||
count = 0
|
||||
tmpdict = {}
|
||||
while True:
|
||||
count += 1
|
||||
url = f"{BASEURL}/v2/people?limit=100&page={count}"
|
||||
getppl = requests.get(url, headers=HEADERS)
|
||||
ppl_response = getppl.json()
|
||||
nextlink = ppl_response["links"]
|
||||
|
||||
for people in ppl_response["data"]:
|
||||
if "2024-07-09" in people["attributes"]["created_at"]:
|
||||
domain = people["attributes"]["email"].split("@")[1]
|
||||
if domain in tmpdict:
|
||||
tmpdict[domain].append(people["id"])
|
||||
else:
|
||||
tmpdict[domain] = [people["id"]]
|
||||
|
||||
if "next" not in nextlink:
|
||||
break
|
||||
|
||||
print(tmpdict)
|
||||
apply_groups(tmpdict)
|
||||
|
||||
|
||||
def apply_groups(tmpdict):
|
||||
df = pd.read_csv(BASEFILE, index_col=None, header=None)
|
||||
for domain, values in tmpdict.items():
|
||||
data = df.loc[df[0] == domain].iloc[:, 1:].values.tolist()
|
||||
cleaned = [x for x in data[0] if str(x) != "nan"]
|
||||
# print(cleaned)
|
||||
payload = {"payload": {"person_ids": values, "group_ids": cleaned}}
|
||||
url = f"{BASEURL}/v2/bulk/people/membership"
|
||||
response = requests.post(url, json=payload, headers=HEADERS)
|
||||
print(response.text)
|
||||
print(response.status_code)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
get_ppl()
|
||||
|
||||
|
||||
"""
|
||||
|
||||
GROUPSTOMAP = {
|
||||
"stlukescollege.edu": [
|
||||
"2b5267b2-ce87-4e77-ad88-5cfec80496b9",
|
||||
"5f35e542-a8cf-4422-8e87-466cdca62864",
|
||||
"fa8914be-0986-460c-884d-9973a9622045",
|
||||
"106775db-a00d-4956-bf27-97ea269bb001",
|
||||
"b9f734fa-de0d-4a0b-9ce2-c092126e1d8d",
|
||||
],
|
||||
"cuhk.edu.hk": [
|
||||
"8302b674-c728-42d2-9ba3-908b4d970436",
|
||||
"604dd8b8-175a-4a74-93d2-28760f1d1835",
|
||||
"2b5267b2-ce87-4e77-ad88-5cfec80496b9",
|
||||
],
|
||||
"allencollege.edu": [
|
||||
"2b5267b2-ce87-4e77-ad88-5cfec80496b9",
|
||||
"8302b674-c728-42d2-9ba3-908b4d970436",
|
||||
"5f35e542-a8cf-4422-8e87-466cdca62864",
|
||||
"fa8914be-0986-460c-884d-9973a9622045",
|
||||
"",
|
||||
"b9f734fa-de0d-4a0b-9ce2-c092126e1d8d",
|
||||
"106775db-a00d-4956-bf27-97ea269bb001",
|
||||
],
|
||||
"trinitycollegeqc.edu": [
|
||||
"2b5267b2-ce87-4e77-ad88-5cfec80496b9",
|
||||
"5f35e542-a8cf-4422-8e87-466cdca62864",
|
||||
"fa8914be-0986-460c-884d-9973a9622045",
|
||||
"106775db-a00d-4956-bf27-97ea269bb001",
|
||||
"b9f734fa-de0d-4a0b-9ce2-c092126e1d8d",
|
||||
],
|
||||
"southuniversity.edu": [
|
||||
"2b5267b2-ce87-4e77-ad88-5cfec80496b9",
|
||||
"bfb708e4-18eb-47b5-afde-737f16721e9a",
|
||||
"5f35e542-a8cf-4422-8e87-466cdca62864",
|
||||
"106775db-a00d-4956-bf27-97ea269bb001",
|
||||
],
|
||||
"pcom.edu": [
|
||||
"2b5267b2-ce87-4e77-ad88-5cfec80496b9",
|
||||
"197da27d-0497-40b5-b2f8-cec4124d32f6",
|
||||
"bfb708e4-18eb-47b5-afde-737f16721e9a",
|
||||
"8302b674-c728-42d2-9ba3-908b4d970436",
|
||||
],
|
||||
"msun.edu": [
|
||||
"2b5267b2-ce87-4e77-ad88-5cfec80496b9",
|
||||
"e53216bf-9815-42c7-89c1-953a7b1289a3",
|
||||
"fa8914be-0986-460c-884d-9973a9622045",
|
||||
"b9f734fa-de0d-4a0b-9ce2-c092126e1d8d",
|
||||
],
|
||||
"mainecc.edu": [
|
||||
"2b5267b2-ce87-4e77-ad88-5cfec80496b9",
|
||||
"197da27d-0497-40b5-b2f8-cec4124d32f6",
|
||||
"f7701275-cebc-482b-ac31-9cfcd93937c3",
|
||||
"59ccfdeb-8a8a-4693-b4fa-27034192071c",
|
||||
"849f1551-604a-4b5c-9b5d-e2771eed488c",
|
||||
"cf5d1920-9618-43f3-8dac-53954d19a956",
|
||||
"d8d7bdba-46cf-4d16-b136-2b5f60eee073",
|
||||
"5f35e542-a8cf-4422-8e87-466cdca62864",
|
||||
"55bae3db-5f62-4be3-823a-bcb429b8a2b2",
|
||||
"fa8914be-0986-460c-884d-9973a9622045",
|
||||
"b9f734fa-de0d-4a0b-9ce2-c092126e1d8d",
|
||||
"448f3335-cf11-4e7a-9939-c734861d16e3",
|
||||
"106775db-a00d-4956-bf27-97ea269bb001",
|
||||
"594cd6c0-17db-4241-be56-ad28a8db4f7b",
|
||||
"95f7b67d-3ba8-4d18-bcbb-3e02f7bfaf7a",
|
||||
],
|
||||
"mccneb.edu": [
|
||||
"2b5267b2-ce87-4e77-ad88-5cfec80496b9",
|
||||
"f7701275-cebc-482b-ac31-9cfcd93937c3",
|
||||
"fcfe4ee2-b247-4244-8cfc-f3d98d219fea",
|
||||
"c6b6d415-323e-46c1-859e-be86fd36ec48",
|
||||
"125acb85-889b-4638-a6bb-6eda8e761b08",
|
||||
],
|
||||
"mtu.edu": [],
|
||||
"stchas.edu": [
|
||||
"2b5267b2-ce87-4e77-ad88-5cfec80496b9",
|
||||
"197da27d-0497-40b5-b2f8-cec4124d32f6",
|
||||
"3b149bfe-31c5-4991-bd6c-ba4c760089d4",
|
||||
"b6ae5e37-db6a-4b79-949f-be73b216f677",
|
||||
"bfb708e4-18eb-47b5-afde-737f16721e9a",
|
||||
"f02032d3-3d60-4cb1-acac-855c229646c3",
|
||||
"59ccfdeb-8a8a-4693-b4fa-27034192071c",
|
||||
"849f1551-604a-4b5c-9b5d-e2771eed488c",
|
||||
"4d0bf08e-3dda-4a2e-8213-72a020873a03",
|
||||
"e48c8995-6a64-45c1-ae62-ba96fcc01542",
|
||||
"84d32175-8cb8-4fb0-95cc-6ae13d40aaaa",
|
||||
"27489e34-b04c-410e-99a2-0d93e2e42fbf",
|
||||
"5f35e542-a8cf-4422-8e87-466cdca62864",
|
||||
"f50cb362-2f86-44eb-89e6-bea6ecbaf89f",
|
||||
"fa8914be-0986-460c-884d-9973a9622045",
|
||||
"b9f734fa-de0d-4a0b-9ce2-c092126e1d8d",
|
||||
"106775db-a00d-4956-bf27-97ea269bb001",
|
||||
"594cd6c0-17db-4241-be56-ad28a8db4f7b",
|
||||
],
|
||||
"gveltec.edu": [
|
||||
"3f8dc68e-1458-4199-9641-6781960e085e",
|
||||
"8585fe89-a050-4dbb-beb8-6ebd7358a970",
|
||||
"2b5267b2-ce87-4e77-ad88-5cfec80496b9",
|
||||
"197da27d-0497-40b5-b2f8-cec4124d32f6",
|
||||
"a031d9a8-e433-45cf-826a-8881644f8eac",
|
||||
"3b149bfe-31c5-4991-bd6c-ba4c760089d4",
|
||||
"59ccfdeb-8a8a-4693-b4fa-27034192071c",
|
||||
"849f1551-604a-4b5c-9b5d-e2771eed488c",
|
||||
"4d0bf08e-3dda-4a2e-8213-72a020873a03",
|
||||
"e48c8995-6a64-45c1-ae62-ba96fcc01542",
|
||||
"8302b674-c728-42d2-9ba3-908b4d970436",
|
||||
"604dd8b8-175a-4a74-93d2-28760f1d1835",
|
||||
"26c5277c-440a-4dea-b625-beb986cff673",
|
||||
"1ef34494-4d48-4b69-9819-a22c5870fc24",
|
||||
"84d32175-8cb8-4fb0-95cc-6ae13d40aaaa",
|
||||
"27489e34-b04c-410e-99a2-0d93e2e42fbf",
|
||||
"e5e8565f-80e2-4462-b687-56f6d64f95e4",
|
||||
"5f35e542-a8cf-4422-8e87-466cdca62864",
|
||||
"853de4bd-6f6a-4d1d-980a-b67eb1b0e876",
|
||||
"fa8914be-0986-460c-884d-9973a9622045",
|
||||
"106775db-a00d-4956-bf27-97ea269bb001",
|
||||
"fa8914be-0986-460c-884d-9973a9622045",
|
||||
"106775db-a00d-4956-bf27-97ea269bb001",
|
||||
],
|
||||
}
|
||||
"""
|
||||
@ -1,18 +0,0 @@
|
||||
import pandas as pd
|
||||
import os
|
||||
|
||||
file = "~/Downloads/Anthology-EngageT1T2-MCA-CSV.csv"
|
||||
df = pd.read_csv(file)
|
||||
df["engage"] = df["Groups"].str.contains("(T2)")
|
||||
# print(df["engage"].value_counts())
|
||||
print(df["Domain"].value_counts())
|
||||
df.sort_values("Email", inplace=True)
|
||||
df.drop_duplicates(subset="Email", keep=False, inplace=True)
|
||||
print(df["Domain"].value_counts())
|
||||
|
||||
# df2 = df[[ "Domain", "Groups" ]].copy()
|
||||
# print(df2)
|
||||
|
||||
# accounts = df["Domain"].unique().tolist()
|
||||
# for x in accounts:
|
||||
# df_dict = {name: df.loc[df["Domain"] == name] for name in accounts}
|
||||
@ -1,210 +0,0 @@
|
||||
payload = {
|
||||
"payload": {
|
||||
"person_ids": [
|
||||
"537c590d-2f51-4cf9-936b-ef98b97e7af8",
|
||||
"f44363ca-eff8-4cc9-b67f-d49fcbd1f20d",
|
||||
"3ae7add2-9110-4d57-be90-f5db45260e7e",
|
||||
"07fd80f8-3fe8-4386-84dc-280dade1ed5f",
|
||||
"8bffdf96-3947-4f14-8041-c25e4a488b80",
|
||||
"a82c4c07-8503-414e-a433-ed413d6600c3",
|
||||
"a68a6120-067e-477d-89d5-d1da1a96d09f",
|
||||
"03c65c74-2cb8-4c65-a712-6f0f48939d8b",
|
||||
"56919b58-7be1-4c1b-912f-54887303eefb",
|
||||
"1a01a97b-476d-40b3-8680-8d2b12a9e164",
|
||||
"b7e51667-d26f-4851-8878-d54bb4ce8a51",
|
||||
"a6caff42-f210-4e33-9410-53dbe15d1451",
|
||||
"8506f5ed-aaf2-4f21-8ae4-e2b4ed7b2f1b",
|
||||
"45fb5c92-2c3d-4c49-9f3e-949ab66b06e5",
|
||||
"ea3706d8-c312-4830-8c18-0b7dcc0285d8",
|
||||
"3b32a731-7cc9-4260-a898-b76570b8131a",
|
||||
"10edf9db-3bec-4beb-9047-44da8e3047ab",
|
||||
"3c976bca-3f07-438b-9b8c-953782236666",
|
||||
"e3f1be20-6e7f-452d-87af-ca897a2b35df",
|
||||
"b36d7d59-fc3c-480a-8d6a-9025e6ee4cbb",
|
||||
"ea74604c-18c7-40dd-ae12-492d864ba7ad",
|
||||
"5718e19a-82d4-4855-af92-45c5cf8e670f",
|
||||
"a3cdfd66-76dc-4e11-89ca-8a7fa32d2a47",
|
||||
"123ef7cc-9a29-4a70-9e2c-86567ca02ab8",
|
||||
"399b584b-091a-404b-882a-c30dab8651a4",
|
||||
"afafdd9d-5dd9-4065-8876-304c5aead878",
|
||||
"2d5b81f4-d268-447e-806d-56ea1bed11d5",
|
||||
"6824bf49-c00b-4391-8d2b-8ad523bdf81e",
|
||||
"4ef4054a-2673-4b8b-ae97-485a4e3f5787",
|
||||
"55498b66-5616-4f7c-a29c-9506e3d537cf",
|
||||
"0f4eebaf-793e-4267-9497-17fba27986ea",
|
||||
"94ed3338-37a8-4e84-8e33-229109d61a0f",
|
||||
"4f1c1304-ad6c-4ea6-83f6-c91f363df326",
|
||||
"33362a6f-5515-4d90-b32d-3083d7b7c4d4",
|
||||
"781d706e-3a9f-44dd-acca-2d0570b41544",
|
||||
"58028ff3-4fb3-453b-8cc3-14c831977da4",
|
||||
"56d52d1f-7eee-4f32-ac89-7bbf6c668cdd",
|
||||
"676e5121-7530-4b67-ab68-d4b453f6de1e",
|
||||
"baf1c792-3a87-4357-a93b-871eaabc0ab0",
|
||||
"00969b3e-de91-4133-aa05-421a75651508",
|
||||
"87c4fed6-166e-447a-b542-fb0403188fba",
|
||||
"15de19d9-e435-44d6-9586-bbaafac90667",
|
||||
"f67c2064-cb30-4b5d-9ad3-f3e42c5631ea",
|
||||
"c84a13e9-950f-4109-a7e4-a2412fb6889b",
|
||||
"1d579f1e-cae7-4866-9669-19074dfe8793",
|
||||
"fd6bc3ff-5416-418f-928c-4d1a5e96c651",
|
||||
"7723fe1b-bd33-4b89-84fc-7218303e2bad",
|
||||
"feffbe3e-f188-42c7-80b5-1626009929f3",
|
||||
"3a8a77c0-eb96-4148-bdb8-6854c4b55129",
|
||||
"621bce12-e2f0-4340-b573-8df83713c779",
|
||||
"f8410b69-f5e7-4fbe-b89c-a405173570ac",
|
||||
"132c6541-10ff-4a47-9a23-cb89f26a7ed7",
|
||||
"82adc395-7141-4de2-9b5f-a9c128bdd00f",
|
||||
"8522f536-b77a-4c4b-8025-d6a10410f20a",
|
||||
"eb857569-7fde-47f0-b404-db1a3ace1a19",
|
||||
"daf7691c-5391-4f79-9da6-3ec383f955f0",
|
||||
"242df255-14d0-41b8-ad57-afa4e788bdcf",
|
||||
"fe356134-45d1-4360-8728-b85daaf4b07f",
|
||||
"1d8ffc86-80f5-4d42-8d3f-c705ee2e1482",
|
||||
"23da9e58-b7fc-40cc-bacb-5ec98b9da3df",
|
||||
"f4da7725-9c24-4d63-ba9b-fd1962f1fd4e",
|
||||
"e6954ff8-2fcb-4044-bc8f-423de5b0911d",
|
||||
"f7ec7cf5-bf70-4af6-b4bb-09891362df3f",
|
||||
"57d62b0f-c935-4974-85c9-1bce08afe567",
|
||||
"29c4a6a5-16e9-42c1-8692-5ce800b30bc9",
|
||||
"d0648191-211e-4800-8526-91b2e8019b49",
|
||||
"e4c08d0e-df51-432a-bc6a-648e0cfcb31f",
|
||||
"24dcc76e-23e4-43ce-ad51-06b23f900527",
|
||||
"415515be-c141-4002-83b1-6a6466507278",
|
||||
"998508ee-fc6e-4770-a7b7-19b34eab3f0b",
|
||||
"2beef7d2-7821-4f8b-9f02-63dac27252ad",
|
||||
"d790b773-2ceb-4cc7-8011-05d1f3a83b1f",
|
||||
"33921abd-474a-469b-a114-a8f5bfec8a1a",
|
||||
"48fd210e-0684-45ca-b29d-3d27ffcc5923",
|
||||
"7be60e36-a86d-4dfd-aaac-deb01afcf9bc",
|
||||
"4b7f75e4-d708-45d6-82e8-17e6ab98ba69",
|
||||
"07f30e75-5a77-4b29-897b-caf9833b526b",
|
||||
"303fccc3-cf87-4890-987a-4c246514a4cb",
|
||||
"e0c85f8e-e03d-43b0-94dc-1aaf573a09b0",
|
||||
"5c149b67-f64a-4ca9-810d-39746c9ec892",
|
||||
"9d350ea8-33c1-49d5-99df-066fbbabfa7d",
|
||||
"e29f6842-ac5b-4d8b-9a58-54488df62e8b",
|
||||
"f22a93cd-e419-4c8b-b8ca-0fc44e8a01d3",
|
||||
"2197fdea-28c7-40f2-80d3-067617511c7f",
|
||||
"b1d14179-6287-4e4f-b199-cbe0e820a09a",
|
||||
"3b03ab01-d458-4617-83e7-1c6444421d82",
|
||||
"cd844391-f786-4ea1-bccb-80b1b3a88eba",
|
||||
"964fce35-c10a-458e-b774-d5d36f9f90a3",
|
||||
"9206f9d4-6a43-4418-bfa4-fdc2e80cb601",
|
||||
"00844733-959c-4182-9f23-277f165e1991",
|
||||
"222f8edc-cdca-4638-b93b-57b62cca9bc9",
|
||||
"82b877c2-fba9-47d6-a73d-7e7a73fb9127",
|
||||
"2ee1c1d9-d332-49c0-b186-50dbdffcc5da",
|
||||
"ae1cd5bf-b85e-45c7-b087-136f3099dbff",
|
||||
"a30b533d-c1b6-44ce-a67f-31a1f20a2bf6",
|
||||
"603be042-5434-4482-a1a5-ba3f4f351b0b",
|
||||
"53a70521-9bab-4177-9ec7-21d38ec52da3",
|
||||
"8aa5d835-2a94-437e-9482-8cefbc7f73c5",
|
||||
"5f8c5f02-722c-46a6-b6cd-7fc991ba91fe",
|
||||
"9a69f913-d065-4bd1-8c8f-306b99253077",
|
||||
"6eeacf18-15c7-46c4-98c9-e4cc38d4d927",
|
||||
"f8e2668e-da42-426d-bfd7-7302958acaa8",
|
||||
"134358ea-c9b0-4a7a-94f1-13c58e55a0ee",
|
||||
"8728c40f-b943-40c5-a2fe-26225cb41eae",
|
||||
"575ba093-7bf8-4702-a46d-27a3783310ea",
|
||||
"d5d06c6d-d1af-4340-8ed1-ddd9c4aaa005",
|
||||
"f6f2f233-24db-4541-ab55-813c547b3132",
|
||||
"05e5d881-3896-4ba1-9a78-7eac2518d89c",
|
||||
"3d73474f-5b7e-443a-9a9e-be33333d4a82",
|
||||
"c2bae366-64c9-4bd0-a7d1-251971b65c61",
|
||||
"32db9bd3-30aa-4b7f-add3-27adc42db1be",
|
||||
"9b7acd6b-c1c3-43ec-8578-0a4ba752c44f",
|
||||
"01514376-77b2-4432-8ee4-6f303969318d",
|
||||
"1703965c-a6d4-4b33-8389-92ad9acad858",
|
||||
"3f3e16ac-28da-4d5d-803a-97f3bc4cda8f",
|
||||
"d56bbe1d-2d58-4fea-a84e-3eab4d30f665",
|
||||
"044fb66b-2232-415d-bc47-1c309419ff4a",
|
||||
"f528c291-d2e6-4fd3-9253-24fd9a2a04b3",
|
||||
"138a9b94-56fe-4730-8b3f-b6f678d42922",
|
||||
"117f2aaf-30bb-4b92-b9b2-42a8ae0d72e9",
|
||||
"f250d932-5bb2-472c-98b3-f5fc3ed1254b",
|
||||
"d334a708-4512-4550-ac1e-0d0b1d4020b9",
|
||||
"573be4c2-3b02-4c88-8d29-c170e33d951e",
|
||||
"ee18a795-4c0e-4e3a-accf-9018035a0195",
|
||||
"5acff021-3b6e-4313-a07c-6a000791a093",
|
||||
"71ce9d84-ebd2-4a4c-a074-78ec9070fd22",
|
||||
"59869b4f-a83e-463f-a0d5-241c3b553fc1",
|
||||
"03664560-584c-4b82-b8f2-ec19c083b746",
|
||||
"38a5c677-4443-4d84-8e2d-3cdae3aa0648",
|
||||
"090a8ef5-7987-417f-b50f-12abe955bc7a",
|
||||
"fb2806ac-a1bf-41fd-bd0c-01f4aed2cf3b",
|
||||
"1d78557e-827a-435f-b496-7fe2a78c402b",
|
||||
"97c2d311-9f33-4899-bcfd-5633be0efda8",
|
||||
"cff1bfd8-ebbf-4f63-9b9b-95ffea97fbbc",
|
||||
"fcf0f4cd-4bf1-4be4-a071-84f8055cfa6c",
|
||||
"cfedb93c-e5f9-48d8-9759-bbfed6b80c36",
|
||||
"c2a40abd-ccc2-47af-86a0-2fdd616e5612",
|
||||
"5b12d62b-47f1-461b-88c7-022f50430e77",
|
||||
"09e46a25-779d-4abd-9473-83232fb9fb78",
|
||||
"a83219ba-1124-4dae-a0f1-73ec6e06bf0a",
|
||||
"9367ee67-05e5-4663-a394-2cd3e91655e3",
|
||||
"0633bb08-c971-4fd2-9849-99b20ae1a25c",
|
||||
],
|
||||
"group_ids": [
|
||||
"3f8dc68e-1458-4199-9641-6781960e085e",
|
||||
"8585fe89-a050-4dbb-beb8-6ebd7358a970",
|
||||
"d2542667-0dbf-4680-a5af-042d70f24a55",
|
||||
"2b5267b2-ce87-4e77-ad88-5cfec80496b9",
|
||||
"483c3416-ddfb-43fe-983b-08abb6b50c62",
|
||||
"1582d056-55fb-403b-8a65-f3b641c96b69",
|
||||
"be95bdcc-e72a-4132-8a67-9dde9bad5e2a",
|
||||
"0a3412da-5f73-4738-8364-15d5919750f3",
|
||||
"197da27d-0497-40b5-b2f8-cec4124d32f6",
|
||||
"a031d9a8-e433-45cf-826a-8881644f8eac",
|
||||
"02702bf3-261c-41e0-a22d-26d3e90493a3",
|
||||
"3b149bfe-31c5-4991-bd6c-ba4c760089d4",
|
||||
"b6ae5e37-db6a-4b79-949f-be73b216f677",
|
||||
"bfb708e4-18eb-47b5-afde-737f16721e9a",
|
||||
"f02032d3-3d60-4cb1-acac-855c229646c3",
|
||||
"96b24666-85f2-4f70-ae59-f5a924cc045f",
|
||||
"f7701275-cebc-482b-ac31-9cfcd93937c3",
|
||||
"fcfe4ee2-b247-4244-8cfc-f3d98d219fea",
|
||||
"c6b6d415-323e-46c1-859e-be86fd36ec48",
|
||||
"e53216bf-9815-42c7-89c1-953a7b1289a3",
|
||||
"5eeef2ff-1616-43bb-a0c1-aa84ad551824",
|
||||
"59ccfdeb-8a8a-4693-b4fa-27034192071c",
|
||||
"849f1551-604a-4b5c-9b5d-e2771eed488c",
|
||||
"cf5d1920-9618-43f3-8dac-53954d19a956",
|
||||
"0a5c0100-9500-46a5-a7be-40d03fc5dfe9",
|
||||
"4d0bf08e-3dda-4a2e-8213-72a020873a03",
|
||||
"e48c8995-6a64-45c1-ae62-ba96fcc01542",
|
||||
"0ef5fdd2-718c-47d2-88bc-2d0193b18530",
|
||||
"8302b674-c728-42d2-9ba3-908b4d970436",
|
||||
"604dd8b8-175a-4a74-93d2-28760f1d1835",
|
||||
"26c5277c-440a-4dea-b625-beb986cff673",
|
||||
"8e33adf0-5932-4535-90c7-10fa04e97201",
|
||||
"1ef34494-4d48-4b69-9819-a22c5870fc24",
|
||||
"b2b8d7aa-06e8-4ed5-bc9b-cb9ce0e81309",
|
||||
"e4017ee0-6141-4145-816f-ed68ee6931bc",
|
||||
"84d32175-8cb8-4fb0-95cc-6ae13d40aaaa",
|
||||
"27489e34-b04c-410e-99a2-0d93e2e42fbf",
|
||||
"e5e8565f-80e2-4462-b687-56f6d64f95e4",
|
||||
"27accc37-c3fd-465f-99cd-3e131081aeca",
|
||||
"32e112bd-5495-4399-85dd-1925e1ccbba5",
|
||||
"dc50ca43-5071-45b3-bf42-e1e64416ffd0",
|
||||
"950a6345-5a13-4931-8d82-eac6adef03e3",
|
||||
"700640e7-0de3-49dc-b441-4efff8ad33ba",
|
||||
"5f35e542-a8cf-4422-8e87-466cdca62864",
|
||||
"f50cb362-2f86-44eb-89e6-bea6ecbaf89f",
|
||||
"31a7cbe0-6aa6-403b-a561-6bc4fa81c0b1",
|
||||
"853de4bd-6f6a-4d1d-980a-b67eb1b0e876",
|
||||
"cd0fa4e0-2d24-4b35-918a-33baa736015e",
|
||||
"933baf03-3664-4c33-bd97-208a9f7ab78b",
|
||||
"55bae3db-5f62-4be3-823a-bcb429b8a2b2",
|
||||
"4754b85b-e7a6-41a8-b0e9-5e02c58ebc38",
|
||||
"33f4fc73-102d-492e-9b0a-383d0b0f68b0",
|
||||
"fa8914be-0986-460c-884d-9973a9622045",
|
||||
"b9f734fa-de0d-4a0b-9ce2-c092126e1d8d",
|
||||
"448f3335-cf11-4e7a-9939-c734861d16e3",
|
||||
"106775db-a00d-4956-bf27-97ea269bb001",
|
||||
"594cd6c0-17db-4241-be56-ad28a8db4f7b",
|
||||
"95f7b67d-3ba8-4d18-bcbb-3e02f7bfaf7a",
|
||||
"594cd6c0-17db-4241-be56-ad28a8db4f7b",
|
||||
"95f7b67d-3ba8-4d18-bcbb-3e02f7bfaf7a",
|
||||
],
|
||||
}
|
||||
}
|
||||
@ -1,110 +0,0 @@
|
||||
import pprint
|
||||
import csv
|
||||
import requests
|
||||
import Apikeys
|
||||
|
||||
BASEURL = "https://api.northpass.com/v2"
|
||||
APIKEY = Apikeys.ANTHOLOGY
|
||||
HEADERS = {"accept": "*/*","X-Api-Key": APIKEY,"content-type": "application/json"}
|
||||
pp=pprint.PrettyPrinter(indent=4)
|
||||
|
||||
def main():
|
||||
count = 0
|
||||
new_full_list = []
|
||||
while True:
|
||||
count += 1
|
||||
getpplprops = f"{BASEURL}/properties/people?limit=100&page={count}"
|
||||
# getppl = f"{BASEURL}/people?limit=100&page={count}"
|
||||
getpplreq = requests.get(getpplprops, headers=HEADERS).json()
|
||||
nextlink = getpplreq["links"]
|
||||
for name in getpplreq['data']:
|
||||
uuid = name['id']
|
||||
subscription_levels = name['attributes']['properties']['subscription_levels']
|
||||
if subscription_levels is not None:# or "Core" not in subscription_levels:
|
||||
if "Core" not in subscription_levels:
|
||||
try:
|
||||
subs = subscription_levels.split(", ")
|
||||
except AttributeError as e:
|
||||
print(e)
|
||||
subs = subscription_levels
|
||||
# print(name["attributes"]["properties"]["email"])
|
||||
new_subscriptions = change_property_values(uuid, subs)
|
||||
paired_with_uuid = (uuid, new_subscriptions)
|
||||
new_full_list.append(paired_with_uuid)
|
||||
print(count)
|
||||
|
||||
if "next" not in nextlink or count == 5:
|
||||
break
|
||||
|
||||
return new_full_list
|
||||
|
||||
def change_property_values(uuid, subs):
|
||||
strip_list = []
|
||||
subs = list(filter(lambda x: x != '', subs))
|
||||
subs = list(filter(lambda x: x != ' ', subs))
|
||||
# print("\n")
|
||||
# print(subs)
|
||||
# print(len(subs))
|
||||
for item in subs:
|
||||
stripped = item.strip()
|
||||
x = ""
|
||||
if "Enhanced+" in stripped:
|
||||
x = stripped.replace('Enhanced+', 'Premium')
|
||||
strip_list.append(x)
|
||||
else:
|
||||
if "Enhanced" in stripped:
|
||||
x = stripped.replace("Enhanced", "Core")
|
||||
elif "Essential" in stripped:
|
||||
x = stripped.replace("Essential", "Core")
|
||||
strip_list.append(x)
|
||||
strip_list = list(filter(lambda x: x != '', strip_list))
|
||||
strip_list = set(strip_list)
|
||||
# print(strip_list)
|
||||
# print(len(strip_list))
|
||||
return strip_list
|
||||
|
||||
def chunk_and_push(new_full_list):
|
||||
fill_props_url = f"{BASEURL}/properties/people/bulk"
|
||||
if len(new_full_list) > 10:
|
||||
for chunk in range(0, len(new_full_list), 10):
|
||||
i = chunk
|
||||
mediumload = []
|
||||
to_push = new_full_list[i:i+10]
|
||||
for individuals in to_push:
|
||||
subscripts = individuals[1]
|
||||
subscripts = str(subscripts).replace('{', '').replace('}','').replace("'",'')
|
||||
print(subscripts)
|
||||
miniload = {
|
||||
"attributes": { "properties": { "subscription_level": subscripts } },
|
||||
"id": individuals[0],
|
||||
"type": "person_properties"
|
||||
},
|
||||
mediumload.append(miniload)
|
||||
payload = { "data": mediumload }
|
||||
print(payload)
|
||||
|
||||
def backup_current_props(new_full_list):
|
||||
for pers_props in new_full_list:
|
||||
with open('/Users/normrasmussen/Downloads/new_props_backup.csv', 'a') as file:
|
||||
backup = csv.writer(file, delimiter=',')
|
||||
backup.writerow(pers_props)
|
||||
|
||||
if __name__ == "__main__":
|
||||
new_full_list = main()
|
||||
# backup_current_props(new_full_list)
|
||||
chunk_and_push(new_full_list)
|
||||
# str1 = "Anthology Encompass: Essential"
|
||||
# str2 = str1.replace("Essential", "Core")
|
||||
# print(str1)
|
||||
# print(str2)
|
||||
"""
|
||||
Anthology 101: Essential Anthology Encompass: Essential
|
||||
Anthology Insight: Essential
|
||||
Blackboard Learn: Essential
|
||||
Anthology Planning: Essential
|
||||
Power BI: Essential
|
||||
Anthology Student: Essential
|
||||
Anthology Student: Enhanced
|
||||
Anthology Student: Enhanced+
|
||||
Anthology National University: Enhanced+
|
||||
"""
|
||||
17
Scripts/API_Tests/parse-learner-export.py
Normal file
17
Scripts/API_Tests/parse-learner-export.py
Normal file
@ -0,0 +1,17 @@
|
||||
import pandas as pd
|
||||
|
||||
FILE = "~/Downloads/woodmac-learners.csv"
|
||||
|
||||
|
||||
df = pd.read_csv(FILE)
|
||||
df[["Email", "Domain"]] = df["Email"].str.split("@", expand=True)
|
||||
non_woodmac = df[df["Domain"] != "woodmac.com"]
|
||||
print("All Non WoodMac Domains Status (Combined Domains)")
|
||||
not_wm_status = non_woodmac.value_counts(subset=["Status"]).sort_index()
|
||||
print(not_wm_status)
|
||||
|
||||
print("WoodMac Domain Only Status")
|
||||
filter_woodmac = df[df["Domain"] == "woodmac.com"]
|
||||
woodmac_status = filter_woodmac.value_counts(subset=["Domain", "Status"]).sort_index()
|
||||
print(woodmac_status)
|
||||
|
||||
Reference in New Issue
Block a user