ferrero-opentext/Python-Version/tests/check_asset_metadata.py
DJP d818a8b6a8 Update comprehensive README and reorganize documentation files
Major README overhaul with complete deployment and configuration guide.
Moved old docs to tests/ folder for archive.

README.md UPDATES (880 lines - completely rewritten):
✓ Table of contents with navigation
✓ Complete overview of all 4 workflows + daily report
✓ Detailed authentication section (OAuth2 vs mTLS)
✓ Box-config.json location explanation
✓ Server deployment step-by-step guide
✓ Database setup (Docker + native PostgreSQL)
✓ Cron job examples for all workflows
✓ Comprehensive troubleshooting section
✓ Security checklist
✓ Monitoring and log rotation details
✓ Common SQL queries
✓ File structure diagram

KEY SECTIONS ADDED:
1. What's Included - All 5 scripts explained
2. Quick Start - Local setup guide
3. Server Deployment - 6-step process with commands
4. Workflows - Detailed process for each (A1→A2, A5→A6, B1→B2, A2→A3, Daily Report)
5. Authentication - OAuth2 vs mTLS with examples
6. Configuration - All .env variables documented
7. Database - Schema, setup, queries
8. Monitoring - Logs, emails, database queries
9. Troubleshooting - Common issues + solutions
10. File Structure - Complete directory tree

BOX-CONFIG.JSON LOCATION DOCUMENTED:
✓ Must be one folder up from Python-Version
✓ Referenced as ../Box-config.json in config.yaml
✓ Server deployment instructions include copying both files
✓ Troubleshooting section explains file not found errors

MTLS DOCUMENTATION:
✓ Different base URL explained (dev-auth.app-api.ferrero.com)
✓ --auth-pfx flag usage
✓ Whitelisted IP requirement noted
✓ Certificate testing commands

REORGANIZATION:
- Moved old DEPLOYMENT.md → tests/DEPLOYMENT.md (archive)
- Moved old WORKFLOW_DIAGRAMS.md → tests/WORKFLOW_DIAGRAMS.md (archive)
- New DEPLOYMENT_GUIDE.md is the current deployment doc
- README.md is now comprehensive one-stop documentation

Changes:
- Python-Version/README.md (completely rewritten, 880 lines)
- Moved 2 old docs to tests/ folder
- Added test files to tests/ folder

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-05 10:57:11 -05:00

91 lines
3 KiB
Python

import sys
sys.path.insert(0, '.')
from shared.config_loader import load_config
from shared.dam_client import DAMClient
import json
# Load config
config = load_config('config/config.yaml')
dam = DAMClient(config)
# Asset ID to check
asset_id = 'b1d3c39d6275c00c6aa9d871e18cbf8357210c7c'
print("=" * 80)
print("Fetching asset metadata for:")
print("Asset ID: {}".format(asset_id))
print("=" * 80)
try:
# Get asset details
token = dam.get_access_token()
import requests
response = requests.get(
"{}/v6/assets/{}?load_type=full".format(dam.base_url, asset_id),
headers={
'Authorization': 'Bearer {}'.format(token),
'Accept': 'application/json'
},
verify=False,
timeout=30
)
if response.status_code == 200:
asset_data = response.json()
print("\nAsset Name: {}".format(asset_data.get('name', 'N/A')))
# Check if NOT APPROVED
is_rejected = dam.is_asset_not_approved(asset_data)
print("\nIS NOT APPROVED: {}".format(is_rejected))
# Extract rejection details
if is_rejected:
details = dam.extract_rejection_details(asset_data)
print("\nREJECTION DETAILS:")
print(json.dumps(details, indent=2))
# Look for ECOMMERCE STATUS field
print("\n" + "=" * 80)
print("SEARCHING FOR ECOMMERCE STATUS FIELD:")
print("=" * 80)
metadata = asset_data.get('metadata', {})
metadata_elements = metadata.get('metadata_element_list', [])
found_status = False
for category in metadata_elements:
category_name = category.get('name', 'Unknown')
for element in category.get('metadata_element_list', []):
field_id = element.get('id', '')
field_name = element.get('name', '')
if 'ECOMMERCE' in field_id.upper() or 'STATUS' in field_id.upper() or 'APPROVAL' in field_id.upper():
value = dam._extract_field_value(element)
print("\nFound field:")
print(" Category: {}".format(category_name))
print(" Field ID: {}".format(field_id))
print(" Field Name: {}".format(field_name))
print(" Value: {}".format(value))
found_status = True
if not found_status:
print("\nNo ECOMMERCE STATUS or STATUS fields found!")
# Save full metadata to file for inspection
with open('asset_metadata_debug.json', 'w') as f:
json.dump(asset_data, f, indent=2)
print("\n" + "=" * 80)
print("Full metadata saved to: asset_metadata_debug.json")
print("=" * 80)
else:
print("ERROR: HTTP {}".format(response.status_code))
print(response.text)
except Exception as e:
print("ERROR: {}".format(str(e)))
import traceback
traceback.print_exc()