Example: Basic Code to use Python and Split REST API to export all Split definitions JSON structure in all environments and workspaces to files.
Environment:
- Python 2.7.15
- request 2.20.1
How to use:
- Class wrapper for Admin API is:
SplitAPI.py
- Update your relevant Split Admin API Key in:
Main.py
- File name will be [Workspace Name]_[Environment Name]_[Split Name].json
#############################################
targetFolder="/Users/bilalal-shahwany/Desktop/WeWork/"
#############################################
def SaveToFile(splitDefinition, splitName, workspaceName, environmentName):
reportObj = open(targetFolder+workspaceName+"_"+environmentName+"_"+splitName+".json", "w")
json.dump(splitDefinition, reportObj)
reportObj.close()
mySplit = SplitAPI.SplitAPI('ADMIN API KEY')
for workspace in mySplit.GetWorkspaces():
print "Workspace: "+workspace['name']
for environment in mySplit.GetEnvironments(workspace['id']):
print "Environment: "+environment['name']
for split in mySplit.GetSplitsInEnvironment(workspace['id'], environment['name']):
time.sleep(1)
print "Exporting Split: "+split['name']
SaveToFile(mySplit.GetSplitDefinition(workspace['id'], split['name'], environment['name']), split['name'], workspace['name'], environment['name'])
Comments
0 comments
Please sign in to leave a comment.