Example:
Basic Code to use Python and Split REST API to delete a given feature flags names from all projects.
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
#############################################
feature_flags = ['feature_flag1', 'feature_flag2', 'feature_flag3']
#############################################
client = get_client({'apikey': 'ADMIN API KEY'})
for project in client.workspaces.list():
print("Project: "+project.name)
for env in client.environments.list(project.id):
print("Environment: "+env.name)
for flagDef in client.split_definitions.list(env.id, project.id):
for flag in feature_flags:
if flagDef._name==flag:
print("Feature flag: "+flagDef.name+", deleting definition")
client.splits.remove_from_environment(flag, env.id, project.id)
for flag in feature_flags:
for ff in client.splits.list(project.id):
if flag==ff._name:
print("deleting feature flag "+flag)
project.delete_split(flag)
Comments
0 comments
Please sign in to leave a comment.