-
-
Save reubendevries-cta/1b1edf6000ad10278e15ac8173e745a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def remove_user_from_atlassian(at_api_key, email): | |
secret_value = at_api_key["Atlassian-API"] | |
auth = HTTPBasicAuth("emailaddress@emailaddress.com", "{}".format(secret_value)) | |
headers = { | |
"Accept": "application/json" | |
} | |
api = "https://organizationspace.atlassian.net/rest/api/3/" | |
search_all_users = "users/search" | |
url = api + search_all_users | |
list_all_users = requests.get(url, headers=headers, auth=auth) | |
response = json.loads(list_all_users.text) | |
for users in response: | |
account_id = users["accountId"].split(":")[-1] | |
print(account_id) | |
user_email = "users/email" | |
params = { | |
"accountId": account_id | |
} | |
url = api + user_email | |
response = requests.get(url, headers=headers, auth=auth, params=params) | |
print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": "))) | |
for email in response: | |
print(json.loads(email)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment