feat(data_store): finalize V3 cascading lookup with limit override

- Update GET /v3/data_store/code/{code} to support 'limit' query parameter.
- Refactor return logic: returns single object if limit=1, otherwise returns a list.
- Clean up formatting in GUIDE__V3_FRONTEND_API.md and sync to agents_sync.
- Finalize unified E2E test script: tests/e2e/test_e2e_v3_data_store_lookup.py.
This commit is contained in:
Scott Idem
2026-01-28 17:01:34 -05:00
parent fdcc859017
commit 0606cecb61
3 changed files with 40 additions and 46 deletions

View File

@@ -15,11 +15,11 @@ CONTEXTS = {
"event_1358": "nmBfuGFeR0k"
}
def run_lookup(code, description, account_id=None, for_type=None, for_id=None, version="v3"):
def run_lookup(code, description, account_id=None, for_type=None, for_id=None, limit=1, version="v3"):
"""
Performs a Data Store lookup and prints standardized results.
"""
print(f"[{version.upper()}] {description}")
print(f"[{version.upper()}] {description} (Limit: {limit})")
headers = {
"X-Aether-API-Key": AGENT_API_KEY,
@@ -33,7 +33,7 @@ def run_lookup(code, description, account_id=None, for_type=None, for_id=None, v
if version == "v3":
url = f"{BASE_URL}/v3/data_store/code/{code}"
params = {"for_type": for_type, "for_id": for_id}
params = {"for_type": for_type, "for_id": for_id, "limit": limit}
response = requests.get(url, headers=headers, params=params)
else:
# Legacy Endpoint
@@ -41,7 +41,7 @@ def run_lookup(code, description, account_id=None, for_type=None, for_id=None, v
url = f"{BASE_URL}/data_store/code/{code}/{for_type}/{for_id}"
else:
url = f"{BASE_URL}/data_store/code/{code}"
response = requests.get(url, headers=headers)
response = requests.get(url, headers=headers, params={"limit": limit})
print(f" URL: {response.url}")
print(f" Status: {response.status_code}")
@@ -49,11 +49,14 @@ def run_lookup(code, description, account_id=None, for_type=None, for_id=None, v
if response.status_code == 200:
data = response.json().get('data')
if data:
obj = data[0] if isinstance(data, list) else data
rec_id = obj.get('id') or obj.get('data_store_id') or obj.get('data_store_id_random')
print(f" Result: SUCCESS")
print(f" ID: {rec_id}")
print(f" Name: {obj.get('name')}")
if isinstance(data, list):
print(f" Result: SUCCESS (List of {len(data)})")
for i, item in enumerate(data):
print(f" [{i+1}] ID: {item.get('id') or item.get('data_store_id')}, Name: {item.get('name')[:40]}...")
else:
print(f" Result: SUCCESS (Single Object)")
print(f" ID: {data.get('id') or data.get('data_store_id')}")
print(f" Name: {data.get('name')}")
else:
print(f" Result: NULL (No record found or validation failed)")
else:
@@ -69,25 +72,16 @@ if __name__ == "__main__":
print(f"Target: {BASE_URL}")
print(f"Code: {args.code}\n")
# 1. Global Context
run_lookup(args.code, "Scenario: Global Context (Bypass Account)")
# 1. Standard Single Result (Default)
run_lookup(args.code, "Scenario: Single Result (Default)", account_id=CONTEXTS["account_1"])
# 2. Account 1 Context
run_lookup(args.code, "Scenario: Account 1 Context", account_id=CONTEXTS["account_1"])
# 2. Multi-Result Override (Limit 5)
run_lookup(args.code, "Scenario: Multi-Result Override", account_id=CONTEXTS["account_1"], limit=5)
# 3. Account 22 Context
run_lookup(args.code, "Scenario: Account 22 Context", account_id=CONTEXTS["account_22"])
# 4. Object Specific Context (Event 1358 - belongs to Account 1)
# 3. Object Specific Context (Event 1358)
run_lookup(args.code, "Scenario: Event 1358 (under Account 1)",
account_id=CONTEXTS["account_1"],
for_type="event",
for_id=CONTEXTS["event_1358"])
# 5. Cross-Account Security Check (Event 1358 requested by Account 23)
run_lookup(args.code, "Scenario: Security Check (Event 1358 by Account 23 - SHOULD BE NULL)",
account_id=CONTEXTS["account_23"],
for_type="event",
for_id=CONTEXTS["event_1358"])
print("\nTests Complete.")