Finalized Confluence Script and Started Skuid
This commit is contained in:
@ -1,81 +1,28 @@
|
||||
import requests
|
||||
from collections import Counter
|
||||
import pandas as pd
|
||||
|
||||
basecsv = "/Users/normrasmussen/Documents/Northpass/Scripts/G2_Unenroll/g2mca_112122.csv"
|
||||
apiKey = "JRDpCGQ7vSRiva6t5OkWDr5eJ" #G2
|
||||
basecsv = "/Users/normrasmussen/Documents/Northpass/Scripts/G2_Unenroll/skuid_05lp.csv"
|
||||
|
||||
def mainFunc(basecsv, apiKey):
|
||||
def mainFunc(basecsv):
|
||||
readData = pd.read_csv(
|
||||
basecsv,
|
||||
index_col=False,
|
||||
)
|
||||
readData.loc[readData['Course Name'].isin([
|
||||
'G2 Profile Anatomy', 'Profile Performance & Lead Management',
|
||||
'Review Tracking & Brand Building', 'The Review Rundown'])]
|
||||
extractedList = readData.loc[readData['Attempt Start'].isnull(),'Email'].tolist()
|
||||
fourOccs = Counter(extractedList)
|
||||
finalNames = []
|
||||
for name, occurences in fourOccs.items():
|
||||
if occurences == 4:
|
||||
finalNames.append(name)
|
||||
findUuids(finalNames, readData, apiKey)
|
||||
parsedData = readData.drop_duplicates(subset='Course_Name', keep="first")
|
||||
if parsedData.loc[readData['Course Name'].isin([
|
||||
'Get Started with Models - Level 1',
|
||||
'Configure Model Fields - Level 1',
|
||||
'Configure Model Conditions - Level 1',
|
||||
'Configure Model Actions - Level 1',
|
||||
'Manage Models - Level 1',
|
||||
'Intro to UI Only Fields - Level 1'])]:
|
||||
extractedList = readData.loc[readData['Email'].tolist()
|
||||
fourOccs = Counter(extractedList)
|
||||
finalNames = []
|
||||
for name, occurences in fourOccs.items():
|
||||
if occurences == 6:
|
||||
finalNames.append(name)
|
||||
|
||||
def findUuids(finalNames, readData, apiKey):
|
||||
emailUuid = []
|
||||
uuidList = []
|
||||
deactivateUuid = {}
|
||||
try:
|
||||
for name in finalNames:
|
||||
baseUrlname = "https://api.northpass.com/v2/people?filter[email][eq]="
|
||||
name = name
|
||||
url = baseUrlname + f"{name}"
|
||||
headers = {
|
||||
"accept": "*/*",
|
||||
"x-api-key": apiKey,
|
||||
"content-type": "application/json",
|
||||
}
|
||||
response = requests.get(url, headers=headers)
|
||||
response = response.json()
|
||||
uuid = response["data"][0]["id"]
|
||||
uuidList.append(uuid)
|
||||
deactivateUuid.update({name: uuid})
|
||||
emailUuid.append(deactivateUuid)
|
||||
except:
|
||||
print("An error occured")
|
||||
finally:
|
||||
print(deactivateUuid)
|
||||
removeFromGroup(uuidList, apiKey)
|
||||
|
||||
def removeFromGroup(uuidList, apiKey):
|
||||
numRemoved = 0
|
||||
badUuid = []
|
||||
for uuid in uuidList:
|
||||
uuidList = []
|
||||
url = f"https://api.northpass.com/v2/people/{uuid}/relationships/groups"
|
||||
headers = {
|
||||
"accept": "application/json",
|
||||
"content-type": "application/json",
|
||||
"X-Api-Key": apiKey
|
||||
}
|
||||
payload = {"data": [
|
||||
{
|
||||
"id": "d78af2ad-a6c8-4016-90a4-fb00bcc67891",
|
||||
"type": "membership-groups"
|
||||
}
|
||||
]}
|
||||
response = requests.delete(url, json=payload, headers=headers)
|
||||
status = response.status_code
|
||||
if response.status_code == 200:
|
||||
print(f"UserID {uuid} okay to be deleted.")
|
||||
numRemoved += 1
|
||||
uuidList.append(uuid)
|
||||
else:
|
||||
print(f"Some other error {status} for {uuid}")
|
||||
badUuid.append(uuid)
|
||||
print(f"Complete! {numRemoved} people removed from group.")
|
||||
print("Bad UUIDS: ")
|
||||
print(badUuid)
|
||||
|
||||
if __name__ == "__main__":
|
||||
mainFunc(basecsv, apiKey)
|
||||
mainFunc(basecsv)
|
||||
|
||||
27
Scripts/G2_Unenroll/skuid_lp.py
Normal file
27
Scripts/G2_Unenroll/skuid_lp.py
Normal file
@ -0,0 +1,27 @@
|
||||
from collections import Counter
|
||||
import pandas as pd
|
||||
|
||||
basecsv = "/Users/normrasmussen/Documents/Northpass/Scripts/G2_Unenroll/skuid_05lp.csv"
|
||||
|
||||
def mainFunc(basecsv):
|
||||
readData = pd.read_csv(
|
||||
basecsv,
|
||||
index_col=False,
|
||||
)
|
||||
parsedData = readData.drop_duplicates(subset='Course_Name', keep="first")
|
||||
if parsedData.loc[readData['Course Name'].isin([
|
||||
'Get Started with Models - Level 1',
|
||||
'Configure Model Fields - Level 1',
|
||||
'Configure Model Conditions - Level 1',
|
||||
'Configure Model Actions - Level 1',
|
||||
'Manage Models - Level 1',
|
||||
'Intro to UI Only Fields - Level 1'])]:
|
||||
extractedList = readData.loc[readData['Email'].tolist()
|
||||
fourOccs = Counter(extractedList)
|
||||
finalNames = []
|
||||
for name, occurences in fourOccs.items():
|
||||
if occurences == 6:
|
||||
finalNames.append(name)
|
||||
|
||||
if __name__ == "__main__":
|
||||
mainFunc(basecsv)
|
||||
Reference in New Issue
Block a user