#!/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 debug():
    url = f"{BASE_URL}/api/v3/requests"
    headers = {
        "authtoken": API_TOKEN,
        "Accept": "application/vnd.manageengine.sdp.v3+json"
    }
    
    # Вариант 1: без фильтра, посмотреть все поля
    print("=== Все заявки (без фильтра) ===")
    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()
        requests = data.get("requests", [])
        
        for req in requests:
            print(f"\n--- Заявка {req.get('request_id', '?')} ---")
            print(f"  subject: {req.get('subject')}")
            print(f"  created_time: {req.get('created_time')}")
            print(f"  created_time type: {type(req.get('created_time')).__name__}")
            # Показать все ключи
            print(f"  Ключи: {list(req.keys())}")

if __name__ == "__main__":
    urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
    asyncio.run(debug())
