Skip to content

Instantly share code, notes, and snippets.

@reubendevries-cta
Created March 15, 2021 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reubendevries-cta/1b1edf6000ad10278e15ac8173e745a3 to your computer and use it in GitHub Desktop.
Save reubendevries-cta/1b1edf6000ad10278e15ac8173e745a3 to your computer and use it in GitHub Desktop.
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