<reponame>jojowei-cooler/ad
import requests
import requests.packages.urllib3
requests.packages.urllib3.disable_warnings()
import json

def upload_to_dashboard(ue_name, du_name, degradation, timestamp):
    ThingName="jojo_datatable"
    ServiceName="Upload"
    Appkey="<KEY>" 
    # Appkey is from thingworx, for accessing thingworx key
    
    pre_url = 'https://192.168.3.11:5033/Thingworx/Things/'
    url=pre_url+ThingName+'/Services/'+ServiceName

    payload={
        "UE" : ue_name,
        "DU": du_name,
        "Degradation": degradation,
        "Timestamp": timestamp
    }
    headers={
        "appKey": Appkey,
        "Content-Type": "application/json"
    }
    r= requests.put(url, data=json.dumps(payload), headers=headers, verify=False)

def delete_dashboard_element(ue_name):
    ThingName="jojo_datatable"
    ServiceName="Deletion"
    Appkey="<KEY>" 
    # Appkey is from thingworx, for accessing thingworx key
    
    pre_url = 'https://192.168.3.11:5033/Thingworx/Things/'
    url=pre_url+ThingName+'/Services/'+ServiceName

    payload={
        "UE" : ue_name
    }
    headers={
        "appKey": Appkey,
        "Content-Type": "application/json"
    }
    r= requests.put(url, data=json.dumps(payload), headers=headers, verify=False)