Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to the dashboard and improvements to the queries #185

Merged
merged 4 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dashboards/SAT_Dashboard_definition.json

Large diffs are not rendered by default.

16 changes: 6 additions & 10 deletions notebooks/Setup/5. import_dashboard_template_lakeview.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

# COMMAND ----------

# COMMAND ----------

dfexist = readWorkspaceConfigFile()
dfexist.filter((dfexist.analysis_enabled==True) & (dfexist.connection_test==True)).createOrReplaceTempView('all_workspaces')

Expand Down Expand Up @@ -75,7 +77,6 @@
import requests

DOMAIN = ws.deployment_url
loggr.info(f"Looking for data_source_id for : {json_['sql_warehouse_id']}!")
response = requests.get(
'https://%s/api/2.0/preview/sql/data_sources' % (DOMAIN),
headers={'Authorization': 'Bearer %s' % token},
Expand All @@ -88,13 +89,11 @@
for resource in resources:
if resource['endpoint_id'] == json_['sql_warehouse_id']:
data_source_id = resource['id']
loggr.info(f"Found data_source_id for : {json_['sql_warehouse_id']}!")
found = True
break
if (found == False):
dbutils.notebook.exit("The configured SQL Warehouse Endpoint is not found.")
else:
loggr.info(f"Error with token, {response.text}")
dbutils.notebook.exit("Invalid access token, check configuration value for this workspace.")


Expand Down Expand Up @@ -146,9 +145,8 @@ def replace_string(obj, old_str, new_str):

import requests

BODY = {'path': f'{basePath()}/[SAT] Security Analysis Tool - Workspace In-Depth.lvdash.json'}
BODY = {'path': f'{basePath()}/[SAT] Security Analysis Tool - Assessment Results.lvdash.json'}

loggr.info(f"Getting Dashboard")
response = requests.get(
'https://%s/api/2.0/workspace/get-status' % (DOMAIN),
headers={'Authorization': 'Bearer %s' % token},
Expand All @@ -172,7 +170,6 @@ def replace_string(obj, old_str, new_str):

if exists != False:

loggr.info(f"Deleting Dashboard")
response = requests.delete(
'https://%s/api/2.0/lakeview/dashboards/%s' % (DOMAIN, dashboard_id),
headers={'Authorization': 'Bearer %s' % token},
Expand All @@ -197,9 +194,8 @@ def replace_string(obj, old_str, new_str):

json_string = json_string = json.dumps(json_data)

BODY = {'display_name': '[SAT] Security Analysis Tool - Workspace In-Depth','warehouse_id': json_['sql_warehouse_id'], 'serialized_dashboard': json_string, 'parent_path': f"{basePath()}/dashboards"}
BODY = {'display_name': '[SAT] Security Analysis Tool - Assessment Results','warehouse_id': json_['sql_warehouse_id'], 'serialized_dashboard': json_string, 'parent_path': f"{basePath()}/dashboards"}

loggr.info(f"Creating Dashboard")
response = requests.post(
'https://%s/api/2.0/lakeview/dashboards' % (DOMAIN),
headers={'Authorization': 'Bearer %s' % token},
Expand All @@ -211,7 +207,8 @@ def replace_string(obj, old_str, new_str):

if 'RESOURCE_ALREADY_EXISTS' not in response.text:
json_response = response.json()
dashboard_id = json_response['dashboard_id']
dashboard_id = json_response['dashboard_id']
serialized_dashboard = json_response['serialized_dashboard']
else:
exists = True
print("Lakeview Dashboard already exists")
Expand All @@ -231,7 +228,6 @@ def replace_string(obj, old_str, new_str):
URL = "https://"+DOMAIN+"/api/2.0/lakeview/dashboards/"+dashboard_id+"/published"
BODY = {'embed_credentials': 'true', 'warehouse_id': json_['sql_warehouse_id']}

loggr.info(f"Publishing the Dashboard using the SAT SQL Warehouse")
response = requests.post(
URL,
headers={'Authorization': 'Bearer %s' % token},
Expand Down