@@ -46,6 +46,7 @@ pip install vulncheck-sdk
4646## Quickstart
4747
4848``` python
49+ import json
4950import urllib.request
5051import vulncheck_sdk
5152import os
@@ -56,6 +57,7 @@ TOKEN = os.environ["VULNCHECK_API_TOKEN"] # Remember to store your token secure
5657# Now let's create a configuration object
5758configuration = vulncheck_sdk.Configuration()
5859configuration.api_key[" Bearer" ] = TOKEN
60+ configuration.ignore_operation_servers = True
5961
6062# Pass that config object to our API client and now...
6163with vulncheck_sdk.ApiClient(configuration) as api_client:
@@ -77,10 +79,13 @@ with vulncheck_sdk.ApiClient(configuration) as api_client:
7779 print (cve)
7880
7981 # Download a Backup
82+ backup_client = vulncheck_sdk.BackupApi(api_client)
8083 index = " initial-access"
81- api_response = endpoints_client.backup_index_get(index)
84+ raw = backup_client.backup_index_get_without_preload_content(index)
85+ response_data = json.loads(raw.read())
86+ download_url = response_data[" data" ][0 ][" url" ]
8287 file_path = f " { index} .zip "
83- with urllib.request.urlopen(api_response.data[ 0 ].url ) as response:
88+ with urllib.request.urlopen(download_url ) as response:
8489 with open (file_path, " wb" ) as file :
8590 file .write(response.read())
8691
@@ -98,6 +103,7 @@ with vulncheck_sdk.ApiClient(configuration) as api_client:
98103
99104``` python
100105import asyncio
106+ import json
101107import os
102108import aiohttp
103109import vulncheck_sdk.aio as vcaio
@@ -107,13 +113,15 @@ TOKEN = os.environ.get("VULNCHECK_API_TOKEN")
107113
108114configuration = vcaio.Configuration()
109115configuration.api_key[" Bearer" ] = TOKEN
116+ configuration.ignore_operation_servers = True
110117
111118
112119async def run_vulnerability_checks ():
113120 # Use 'async with' to manage the ApiClient connection pool
114121 async with vcaio.ApiClient(configuration) as api_client:
115122 endpoints_client = vcaio.EndpointsApi(api_client)
116123 indices_client = vcaio.IndicesApi(api_client)
124+ backup_client = vcaio.BackupApi(api_client)
117125
118126 # --- PURL Search ---
119127 # 'await' the coroutine to get results
@@ -138,11 +146,12 @@ async def run_vulnerability_checks():
138146
139147 # --- Download Backup (Async) ---
140148 index_name = " initial-access"
141- # 'await' the coroutine to get results
142- backup_response = await endpoints_client.backup_index_get(index_name)
149+ # 'await' the coroutine to get raw response bytes
150+ raw = await backup_client.backup_index_get_without_preload_content(index_name)
151+ response_data = json.loads(await raw.read())
143152
144- if backup_response. data:
145- download_url = backup_response. data[0 ]. url
153+ if response_data.get( " data" ) :
154+ download_url = response_data[ " data" ] [0 ][ " url" ]
146155 file_path = f " { index_name} .zip "
147156
148157 print (f " Downloading backup from { download_url} ... " )
@@ -314,6 +323,7 @@ if __name__ == "__main__":
314323Download the backup for an index
315324
316325``` python
326+ import json
317327import urllib.request
318328import vulncheck_sdk
319329import os
@@ -322,16 +332,19 @@ TOKEN = os.environ["VULNCHECK_API_TOKEN"]
322332
323333configuration = vulncheck_sdk.Configuration()
324334configuration.api_key[" Bearer" ] = TOKEN
335+ configuration.ignore_operation_servers = True
325336
326337with vulncheck_sdk.ApiClient(configuration) as api_client:
327- endpoints_client = vulncheck_sdk.EndpointsApi (api_client)
338+ backup_client = vulncheck_sdk.BackupApi (api_client)
328339
329340 index = " initial-access"
330341
331- api_response = endpoints_client.backup_index_get(index)
342+ raw = backup_client.backup_index_get_without_preload_content(index)
343+ response_data = json.loads(raw.read())
344+ download_url = response_data[" data" ][0 ][" url" ]
332345
333346 file_path = f " { index} .zip "
334- with urllib.request.urlopen(api_response.data[ 0 ].url ) as response:
347+ with urllib.request.urlopen(download_url ) as response:
335348 with open (file_path, " wb" ) as file :
336349 file .write(response.read())
337350```
@@ -341,6 +354,7 @@ with vulncheck_sdk.ApiClient(configuration) as api_client:
341354
342355``` python
343356import asyncio
357+ import json
344358import os
345359import urllib.request
346360import vulncheck_sdk.aio as vcaio
@@ -350,6 +364,7 @@ TOKEN = os.environ.get("VULNCHECK_API_TOKEN")
350364
351365configuration = vcaio.Configuration()
352366configuration.api_key[" Bearer" ] = TOKEN
367+ configuration.ignore_operation_servers = True
353368
354369
355370def download_sync (url , file_path ):
@@ -365,23 +380,19 @@ def download_sync(url, file_path):
365380async def main ():
366381 # Use 'async with' to manage the connection life-cycle
367382 async with vcaio.ApiClient(configuration) as api_client:
368- endpoints_client = vcaio.EndpointsApi (api_client)
383+ backup_client = vcaio.BackupApi (api_client)
369384 index = " initial-access"
370385
371- # 'await' the coroutine to get the actual response data
372- api_response = await endpoints_client.backup_index_get(index)
373-
374- if not api_response.data:
375- print (" No backup URL found." )
376- return
386+ # 'await' the coroutine to get the raw response bytes
387+ raw = await backup_client.backup_index_get_without_preload_content(index)
388+ response_data = json.loads(await raw.read())
389+ download_url = response_data[" data" ][0 ][" url" ]
377390
378- download_url = api_response.data[0 ].url
379391 file_path = f " { index} .zip "
380392
381393 print (f " Downloading { index} via urllib (offloaded to thread)... " )
382394
383395 # Use asyncio.to_thread to run the blocking call safely
384- # 'await' the coroutine to get the actual response data
385396 await asyncio.to_thread(download_sync, download_url, file_path)
386397
387398 print (f " Successfully saved to { file_path} " )
0 commit comments