1- from falconfoundry import FoundryFunction , FoundryRequest , FoundryResponse , FoundryAPIError
1+ from crowdstrike . foundry . function import Function , Request , Response , APIError
22from falconpy import APIHarnessV2
33import time
44import os
55import uuid
66
7- func = FoundryFunction .instance ()
7+ func = Function .instance ()
88
99
1010@func .handler (method = 'POST' , path = '/log-event' )
11- def on_post (request : FoundryRequest ) -> FoundryResponse :
11+ def on_post (request : Request ) -> Response :
1212 # Validate request
1313 if 'event_data' not in request .body :
14- return FoundryResponse (
14+ return Response (
1515 code = 400 ,
16- errors = [FoundryAPIError (code = 400 , message = 'missing event_data' )]
16+ errors = [APIError (code = 400 , message = 'missing event_data' )]
1717 )
1818
1919 event_data = request .body ['event_data' ]
@@ -47,9 +47,9 @@ def on_post(request: FoundryRequest) -> FoundryResponse:
4747
4848 if response ["status_code" ] != 200 :
4949 error_message = response .get ('error' , {}).get ('message' , 'Unknown error' )
50- return FoundryResponse (
50+ return Response (
5151 code = response ["status_code" ],
52- errors = [FoundryAPIError (
52+ errors = [APIError (
5353 code = response ["status_code" ],
5454 message = f"Failed to store event: { error_message } "
5555 )]
@@ -63,17 +63,17 @@ def on_post(request: FoundryRequest) -> FoundryResponse:
6363 headers = headers
6464 )
6565
66- return FoundryResponse (
66+ return Response (
6767 body = {
6868 "stored" : True ,
6969 "metadata" : query_response .get ("body" ).get ("resources" , [])
7070 },
7171 code = 200
7272 )
7373 except Exception as e :
74- return FoundryResponse (
74+ return Response (
7575 code = 500 ,
76- errors = [FoundryAPIError (code = 500 , message = f"Error saving collection: { str (e )} " )]
76+ errors = [APIError (code = 500 , message = f"Error saving collection: { str (e )} " )]
7777 )
7878
7979
0 commit comments