Migrate collection operations from APIHarnessV2 to CustomStorage#118
Draft
Migrate collection operations from APIHarnessV2 to CustomStorage#118
Conversation
Use CustomStorage service class instead of APIHarnessV2 (Uber class) for
collection CRUD operations. Service class imports enable the Foundry Functions
Editor to auto-detect required OAuth scopes, which is not possible with
Uber class .command() calls.
Changes:
- Replace APIHarnessV2 with CustomStorage(ext_headers=_app_headers())
- Replace .command("PutObject"/"SearchObjects") with .PutObject()/.SearchObjects()
- Add defensive .get() for SearchObjects response body
- Move header construction to _app_headers() helper
Align test mocks with the APIHarnessV2-to-CustomStorage migration in main.py: patch CustomStorage instead of APIHarnessV2, mock individual PutObject/SearchObjects methods instead of .command() side_effect, and verify ext_headers construction instead of per-request headers kwargs.
prvn
reviewed
Mar 31, 2026
| """Build app headers for CustomStorage construction.""" | ||
| app_id = os.environ.get("APP_ID") | ||
| if app_id: | ||
| return {"X-CS-APP-ID": app_id} |
There was a problem hiding this comment.
I think we don’t need this if calling from a app function
Contributor
Author
There was a problem hiding this comment.
Correct, but it's needed when running locally. I wrote about it in https://www.crowdstrike.com/tech-hub/ng-siem/dive-into-falcon-foundry-functions-with-python/#communicating-with-collections-from-a-falcon-foundry-function
Add verifyWorkflowExecutionCompleted() that polls the execution status page until terminal state, catching function failures that were previously invisible.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces APIHarnessV2 (Uber class) with CustomStorage (service class) for collection CRUD operations in the log-event function handler.
The Falcon Foundry Functions Editor parses
from falconpy import CustomStorageto auto-detect required OAuth scopes (custom-storage:read,custom-storage:write). It cannot parse the Uber class.command()pattern, which means apps using APIHarnessV2 require manual scope configuration.Changes in log-event/main.py:
APIHarnessV2().command("PutObject", ...)→CustomStorage(ext_headers=...).PutObject(...)APIHarnessV2().command("SearchObjects", ...)→client.SearchObjects(...).get("body", {})for SearchObjects response handlingThe
ext_headersconstructor parameter replaces per-requestheaderskwargs, applying theX-CS-APP-IDheader to all requests from the client instance. Response shapes and behavior are unchanged.Draft because the associated blog post needs updating to match the new patterns.