Skip to content

Commit a739d41

Browse files
Merge pull request #49 from databricks-industry-solutions/alert_fix_dev_0.1.2
Fixed alerts subscription error due to the REST API change
2 parents 00559ba + 2b47c45 commit a739d41

File tree

1 file changed

+0
-34
lines changed

1 file changed

+0
-34
lines changed

notebooks/Setup/6. configure_alerts_template.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -236,40 +236,6 @@ def delete_ws_folder(ws, dir_name):
236236
else:
237237
loggr.info(f"Error creating alert: {(response.json())}")
238238

239-
if alert_id is not None:
240-
response = requests.get(
241-
'https://%s/api/2.0/preview/scim/v2/Users?filter=userName+eq+%s' % (DOMAIN,ws_to_load.alert_subscriber_user_id),
242-
headers={'Authorization': 'Bearer %s' % TOKEN},
243-
json=None,
244-
timeout=60
245-
)
246-
247-
result = json.loads(response.text)
248-
if result['totalResults'] != 0 :
249-
resources = result['Resources']
250-
for resource in resources:
251-
user_id = resource["id"]
252-
253-
if user_id is not None:
254-
response = session.post(
255-
'https://%s/api/2.0/preview/sql/alerts/%s/subscriptions' % (DOMAIN, alert_id),
256-
headers={'Authorization': 'Bearer %s' % TOKEN},
257-
json={
258-
"alert_id":alert_id,
259-
"user_id":user_id
260-
},
261-
timeout=60
262-
)
263-
264-
if response.status_code == 200:
265-
loggr.info(f"Alert subscription is successfuly associated to user {response.json()['user']}!")
266-
else:
267-
loggr.info(f"Error creating alert subscription: {(response.json())}")
268-
dbutils.notebook.exit("Error creating alert subscription")
269-
else:
270-
loggr.info(f"User not found with login : {ws_to_load.alert_subscriber_user_id}")
271-
dbutils.notebook.exit("Error creating alert subscription, Configured user not found " + user_id )
272-
273239
# COMMAND ----------
274240

275241
dbutils.notebook.exit('OK')

0 commit comments

Comments
 (0)