Files
Gainsight/Scripts/API_Tests/addalltogroup.py
2023-02-09 10:50:14 -05:00

51 lines
1.3 KiB
Python

import requests
apiKey = "84GO7zb7a990UJrnFJqiYcd0m"
# Skuid's API
def getallUuid(apiKey):
x = 0
uuid = []
while True:
x += 1
url = f"https://api.northpass.com/v2/people?page={x}"
headers = {"accept": "application/json", "X-Api-Key": apiKey}
response = requests.get(url, headers=headers)
jsonResponse = response.json()
next = jsonResponse["links"]
for id in jsonResponse["data"]:
user = id["id"]
uuid.append(user)
if "next" not in next:
break
print(uuid)
addtoGroup(apiKey, uuid)
def addtoGroup(apiKey, uuid):
for x in uuid:
url = f"https://api.northpass.com/v2/people/{x}/relationships/groups"
payload = {
"data": [
{
"type": "membership-groups",
"id": "2f9aaac9-000a-4888-be33-3b65b76b5b9f",
}
]
}
headers = {
"accept": "application/json",
"content-type": "application/json",
"X-Api-Key": apiKey,
}
response = requests.post(url, json=payload, headers=headers)
# jsonResponse = response.json()
print(response)
if __name__ == "__main__":
getallUuid(apiKey)