Example:
Basic Code to use Python and Split REST API to delete a given feature flags names from all workspaces.
How to use:
- Class wrapper for Admin API, installation instructions in this link: Python Admin API Library Wrapper
- Update your relevant Split Admin API key in code below.
- Update the feature flags array with feature flag names to be deleted.
Note: Please be very careful when running the script below, once a feature flag is deleted, there is no Undo or Undelete operation.
from splitapiclient.main import get_client
#############################################
splits = ['split1', 'split2', 'split3']
#############################################
client = get_client({'apikey': 'ADMIN API KEY'})
for ws in client.workspaces.list():
print("Workspace: "+ws.name)
for env in client.environments.list(ws.id):
print("Environment: "+env.name)
for spDef in client.split_definitions.list(env.id, ws.id):
for split in splits:
if spDef._name==split:
print("Split: "+spDef.name+", deleting definition")
client.splits.remove_from_environment(split, env.id, ws.id)
for split in splits:
for sp in client.splits.list(ws.id):
if split==sp._name:
print("deleting split "+split)
ws.delete_split(split)
Comments
0 comments
Please sign in to leave a comment.