from fastapi import APIRouter, Request
from typing import Any, List, Dict, Union
from app.services.tjnetwork import (
    Any,
    ChangeSet,
    get_tag,
    get_tag_schema,
    get_tags,
    set_tag,
)

router = APIRouter()

############################################################
# tag 8.[TAGS]
############################################################

@router.get("/gettagschema/")
async def fastapi_get_tag_schema(network: str) -> dict[str, dict[str, Any]]:
    return get_tag_schema(network)

@router.get("/gettag/")
async def fastapi_get_tag(network: str, t_type: str, id: str) -> dict[str, Any]:
    return get_tag(network, t_type, id)

@router.get("/gettags/")
async def fastapi_get_tags(network: str) -> list[dict[str, Any]]:
    tags = get_tags(network)
    return tags

@router.post("/settag/", response_model=None)
async def fastapi_set_tag(network: str, req: Request) -> ChangeSet:
    props = await req.json()
    return set_tag(network, ChangeSet(props))
