#!/usr/bin/env python3
import asyncio
import httpx
import json
import urllib3

BASE_URL = "https://192.168.1.237:8080"
API_TOKEN = "062CE056-C1F5-490C-A6DF-FD2C653A71DD"

async def main():
    url = f"{BASE_URL}/api/v3/requests"
    headers = {
        "authtoken": API_TOKEN,
        "Accept": "application/vnd.manageengine.sdp.v3+json"
    }
    
    async with httpx.AsyncClient(verify=False, timeout=30.0) as client:
        resp = await client.get(url, headers=headers, params={
            "input_data": json.dumps({
                "list_info": {"row_count": 100, "start_index": 1}
            })
        })
        data = resp.json()
        print(f"Status: {resp.status_code}")
        print(f"Has more: {data.get('list_info', {}).get('has_more_rows')}")
        requests = data.get("requests", [])
        print(f"Total: {len(requests)}")
        for r in requests:
            print(f"  ID={r.get('id')} subject={r.get('subject')} created={r.get('created_time')}")

if __name__ == "__main__":
    urllib3.disable_warnings()
    asyncio.run(main())
