@@ -57,19 +57,16 @@ DOCUMENT = """
5757client = GGClient(api_key = API_KEY )
5858
5959# Check the health of the API and the API key used.
60- health_obj, status = client.health_check()
61-
62- if status != codes[r " \o /" ]: # this is 200 but cooler
60+ if client.health_check().success:
61+ try :
62+ scan_result = client.content_scan(DOCUMENT )
63+ except Exception as exc:
64+ # Handle exceptions such as schema validation
65+ traceback.print_exc(2 , file = sys.stderr)
66+ print (str (exc))
67+ print (scan_result)
68+ else :
6369 print (" Invalid API Key" )
64-
65- try :
66- scan_result = client.content_scan(DOCUMENT )
67- except Exception as exc:
68- # Handle exceptions such as schema validation
69- traceback.print_exc(2 , file = sys.stderr)
70- print (str (exc))
71-
72- print (" Scan results:" , scan_result.has_secrets, " -" , scan_result.policy_break_count)
7370```
7471
7572### Scanning multiple files
@@ -79,11 +76,11 @@ API_KEY = os.getenv("GG_API_KEY")
7976client = GGClient(api_key = API_KEY )
8077# Create a list of dictionaries for scanning
8178to_scan = []
82- for name in glob.glob(" **/*" ):
79+ for name in glob.glob(" **/*" , recursive = True ):
8380 with open (name) as fn:
8481 to_scan.append({" document" : fn.read(), " filename" : os.path.basename(name)})
8582
86- scan, status_code = client.multi_content_scan(to_scan)
83+ scan = client.multi_content_scan(to_scan)
8784```
8885
8986### Transform results to dict or JSON
0 commit comments