Skip to content

Instantly share code, notes, and snippets.

@cundi cundi/demo.py
Created Jan 8, 2018

Embed
What would you like to do?
demo for delete kandy user
huatang_DAK = xxx
huatang_DAS = xxx
def get_dat(dak, das):
"""
Domain access token
GET
/v1.3/domains/accessTokens{?key,domain_api_secret}
"""
url = api_host + '/v1.3/domains/accessTokens?key={0}&domain_api_secret={1}'.format(dak, das)
r = get(url)
DAT = r.json()['result']['domain_access_token']
return DAT
def get_domain_users(dak, das):
"""
Get a list of Users for a Domain
"""
url = api_host + '/v1.3/domains/users?key={DAT}'.format(DAT=get_dat(dak, das))
r = get(url)
resp = r.json()
return resp
def delete_domain_users():
"""
"""
url = 'https://api.kandycn.com/v1.3/domains/users?key={0}&user_api_key={1}'
raw_users = get_domain_users(huatang_DAK, huatang_DAS)
users = raw_users.get('result').get('users')
headers = {'content-type': 'application/json'}
DAT = get_dat(huatang_DAK, huatang_DAS)
print(DAT)
for i in users:
uak = i['user_api_key']
response = delete(url.format(DAT, uak), headers=headers)
print(response)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.