Adjusting env calls

master
Patryk Gudalewicz 2022-10-28 10:02:40 +02:00
parent 2c45333704
commit 2b12f710a0
1 changed files with 3 additions and 3 deletions

View File

@ -57,7 +57,7 @@ def get_all_dashboards_withname(DTAPIToken, DTENV,name):
def remove_dashboards(DTAPIToken, DTENV, dashboards):
for dashboard in dashboards:
print("Removing dashboard from Dynatrace: "+dashboard["name"])
DTAPIURL = DTENV + "api/config/v1/dashboards/" + dashboard["id"]
DTAPIURL = DTENV + "/api/config/v1/dashboards/" + dashboard["id"]
print(make_request(DTAPIURL,DTAPIToken,True,"delete",None))
def create_or_update_dashboard(DTAPIToken, DTENV, dashboards, templatename, dashname):
@ -70,7 +70,7 @@ def create_or_update_dashboard(DTAPIToken, DTENV, dashboards, templatename, dash
existingdashboard = next((dashboard for dashboard in dashboards if dashboard["name"] == dashname), None)
if existingdashboard:
print("Found dashboard, Name: "+ existingdashboard["name"])
DTAPIURL = DTENV + "api/config/v1/dashboards/" + existingdashboard["id"]
DTAPIURL = DTENV + "/api/config/v1/dashboards/" + existingdashboard["id"]
r = make_request(DTAPIURL,DTAPIToken,True,"get",None)
entityResponse = r.json()
entityResponse["tiles"] = tilesjson
@ -87,7 +87,7 @@ def create_or_update_dashboard(DTAPIToken, DTENV, dashboards, templatename, dash
},
"tiles":[]
}
DTAPIURL = DTENV + "api/config/v1/dashboards"
DTAPIURL = DTENV + "/api/config/v1/dashboards"
newdashboard["tiles"] = tilesjson
print("Creating dashboard: "+newdashboard["dashboardMetadata"]["name"])
print(make_request(DTAPIURL,DTAPIToken,True,"post",json.dumps(newdashboard)))