A utility script for removing resources from a Harness FME/Split.io project workspace.
The script is configured for Harness-mode accounts by default:
client = get_client({
'harness_token': thisApiKey,
'harness_mode': True
})Project deletion is intentionally not executed by the script. After the script removes the project components it can access through the API, delete the project manually from the Harness UI if needed.
This script systematically deletes resources associated with a specific workspace/project in FME, including:
-
Environment-level resources:
- Splits/Feature Flags
- Segments (standard, rule-based, and large segments)
-
Project-level resources:
- Splits/Feature Flags
- Segments (all types)
- Traffic Types
- Flag Sets
-
Infrastructure:
- SDK keys/API keys listed in
environmentNameToSDKKeyMap - Environments
- Project components that can be deleted through the Split API client
- SDK keys/API keys listed in
- Python 3.x
- Split API Client library (
splitapiclient) - Harness FME admin token with permissions to delete project resources
- SDK keys for each environment whose API keys should be deleted
Before running the script, configure the following parameters:
projectName: Name of the workspace/project to deletethisApiKey: Your Harness FME admin tokenenvironmentNameToSDKKeyMap: Dictionary mapping exact environment names to the SDK keys that should be deleted for each environmentdryRun: Set toTrueto run in simulation mode, orFalseto perform deletions
Example:
projectName = 'YOUR_PROJECT_NAME'
thisApiKey = 'your-harness-token'
environmentNameToSDKKeyMap = {
'Production': ['prod-sdk-key'],
'Staging': ['staging-sdk-key'],
}
dryRun = True # Set to False only when you are ready to delete resourcesIf you are running against a legacy Split account instead of a Harness FME account, update the get_client configuration to use the appropriate Split API client authentication options for that account.
Simply run the script with Python:
python delete_all.pyThe script supports a dry run mode for safely previewing what would be deleted without actually making any changes:
- Leave
dryRun = Trueat the top of the script - Run the script as normal
- Review the output to see what would be deleted
- When ready to proceed with actual deletion, set
dryRun = False
The script deletes resources in this order:
- Environment-level split/feature flag definitions
- Environment-level segment definitions, rule-based segment definitions, and large segment definitions
- Project-level splits/feature flags
- Project-level segments, rule-based segments, and large segments
- Traffic types
- Flag sets
- SDK keys listed in
environmentNameToSDKKeyMap - Environments
The workspace/project itself is not deleted by default. The workspace deletion code is commented out because Harness FME projects accessed from app.harness.io must be deleted from the Harness UI or another Harness-supported path.
The script may fail with the following errors:
'NoneType' object has no attribute 'id': This occurs if the workspace specified inprojectNamecannot be found. Verify the workspace name is correct and that your API key has access to it.- API permission errors: Ensure your Harness FME token has sufficient permissions to delete all resource types.
- Missing SDK key cleanup: SDK keys are only deleted for environments included in
environmentNameToSDKKeyMap. - Because the API does not have access to metric configurations, the script will not delete them. This also means that traffic types will not be deleted if they are used in a metric and this will result in errors.
USE WITH CAUTION
This script performs irreversible deletion of data. Once executed, all specified resources will be permanently removed. It is recommended to:
- Verify the
projectNamecarefully before running - Back up any important configuration before deletion
- Use in non-production environments first to understand the behavior
splitapiclient
Install using:
pip install splitapiclient