52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
import json
|
|
import os
|
|
import re
|
|
|
|
def find_param_defs(har_path):
|
|
param_map = {}
|
|
with open(har_path, 'r', encoding='utf-8') as f:
|
|
har_data = json.load(f)
|
|
|
|
for entry in har_data['log']['entries']:
|
|
resp = entry['response']
|
|
if 'content' in resp and 'text' in resp['content']:
|
|
text = resp['content']['text']
|
|
# Search for pattern "svcOperationCfsParamId":X,"svcOperationCfsParam":"NAME"
|
|
# Or "svcOperationCfsParamId":X ... "svcOperationCfsParam":"NAME"
|
|
# Matches in JSON structure
|
|
try:
|
|
data = json.loads(text)
|
|
def walk(obj):
|
|
if isinstance(obj, dict):
|
|
if 'svcOperationCfsParamId' in obj and 'svcOperationCfsParam' in obj:
|
|
param_map[obj['svcOperationCfsParamId']] = {
|
|
'name': obj['svcOperationCfsParam'],
|
|
'label': obj.get('label'),
|
|
'dataType': obj.get('dataType'),
|
|
'isRequired': obj.get('isRequired')
|
|
}
|
|
for v in obj.values():
|
|
walk(v)
|
|
elif isinstance(obj, list):
|
|
for item in obj:
|
|
walk(item)
|
|
walk(data)
|
|
except:
|
|
pass
|
|
return param_map
|
|
|
|
har_files = [
|
|
'/home/naeel/terra/har/f12vmbad.har',
|
|
'/home/naeel/terra/har/f12vmbad1.har',
|
|
'/home/naeel/terra/har/faststart.har'
|
|
]
|
|
|
|
all_params = {}
|
|
for h in har_files:
|
|
if os.path.exists(h):
|
|
all_params.update(find_param_defs(h))
|
|
|
|
# Print mapping
|
|
for pid in sorted(all_params.keys()):
|
|
print(f"{pid}: {all_params[pid]}")
|