ferrero-opentext/Python-Version/scripts
DJP 766063079c Remove slow job polling, add fast folder search for asset IDs
Replaces 20+ second job polling with instant folder search.

PERFORMANCE IMPROVEMENT:
Before: Poll job 10 times, 2 sec each = 20+ seconds per upload
After: No polling, instant return + optional folder search

CHANGES:
1. Removed job polling from upload_asset()
   - No more 20 second waits
   - Returns job_id immediately for async uploads
   - Adds 'is_async' flag to response

2. NEW METHOD: find_asset_by_filename_in_folder()
   - Fast search by filename in folder
   - Can be called after batch uploads complete
   - Returns actual asset ID instantly

UPLOAD FLOW:
Immediate Response (201):
  → Returns asset ID immediately
  → Log: "Upload successful (immediate): file.jpg → Asset ID: abc123"

Async Response (202):
  → Returns job ID immediately (no waiting!)
  → Log: "Upload accepted (async): file.jpg → Job ID: job456"
  → Log: "Note: Job processing in background. Asset ID can be found later."

FINDING ASSET ID LATER (OPTIONAL):
After batch uploads, call once per folder:
```python
# Upload all files first (fast!)
for file in files:
    result = dam.upload_asset(...)
    job_ids.append(result['job_id'])

# Then search folder for actual IDs (one API call)
for filename in filenames:
    asset_id = dam.find_asset_by_filename_in_folder(folder_id, filename)
```

BENEFITS:
✓ No 20 second waits per file
✓ Batch uploads can run quickly
✓ Optional post-upload search for asset IDs
✓ Single API call to get all IDs

USE CASES:
- Fast uploads: Don't need immediate asset ID
- Batch processing: Upload many files quickly
- Later retrieval: Search folder when needed
- Status updates: Can update campaign without waiting

The job_id is stored and can be used for tracking.
Actual asset_id can be retrieved later if needed.

Changes:
- scripts/shared/dam_client.py
  - Removed polling from upload_asset()
  - Added find_asset_by_filename_in_folder() method
  - Returns immediately with job_id for async
  - Added 'is_async' flag to response

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-05 14:12:39 -05:00
..
shared Remove slow job polling, add fast folder search for asset IDs 2025-11-05 14:12:39 -05:00
a1_to_a2_download.py Add optional mTLS certificate authentication with --auth-pfx flag 2025-11-04 18:01:23 -05:00
a2_to_a3_upload.py Complete Python automation implementation - All components built 2025-10-30 16:49:14 -04:00
a2_to_a3_upload_polling.py Add --keep-files flag to A2→A3 script to preserve Box files 2025-11-05 13:17:11 -05:00
a5_to_a6_download.py Add optional mTLS certificate authentication with --auth-pfx flag 2025-11-04 18:01:23 -05:00
b1_to_b2_download.py Add optional mTLS certificate authentication with --auth-pfx flag 2025-11-04 18:01:23 -05:00
daily_report.py Add daily summary report with comprehensive statistics 2025-11-04 16:34:44 -05:00
test_connection.py Add optional mTLS certificate authentication with --auth-pfx flag 2025-11-04 18:01:23 -05:00
test_mtls_cert.py Add optional mTLS certificate authentication with --auth-pfx flag 2025-11-04 18:01:23 -05:00
test_mtls_debug.py Add separate mTLS base URL configuration for certificate authentication 2025-11-05 08:25:31 -05:00