Skip to content

Tools for cloning Marketplace Platform agreements with modified licensee or listing while preserving all other details

License

Notifications You must be signed in to change notification settings

softwareone-platform/mpt-clone-agreements

Repository files navigation

Marketplace Platform Agreement Clone Scripts

Simple scripts to clone Marketplace Platform agreements by changing either the licensee or listing while keeping all other agreement details intact.

Installation

  1. Install dependencies:
pip install -r requirements.txt
  1. Configure environment variables. You can either:

    Option A: Put them in ~/.mpt-clone-agreement file:

    OPS_TOKEN=your_operations_token
    VENDOR_TOKEN=your_vendor_token
    API_URL=https://api.portal.platform.softwareone.com
    

    Option 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 URL
  • CSP_TOKEN - CSP token

Usage

1. Dump Agreement (dump_agreement.py)

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-9012

Output files are saved in output/AGR-XXXX-XXXX-XXXX/:

  • agreement_object.json - Original agreement
  • new_agreement_object.json - Modified agreement ready for creation
  • subscriptions.xlsx - Subscription data
  • authorization.json - Authorization details
  • SUB-XXXX-XXXX-XXXX.json - Individual subscription JSON files

2. Create New Agreement (create_new_agreement.py)

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-sync

3. Update Subscription Markups (update_subscription_markups.py)

Update 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-price

4. Terminate Agreement (terminate_agreement.py)

Terminate all subscriptions for an agreement:

python terminate_agreement.py --agreement-id AGR-1234-5678-9012

5. Add Audit Records (add_audit_record.py)

Create audit records for both old and new agreements to track the cloning operation:

python add_audit_record.py --agreement-id AGR-1234-5678-9012

This script:

  • Reads both agreement_object.json (old agreement) and final_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.

Requirements

  • 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-sync flag

Workflow

  1. Run dump_agreement.py with either --listing-id or --licensee-id
  2. Run terminate_agreement.py to terminate the original agreement
  3. Review the generated files in output/AGR-XXXX-XXXX-XXXX/
  4. Run create_new_agreement.py to create the new agreement
  5. Run update_subscription_markups.py to adjust pricing
  6. Run add_audit_record.py to create audit records for tracking

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

About

Tools for cloning Marketplace Platform agreements with modified licensee or listing while preserving all other details

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages