
import network_constants as nc
from security.token_manager import TokenManager
import requests
from typing import List

def postTableToSwagger(use_case:str, table:dict ):

    jwt = TokenManager.getInstance().getToken()

    url = f"https://articonf1.itec.aau.at:30420/api/use-cases/{use_case}/tables"

    response = requests.post(
            url,
            verify=False, 
            proxies = { "http":None, "https":None },
            headers = { "Authorization": f"Bearer {jwt}"},
            json = table
        )

    print(url+": "+str(response.status_code)+" MSG:"+str(response.content))


def postLayersToSwagger(use_case:str, layers: List[dict]):
    
    jwt = TokenManager.getInstance().getToken()

    for layer in layers:
        url = f"https://articonf1.itec.aau.at:30420/api/layers"

        response = requests.post(
            url,
            verify=False, 
            proxies = { "http":None, "https":None },
            headers = { "Authorization": f"Bearer {jwt}"},
            json = layer
        )

        print(url+": "+str(response.status_code)+" MSG:"+str(response.content))