Skip to content

Split-Community/delete-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 

Repository files navigation

Harness FME Project Cleanup Script

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.

Overview

This script systematically deletes resources associated with a specific workspace/project in FME, including:

  1. Environment-level resources:

    • Splits/Feature Flags
    • Segments (standard, rule-based, and large segments)
  2. Project-level resources:

    • Splits/Feature Flags
    • Segments (all types)
    • Traffic Types
    • Flag Sets
  3. Infrastructure:

    • SDK keys/API keys listed in environmentNameToSDKKeyMap
    • Environments
    • Project components that can be deleted through the Split API client

Prerequisites

  • 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

Configuration

Before running the script, configure the following parameters:

  1. projectName: Name of the workspace/project to delete
  2. thisApiKey: Your Harness FME admin token
  3. environmentNameToSDKKeyMap: Dictionary mapping exact environment names to the SDK keys that should be deleted for each environment
  4. dryRun: Set to True to run in simulation mode, or False to 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 resources

If 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.

Usage

Simply run the script with Python:

python delete_all.py

Dry Run Mode

The script supports a dry run mode for safely previewing what would be deleted without actually making any changes:

  1. Leave dryRun = True at the top of the script
  2. Run the script as normal
  3. Review the output to see what would be deleted
  4. When ready to proceed with actual deletion, set dryRun = False

Deletion Order

The script deletes resources in this order:

  1. Environment-level split/feature flag definitions
  2. Environment-level segment definitions, rule-based segment definitions, and large segment definitions
  3. Project-level splits/feature flags
  4. Project-level segments, rule-based segments, and large segments
  5. Traffic types
  6. Flag sets
  7. SDK keys listed in environmentNameToSDKKeyMap
  8. 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.

Error Handling

The script may fail with the following errors:

  • 'NoneType' object has no attribute 'id': This occurs if the workspace specified in projectName cannot 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.

Warning

USE WITH CAUTION

This script performs irreversible deletion of data. Once executed, all specified resources will be permanently removed. It is recommended to:

  1. Verify the projectName carefully before running
  2. Back up any important configuration before deletion
  3. Use in non-production environments first to understand the behavior

Dependencies

splitapiclient

Install using:

pip install splitapiclient

About

Sample code to delete all components of a project in FME

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages