Simple scripts to clone Marketplace Platform agreements by changing either the licensee or listing while keeping all other agreement details intact.
- Install dependencies:
pip install -r requirements.txt-
Configure environment variables. You can either:
Option A: Put them in
~/.mpt-clone-agreementfile:OPS_TOKEN=your_operations_token VENDOR_TOKEN=your_vendor_token API_URL=https://api.portal.platform.softwareone.comOption B: Export them as environment variables:
export OPS_TOKEN=your_operations_token export VENDOR_TOKEN=your_vendor_token export API_URL=https://api.portal.platform.softwareone.com
Optional variables (only needed for --microsoft-sync flag):
CSP_URL_TUNNEL- CSP tunnel URLCSP_TOKEN- CSP token
Extract agreement and subscription data. Choose either --listing-id or --licensee-id:
# Clone to a different listing
python dump_agreement.py --agreement-id AGR-1234-5678-9012 --listing-id LST-9279-6638
# Clone to a different licensee
python dump_agreement.py --agreement-id AGR-1234-5678-9012 --licensee-id LCE-1234-5678-9012Output files are saved in output/AGR-XXXX-XXXX-XXXX/:
agreement_object.json- Original agreementnew_agreement_object.json- Modified agreement ready for creationsubscriptions.xlsx- Subscription dataauthorization.json- Authorization detailsSUB-XXXX-XXXX-XXXX.json- Individual subscription JSON files
Create the new agreement from the dumped data:
# Create subscriptions from Excel/JSON files
python create_new_agreement.py --agreement-id AGR-1234-5678-9012
# Or trigger Microsoft platform sync
python create_new_agreement.py --agreement-id AGR-1234-5678-9012 --microsoft-syncUpdate markups for subscriptions based on Excel data:
# Dry run (default)
python update_subscription_markups.py --agreement-id AGR-1234-5678-9012
# Apply changes
python update_subscription_markups.py --agreement-id AGR-1234-5678-9012 --no-dry-run
# Keep purchase price when updating
python update_subscription_markups.py --agreement-id AGR-1234-5678-9012 --no-dry-run --keep-purchase-priceTerminate all subscriptions for an agreement:
python terminate_agreement.py --agreement-id AGR-1234-5678-9012Create audit records for both old and new agreements to track the cloning operation:
python add_audit_record.py --agreement-id AGR-1234-5678-9012This script:
- Reads both
agreement_object.json(old agreement) andfinal_agreement.json(new agreement) - Creates an audit record for the old agreement documenting it was cloned to the new one
- Creates an audit record for the new agreement documenting it was cloned from the old one
- Both audit records include complete agreement payloads for reference
Note: This script requires both dump_agreement.py and create_new_agreement.py to have been run first.
- Operations Token (OPS_TOKEN): Required for reading agreements and subscriptions
- Vendor Token (VENDOR_TOKEN): Required for creating/updating agreements and subscriptions
- CSP Token (CSP_TOKEN): Only required if using
--microsoft-syncflag
- Run
dump_agreement.pywith either--listing-idor--licensee-id - Run
terminate_agreement.pyto terminate the original agreement - Review the generated files in
output/AGR-XXXX-XXXX-XXXX/ - Run
create_new_agreement.pyto create the new agreement - Run
update_subscription_markups.pyto adjust pricing - Run
add_audit_record.pyto create audit records for tracking
This project is licensed under the Apache License 2.0. See the LICENSE file for details.