File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
extensions/content-health-monitor Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,10 @@ connect_server = get_env_var("CONNECT_SERVER") # Automatically provided by Conne
3030api_key = get_env_var("CONNECT_API_KEY") # Automatically provided by Connect, must be set when previewing locally
3131monitored_content_guid = get_env_var("MONITORED_CONTENT_GUID")
3232
33+ # Extract GUID if it's a string or URL containing a GUID
34+ if monitored_content_guid:
35+ monitored_content_guid = extract_guid(monitored_content_guid)
36+
3337# Only instantiate the client if we have the required environment variables
3438client = None
3539if not show_instructions:
Original file line number Diff line number Diff line change 11import json
22import os
3+ import re
34import requests
45from posit import connect
56
@@ -94,6 +95,27 @@ def format_error_message(exception):
9495
9596 return error_message
9697
98+ # Function to extract GUID string or URL
99+ def extract_guid (input_string ):
100+ """
101+ Extract GUID from a string or URL.
102+
103+ Args:
104+ input_string: String that may contain a GUID
105+
106+ Returns:
107+ str: Extracted GUID or original string if no GUID found
108+ """
109+ # Match UUIDs in various formats that might appear in URLs
110+ guid_pattern = re .compile (r'[0-9a-fA-F]{8}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{12}' )
111+
112+ match = guid_pattern .search (input_string )
113+ if match :
114+ return match .group (0 )
115+
116+ # Return original string if no GUID found
117+ return input_string
118+
97119# Function to get content details from Connect API
98120def get_content (client , guid ):
99121 try :
You can’t perform that action at this time.
0 commit comments